mirror of https://github.com/CGAL/cgal
- New function TDS::create_face() to prepare for the merge TDS_2/TDS_3.
This commit is contained in:
parent
7b41bb7c0b
commit
44a5ece648
|
|
@ -1,3 +1,7 @@
|
|||
Version 1.93 (?? September 01)
|
||||
- Use CGAL/iterator.h.
|
||||
- New function TDS::create_face() to prepare for the merge TDS_2/TDS_3.
|
||||
|
||||
Version 1.92 (25 September 01)
|
||||
- Various fixes.
|
||||
|
||||
|
|
|
|||
|
|
@ -459,21 +459,16 @@ insert(const Weighted_point & p, Cell_handle start, Vertex_handle v)
|
|||
if ( bound[0] != bound[1] ) {
|
||||
if ( (c != bound[0]) && (c != bound[1]) )
|
||||
(void) conflicts.insert(c);
|
||||
bound[0]->set_vertex(0,v);
|
||||
v->set_cell(bound[0]);
|
||||
bound[1]->set_vertex(1,v);
|
||||
_tds.set_adjacency(bound[0], 1, bound[1], 0);
|
||||
}
|
||||
else {
|
||||
bound[1] = _tds.create_cell(bound[0]->vertex(0), v, NULL, NULL,
|
||||
bound[0], bound[0]->neighbor(1), NULL, NULL);
|
||||
bound[0]->neighbor(1)->set_neighbor(0,bound[1]);
|
||||
bound[1] = _tds.create_face(bound[0]->vertex(0), v, NULL);
|
||||
_tds.set_adjacency(bound[1], 1, bound[0]->neighbor(1), 0);
|
||||
bound[0]->vertex(0)->set_cell(bound[1]);
|
||||
|
||||
bound[0]->set_neighbor(1,bound[1]);
|
||||
bound[0]->set_vertex(0,v);
|
||||
v->set_cell(bound[0]);
|
||||
}
|
||||
bound[0]->set_vertex(0,v);
|
||||
_tds.set_adjacency(bound[1], 0, bound[0], 1);
|
||||
v->set_cell(bound[0]);
|
||||
|
||||
_tds.delete_cells(conflicts.begin(), conflicts.end());
|
||||
return v;
|
||||
|
|
|
|||
|
|
@ -167,7 +167,20 @@ public:
|
|||
Vertex_handle v2, Vertex_handle v3)
|
||||
{
|
||||
Cell_handle c = get_new_cell();
|
||||
c->set_vertices(v0,v1,v2,v3);
|
||||
c->set_vertex(0, v0);
|
||||
c->set_vertex(1, v1);
|
||||
c->set_vertex(2, v2);
|
||||
c->set_vertex(3, v3);
|
||||
return c;
|
||||
}
|
||||
|
||||
Cell_handle create_face(Vertex_handle v0, Vertex_handle v1, Vertex_handle v2)
|
||||
{
|
||||
CGAL_triangulation_precondition(dimension()<3);
|
||||
Cell_handle c = get_new_cell();
|
||||
c->set_vertex(0, v0);
|
||||
c->set_vertex(1, v1);
|
||||
c->set_vertex(2, v2);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
|
@ -716,10 +729,11 @@ create_star_2(Vertex_handle v, Cell_handle c, int li )
|
|||
}
|
||||
cur->neighbor(cw(i1))->set_in_conflict_flag(0);
|
||||
// here cur has an edge on the boundary of region
|
||||
cnew = create_cell( v, v1, cur->vertex( ccw(i1) ), NULL,
|
||||
cur->neighbor(cw(i1)), NULL, pnew, NULL);
|
||||
cur->neighbor(cw(i1))->set_neighbor
|
||||
( cur->neighbor(cw(i1))->index(cur), cnew );
|
||||
cnew = create_face( v, v1, cur->vertex( ccw(i1) ) );
|
||||
set_adjacency(cnew, 0, cur->neighbor(cw(i1)),
|
||||
cur->neighbor(cw(i1))->index(cur));
|
||||
cnew->set_neighbor(1, NULL);
|
||||
cnew->set_neighbor(2, pnew);
|
||||
// pnew is null at the first iteration
|
||||
v1->set_cell(cnew);
|
||||
//pnew->set_neighbor( cw(pnew->index(v1)), cnew );
|
||||
|
|
@ -1311,7 +1325,7 @@ read_cells(std::istream& is, std::map< int, Vertex_handle > &V,
|
|||
|
||||
// CGAL_triangulation_assertion( n == 2 );
|
||||
for (int i=0; i < 2; i++) {
|
||||
Cell_handle c = create_cell(V[i], NULL, NULL, NULL);
|
||||
Cell_handle c = create_face(V[i], NULL, NULL);
|
||||
C[i] = c;
|
||||
V[i]->set_cell(c);
|
||||
}
|
||||
|
|
@ -1325,7 +1339,7 @@ read_cells(std::istream& is, std::map< int, Vertex_handle > &V,
|
|||
{
|
||||
m = 1;
|
||||
// CGAL_triangulation_assertion( n == 1 );
|
||||
Cell_handle c = create_cell(V[0], NULL, NULL, NULL);
|
||||
Cell_handle c = create_face(V[0], NULL, NULL);
|
||||
C[0] = c;
|
||||
V[0]->set_cell(c);
|
||||
break;
|
||||
|
|
@ -1595,13 +1609,13 @@ insert_in_facet(Vertex_handle v, Cell_handle c, int i)
|
|||
{
|
||||
CGAL_triangulation_expensive_precondition( is_facet(c,i) );
|
||||
Cell_handle n = c->neighbor(2);
|
||||
Cell_handle cnew = create_cell(c->vertex(0),c->vertex(1),v,NULL);
|
||||
Cell_handle cnew = create_face(c->vertex(0),c->vertex(1),v);
|
||||
set_adjacency(cnew, 2, n, n->index(c));
|
||||
set_adjacency(cnew, 0, c, 2);
|
||||
c->vertex(0)->set_cell(cnew);
|
||||
|
||||
n = c->neighbor(1);
|
||||
Cell_handle dnew = create_cell(c->vertex(0),v,c->vertex(2),NULL);
|
||||
Cell_handle dnew = create_face(c->vertex(0),v,c->vertex(2));
|
||||
set_adjacency(dnew, 1, n, n->index(c));
|
||||
set_adjacency(dnew, 0, c, 1);
|
||||
set_adjacency(dnew, 2, cnew, 1);
|
||||
|
|
@ -1688,7 +1702,7 @@ insert_in_edge(Vertex_handle v, Cell_handle c, int i, int j)
|
|||
case 1:
|
||||
{
|
||||
CGAL_triangulation_expensive_precondition( is_edge(c,i,j) );
|
||||
Cell_handle cnew = create_cell(v,c->vertex(1),NULL,NULL);
|
||||
Cell_handle cnew = create_face(v,c->vertex(1),NULL);
|
||||
c->vertex(1)->set_cell(cnew);
|
||||
c->set_vertex(1,v);
|
||||
set_adjacency(cnew, 0, c->neighbor(0), 1);
|
||||
|
|
@ -1737,7 +1751,7 @@ insert_increase_dimension(Vertex_handle v, // new vertex
|
|||
// insertion of the first vertex
|
||||
// ( geometrically : infinite vertex )
|
||||
{
|
||||
Cell_handle c = create_cell( v, NULL, NULL, NULL);
|
||||
Cell_handle c = create_face( v, NULL, NULL);
|
||||
v->set_cell(c);
|
||||
break;
|
||||
}
|
||||
|
|
@ -1746,7 +1760,7 @@ insert_increase_dimension(Vertex_handle v, // new vertex
|
|||
// insertion of the second vertex
|
||||
// ( geometrically : first finite vertex )
|
||||
{
|
||||
Cell_handle d = create_cell( v, NULL, NULL, NULL);
|
||||
Cell_handle d = create_face( v, NULL, NULL);
|
||||
v->set_cell(d);
|
||||
set_adjacency(d, 0, star->cell(), 0);
|
||||
break;
|
||||
|
|
@ -1765,7 +1779,7 @@ insert_increase_dimension(Vertex_handle v, // new vertex
|
|||
d->set_vertex(1,d->vertex(0));
|
||||
d->set_vertex(0,v);
|
||||
set_adjacency(c, 1, d, 0);
|
||||
Cell_handle e = create_cell( star, v, NULL, NULL);
|
||||
Cell_handle e = create_face( star, v, NULL);
|
||||
set_adjacency(e, 0, d, 1);
|
||||
set_adjacency(e, 1, c, 0);
|
||||
}
|
||||
|
|
@ -1773,7 +1787,7 @@ insert_increase_dimension(Vertex_handle v, // new vertex
|
|||
c->set_vertex(1,d->vertex(0));
|
||||
d->set_vertex(1,v);
|
||||
d->set_neighbor(1,c);
|
||||
Cell_handle e = create_cell( v, star, NULL, NULL);
|
||||
Cell_handle e = create_face( v, star, NULL);
|
||||
set_adjacency(e, 0, c, 1);
|
||||
set_adjacency(e, 1, d, 0);
|
||||
}
|
||||
|
|
@ -1798,7 +1812,7 @@ insert_increase_dimension(Vertex_handle v, // new vertex
|
|||
Cell_handle enew=NULL;
|
||||
|
||||
while( e != d ){
|
||||
enew = create_cell( );
|
||||
enew = create_cell();
|
||||
enew->set_vertex(i,e->vertex(j));
|
||||
enew->set_vertex(j,e->vertex(i));
|
||||
enew->set_vertex(2,star);
|
||||
|
|
@ -1846,18 +1860,20 @@ insert_increase_dimension(Vertex_handle v, // new vertex
|
|||
Cell_iterator it = cells_begin();
|
||||
// allowed since the dimension has already been set to 3
|
||||
|
||||
v->set_cell(&(*it)); // ok since there is at least one ``cell''
|
||||
v->set_cell(it->handle()); // ok since there is at least one ``cell''
|
||||
for(; it != cells_end(); ++it) {
|
||||
// Here we must be careful since we create_cells in a loop controlled
|
||||
// by an iterator. So we first take care of the cells newly created
|
||||
// by the following test :
|
||||
if (it->neighbor(0) == NULL)
|
||||
continue;
|
||||
it->set_neighbor(3, NULL);
|
||||
it->set_vertex(3,v);
|
||||
if ( ! it->has_vertex(star) ) {
|
||||
Cell_handle cnew = create_cell( it->vertex(0), it->vertex(2),
|
||||
it->vertex(1), star);
|
||||
set_adjacency(cnew, 3, it->handle(), 3);
|
||||
cnew->set_neighbor(0, NULL);
|
||||
new_cells.push_back(cnew);
|
||||
}
|
||||
}
|
||||
|
|
@ -2147,13 +2163,13 @@ copy_tds(const Tds & tds, Vertex_handle vert )
|
|||
// Link the vertices to a cell.
|
||||
for (Vertex_iterator vit2 = tds.vertices_begin();
|
||||
vit2 != tds.vertices_end(); ++vit2)
|
||||
V[&(*vit2)]->set_cell( F[vit2->cell()] );
|
||||
V[vit2->handle()]->set_cell( F[vit2->cell()] );
|
||||
|
||||
// Hook neighbor pointers of the cells.
|
||||
for (Cell_iterator cit2 = tds.cell_container().begin();
|
||||
cit2 != tds.cells_end(); ++cit2) {
|
||||
for (int j = 0; j < 4; j++)
|
||||
F[&(*cit2)]->set_neighbor(j, F[cit2->neighbor(j)] );
|
||||
F[cit2->handle()]->set_neighbor(j, F[cit2->neighbor(j)] );
|
||||
}
|
||||
|
||||
CGAL_triangulation_postcondition( is_valid() );
|
||||
|
|
@ -2166,7 +2182,8 @@ void
|
|||
Triangulation_data_structure_3<Vb,Cb>::
|
||||
swap(Tds & tds)
|
||||
{
|
||||
// tds and *this are supposed to be valid
|
||||
CGAL_triangulation_expensive_precondition(tds.is_valid() && is_valid());
|
||||
|
||||
std::swap(_dimension, tds._dimension);
|
||||
std::swap(_number_of_vertices, tds._number_of_vertices);
|
||||
cell_container().swap(tds.cell_container());
|
||||
|
|
|
|||
|
|
@ -188,14 +188,13 @@ Triangulation_ds_cell_3<Tds>::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) {
|
||||
if (verbose)
|
||||
std::cerr << "vertex 1,2 or 3 != NULL" << std::endl;
|
||||
std::cerr << "vertex 1 or 2 != NULL" << std::endl;
|
||||
CGAL_triangulation_assertion(false);
|
||||
return false;
|
||||
}
|
||||
if ( neighbor(0) != NULL || neighbor(1) != NULL ||
|
||||
neighbor(2) != NULL || neighbor(3) != NULL ) {
|
||||
if ( neighbor(0) != NULL || neighbor(1) != NULL || neighbor(2) != NULL) {
|
||||
if (verbose)
|
||||
std::cerr << "one neighbor != NULL" << std::endl;
|
||||
CGAL_triangulation_assertion(false);
|
||||
|
|
@ -219,16 +218,15 @@ Triangulation_ds_cell_3<Tds>::is_valid
|
|||
CGAL_triangulation_assertion(false);
|
||||
return false;
|
||||
}
|
||||
if ( vertex(1) != NULL || vertex(2) != NULL || vertex(3) != NULL ) {
|
||||
if ( vertex(1) != NULL || vertex(2) != NULL ) {
|
||||
if (verbose)
|
||||
std::cerr << "vertex 1, 2 or 3 != NULL" << std::endl;
|
||||
std::cerr << "vertex 1 or 2 != NULL" << std::endl;
|
||||
CGAL_triangulation_assertion(false);
|
||||
return false;
|
||||
}
|
||||
if ( neighbor(1) != NULL ||
|
||||
neighbor(2) != NULL || neighbor(3) != NULL ) {
|
||||
if ( neighbor(1) != NULL || neighbor(2) != NULL ) {
|
||||
if (verbose)
|
||||
std::cerr << "neighbor 1, 2 or 3 != NULL" << std::endl;
|
||||
std::cerr << "neighbor 1 or 2 != NULL" << std::endl;
|
||||
CGAL_triangulation_assertion(false);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -263,15 +261,15 @@ Triangulation_ds_cell_3<Tds>::is_valid
|
|||
CGAL_triangulation_assertion(false);
|
||||
return false;
|
||||
}
|
||||
if ( vertex(2) != NULL || vertex(3) != NULL ) {
|
||||
if ( vertex(2) != NULL) {
|
||||
if (verbose)
|
||||
std::cerr << "vertex 2 or 3 != NULL" << std::endl;
|
||||
std::cerr << "vertex 2 != NULL" << std::endl;
|
||||
CGAL_triangulation_assertion(false);
|
||||
return false;
|
||||
}
|
||||
if ( neighbor(2) != NULL || neighbor(3) != NULL ) {
|
||||
if ( neighbor(2) != NULL) {
|
||||
if (verbose)
|
||||
std::cerr << "neighbor 2 or 3 != NULL" << std::endl;
|
||||
std::cerr << "neighbor 2 != NULL" << std::endl;
|
||||
CGAL_triangulation_assertion(false);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -320,19 +318,6 @@ Triangulation_ds_cell_3<Tds>::is_valid
|
|||
vertex(0)->is_valid(verbose,level);
|
||||
vertex(1)->is_valid(verbose,level);
|
||||
vertex(2)->is_valid(verbose,level);
|
||||
if ( vertex(3) != NULL ) {
|
||||
if (verbose)
|
||||
std::cerr << "vertex 3 != NULL" << std::endl;
|
||||
CGAL_triangulation_assertion(false);
|
||||
return false;
|
||||
}
|
||||
if ( neighbor(3) != NULL ) {
|
||||
if (verbose)
|
||||
std::cerr << "neighbor 3 != NULL" << std::endl;
|
||||
CGAL_triangulation_assertion(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
int in;
|
||||
Cell_handle n;
|
||||
for(int i = 0; i < 3; i++) {
|
||||
|
|
@ -394,7 +379,7 @@ Triangulation_ds_cell_3<Tds>::is_valid
|
|||
}
|
||||
|
||||
int in;
|
||||
if ( ! n->has_neighbor((Cell_handle)this,in) ) {
|
||||
if ( ! n->has_neighbor(this,in) ) {
|
||||
if (verbose)
|
||||
std::cerr << "neighbor of c has not c as neighbor" << std::endl;
|
||||
CGAL_triangulation_assertion(false);
|
||||
|
|
|
|||
|
|
@ -78,27 +78,31 @@ _test_cls_tds_3( const Tds &)
|
|||
Vertex_iterator vit;
|
||||
vit=tds3.vertices_begin();
|
||||
Vertex_handle v2 = tds3.create_vertex();
|
||||
tds3.insert_increase_dimension(v2,&*vit);
|
||||
tds3.insert_increase_dimension(v2, vit->handle());
|
||||
std::cout << "ok" << std::endl;
|
||||
assert(tds3.is_valid());
|
||||
Tds tds4 = tds3;
|
||||
vit=tds4.vertices_begin();
|
||||
Vertex_handle v3 = tds4.create_vertex();
|
||||
tds4.insert_increase_dimension(v3,&*vit);
|
||||
tds4.insert_increase_dimension(v3, vit->handle());
|
||||
std::cout << "ok" << std::endl;
|
||||
assert(tds4.is_valid());
|
||||
Tds tds5;
|
||||
tds5.swap(tds4);
|
||||
tds4=tds5;
|
||||
vit=tds5.vertices_begin();
|
||||
Vertex_handle v4 = tds5.create_vertex();
|
||||
tds5.insert_increase_dimension(v4,&*vit);
|
||||
tds5.insert_increase_dimension(v4, vit->handle());
|
||||
std::cout << "ok" << std::endl;
|
||||
assert(tds5.is_valid());
|
||||
Tds tds6;
|
||||
tds6.swap(tds5);
|
||||
tds5=tds6;
|
||||
vit=tds6.vertices_begin();
|
||||
Vertex_handle v5 = tds6.create_vertex();
|
||||
tds6.insert_increase_dimension(v5,&*vit);
|
||||
tds6.insert_increase_dimension(v5, vit->handle());
|
||||
std::cout << "ok" << std::endl;
|
||||
assert(tds6.is_valid());
|
||||
|
||||
// Setting functions
|
||||
std::cout << " setting functions" << std::endl;
|
||||
|
|
@ -127,13 +131,13 @@ _test_cls_tds_3( const Tds &)
|
|||
int i;
|
||||
Vertex_handle v6 = tds6.create_vertex();
|
||||
cit = tds6.cells_begin();
|
||||
tds6.insert_in_cell(v6, &(*cit));
|
||||
tds6.insert_in_cell(v6, cit->handle());
|
||||
Vertex_handle v7 = tds6.create_vertex();
|
||||
cit = tds6.cells_begin();
|
||||
tds6.insert_in_cell(v7, &(*cit));
|
||||
tds6.insert_in_cell(v7, cit->handle());
|
||||
Vertex_handle v8 = tds6.create_vertex();
|
||||
cit = tds6.cells_begin();
|
||||
tds6.insert_in_cell(v8, &(*cit));
|
||||
tds6.insert_in_cell(v8, cit->handle());
|
||||
assert(tds6.number_of_vertices()==8);
|
||||
// std::cout << tds6.number_of_cells()<< " cells" << std::endl;
|
||||
|
||||
|
|
@ -152,7 +156,7 @@ _test_cls_tds_3( const Tds &)
|
|||
nbflips++;
|
||||
tds6.flip_flippable( cit->handle(), i );
|
||||
assert(tds6.is_valid());
|
||||
// if ( tds6.flip( &(*cit), i ) ) {
|
||||
// if ( tds6.flip( cit->handle(), i ) ) {
|
||||
// tds6.is_valid(true);
|
||||
// nbflips++;
|
||||
// }
|
||||
|
|
@ -176,7 +180,7 @@ _test_cls_tds_3( const Tds &)
|
|||
next_cell = ++cit; --cit;
|
||||
while ( (! flipped) && (i<4) ) {
|
||||
if ( (i!=j) ) {
|
||||
flipped = tds6.flip( &(*cit), i, j ) ;
|
||||
flipped = tds6.flip( cit->handle(), i, j ) ;
|
||||
if (flipped) {
|
||||
nbflips++;
|
||||
assert(tds6.is_valid());
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ _test_cell_tds_3(const Tds &)
|
|||
std::cout << " Cells Tds Constructors " << std::endl;
|
||||
int ind;
|
||||
Tds tds;
|
||||
tds.set_dimension(3);
|
||||
Vertex_handle v0= tds.create_vertex();
|
||||
Vertex_handle v1= tds.create_vertex();
|
||||
Vertex_handle v2= tds.create_vertex();
|
||||
|
|
|
|||
Loading…
Reference in New Issue