diff --git a/Heat_method_3/include/CGAL/Heat_method_3/Surface_mesh_geodesic_distances_3.h b/Heat_method_3/include/CGAL/Heat_method_3/Surface_mesh_geodesic_distances_3.h index 69f024199a1..d1499bbca35 100644 --- a/Heat_method_3/include/CGAL/Heat_method_3/Surface_mesh_geodesic_distances_3.h +++ b/Heat_method_3/include/CGAL/Heat_method_3/Surface_mesh_geodesic_distances_3.h @@ -24,7 +24,6 @@ #include #include #include -#include #include #ifdef CGAL_EIGEN3_ENABLED #include @@ -52,11 +51,9 @@ struct Intrinsic_Delaunay {}; namespace internal { - template - bool has_degenerate_faces(const TriangleMesh& tm); - template - bool has_degenerate_faces(const TriangleMesh& tm, VertexPointMap vpm); + template + bool has_degenerate_faces(const TriangleMesh& tm, const Traits& traits); } namespace internal { @@ -489,7 +486,7 @@ public: void estimate_geodesic_distances(VertexDistanceMap vdm) { CGAL_precondition( - !CGAL::Heat_method_3::internal::has_degenerate_faces(triangle_mesh(), vertex_point_map())); + !CGAL::Heat_method_3::internal::has_degenerate_faces(triangle_mesh(), Traits())); if(is_empty(tm)){ return; @@ -689,25 +686,32 @@ struct Idt_storage {} }; -template -bool has_degenerate_faces(const TriangleMesh& tm, VertexPointMap vpm) +template +bool has_degenerate_faces(const TriangleMesh& tm, const Traits& traits) { + typedef typename Traits::Point_3 Point; + typedef typename Traits::Vector_3 Vector_3; + typename Traits::Construct_vector_3 + construct_vector = traits.construct_vector_3_object(); + typename Traits::Compute_scalar_product_3 + scalar_product = traits.compute_scalar_product_3_object(); + typename Traits::Construct_cross_product_vector_3 + cross_product = traits.construct_cross_product_vector_3_object(); + + typename boost::property_map< TriangleMesh, boost::vertex_point_t>::const_type + vpm = get(boost::vertex_point, tm); for (typename boost::graph_traits::face_descriptor f : faces(tm)) { - if (CGAL::Polygon_mesh_processing::is_degenerate_triangle_face(f, tm, - CGAL::Polygon_mesh_processing::parameters::vertex_point_map(vpm))) + const Point p1 = get(vpm, target(halfedge(f, tm), tm)); + const Point p2 = get(vpm, target(next(halfedge(f, tm), tm), tm)); + const Point p3 = get(vpm, target(next(next(halfedge(f, tm), tm), tm), tm)); + Vector_3 v = cross_product(construct_vector(p1, p2), construct_vector(p1, p3)); + if(scalar_product(v, v) == 0.) return true; } return false; } -template -bool has_degenerate_faces(const TriangleMesh& tm) -{ - return has_degenerate_faces(tm, get(vertex_point, tm)); -} - - template void estimate_geodesic_distances(VertexDistanceMap vdm) { CGAL_precondition( - !CGAL::Heat_method_3::internal::has_degenerate_faces(this->m_idt.triangle_mesh())); + !CGAL::Heat_method_3::internal::has_degenerate_faces( + this->m_idt.triangle_mesh(), Traits())); base().estimate_geodesic_distances(this->m_idt.vertex_distance_map(vdm)); } }; @@ -967,8 +972,6 @@ estimate_geodesic_distances(const TriangleMesh& tm, typename boost::graph_traits::vertex_descriptor source, Mode) { - CGAL_precondition(!internal::has_degenerate_faces(tm)); - CGAL::Heat_method_3::Surface_mesh_geodesic_distances_3 hm(tm); hm.add_source(source); hm.estimate_geodesic_distances(vdm); @@ -982,8 +985,6 @@ estimate_geodesic_distances(const TriangleMesh& tm, VertexDistanceMap vdm, typename boost::graph_traits::vertex_descriptor source) { - CGAL_precondition(!internal::has_degenerate_faces(tm)); - CGAL::Heat_method_3::Surface_mesh_geodesic_distances_3 hm(tm); hm.add_source(source); hm.estimate_geodesic_distances(vdm); @@ -1018,8 +1019,6 @@ estimate_geodesic_distances(const TriangleMesh& tm, #endif ) { - CGAL_precondition(!internal::has_degenerate_faces(tm)); - CGAL::Heat_method_3::Surface_mesh_geodesic_distances_3 hm(tm); hm.add_sources(sources); hm.estimate_geodesic_distances(vdm); @@ -1035,8 +1034,6 @@ estimate_geodesic_distances(const TriangleMesh& tm, typename boost::has_range_const_iterator >::type* = 0) { - CGAL_precondition(!internal::has_degenerate_faces(tm)); - CGAL::Heat_method_3::Surface_mesh_geodesic_distances_3 hm(tm); hm.add_sources(sources); hm.estimate_geodesic_distances(vdm);