From cdbf0d7d9a12ca290813adfe5c1a039c2e8516fc Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 9 Mar 2022 11:34:12 +0000 Subject: [PATCH] Initialize the size of Unique_hash_map --- .../include/CGAL/Periodic_2_triangulation_2.h | 4 ++-- .../include/CGAL/Periodic_3_triangulation_3.h | 4 ++-- TDS_2/include/CGAL/Triangulation_data_structure_2.h | 11 ++++++----- TDS_3/include/CGAL/Triangulation_data_structure_3.h | 8 ++++---- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_2.h b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_2.h index 542fcb98d3d..4104f5d9923 100644 --- a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_2.h +++ b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_2.h @@ -4164,7 +4164,7 @@ Periodic_2_triangulation_2::save(std::ostream& os) const return os; // write the vertices - Unique_hash_map V; + Unique_hash_map V(0, number_of_vertices()); std::size_t i = 0; if (is_1_cover()) { @@ -4208,7 +4208,7 @@ Periodic_2_triangulation_2::save(std::ostream& os) const } CGAL_triangulation_postcondition(i == _cover[0]*_cover[1]*n); - Unique_hash_map F; + Unique_hash_map F(0, _tds.number_of_faces()); int inum = 0; // asks the tds for the combinatorial information // vertices of the faces diff --git a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3.h b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3.h index a80c3995d5c..c5bfcff1431 100644 --- a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3.h +++ b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3.h @@ -3205,7 +3205,7 @@ periodic_remove(Vertex_handle v, PointRemover& remover, CoverManager& cover_mana // in Euclidean space and make a map from the vertices in remover.tmp // towards the vertices in *this - Unique_hash_map vmap; + Unique_hash_map vmap(Vertex_handle(), vertices_size()); CellE_handle ch; remover.tmp.clear(); @@ -4145,7 +4145,7 @@ operator<< (std::ostream& os,const Periodic_3_triangulation_3& tr) return os; // write the vertices - Unique_hash_map V; + Unique_hash_map V(0, tr.number_of_vertices()); std::size_t i=0; if(tr.is_1_cover()) { for(Vertex_iterator it=tr.vertices_begin(); it!=tr.vertices_end(); ++it) { diff --git a/TDS_2/include/CGAL/Triangulation_data_structure_2.h b/TDS_2/include/CGAL/Triangulation_data_structure_2.h index e9aea5691c9..77f58af1644 100644 --- a/TDS_2/include/CGAL/Triangulation_data_structure_2.h +++ b/TDS_2/include/CGAL/Triangulation_data_structure_2.h @@ -2008,9 +2008,10 @@ copy_tds(const TDS_src& tds_src, // Number of neighbors to set in each face (dim -1 has a single face) const int nn = (std::max)(0, dimension() + 1); + std::cout << "in copy_tds" << std::endl; //initializes maps - Unique_hash_map vmap; - Unique_hash_map fmap; + Unique_hash_map vmap(Vertex_handle(), tds_src.number_of_vertices()); + Unique_hash_map fmap(Face_handle(), tds_src.number_of_faces()); // create vertices typename TDS_src::Vertex_iterator vit1 = tds_src.vertices_begin(); @@ -2120,8 +2121,8 @@ file_output( std::ostream& os, Vertex_handle v, bool skip_first) const else os << n << m << dimension(); if (n==0) return; - Unique_hash_map V; - Unique_hash_map F; + Unique_hash_map V(-1, number_of_vertices()); + Unique_hash_map F(-1, number_of_faces()); // first vertex @@ -2257,7 +2258,7 @@ vrml_output( std::ostream& os, Vertex_handle v, bool skip_infinite) const os << "\t\tcoord Coordinate {" << std::endl; os << "\t\t\tpoint [" << std::endl; - Unique_hash_map vmap; + Unique_hash_map vmap(-1, number_of_vertices()); Vertex_iterator vit; Face_iterator fit; diff --git a/TDS_3/include/CGAL/Triangulation_data_structure_3.h b/TDS_3/include/CGAL/Triangulation_data_structure_3.h index 9b164cb726a..89e237cc0d4 100644 --- a/TDS_3/include/CGAL/Triangulation_data_structure_3.h +++ b/TDS_3/include/CGAL/Triangulation_data_structure_3.h @@ -2001,7 +2001,7 @@ operator<<(std::ostream& os, const Triangulation_data_structure_3 &tds typedef typename Tds::Vertex_iterator Vertex_iterator; - Unique_hash_map V; + Unique_hash_map V(0, tds.number_of_vertices()); // outputs dimension and number of vertices size_type n = tds.number_of_vertices(); @@ -2589,7 +2589,7 @@ void Triangulation_data_structure_3:: print_cells(std::ostream& os, const Unique_hash_map &V ) const { - Unique_hash_map C; + Unique_hash_map C(0, number_of_cells()); std::size_t i = 0; switch ( dimension() ) { @@ -4053,8 +4053,8 @@ copy_tds(const TDS_src& tds, const int nn = (std::max)(0, dimension() + 1); // Initializes maps - Unique_hash_map< typename TDS_src::Vertex_handle,Vertex_handle > V; - Unique_hash_map< typename TDS_src::Cell_handle,Cell_handle > F; + Unique_hash_map< typename TDS_src::Vertex_handle,Vertex_handle > V(Vertex_handle(), tds.number_of_vertices()); + Unique_hash_map< typename TDS_src::Cell_handle,Cell_handle > F(Cell_handle(), tds.number_of_cells()); // Create the vertices. for (typename TDS_src::Vertex_iterator vit = tds.vertices_begin();