From ed0c55df89c92364f30a4b53b2e9a95c782eb5a4 Mon Sep 17 00:00:00 2001 From: Guillaume Damiand Date: Thu, 5 Apr 2018 10:16:43 +0200 Subject: [PATCH] Bugfix in function that test if a face is convex. --- GraphicsView/include/CGAL/Buffer_for_vao.h | 24 +++++++++------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/GraphicsView/include/CGAL/Buffer_for_vao.h b/GraphicsView/include/CGAL/Buffer_for_vao.h index c7fe936dd90..607be5d58a8 100644 --- a/GraphicsView/include/CGAL/Buffer_for_vao.h +++ b/GraphicsView/include/CGAL/Buffer_for_vao.h @@ -372,15 +372,13 @@ public: if (m_points_of_face.size()==3) { triangular_face_end_internal(normal); } // Triangle: no need to triangulate - /* - // TODO BUG FIX HERE - else if (is_current_face_convex(normal)) + else if (is_current_face_convex(normal)) { if (m_points_of_face.size()==4) { convex_quadrangular_face_end_internal(normal); } // Convex quad else { convex_face_end_internal(normal); } // Convex face with > 4 vertices - } */ + } else { // Non convex and more than 3 points: we triangulate nonconvex_face_end_internal(normal); @@ -421,15 +419,15 @@ public: static bool is_facet_convex(const std::vector& facet, const Local_vector& normal) { - Local_kernel::Orientation orientation; + Local_kernel::Orientation orientation, local_orientation; std::size_t id=0; do { const Local_point& S=facet[id]; - const Local_point& T=facet[id+1]; + const Local_point& T=facet[(id+1==facet.size())?0:id+1]; Local_vector V1=Local_vector((T-S).x(), (T-S).y(), (T-S).z()); - const Local_point& U=facet[id+2]; + const Local_point& U=facet[(id+2==facet.size())?0:id+2]; Local_vector V2=Local_vector((U-T).x(), (U-T).y(), (U-T).z()); orientation = Local_kernel::Orientation_3()(V1, V2, normal); @@ -440,24 +438,22 @@ public: //Here, all orientations were COPLANAR. Not sure this case is possible, // but we stop here. - if (orientation==CGAL::COPLANAR) + if (orientation==CGAL::COPLANAR || orientation==CGAL::ZERO) { return false; } // Now we compute convexness for(id=0; id