diff --git a/Packages/Triangulation_3/changes.txt b/Packages/Triangulation_3/changes.txt index 8f596adeb43..2e7c3fbf4f9 100644 --- a/Packages/Triangulation_3/changes.txt +++ b/Packages/Triangulation_3/changes.txt @@ -1,3 +1,6 @@ +Version 1.74 (13 July 01) +- copy_tds() cleanups. + Version 1.73 (13 July 01) - print_cells and read_cells small cleanup. - With VC++, MP_Float.h must be included before Filtered_exact.h. diff --git a/Packages/Triangulation_3/include/CGAL/Triangulation_data_structure_3.h b/Packages/Triangulation_3/include/CGAL/Triangulation_data_structure_3.h index f41e7dc6a61..3a486bb3c58 100644 --- a/Packages/Triangulation_3/include/CGAL/Triangulation_data_structure_3.h +++ b/Packages/Triangulation_3/include/CGAL/Triangulation_data_structure_3.h @@ -191,16 +191,6 @@ public: } private: - // not documented - // only used by copy_tds in the TDS class - Cell* create_cell(Vertex* v0, Vertex* v1, Vertex* v2, Vertex* v3, - const Cell & old_cell) - { - Cell* cnew = new Cell( v0,v1,v2,v3,old_cell ); - cnew->init(); - add_cell(cnew); - return cnew; - } // Used to initialize the lists to empty lists. void init_cell_list(Cell* c) @@ -2365,11 +2355,6 @@ copy_tds(const Tds & tds, Vertex* vert ) CGAL_triangulation_expensive_precondition( vert == NULL || tds.is_vertex(vert) ); - std::map< void*, void* > V; - std::map< void*, void* > F; - Vertex* v; - Cell* f; - clear(); int n = tds.number_of_vertices(); @@ -2394,39 +2379,39 @@ copy_tds(const Tds & tds, Vertex* vert ) std::sort(TV.begin(), TV.end(), Vertex_tds_compare_order_of_creation()); - for (i=0; i <= n-1; i++) - V[ TV[i] ] = new Vertex( *TV[i] ); + std::map< Vertex*, Vertex* > V; + std::map< Cell*, Cell* > F; + + for (i=0; i <= n-1; i++) { + V[ TV[i] ] = create_vertex(); + *V[ TV[i] ] = *TV[i]; + } // Create the cells. for (Cell* cit = tds._list_of_cells._next_cell; cit != tds.past_end_cell(); cit = cit->_next_cell) { - F[&(*cit)] = create_cell((Vertex*) V[cit->vertex(0)], - (Vertex*) V[cit->vertex(1)], - (Vertex*) V[cit->vertex(2)], - (Vertex*) V[cit->vertex(3)], - *cit); + F[&(*cit)] = create_cell(&*cit); + F[&(*cit)]->set_vertices(V[cit->vertex(0)], + V[cit->vertex(1)], + V[cit->vertex(2)], + V[cit->vertex(3)]); } // Link the vertices to a cell. for (Vertex_iterator vit2 = tds.vertices_begin(); - vit2 != tds.vertices_end(); ++vit2) { - v = (Vertex*) V[&(*vit2)]; - v->set_cell( (Cell*) F[vit2->cell()] ); - } + vit2 != tds.vertices_end(); ++vit2) + V[&(*vit2)]->set_cell( F[vit2->cell()] ); // Hook neighbor pointers of the cells. for (Cell* cit2 = tds._list_of_cells._next_cell; cit2 != tds.past_end_cell(); cit2 = cit2->_next_cell) { - for (int j = 0; j < 4; j++) { - f = ((Cell*) F[&(*cit2)]); - f->set_neighbor(j, (Cell*) F[cit2->neighbor(j)] ); - } + for (int j = 0; j < 4; j++) + F[&(*cit2)]->set_neighbor(j, F[cit2->neighbor(j)] ); } CGAL_triangulation_postcondition( is_valid() ); - if ( vert != NULL ) - return (Vertex*) V[vert]; - return NULL; + + return (vert != NULL) ? V[vert] : NULL; } template diff --git a/Packages/Triangulation_3/include/CGAL/Triangulation_ds_cell_3.h b/Packages/Triangulation_3/include/CGAL/Triangulation_ds_cell_3.h index 187a1d70853..44be1e570d6 100644 --- a/Packages/Triangulation_3/include/CGAL/Triangulation_ds_cell_3.h +++ b/Packages/Triangulation_3/include/CGAL/Triangulation_ds_cell_3.h @@ -79,16 +79,6 @@ public: : Cb(v0,v1,v2,v3,n0,n1,n2,n3), in_conflict_flag(0) {} - // not documented - // only used by copy_tds in the TDS class - Triangulation_ds_cell_3(Vertex* v0, Vertex* v1, - Vertex* v2, Vertex* v3, - const Cell& old_cell) - : Cb(old_cell), in_conflict_flag(0) - { - set_vertices(v0,v1,v2,v3); - } - // SETTING void set_vertex(int i, Vertex* v) @@ -198,14 +188,15 @@ private: { std::cerr << "neighbor of c has not c as neighbor" << std::endl; } -}; // __attribute__((__aligned__(16))); // Memory alignment. For GCC only +}; template bool Triangulation_ds_cell_3::is_valid (int dim, bool verbose, int level) const { - if ( ! Cb::is_valid(verbose,level) ) return false; + if ( ! Cb::is_valid(verbose,level) ) + return false; switch (dim) { case -2: @@ -218,8 +209,7 @@ Triangulation_ds_cell_3::is_valid return false; } vertex(0)->is_valid(verbose,level); - if ( vertex(1) != NULL || - vertex(2) != NULL || vertex(3) != NULL ) { + if ( vertex(1) != NULL || vertex(2) != NULL || vertex(3) != NULL ) { if (verbose) std::cerr << "vertex 1,2 or 3 != NULL" << std::endl; CGAL_triangulation_assertion(false);