Add missing operator->() to Facet_circulator.

This commit is contained in:
Sylvain Pion 2007-08-23 12:59:06 +00:00
parent 990b6df224
commit 606b7aa6f0
3 changed files with 135 additions and 67 deletions

View File

@ -348,6 +348,17 @@ public:
return Facet(pos, next_around_edge( pos->index(_s), pos->index(_t) ) ); return Facet(pos, next_around_edge( pos->index(_s), pos->index(_t) ) );
} }
struct Proxy_Facet {
Proxy_Facet(const Facet & ff) : f(ff) {}
Facet f;
const Facet* operator->() const { return &f; }
};
Proxy_Facet operator->() const
{
return Proxy_Facet(* *this);
}
bool operator==(const Facet_circulator & ccir) const bool operator==(const Facet_circulator & ccir) const
{ {
return pos == ccir.pos && _s == ccir._s && _t == ccir._t; return pos == ccir.pos && _s == ccir._s && _t == ccir._t;

View File

@ -13,7 +13,7 @@
// //
// $URL$ // $URL$
// $Id$ // $Id$
// //
// //
// Author(s) : Francois Rebufat (Francois.Rebufat@sophia.inria.fr) // Author(s) : Francois Rebufat (Francois.Rebufat@sophia.inria.fr)
// Monique Teillaud // Monique Teillaud
@ -43,26 +43,26 @@ _test_circulator( const Triangulation &T )
Edge_iterator eit; Edge_iterator eit;
Finite_edges_iterator feit; Finite_edges_iterator feit;
// testing incident_cells(edge *); // testing incident_cells(edge *);
// for (eit=T.edges_begin(); eit!=T.edges_end(); eit++) // for (eit=T.edges_begin(); eit!=T.edges_end(); eit++)
eit=T.edges_begin(); eit=T.edges_begin();
{ {
cc0=cc=T.incident_cells(*eit); cc0=cc=T.incident_cells(*eit);
Cell_handle ch = cc0; // Test the conversion. Cell_handle ch = cc0; // Test the conversion.
(void) ch; (void) ch;
do { do {
assert(cc->has_vertex((*eit).first->vertex((*eit).second))); assert(cc->has_vertex(eit->first->vertex(eit->second)));
assert(cc->has_vertex((*eit).first->vertex((*eit).third))); assert(cc->has_vertex(eit->first->vertex(eit->third)));
cc++; n++; cc++; n++;
} while (cc != cc0); } while (cc != cc0);
} }
// test of incident_cells(cellhandle,int,int) and -- // test of incident_cells(cellhandle,int,int) and --
feit=T.finite_edges_begin(); feit=T.finite_edges_begin();
{ {
cc0=cc=T.incident_cells((*feit).first,(*feit).second,(*feit).third); cc0=cc=T.incident_cells(feit->first, feit->second, feit->third);
do { do {
assert(cc->has_vertex((*feit).first->vertex((*feit).second))); assert(cc->has_vertex(feit->first->vertex(feit->second)));
assert(cc->has_vertex((*feit).first->vertex((*feit).third))); assert(cc->has_vertex(feit->first->vertex(feit->third)));
cc--; n++; cc--; n++;
} while (cc != cc0); } while (cc != cc0);
} }
@ -70,26 +70,26 @@ _test_circulator( const Triangulation &T )
// for (eit=T.edges_begin(); eit!=T.edges_end(); eit++) // for (eit=T.edges_begin(); eit!=T.edges_end(); eit++)
eit=T.edges_begin(); eit=T.edges_begin();
{ {
cc0=cc=T.incident_cells(*eit,(*eit).first); cc0=cc=T.incident_cells(*eit, eit->first);
do { do {
assert(cc->has_vertex((*eit).first->vertex((*eit).second))); assert(cc->has_vertex(eit->first->vertex(eit->second)));
assert(cc->has_vertex((*eit).first->vertex((*eit).third))); assert(cc->has_vertex(eit->first->vertex(eit->third)));
cc++; n++; cc++; n++;
} while (cc != cc0); } while (cc != cc0);
} }
// test of incident_cells(cellhandle,int,int,cellhandle) and -- // test of incident_cells(cellhandle,int,int,cellhandle) and --
feit=T.finite_edges_begin(); feit=T.finite_edges_begin();
{ {
cc0=cc=T.incident_cells((*feit).first,(*feit).second,(*feit).third, cc0=cc=T.incident_cells(feit->first, feit->second, feit->third,
(*feit).first); feit->first);
do { do {
assert(cc->has_vertex((*feit).first->vertex((*feit).second))); assert(cc->has_vertex(feit->first->vertex(feit->second)));
assert(cc->has_vertex((*feit).first->vertex((*feit).third))); assert(cc->has_vertex(feit->first->vertex(feit->third)));
cc--; n++; cc--; n++;
} while (cc != cc0); } while (cc != cc0);
} }
// the following is not useful here, it tests iterators more than // the following is not useful here, it tests iterators more than
// circulators // circulators
// for (eit=T.finite_edges_begin(); eit!=T.edges_end(); eit++) // for (eit=T.finite_edges_begin(); eit!=T.edges_end(); eit++)
// { // {
// cc0=cc=T.incident_cells(*eit); // cc0=cc=T.incident_cells(*eit);
@ -99,7 +99,7 @@ _test_circulator( const Triangulation &T )
// } // }
// for (eit=T.finite_edges_begin(); eit!=T.edges_end(); eit++) // for (eit=T.finite_edges_begin(); eit!=T.edges_end(); eit++)
// { // {
// cc0=cc=T.incident_cells(*eit,(*eit).first); // cc0=cc=T.incident_cells(*eit, eit->first);
// do { // do {
// cc++; n++; // cc++; n++;
// } while (cc != cc0); // } while (cc != cc0);
@ -111,7 +111,7 @@ _test_circulator( const Triangulation &T )
Vertex_handle vh = T.vertices_begin(); Vertex_handle vh = T.vertices_begin();
T.incident_cells(vh,std::back_inserter(cells)); T.incident_cells(vh, std::back_inserter(cells));
T.incident_vertices(vh, std::back_inserter(vertices)); T.incident_vertices(vh, std::back_inserter(vertices));
T.incident_facets(vh, std::back_inserter(facets)); T.incident_facets(vh, std::back_inserter(facets));
@ -136,20 +136,20 @@ _test_circulator( const Triangulation &T )
{ {
fc0=fc=T.incident_facets(*eit); fc0=fc=T.incident_facets(*eit);
do { do {
assert((*fc).first->has_vertex((*eit).first->vertex((*eit).second), i)); assert(fc->first->has_vertex(eit->first->vertex(eit->second), i));
assert((*fc).first->has_vertex((*eit).first->vertex((*eit).third), j)); assert(fc->first->has_vertex(eit->first->vertex(eit->third), j));
assert( (*fc).second == T.next_around_edge(i,j) ); assert(fc->second == T.next_around_edge(i, j) );
fc++; n++; fc++; n++;
} while (fc != fc0); } while (fc != fc0);
} }
// for (eit=T.edges_begin(); eit!=T.edges_end(); eit++) // for (eit=T.edges_begin(); eit!=T.edges_end(); eit++)
feit=T.finite_edges_begin(); // test (cell*,int,int) feit=T.finite_edges_begin(); // test (cell*,int,int)
{ {
fc0=fc=T.incident_facets((*feit).first,(*feit).second,(*feit).third); fc0=fc=T.incident_facets(feit->first, feit->second, feit->third);
do { do {
assert((*fc).first->has_vertex((*feit).first->vertex((*feit).second), i)); assert(fc->first->has_vertex(feit->first->vertex(feit->second), i));
assert((*fc).first->has_vertex((*feit).first->vertex((*feit).third), j)); assert(fc->first->has_vertex(feit->first->vertex(feit->third), j));
assert( (*fc).second == T.next_around_edge(i,j) ); assert(fc->second == T.next_around_edge(i, j) );
fc--; n++; fc--; n++;
} while (fc != fc0); } while (fc != fc0);
} }
@ -157,15 +157,15 @@ _test_circulator( const Triangulation &T )
// for (eit=T.edges_begin(); eit!=T.edges_end(); eit++) // for (eit=T.edges_begin(); eit!=T.edges_end(); eit++)
eit=T.edges_begin(); // test (edge, Cell*,int) eit=T.edges_begin(); // test (edge, Cell*,int)
{ {
// for (fi=0; fi!=4 ; fi++) // for (fi=0; fi!=4 ; fi++)
// { // {
// if (t.dimension()==2) {fi=3;} // if (t.dimension()==2) {fi=3;}
fc0=fc=T.incident_facets(*eit,(*eit).first, fc0=fc=T.incident_facets(*eit, eit->first,
T.next_around_edge((*eit).second,(*eit).third)); T.next_around_edge(eit->second, eit->third));
do { do {
assert((*fc).first->has_vertex((*eit).first->vertex((*eit).second), i)); assert(fc->first->has_vertex(eit->first->vertex(eit->second), i));
assert((*fc).first->has_vertex((*eit).first->vertex((*eit).third), j)); assert(fc->first->has_vertex(eit->first->vertex(eit->third), j));
assert( (*fc).second == T.next_around_edge(i,j) ); assert(fc->second == T.next_around_edge(i, j) );
fc++; n++; fc++; n++;
} while (fc != fc0); } while (fc != fc0);
// } // }
@ -173,29 +173,29 @@ _test_circulator( const Triangulation &T )
// for (eit=T.edges_begin(); eit!=T.edges_end(); eit++) // for (eit=T.edges_begin(); eit!=T.edges_end(); eit++)
feit=T.finite_edges_begin(); // test (Cell*,int,int,cell*,int) feit=T.finite_edges_begin(); // test (Cell*,int,int,cell*,int)
{ {
fc0=fc=T.incident_facets((*feit).first,(*feit).second,(*feit).third, fc0=fc=T.incident_facets(feit->first, feit->second, feit->third,
(*feit).first, feit->first,
T.next_around_edge((*feit).second,(*feit).third)); T.next_around_edge(feit->second, feit->third));
do { do {
assert((*fc).first->has_vertex((*feit).first->vertex((*feit).second), i)); assert(fc->first->has_vertex(feit->first->vertex(feit->second), i));
assert((*fc).first->has_vertex((*feit).first->vertex((*feit).third), j)); assert(fc->first->has_vertex(feit->first->vertex(feit->third), j));
assert( (*fc).second == T.next_around_edge(i,j) ); assert(fc->second == T.next_around_edge(i, j) );
fc--; n++; fc--; n++;
} while (fc != fc0); } while (fc != fc0);
} }
eit=T.edges_begin(); // test (edge, Facet) eit=T.edges_begin(); // test (edge, Facet)
{ {
// for (fi=0; fi!=4 ; fi++) // for (fi=0; fi!=4 ; fi++)
// { // {
// if (t.dimension()==2) {fi=3;} // if (t.dimension()==2) {fi=3;}
fc0=fc=T.incident_facets(*eit,std::make_pair( (*eit).first, fc0=fc=T.incident_facets(*eit, std::make_pair( eit->first,
T.next_around_edge((*eit).second, T.next_around_edge(eit->second,
(*eit).third)) ); eit->third)) );
do { do {
assert((*fc).first->has_vertex((*eit).first->vertex((*eit).second), i)); assert(fc->first->has_vertex(eit->first->vertex(eit->second), i));
assert((*fc).first->has_vertex((*eit).first->vertex((*eit).third), j)); assert(fc->first->has_vertex(eit->first->vertex(eit->third), j));
assert( (*fc).second == T.next_around_edge(i,j) ); assert(fc->second == T.next_around_edge(i, j) );
fc++; n++; fc++; n++;
} while (fc != fc0); } while (fc != fc0);
// } // }
@ -203,14 +203,14 @@ _test_circulator( const Triangulation &T )
// for (eit=T.edges_begin(); eit!=T.edges_end(); eit++) // for (eit=T.edges_begin(); eit!=T.edges_end(); eit++)
feit=T.finite_edges_begin(); // test (Cell*,int,int,Facet) feit=T.finite_edges_begin(); // test (Cell*,int,int,Facet)
{ {
fc0=fc=T.incident_facets((*feit).first,(*feit).second,(*feit).third, fc0=fc=T.incident_facets(feit->first, feit->second, feit->third,
std::make_pair( (*feit).first, std::make_pair( feit->first,
T.next_around_edge((*feit).second, T.next_around_edge(feit->second,
(*feit).third)) ); feit->third)) );
do { do {
assert((*fc).first->has_vertex((*feit).first->vertex((*feit).second), i)); assert(fc->first->has_vertex(feit->first->vertex(feit->second), i));
assert((*fc).first->has_vertex((*feit).first->vertex((*feit).third), j)); assert(fc->first->has_vertex(feit->first->vertex(feit->third), j));
assert( (*fc).second == T.next_around_edge(i,j) ); assert(fc->second == T.next_around_edge(i, j) );
fc--; n++; fc--; n++;
} while (fc != fc0); } while (fc != fc0);
} }

View File

@ -13,7 +13,7 @@
// //
// $URL$ // $URL$
// $Id$ // $Id$
// //
// //
// Author(s) : Francois Rebufat (Francois.Rebufat@sophia.inria.fr) // Author(s) : Francois Rebufat (Francois.Rebufat@sophia.inria.fr)
@ -25,29 +25,58 @@ int
_test_vertex_iterator( const Triangulation &T ) _test_vertex_iterator( const Triangulation &T )
{ {
typedef typename Triangulation::size_type size_type; typedef typename Triangulation::size_type size_type;
typedef typename Triangulation::Vertex Vertex;
typedef typename Triangulation::Vertex_handle Vertex_handle; typedef typename Triangulation::Vertex_handle Vertex_handle;
typedef typename Triangulation::Cell_handle Cell_handle;
typedef typename Triangulation::Vertex_iterator Vertex_iterator; typedef typename Triangulation::Vertex_iterator Vertex_iterator;
typedef typename Triangulation::Finite_vertices_iterator typedef typename Triangulation::Finite_vertices_iterator
Finite_vertices_iterator; Finite_vertices_iterator;
size_type n = 0; size_type n = 0;
Vertex_iterator vit; for (Vertex_iterator vit = T.vertices_begin(); vit != T.vertices_end(); ++vit)
for (vit = T.vertices_begin(); vit != T.vertices_end(); ++vit)
{ {
Vertex_handle vh = vit; // Test the conversion. Vertex_handle vh = vit; // Test the conversion.
n++;
const Vertex & v = *vit; // Test operator*;
Cell_handle c = vit->cell(); // Test operator->;
(void) vh; (void) vh;
n++; (void) v;
(void) c;
} }
assert( n-1 == T.number_of_vertices() ); assert( n-1 == T.number_of_vertices() );
n=0; n=0;
Finite_vertices_iterator fvit; for (Finite_vertices_iterator fvit = T.finite_vertices_begin();
for (fvit = T.finite_vertices_begin(); fvit != T.finite_vertices_end(); ++fvit) fvit != T.finite_vertices_end(); ++fvit)
{
Vertex_handle vh = fvit; // Test the conversion.
const Vertex & v = *fvit; // Test operator*;
Cell_handle c = fvit->cell(); // Test operator->;
n++;
(void) vh;
(void) v;
(void) c;
}
assert( n == T.number_of_vertices() );
// Test Backward-ness of the iterators.
n=0;
for (Vertex_iterator vit = T.vertices_end(); vit != T.vertices_begin(); --vit)
{
Vertex_handle vh = vit; // Test the conversion.
(void) vh;
n++;
}
assert( n-1 == T.number_of_vertices() );
n=0;
for (Finite_vertices_iterator fvit = T.finite_vertices_end();
fvit != T.finite_vertices_begin(); --fvit)
{ {
Vertex_handle vh = fvit; // Test the conversion. Vertex_handle vh = fvit; // Test the conversion.
(void) vh; (void) vh;
n++; n++;
} }
assert( n == T.number_of_vertices() ); assert( n == T.number_of_vertices() );
return n; return n;
} }
@ -65,7 +94,10 @@ _test_triangulation_iterator( const Triangulation &T )
typedef typename Triangulation::Edge_iterator Edge_iterator; typedef typename Triangulation::Edge_iterator Edge_iterator;
typedef typename Triangulation::Vertex_iterator Vertex_iterator; typedef typename Triangulation::Vertex_iterator Vertex_iterator;
typedef typename Triangulation::Cell Cell;
typedef typename Triangulation::Facet Facet; typedef typename Triangulation::Facet Facet;
typedef typename Triangulation::Edge Edge;
typedef typename Triangulation::Vertex Vertex;
typedef typename Triangulation::Cell_handle Cell_handle; typedef typename Triangulation::Cell_handle Cell_handle;
int n=0 , m=0 , f=0 , t=0; int n=0 , m=0 , f=0 , t=0;
@ -85,21 +117,46 @@ _test_triangulation_iterator( const Triangulation &T )
for (FCit = T.finite_cells_begin(); FCit != T.finite_cells_end(); ++FCit) for (FCit = T.finite_cells_begin(); FCit != T.finite_cells_end(); ++FCit)
{ {
Cell_handle ch = FCit; // Test the conversion. Cell_handle ch = FCit; // Test the conversion.
(void) ch; const Cell & c = *FCit; // Test operator*.
Cell_handle ch2 = FCit->neighbor(0); // Test operator->.
(void) ch;
(void) c;
(void) ch2;
t++; t++;
} }
for (FFit = T.finite_facets_begin(); FFit != T.finite_facets_end(); ++FFit) for (FFit = T.finite_facets_begin(); FFit != T.finite_facets_end(); ++FFit) {
const Facet & f2 = *FFit; // Test operator*.
Cell_handle ch = FFit->first; // Test operator->.
(void) f2;
(void) ch;
f++; f++;
for (FEit = T.finite_edges_begin(); FEit != T.finite_edges_end(); ++FEit) }
for (FEit = T.finite_edges_begin(); FEit != T.finite_edges_end(); ++FEit) {
const Edge & e = *FEit; // Test operator*.
Cell_handle ch = FEit->first; // Test operator->.
(void) e;
(void) ch;
m++; m++;
for (FVit = T.finite_vertices_begin(); FVit != T.finite_vertices_end(); ++FVit) }
for (FVit = T.finite_vertices_begin(); FVit != T.finite_vertices_end(); ++FVit) {
const Vertex & v = *FVit; // Test operator*.
Cell_handle ch = FVit->cell(); // Test operator->.
(void) v;
(void) ch;
n++; n++;
}
// Test Backward-ness of the iterators.
for (FCit = T.finite_cells_end(); FCit != T.finite_cells_begin(); --FCit) ;
for (FFit = T.finite_facets_end(); FFit != T.finite_facets_begin(); --FFit) ;
for (FEit = T.finite_edges_end(); FEit != T.finite_edges_begin(); --FEit) ;
for (FVit = T.finite_vertices_end(); FVit != T.finite_vertices_begin(); --FVit) ;
assert((n-m+f-t)==1); assert((n-m+f-t)==1);
n=0 ; m=0 ; f=0 ; t=0; n=0 ; m=0 ; f=0 ; t=0;
for (Cit = T.cells_begin(); Cit != T.cells_end(); ++Cit) for (Cit = T.cells_begin(); Cit != T.cells_end(); ++Cit)
{ {
Cell_handle ch = Cit; // Test the conversion. Cell_handle ch = Cit; // Test the conversion.
(void) ch; (void) ch;
t++; t++;
} }
for (Fit = T.facets_begin(); Fit != T.facets_end(); ++Fit) for (Fit = T.facets_begin(); Fit != T.facets_end(); ++Fit)
@ -133,7 +190,7 @@ _test_triangulation_iterator( const Triangulation &T )
if (T.dimension() >=1) if (T.dimension() >=1)
{ {
Finite_edges_iterator Eit2; Finite_edges_iterator Eit2;
FEit = T.finite_edges_begin(); FEit = T.finite_edges_begin();
Eit2=FEit; Eit2=FEit;
assert(*FEit==*Eit2); assert(*FEit==*Eit2);
FEit++ ; FEit-- ; ++FEit ; --FEit ; FEit++ ; FEit-- ; ++FEit ; --FEit ;
@ -141,7 +198,7 @@ _test_triangulation_iterator( const Triangulation &T )
assert(*FEit==*Eit2); assert(*FEit==*Eit2);
} }
Finite_vertices_iterator Vit2; Finite_vertices_iterator Vit2;
FVit = T.finite_vertices_begin(); FVit = T.finite_vertices_begin();
Vit2=FVit; Vit2=FVit;
assert(FVit->point()==Vit2->point()); assert(FVit->point()==Vit2->point());
FVit++ ; FVit-- ; ++FVit ; --FVit ; FVit++ ; FVit-- ; ++FVit ; --FVit ;