diff --git a/Mesh_3/include/CGAL/Mesh_3/Detect_features_in_polyhedra.h b/Mesh_3/include/CGAL/Mesh_3/Detect_features_in_polyhedra.h index 3d496996379..e6d0ee85429 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Detect_features_in_polyhedra.h +++ b/Mesh_3/include/CGAL/Mesh_3/Detect_features_in_polyhedra.h @@ -53,6 +53,7 @@ public: typedef typename Polyhedron::Facet_handle Facet_handle; typedef typename Polyhedron::Halfedge Halfedge; typedef typename Polyhedron::Facet Facet; + typedef typename Facet::Patch_id Patch_id; typedef std::set Facet_handle_set; typedef std::set He_handle_set; @@ -68,8 +69,14 @@ public: private: Vector_3 facet_normal(const Facet_handle& f) const; bool is_sharp(const Halfedge_handle& he, FT cos_angle) const; - void flood(Facet& f, const int index, + void flood(Facet& f, const Patch_id id, Facet_handle_set& unsorted_faces) const; + + template + Int generate_patch_id(Int, int); + + template + std::pair generate_patch_id(std::pair, int); private: // Stores the current surface index (usefull to detect different patches @@ -108,6 +115,24 @@ detect_sharp_edges(Polyhedron& polyhedron, FT angle_in_deg) const } +template +template +Int +Detect_features_in_polyhedra:: +generate_patch_id(Int, int i) +{ + return Int(i); +} + +template +template +std::pair +Detect_features_in_polyhedra:: +generate_patch_id(std::pair, int i) +{ + return std::pair(i, 0); +} + template void Detect_features_in_polyhedra:: @@ -127,13 +152,15 @@ detect_surface_patches(Polyhedron& polyhedron) Facet& f = **(unsorted_faces.begin()); unsorted_faces.erase(unsorted_faces.begin()); - f.set_patch_id(current_surface_index_); - flood(f,current_surface_index_,unsorted_faces); + const Patch_id patch_id = generate_patch_id(Patch_id(), + current_surface_index_); + f.set_patch_id(patch_id); + flood(f,patch_id,unsorted_faces); ++current_surface_index_; } } - - + + template void Detect_features_in_polyhedra:: @@ -218,7 +245,7 @@ is_sharp(const Halfedge_handle& he, FT cos_angle) const template void Detect_features_in_polyhedra:: -flood(Facet& f, const int index, Facet_handle_set& unsorted_faces) const +flood(Facet& f, const Patch_id patch_id, Facet_handle_set& unsorted_faces) const { typedef typename Facet::Halfedge_around_facet_circulator Facet_he_circ; @@ -245,7 +272,7 @@ flood(Facet& f, const int index, Facet_handle_set& unsorted_faces) const Facet& explored_facet = *(he.facet()); // Mark facet and delete it from unsorted - explored_facet.set_patch_id(index); + explored_facet.set_patch_id(patch_id); unsorted_faces.erase(&explored_facet); // Add/Remove facet's halfedge to/from explore list diff --git a/Mesh_3/include/CGAL/Mesh_polyhedron_3.h b/Mesh_3/include/CGAL/Mesh_polyhedron_3.h index cf0bfbe0d48..91f2840328d 100644 --- a/Mesh_3/include/CGAL/Mesh_polyhedron_3.h +++ b/Mesh_3/include/CGAL/Mesh_polyhedron_3.h @@ -89,6 +89,19 @@ public: } }; +template +inline std::pair +patch_id_default_value(std::pair) +{ + return std::pair(1, 0); +} + +template +inline Integral patch_id_default_value(Integral) +{ + return Integral(1); +} + template class Mesh_polyhedron_face : public CGAL::HalfedgeDS_face_base @@ -100,7 +113,7 @@ public: typedef Patch_id_ Patch_id; Mesh_polyhedron_face() - : patch_id_(1) {} + : patch_id_(patch_id_default_value(Patch_id())) {} const Patch_id& patch_id() const { return patch_id_;