diff --git a/Mesh_3/include/CGAL/Polyhedral_mesh_domain_with_features_3.h b/Mesh_3/include/CGAL/Polyhedral_mesh_domain_with_features_3.h index 5f41be7e828..4f99bc8c9eb 100644 --- a/Mesh_3/include/CGAL/Polyhedral_mesh_domain_with_features_3.h +++ b/Mesh_3/include/CGAL/Polyhedral_mesh_domain_with_features_3.h @@ -44,6 +44,8 @@ #include #include +#include +#include #include #include @@ -229,6 +231,47 @@ public: void detect_borders(std::vector& p); void detect_borders() { detect_borders(stored_polyhedra); }; + template + void + add_features(InputIterator first, InputIterator end) + { + auto max = 0; + auto min = (std::numeric_limits::max)(); + for(const auto& polyhedron: stored_polyhedra) { + auto f_pid = get(face_patch_id_t(), polyhedron); + for(auto fd : faces(polyhedron)) { + const auto patch_id = get(f_pid, fd); + min = (std::min)(patch_id, min); + max = (std::max)(patch_id, max); + } + } + boost::dynamic_bitset<> patch_ids_bitset; + patch_ids_bitset.resize(max - min + 1); + for(const auto& polyhedron: stored_polyhedra) { + auto f_pid = get(face_patch_id_t(), polyhedron); + for(auto fd : faces(polyhedron)) { + const auto patch_id = get(f_pid, fd); + patch_ids_bitset.set(patch_id - min); + } + } + using Patch_ids_container = std::vector; + Patch_ids_container all_patch_ids; + all_patch_ids.reserve(patch_ids_bitset.count()); + for(auto i = patch_ids_bitset.find_first(); + i != patch_ids_bitset.npos; + i = patch_ids_bitset.find_next(i)) + { + all_patch_ids.push_back(i + min); + } + using Polyline = typename std::iterator_traits::value_type; + auto identity_property_map = boost::typed_identity_property_map(); + auto all_patch_ids_pmap = + boost::static_property_map(all_patch_ids); + Base::add_features_and_incidences(first, end, + identity_property_map, + all_patch_ids_pmap); + } + // non-documented, provided to the FEniCS project const std::vector& polyhedra()const {