Avoid needless containers in TDS3::copy_tds()

This commit is contained in:
Mael Rouxel-Labbé 2021-07-19 15:57:24 +02:00
parent 1fc3050e0b
commit 8727fd17af
1 changed files with 10 additions and 18 deletions

View File

@ -4039,32 +4039,24 @@ copy_tds(const TDS_src& tds,
|| tds.is_vertex(vert) );
clear();
size_type n = tds.number_of_vertices();
set_dimension(tds.dimension());
if (n == 0) return Vertex_handle();
if(tds.number_of_vertices() == 0)
return Vertex_handle();
// Number of pointers to cell/vertex to copy per cell.
int dim = (std::max)(1, dimension() + 1);
// Create the vertices.
std::vector<typename TDS_src::Vertex_handle> TV(n);
size_type i = 0;
for (typename TDS_src::Vertex_iterator vit = tds.vertices_begin();
vit != tds.vertices_end(); ++vit)
TV[i++] = vit;
CGAL_triangulation_assertion( i == n );
const int dim = (std::max)(1, 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;
for (i=0; i <= n-1; ++i){
Vertex_handle vh=create_vertex( convert_vertex(*TV[i]) );
V[ TV[i] ] = vh;
convert_vertex(*TV[i],*vh);
// Create the vertices.
for (typename TDS_src::Vertex_iterator vit = tds.vertices_begin();
vit != tds.vertices_end(); ++vit) {
Vertex_handle vh = create_vertex( convert_vertex(*vit) );
V[vit] = vh;
convert_vertex(*vit,*vh);
}
// Create the cells.