From 001a6a186ce64c4690770e8018fc717b65b6cdc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 26 Feb 2024 16:16:28 +0100 Subject: [PATCH] Use a hash map in TBB-less Marching Cubes --- ...ogically_correct_marching_cubes_functors.h | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/topologically_correct_marching_cubes_functors.h b/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/topologically_correct_marching_cubes_functors.h index 9a72fb43d51..111e7c2e01d 100644 --- a/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/topologically_correct_marching_cubes_functors.h +++ b/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/topologically_correct_marching_cubes_functors.h @@ -78,6 +78,7 @@ private: using Point_index = std::size_t; using Edge_index = std::array; +#ifdef CGAL_LINKED_WITH_TBB struct Hash_compare { static size_t hash(const Edge_index& key) @@ -95,25 +96,40 @@ private: return key1[0] == key2[0] && key1[1] == key2[1] && key1[2] == key2[2] && key1[3] == key2[3]; } }; +#else + struct Hash + { + std::size_t operator()(const Edge_index& key) const + { + std::size_t res = 17; + res = res * 31 + std::hash()(key[0]); + res = res * 31 + std::hash()(key[1]); + res = res * 31 + std::hash()(key[2]); + res = res * 31 + std::hash()(key[3]); + return res; + } + }; +#endif private: const Domain& m_domain; FT m_isovalue; +#ifdef CGAL_LINKED_WITH_TBB std::atomic m_point_counter; -#ifdef CGAL_LINKED_WITH_TBB tbb::concurrent_vector m_points; tbb::concurrent_vector > m_triangles; using Edge_point_map = tbb::concurrent_hash_map; Edge_point_map m_edges; #else + Point_index m_point_counter; + std::vector m_points; std::vector > m_triangles; - // std::unordered_map m_edges; // @tmp hash map - std::map m_edges; // @tmp hash map + std::unordered_map m_edges; #endif public: