Merge pull request #1284 from maxGimeno/Polyhedron_demo-Fix_cut_plugin-GF

Polyhedron_demo: Fix the Cut_plugin
This commit is contained in:
Laurent Rineau 2016-07-21 12:09:51 +02:00 committed by GitHub
commit 2cfb1f05cf
1 changed files with 19 additions and 5 deletions

View File

@ -1204,14 +1204,28 @@ void Polyhedron_demo_cut_plugin::createCutPlane() {
CGAL::Three::Scene_item* item = scene->item(i);
Scene_polyhedron_item* poly_item = qobject_cast<Scene_polyhedron_item*>(item);
if(!poly_item) continue;
if(!poly_item->polyhedron()->is_pure_triangle())
{
messages->warning(QString("%1 ignored (not a triangulated mesh)").arg(poly_item->name()));
continue;
}
if(facet_trees.find(poly_item) == facet_trees.end()) {
facet_trees[poly_item] = new Facet_tree();
PPMAP pmap;
facet_trees[poly_item]->insert(faces(*(poly_item->polyhedron())).first,
faces(*(poly_item->polyhedron())).second,
*poly_item->polyhedron(),
pmap );
//filter facets to ignore degenerated ones
for(Polyhedron::Facet_iterator
fit = poly_item->polyhedron()->facets_begin(),
end = poly_item->polyhedron()->facets_end();
fit!=end; ++fit)
{
Polyhedron::Point a(fit->halfedge()->vertex()->point()),
b(fit->halfedge()->next()->vertex()->point()),
c(fit->halfedge()->prev()->vertex()->point());
if(!CGAL::collinear(a,b,c))
facet_trees[poly_item]->insert(Facet_primitive(fit, *poly_item->polyhedron(), pmap));
}
Scene_aabb_item* aabb_item = new Scene_aabb_item(*facet_trees[poly_item]);
aabb_item->setName(tr("AABB tree of %1").arg(poly_item->name()));
aabb_item->setRenderingMode(Wireframe);