From 82f429ee308cbf7f3dc9f82e16b90ed02ef70115 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 17 Nov 2017 14:42:09 +0000 Subject: [PATCH] Replace std::map by boost::unordered_map to speed up. We can even do better with Dynamic_property_map --- .../include/CGAL/vsa_approximation.h | 14 +++--- .../include/CGAL/vsa_metrics.h | 50 +++++++++---------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Surface_mesh_approximation/include/CGAL/vsa_approximation.h b/Surface_mesh_approximation/include/CGAL/vsa_approximation.h index 3ee8e1991ef..337781508e9 100644 --- a/Surface_mesh_approximation/include/CGAL/vsa_approximation.h +++ b/Surface_mesh_approximation/include/CGAL/vsa_approximation.h @@ -21,10 +21,10 @@ #include #include +#include #include #include -#include -#include + #include #include @@ -100,7 +100,7 @@ private: typedef typename boost::graph_traits::face_descriptor face_descriptor; // internal typedefs - typedef boost::associative_property_map > Vertex_anchor_map; + typedef boost::associative_property_map > Vertex_anchor_map; typedef std::vector Chord_vector; typedef typename Chord_vector::iterator Chord_vector_iterator; @@ -228,10 +228,10 @@ private: Compute_scalar_product_3 scalar_product_functor; // The facet proxy index map. - std::map internal_fidx_map; - boost::associative_property_map > fproxy_map; + boost::unordered_map internal_fidx_map; + boost::associative_property_map > fproxy_map; // The attached anchor index of a vertex. - std::map internal_vidx_map; + boost::unordered_map internal_vidx_map; Vertex_anchor_map vanchor_map; // Proxies. @@ -1495,7 +1495,7 @@ private: typedef typename SubGraph::vertex_descriptor sg_vertex_descriptor; typedef std::vector VertexVector; - typedef std::map VertexMap; + typedef boost::unordered_map VertexMap; typedef boost::associative_property_map ToSGVertexMap; VertexMap vmap; ToSGVertexMap to_sgv_map(vmap); diff --git a/Surface_mesh_approximation/include/CGAL/vsa_metrics.h b/Surface_mesh_approximation/include/CGAL/vsa_metrics.h index 9ae590c8ae7..5eea2e7d494 100644 --- a/Surface_mesh_approximation/include/CGAL/vsa_metrics.h +++ b/Surface_mesh_approximation/include/CGAL/vsa_metrics.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include namespace CGAL { @@ -72,8 +72,8 @@ class L21_metric typedef typename boost::graph_traits::face_descriptor face_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - typedef boost::associative_property_map > FacetNormalMap; - typedef boost::associative_property_map > FacetAreaMap; + typedef boost::associative_property_map > FacetNormalMap; + typedef boost::associative_property_map > FacetAreaMap; public: // type required by `ErrorMetric` concept @@ -107,8 +107,8 @@ public: } private: - std::map facet_normals; - std::map facet_areas; + boost::unordered_map facet_normals; + boost::unordered_map facet_areas; const FacetNormalMap normal_pmap; const FacetAreaMap area_pmap; Construct_scaled_vector_3 scale_functor; @@ -138,8 +138,8 @@ class L21_metric::halfedge_descriptor halfedge_descriptor; typedef typename boost::property_map::type VertexPointMap; - typedef boost::associative_property_map > FacetNormalMap; - typedef boost::associative_property_map > FacetAreaMap; + typedef boost::associative_property_map > FacetNormalMap; + typedef boost::associative_property_map > FacetAreaMap; public: // type required by `ErrorMetric` concept @@ -174,8 +174,8 @@ public: } private: - std::map facet_normals; - std::map facet_areas; + boost::unordered_map facet_normals; + boost::unordered_map facet_areas; const FacetNormalMap normal_pmap; const FacetAreaMap area_pmap; Construct_scaled_vector_3 scale_functor; @@ -204,7 +204,7 @@ class L21_metric::face_descriptor face_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - typedef boost::associative_property_map > FacetNormalMap; + typedef boost::associative_property_map > FacetNormalMap; public: // type required by `ErrorMetric` concept @@ -237,7 +237,7 @@ public: } private: - std::map facet_normals; + boost::unordered_map facet_normals; const FacetNormalMap normal_pmap; Construct_scaled_vector_3 scale_functor; Compute_scalar_product_3 scalar_product_functor; @@ -265,7 +265,7 @@ class L21_metric::halfedge_descriptor halfedge_descriptor; typedef typename boost::property_map::type VertexPointMap; - typedef boost::associative_property_map > FacetNormalMap; + typedef boost::associative_property_map > FacetNormalMap; public: // type required by `ErrorMetric` concept @@ -298,7 +298,7 @@ public: } private: - std::map facet_normals; + boost::unordered_map facet_normals; const FacetNormalMap normal_pmap; Construct_scaled_vector_3 scale_functor; Compute_scalar_product_3 scalar_product_functor; @@ -335,8 +335,8 @@ class L21_proxy_fitting typedef typename boost::graph_traits::face_descriptor face_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - typedef boost::associative_property_map > FacetNormalMap; - typedef boost::associative_property_map > FacetAreaMap; + typedef boost::associative_property_map > FacetNormalMap; + typedef boost::associative_property_map > FacetAreaMap; public: // type required by `ErrorMetric` concept @@ -384,8 +384,8 @@ public: } private: - std::map facet_normals; - std::map facet_areas; + boost::unordered_map facet_normals; + boost::unordered_map facet_areas; const FacetNormalMap normal_pmap; const FacetAreaMap area_pmap; Construct_scaled_vector_3 scale_functor; @@ -411,8 +411,8 @@ class L21_proxy_fitting::halfedge_descriptor halfedge_descriptor; typedef typename boost::property_map::type VertexPointMap; - typedef boost::associative_property_map > FacetNormalMap; - typedef boost::associative_property_map > FacetAreaMap; + typedef boost::associative_property_map > FacetNormalMap; + typedef boost::associative_property_map > FacetAreaMap; public: // type required by `ErrorMetric` concept @@ -461,8 +461,8 @@ public: } private: - std::map facet_normals; - std::map facet_areas; + boost::unordered_map facet_normals; + boost::unordered_map facet_areas; const FacetNormalMap normal_pmap; const FacetAreaMap area_pmap; Construct_scaled_vector_3 scale_functor; @@ -496,7 +496,7 @@ class L2_metric typedef typename boost::graph_traits::face_descriptor face_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - typedef boost::associative_property_map > FacetAreaMap; + typedef boost::associative_property_map > FacetAreaMap; public: // type required by `ErrorMetric` concept @@ -533,7 +533,7 @@ public: private: const TriangleMesh *mesh; - std::map facet_areas; + boost::unordered_map facet_areas; const FacetAreaMap area_pmap; const VertexPointMap point_pmap; }; @@ -554,7 +554,7 @@ class L2_metric::halfedge_descriptor halfedge_descriptor; typedef typename boost::property_map::type VertexPointMap; - typedef boost::associative_property_map > FacetAreaMap; + typedef boost::associative_property_map > FacetAreaMap; public: // type required by `ErrorMetric` concept @@ -592,7 +592,7 @@ public: private: const TriangleMesh *mesh; - std::map facet_areas; + boost::unordered_map facet_areas; const FacetAreaMap area_pmap; const VertexPointMap point_pmap; };