diff --git a/Mesh_3/include/CGAL/facets_in_complex_3_to_triangle_mesh.h b/Mesh_3/include/CGAL/facets_in_complex_3_to_triangle_mesh.h index d69f445716f..1262ef6f74a 100644 --- a/Mesh_3/include/CGAL/facets_in_complex_3_to_triangle_mesh.h +++ b/Mesh_3/include/CGAL/facets_in_complex_3_to_triangle_mesh.h @@ -18,16 +18,18 @@ #include #include +#include +#include #include #include #include -#include #include #include #include #include +#include #include namespace CGAL { @@ -61,22 +63,24 @@ void facets_in_complex_3_to_triangle_soup(const C3T3& c3t3, typedef typename C3T3::Triangulation Tr; - typedef typename Tr::Vertex_handle Vertex_handle; typedef typename Tr::Cell_handle Cell_handle; typedef typename Tr::Weighted_point Weighted_point; typedef typename C3T3::Facets_in_complex_iterator Ficit; - typedef CGAL::Hash_handles_with_or_without_timestamps Hash_fct; - typedef boost::unordered_map VHmap; + typedef std::unordered_map PIM; typedef typename C3T3::size_type size_type; + // triangulation point to range point + CGAL::Cartesian_converter::type, + typename CGAL::Kernel_traits::type> t2r; + size_type nf = c3t3.number_of_facets_in_complex(); faces.reserve(faces.size() + nf); points.reserve(points.size() + nf/2); // approximating Euler - VHmap vh_to_ids; + PIM p_to_ids; std::size_t inum = 0; for(Ficit fit = c3t3.facets_in_complex_begin(), @@ -95,23 +99,21 @@ void facets_in_complex_3_to_triangle_soup(const C3T3& c3t3, for(std::size_t i=1; i<4; ++i) { - typename VHmap::iterator map_entry; - bool is_new; - Vertex_handle v = c->vertex((s+i)&3); + CGAL_assertion_code(typedef typename Tr::Vertex_handle Vertex_handle;) + CGAL_assertion_code(Vertex_handle v = c->vertex((s+i)&3);) CGAL_assertion(v != Vertex_handle() && !c3t3.triangulation().is_infinite(v)); - boost::tie(map_entry, is_new) = vh_to_ids.insert(std::make_pair(v, inum)); - if(is_new) + const Weighted_point& wp = c3t3.triangulation().point(c, (s+i)&3); + const Point_3& bp = t2r(c3t3.triangulation().geom_traits().construct_point_3_object()(wp)); + + auto insertion_res = p_to_ids.emplace(bp, inum); + if(insertion_res.second) // new point { - const Weighted_point& p = c3t3.triangulation().point(c, (s+i)&3); - const Point_3 bp = Point_3(CGAL::to_double(p.x()), - CGAL::to_double(p.y()), - CGAL::to_double(p.z())); points.push_back(bp); ++inum; } - f[i-1] = map_entry->second; + f[i-1] = insertion_res.first->second; } if(export_all_facets) @@ -166,7 +168,7 @@ void facets_in_complex_3_to_triangle_mesh(const C3T3& c3t3, TriangleMesh& graph) typedef typename boost::property_map::type VertexPointMap; typedef typename boost::property_traits::value_type Point_3; - typedef std::array Face; + typedef std::array Face; std::vector faces; std::vector points;