From 606b7aa6f0752cad9d91acb697b5564d22c45f13 Mon Sep 17 00:00:00 2001 From: Sylvain Pion Date: Thu, 23 Aug 2007 12:59:06 +0000 Subject: [PATCH] Add missing operator->() to Facet_circulator. --- .../CGAL/Triangulation_ds_circulators_3.h | 11 ++ .../include/CGAL/_test_cls_circulator.C | 104 +++++++++--------- .../include/CGAL/_test_cls_iterator.C | 87 ++++++++++++--- 3 files changed, 135 insertions(+), 67 deletions(-) diff --git a/Triangulation_3/include/CGAL/Triangulation_ds_circulators_3.h b/Triangulation_3/include/CGAL/Triangulation_ds_circulators_3.h index a984722c4c9..60ff1724ff7 100644 --- a/Triangulation_3/include/CGAL/Triangulation_ds_circulators_3.h +++ b/Triangulation_3/include/CGAL/Triangulation_ds_circulators_3.h @@ -348,6 +348,17 @@ public: 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 { return pos == ccir.pos && _s == ccir._s && _t == ccir._t; diff --git a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_circulator.C b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_circulator.C index 99a2995aa5a..a671e4042cf 100644 --- a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_circulator.C +++ b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_circulator.C @@ -13,7 +13,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Francois Rebufat (Francois.Rebufat@sophia.inria.fr) // Monique Teillaud @@ -43,26 +43,26 @@ _test_circulator( const Triangulation &T ) Edge_iterator eit; Finite_edges_iterator feit; - // testing incident_cells(edge *); + // testing incident_cells(edge *); // for (eit=T.edges_begin(); eit!=T.edges_end(); eit++) eit=T.edges_begin(); { cc0=cc=T.incident_cells(*eit); - Cell_handle ch = cc0; // Test the conversion. - (void) ch; + Cell_handle ch = cc0; // Test the conversion. + (void) ch; do { - 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->second))); + assert(cc->has_vertex(eit->first->vertex(eit->third))); cc++; n++; } while (cc != cc0); } // test of incident_cells(cellhandle,int,int) and -- 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 { - 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->second))); + assert(cc->has_vertex(feit->first->vertex(feit->third))); cc--; n++; } while (cc != cc0); } @@ -70,26 +70,26 @@ _test_circulator( const Triangulation &T ) // for (eit=T.edges_begin(); eit!=T.edges_end(); eit++) eit=T.edges_begin(); { - cc0=cc=T.incident_cells(*eit,(*eit).first); + cc0=cc=T.incident_cells(*eit, eit->first); do { - 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->second))); + assert(cc->has_vertex(eit->first->vertex(eit->third))); cc++; n++; } while (cc != cc0); } // test of incident_cells(cellhandle,int,int,cellhandle) and -- feit=T.finite_edges_begin(); { - cc0=cc=T.incident_cells((*feit).first,(*feit).second,(*feit).third, - (*feit).first); + cc0=cc=T.incident_cells(feit->first, feit->second, feit->third, + feit->first); do { - 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->second))); + assert(cc->has_vertex(feit->first->vertex(feit->third))); cc--; n++; } while (cc != cc0); } // the following is not useful here, it tests iterators more than - // circulators + // circulators // for (eit=T.finite_edges_begin(); eit!=T.edges_end(); 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++) // { -// cc0=cc=T.incident_cells(*eit,(*eit).first); +// cc0=cc=T.incident_cells(*eit, eit->first); // do { // cc++; n++; // } while (cc != cc0); @@ -111,7 +111,7 @@ _test_circulator( const Triangulation &T ) 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_facets(vh, std::back_inserter(facets)); @@ -136,20 +136,20 @@ _test_circulator( const Triangulation &T ) { fc0=fc=T.incident_facets(*eit); do { - assert((*fc).first->has_vertex((*eit).first->vertex((*eit).second), i)); - assert((*fc).first->has_vertex((*eit).first->vertex((*eit).third), j)); - assert( (*fc).second == T.next_around_edge(i,j) ); + assert(fc->first->has_vertex(eit->first->vertex(eit->second), i)); + assert(fc->first->has_vertex(eit->first->vertex(eit->third), j)); + assert(fc->second == T.next_around_edge(i, j) ); fc++; n++; } while (fc != fc0); } // for (eit=T.edges_begin(); eit!=T.edges_end(); eit++) 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 { - assert((*fc).first->has_vertex((*feit).first->vertex((*feit).second), i)); - assert((*fc).first->has_vertex((*feit).first->vertex((*feit).third), j)); - assert( (*fc).second == T.next_around_edge(i,j) ); + assert(fc->first->has_vertex(feit->first->vertex(feit->second), i)); + assert(fc->first->has_vertex(feit->first->vertex(feit->third), j)); + assert(fc->second == T.next_around_edge(i, j) ); fc--; n++; } while (fc != fc0); } @@ -157,15 +157,15 @@ _test_circulator( const Triangulation &T ) // for (eit=T.edges_begin(); eit!=T.edges_end(); eit++) 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;} - fc0=fc=T.incident_facets(*eit,(*eit).first, - T.next_around_edge((*eit).second,(*eit).third)); + fc0=fc=T.incident_facets(*eit, eit->first, + T.next_around_edge(eit->second, eit->third)); do { - assert((*fc).first->has_vertex((*eit).first->vertex((*eit).second), i)); - assert((*fc).first->has_vertex((*eit).first->vertex((*eit).third), j)); - assert( (*fc).second == T.next_around_edge(i,j) ); + assert(fc->first->has_vertex(eit->first->vertex(eit->second), i)); + assert(fc->first->has_vertex(eit->first->vertex(eit->third), j)); + assert(fc->second == T.next_around_edge(i, j) ); fc++; n++; } while (fc != fc0); // } @@ -173,29 +173,29 @@ _test_circulator( const Triangulation &T ) // for (eit=T.edges_begin(); eit!=T.edges_end(); eit++) feit=T.finite_edges_begin(); // test (Cell*,int,int,cell*,int) { - fc0=fc=T.incident_facets((*feit).first,(*feit).second,(*feit).third, - (*feit).first, - T.next_around_edge((*feit).second,(*feit).third)); + fc0=fc=T.incident_facets(feit->first, feit->second, feit->third, + feit->first, + T.next_around_edge(feit->second, feit->third)); do { - assert((*fc).first->has_vertex((*feit).first->vertex((*feit).second), i)); - assert((*fc).first->has_vertex((*feit).first->vertex((*feit).third), j)); - assert( (*fc).second == T.next_around_edge(i,j) ); + assert(fc->first->has_vertex(feit->first->vertex(feit->second), i)); + assert(fc->first->has_vertex(feit->first->vertex(feit->third), j)); + assert(fc->second == T.next_around_edge(i, j) ); fc--; n++; } while (fc != fc0); } 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;} - fc0=fc=T.incident_facets(*eit,std::make_pair( (*eit).first, - T.next_around_edge((*eit).second, - (*eit).third)) ); + fc0=fc=T.incident_facets(*eit, std::make_pair( eit->first, + T.next_around_edge(eit->second, + eit->third)) ); do { - assert((*fc).first->has_vertex((*eit).first->vertex((*eit).second), i)); - assert((*fc).first->has_vertex((*eit).first->vertex((*eit).third), j)); - assert( (*fc).second == T.next_around_edge(i,j) ); + assert(fc->first->has_vertex(eit->first->vertex(eit->second), i)); + assert(fc->first->has_vertex(eit->first->vertex(eit->third), j)); + assert(fc->second == T.next_around_edge(i, j) ); fc++; n++; } while (fc != fc0); // } @@ -203,14 +203,14 @@ _test_circulator( const Triangulation &T ) // for (eit=T.edges_begin(); eit!=T.edges_end(); eit++) feit=T.finite_edges_begin(); // test (Cell*,int,int,Facet) { - fc0=fc=T.incident_facets((*feit).first,(*feit).second,(*feit).third, - std::make_pair( (*feit).first, - T.next_around_edge((*feit).second, - (*feit).third)) ); + fc0=fc=T.incident_facets(feit->first, feit->second, feit->third, + std::make_pair( feit->first, + T.next_around_edge(feit->second, + feit->third)) ); do { - assert((*fc).first->has_vertex((*feit).first->vertex((*feit).second), i)); - assert((*fc).first->has_vertex((*feit).first->vertex((*feit).third), j)); - assert( (*fc).second == T.next_around_edge(i,j) ); + assert(fc->first->has_vertex(feit->first->vertex(feit->second), i)); + assert(fc->first->has_vertex(feit->first->vertex(feit->third), j)); + assert(fc->second == T.next_around_edge(i, j) ); fc--; n++; } while (fc != fc0); } diff --git a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_iterator.C b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_iterator.C index e35b1b00e51..565c1c6c71b 100644 --- a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_iterator.C +++ b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_iterator.C @@ -13,7 +13,7 @@ // // $URL$ // $Id$ -// +// // // Author(s) : Francois Rebufat (Francois.Rebufat@sophia.inria.fr) @@ -25,29 +25,58 @@ int _test_vertex_iterator( const Triangulation &T ) { typedef typename Triangulation::size_type size_type; + typedef typename Triangulation::Vertex Vertex; typedef typename Triangulation::Vertex_handle Vertex_handle; + typedef typename Triangulation::Cell_handle Cell_handle; typedef typename Triangulation::Vertex_iterator Vertex_iterator; typedef typename Triangulation::Finite_vertices_iterator Finite_vertices_iterator; size_type n = 0; - - Vertex_iterator vit; - for (vit = T.vertices_begin(); vit != T.vertices_end(); ++vit) + + for (Vertex_iterator vit = T.vertices_begin(); vit != T.vertices_end(); ++vit) { Vertex_handle vh = vit; // Test the conversion. + n++; + const Vertex & v = *vit; // Test operator*; + Cell_handle c = vit->cell(); // Test operator->; (void) vh; - n++; + (void) v; + (void) c; } assert( n-1 == T.number_of_vertices() ); n=0; - Finite_vertices_iterator fvit; - for (fvit = T.finite_vertices_begin(); fvit != T.finite_vertices_end(); ++fvit) + for (Finite_vertices_iterator fvit = T.finite_vertices_begin(); + 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. (void) vh; - n++; + n++; } assert( n == T.number_of_vertices() ); + return n; } @@ -65,7 +94,10 @@ _test_triangulation_iterator( const Triangulation &T ) typedef typename Triangulation::Edge_iterator Edge_iterator; typedef typename Triangulation::Vertex_iterator Vertex_iterator; + typedef typename Triangulation::Cell Cell; typedef typename Triangulation::Facet Facet; + typedef typename Triangulation::Edge Edge; + typedef typename Triangulation::Vertex Vertex; typedef typename Triangulation::Cell_handle Cell_handle; 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) { 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++; } - 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++; - 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++; - 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++; + } + // 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); n=0 ; m=0 ; f=0 ; t=0; for (Cit = T.cells_begin(); Cit != T.cells_end(); ++Cit) { Cell_handle ch = Cit; // Test the conversion. - (void) ch; + (void) ch; t++; } for (Fit = T.facets_begin(); Fit != T.facets_end(); ++Fit) @@ -133,7 +190,7 @@ _test_triangulation_iterator( const Triangulation &T ) if (T.dimension() >=1) { Finite_edges_iterator Eit2; - FEit = T.finite_edges_begin(); + FEit = T.finite_edges_begin(); Eit2=FEit; assert(*FEit==*Eit2); FEit++ ; FEit-- ; ++FEit ; --FEit ; @@ -141,7 +198,7 @@ _test_triangulation_iterator( const Triangulation &T ) assert(*FEit==*Eit2); } Finite_vertices_iterator Vit2; - FVit = T.finite_vertices_begin(); + FVit = T.finite_vertices_begin(); Vit2=FVit; assert(FVit->point()==Vit2->point()); FVit++ ; FVit-- ; ++FVit ; --FVit ;