From 594858daf86acfdfb4ebe0cd9ed9fe03f05bd94d Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 9 Dec 2009 16:29:26 +0000 Subject: [PATCH] Set is_external markers. Now the plugin should be able to triangulate non-convex polyhedron facets. To be tested... --- ...yhedron_demo_triangulate_facets_plugin.cpp | 42 ++++++++++++++++--- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_triangulate_facets_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_triangulate_facets_plugin.cpp index 2d748dd91cf..96b1ece09a4 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_triangulate_facets_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_triangulate_facets_plugin.cpp @@ -18,8 +18,8 @@ #include #include "CGAL/compute_normal.h" - // Vector n = compute_facet_normal(*f); - // ::glNormal3d(n.x(),n.y(),n.z()); + +#include typedef Polyhedron::Halfedge_handle Halfedge_handle; @@ -30,7 +30,8 @@ typedef CGAL::Triangulation_vertex_base_with_info_2 Fb1; @@ -55,7 +56,7 @@ public: } bool is_external(CDT::Face_handle fh) const { - return cdt->is_infinite(fh); + return fh->info().is_external; } void operator()(HDS& hds) { @@ -168,6 +169,8 @@ public slots: return; } + QApplication::setOverrideCursor(Qt::WaitCursor); + typedef Polyhedron::Facet Facet; typedef Polyhedron::Facet_iterator Facet_iterator; typedef Polyhedron::Facet_handle Facet_handle; @@ -213,12 +216,39 @@ public slots: } while( ++he_circ != he_circ_end ); cdt.insert_constraint(previous, first); + // sets mark is_external + for(CDT::Finite_faces_iterator + fit = cdt.finite_faces_begin(), + end = cdt.finite_faces_end(); + fit != end; ++fit) + { + fit->info().is_external = false; + } + std::queue face_queue; + face_queue.push(cdt.infinite_vertex()->face()); + while(! face_queue.empty() ) { + CDT::Face_handle fh = face_queue.front(); + face_queue.pop(); + CGAL_assertion(cdt.is_infinite(fh)); + if(fh->info().is_external) continue; + std::cerr << (void*)(&*fh) << std::endl; + fh->info().is_external = true; + for(int i = 0; i <3; ++i) { + if(!cdt.is_constrained(std::make_pair(fh, i))) + { + face_queue.push(fh->neighbor(i)); + } + } + } + // then modify the polyhedron Modifier modifier(&cdt, fit); pMesh->delegate(modifier); - CGAL_assertion_code(pMesh->normalize_border()); - CGAL_assertion(pMesh->is_valid(true, 3)); } + CGAL_assertion_code(pMesh->normalize_border()); + CGAL_assertion(pMesh->is_valid(false, 3)); scene->itemChanged(item); + // default cursor + QApplication::restoreOverrideCursor(); } }