From 92f9eed65e29c8db9da4e47f983bf4adbf54dcad Mon Sep 17 00:00:00 2001 From: Mariette Yvinec Date: Thu, 17 Apr 2003 08:11:05 +0000 Subject: [PATCH] merged midification for new design into main trunc --- Packages/Triangulation_2/TODO | 3 +- .../examples/Triangulation_2/colored_face.C | 38 +- .../Triangulation_2/constrained_plus.C | 2 +- .../examples/Triangulation_2/points.C | 2 +- .../Constrained_Delaunay_triangulation_2.h | 2 +- .../CGAL/Constrained_triangulation_2.h | 24 +- .../Constrained_triangulation_face_base_2.h | 79 +- .../include/CGAL/Delaunay_triangulation_2.h | 3 +- .../include/CGAL/Dummy_tds_2.h | 51 + .../include/CGAL/Regular_triangulation_2.h | 90 +- .../CGAL/Regular_triangulation_face_base_2.h | 36 +- .../Regular_triangulation_vertex_base_2.h | 36 +- .../include/CGAL/Triangulation_2.h | 66 +- .../CGAL/Triangulation_data_structure_2.h | 143 +- .../include/CGAL/Triangulation_ds_face_2.h | 131 +- .../CGAL/Triangulation_ds_face_base_2.h | 352 ++++ .../CGAL/Triangulation_ds_iterators_2.h | 57 +- .../include/CGAL/Triangulation_ds_vertex_2.h | 20 +- .../CGAL/Triangulation_ds_vertex_base_2.h | 93 + .../include/CGAL/Triangulation_face_base_2.h | 304 --- .../include/CGAL/Triangulation_hierarchy_2.h | 113 +- .../Triangulation_hierarchy_vertex_base_2.h | 75 + .../CGAL/Triangulation_iterator_adaptator.h | 54 + .../include/CGAL/Triangulation_iterators_2.h | 107 -- .../CGAL/Triangulation_short_names_2.h | 8 +- .../CGAL/Triangulation_vertex_base_2.h | 68 +- .../CGAL/_test_cls_regular_triangulation_2.C | 1 + .../include/CGAL/_test_cls_tds_2.C | 40 +- .../include/CGAL/_test_cls_tds_face.C | 12 +- .../include/CGAL/_test_cls_tds_vertex.C | 55 +- .../include/CGAL/_test_cls_triangulation_2.C | 2 +- .../CGAL/_test_cls_triangulation_vertex.C | 40 +- .../Triangulation_2/test_triangulation_2.C | 2 +- .../test_triangulation_2_bis.C | 2 +- .../Triangulation_2/test_triangulation_tds.C | 22 +- .../test_delaunay_hierarchy_2.C | 2 +- .../test_delaunay_triangulation_2.C | 15 +- .../test_regular_hierarchy_2.C | 13 +- .../test_const_triang_plus_2.C | 7 +- .../test_constrained_triangulation_2.C | 4 +- .../test/Triangulation_2_newd/Makefile | 65 - .../Triangulation_data_structure_2.h | 1701 ----------------- .../test/Triangulation_2_newd/example_1.C | 166 -- .../test/Triangulation_2_newd/example_2.C | 170 -- .../test/Triangulation_2_newd/example_3.C | 177 -- .../test/Triangulation_2_newd/example_4.C | 106 - 46 files changed, 1150 insertions(+), 3409 deletions(-) create mode 100644 Packages/Triangulation_2/include/CGAL/Dummy_tds_2.h create mode 100644 Packages/Triangulation_2/include/CGAL/Triangulation_ds_face_base_2.h create mode 100644 Packages/Triangulation_2/include/CGAL/Triangulation_ds_vertex_base_2.h delete mode 100644 Packages/Triangulation_2/include/CGAL/Triangulation_face_base_2.h create mode 100644 Packages/Triangulation_2/include/CGAL/Triangulation_hierarchy_vertex_base_2.h create mode 100644 Packages/Triangulation_2/include/CGAL/Triangulation_iterator_adaptator.h delete mode 100644 Packages/Triangulation_2/include/CGAL/Triangulation_iterators_2.h delete mode 100644 Packages/Triangulation_2/test/Triangulation_2_newd/Makefile delete mode 100644 Packages/Triangulation_2/test/Triangulation_2_newd/Triangulation_data_structure_2.h delete mode 100644 Packages/Triangulation_2/test/Triangulation_2_newd/example_1.C delete mode 100644 Packages/Triangulation_2/test/Triangulation_2_newd/example_2.C delete mode 100644 Packages/Triangulation_2/test/Triangulation_2_newd/example_3.C delete mode 100644 Packages/Triangulation_2/test/Triangulation_2_newd/example_4.C diff --git a/Packages/Triangulation_2/TODO b/Packages/Triangulation_2/TODO index 6277713c7f0..764e36aac6a 100644 --- a/Packages/Triangulation_2/TODO +++ b/Packages/Triangulation_2/TODO @@ -1,8 +1,9 @@ +- check the behavior of regular triangulations on + degenerate cases - change the return of get_conflicts and find_conflict to an output iterator ? - doc de le triangulation reguliere a mettre a jour Julia a signale un bug sur le return des fonctions insert et remove -- test de la regular hierarchy - input output of regular triangulation (may be outputing for each face the hidden points in the output operator for faces) diff --git a/Packages/Triangulation_2/examples/Triangulation_2/colored_face.C b/Packages/Triangulation_2/examples/Triangulation_2/colored_face.C index 3d331f61071..18e0b06cb50 100644 --- a/Packages/Triangulation_2/examples/Triangulation_2/colored_face.C +++ b/Packages/Triangulation_2/examples/Triangulation_2/colored_face.C @@ -4,22 +4,42 @@ #include /* A facet with a color member variable. */ -template < class Gt > -class My_face_base : public CGAL::Triangulation_face_base_2 +template < class Fb = CGAL::Triangulation_ds_face_base_2<> > +class My_face_base + : public Fb { + typedef Fb Base; + typedef typename Fb::Triangulation_data_structure TDS; public: + typedef TDS Triangulation_data_structure; + typedef typename TDS::Vertex_handle Vertex_handle; + typedef typename TDS::Face_handle Face_handle; + + template < typename TDS2 > + struct Rebind_TDS { + typedef typename Fb::template Rebind_TDS::Other Fb2; + typedef My_face_base Other; + }; + CGAL::Color color; - My_face_base() : - CGAL::Triangulation_face_base_2() {} - My_face_base(void* v0, void* v1, void* v2) : - CGAL::Triangulation_face_base_2(v0,v1,v2) {} - My_face_base(void* v0, void* v1, void* v2, void* n0, void* n1, void* n2) : - CGAL::Triangulation_face_base_2(v0,v1,v2,n0,n1,n2) {} + + My_face_base() : Base() {} + + My_face_base(Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2) : Base(v0,v1,v2) {} + + My_face_base(Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2, + Face_handle n0, + Face_handle n1, + Face_handle n2) : Base(v0,v1,v2,n0,n1,n2) {} }; typedef CGAL::Cartesian Gt; typedef CGAL::Triangulation_vertex_base_2 Vb; -typedef My_face_base Fb; +typedef My_face_base<> Fb; typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Triangulation_2 Triangulation; diff --git a/Packages/Triangulation_2/examples/Triangulation_2/constrained_plus.C b/Packages/Triangulation_2/examples/Triangulation_2/constrained_plus.C index ee4d36ff4cf..c7158531915 100644 --- a/Packages/Triangulation_2/examples/Triangulation_2/constrained_plus.C +++ b/Packages/Triangulation_2/examples/Triangulation_2/constrained_plus.C @@ -12,7 +12,7 @@ typedef CGAL::Filtered_kernel K2; struct K : public K2 {}; typedef CGAL::Triangulation_vertex_base_2 Vb; -typedef CGAL::Constrained_triangulation_face_base_2 Fb; +typedef CGAL::Constrained_triangulation_face_base_2<> Fb; typedef CGAL::Triangulation_data_structure_2 TDS; typedef CGAL::Exact_predicates_tag Itag; typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; diff --git a/Packages/Triangulation_2/examples/Triangulation_2/points.C b/Packages/Triangulation_2/examples/Triangulation_2/points.C index 9e21a0719c5..f772d1829af 100644 --- a/Packages/Triangulation_2/examples/Triangulation_2/points.C +++ b/Packages/Triangulation_2/examples/Triangulation_2/points.C @@ -8,7 +8,7 @@ typedef Euclidean_2 Gt; typedef CGAL::Triangulation_vertex_base_2 Vb; -typedef CGAL::Triangulation_face_base_2 Fb; +typedef CGAL::Triangulation_ds_face_base_2<> Fb; typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Triangulation_2 Triangulation; typedef CGAL::Delaunay_triangulation_2 Delaunay_triangulation; diff --git a/Packages/Triangulation_2/include/CGAL/Constrained_Delaunay_triangulation_2.h b/Packages/Triangulation_2/include/CGAL/Constrained_Delaunay_triangulation_2.h index edb066f7144..cd6932e2664 100644 --- a/Packages/Triangulation_2/include/CGAL/Constrained_Delaunay_triangulation_2.h +++ b/Packages/Triangulation_2/include/CGAL/Constrained_Delaunay_triangulation_2.h @@ -35,7 +35,7 @@ CGAL_BEGIN_NAMESPACE template , - Constrained_triangulation_face_base_2 >, + Constrained_triangulation_face_base_2<> >, class Itag = No_intersection_tag > class Constrained_Delaunay_triangulation_2 : public Constrained_triangulation_2 diff --git a/Packages/Triangulation_2/include/CGAL/Constrained_triangulation_2.h b/Packages/Triangulation_2/include/CGAL/Constrained_triangulation_2.h index 3900e1c318d..b21515930a1 100644 --- a/Packages/Triangulation_2/include/CGAL/Constrained_triangulation_2.h +++ b/Packages/Triangulation_2/include/CGAL/Constrained_triangulation_2.h @@ -49,7 +49,7 @@ struct Exact_predicates_tag{}; // to be used with filtered exact number template < class Gt, class Tds = Triangulation_data_structure_2 < Triangulation_vertex_base_2, - Constrained_triangulation_face_base_2 >, + Constrained_triangulation_face_base_2<> >, class Itag = No_intersection_tag > class Constrained_triangulation_2 : public Triangulation_2 { @@ -140,6 +140,7 @@ public: // QUERY bool is_constrained(Edge e) const; bool are_there_incident_constraints(Vertex_handle v) const; + bool is_valid(bool verbose = false, int level = 0) const; // template // bool are_there_incident_constraints(Vertex_handle v, // OutputIterator out) const; @@ -916,6 +917,23 @@ are_there_incident_constraints(Vertex_handle v) const return are_there_incident_constraints(v, Emptyset_iterator()); } +template < class Gt, class Tds, class Itag > +inline bool +Constrained_triangulation_2:: +is_valid(bool verbose = false, int level = 0) const +{ + bool result = Triangulation::is_valid(verbose,level); + for( All_faces_iterator it = all_faces_begin(); + it != all_faces_end() ; it++) { + for(int i=0; i<3; i++) { + Face_handle n = it->neighbor(i); + result = result && + it->is_constrained(i) == n->is_constrained(n->index(it)); + } + } + return result; +} + template < class Gt, class Tds, class Itag > inline bool Constrained_triangulation_2:: @@ -1030,8 +1048,8 @@ file_output(std::ostream& os) const Triangulation_2::file_output(os); // write constrained status - typename Tds::Iterator_base ib = this->_tds.iterator_base_begin(); - for( ; ib != this->_tds.iterator_base_end(); ++ib) { + typename Tds::Face_iterator_base ib = this->_tds.face_iterator_base_begin(); + for( ; ib != this->_tds.face_iterator_base_end(); ++ib) { for(int j = 0; j < 3; ++j){ if (ib->is_constrained(j)) { os << "C";} else { os << "N";} diff --git a/Packages/Triangulation_2/include/CGAL/Constrained_triangulation_face_base_2.h b/Packages/Triangulation_2/include/CGAL/Constrained_triangulation_face_base_2.h index 5395f2b5e20..20d4973293d 100644 --- a/Packages/Triangulation_2/include/CGAL/Constrained_triangulation_face_base_2.h +++ b/Packages/Triangulation_2/include/CGAL/Constrained_triangulation_face_base_2.h @@ -30,44 +30,64 @@ CGAL_BEGIN_NAMESPACE -template +template > class Constrained_triangulation_face_base_2 - : public Triangulation_face_base_2 + : public Fb { + typedef Fb Base; + typedef typename Fb::Triangulation_data_structure TDS; public: - typedef Gt Geom_traits; - typedef Triangulation_face_base_2 Fab; - typedef Constrained_triangulation_face_base_2 Constrained_face_base; - typedef typename Gt::Point_2 Point; + typedef TDS Triangulation_data_structure; + typedef typename TDS::Vertex_handle Vertex_handle; + typedef typename TDS::Face_handle Face_handle; + + template < typename TDS2 > + struct Rebind_TDS { + typedef typename Fb::template Rebind_TDS::Other Fb2; + typedef Constrained_triangulation_face_base_2 Other; + }; + protected: bool C[3]; public: Constrained_triangulation_face_base_2() - : Fab() + : Base() { set_constraints(false,false,false); } - Constrained_triangulation_face_base_2(void* v0, void* v1, void* v2) - : Fab(v0,v1,v2) + Constrained_triangulation_face_base_2(Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2) + : Base(v0,v1,v2) { set_constraints(false,false,false); } - Constrained_triangulation_face_base_2(void* v0, void* v1, void* v2, - void* n0, void* n1, void* n2) - : Fab(v0,v1,v2,n0,n1,n2) + Constrained_triangulation_face_base_2(Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2, + Face_handle n0, + Face_handle n1, + Face_handle n2) + : Base(v0,v1,v2,n0,n1,n2) { set_constraints(false,false,false); } - Constrained_triangulation_face_base_2(void* v0, void* v1, void* v2, - void* n0, void* n1, void* n2, - bool c0, bool c1, bool c2 ) - : Fab(v0,v1,v2,n0,n1,n2) + Constrained_triangulation_face_base_2(Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2, + Face_handle n0, + Face_handle n1, + Face_handle n2, + bool c0, + bool c1, + bool c2 ) + : Base(v0,v1,v2,n0,n1,n2) { set_constraints(c0,c1,c2); } @@ -79,7 +99,6 @@ public: void reorient(); void ccw_permute(); void cw_permute(); - bool is_valid(bool verbose = false, int level = 0) const; }; @@ -115,7 +134,7 @@ inline void Constrained_triangulation_face_base_2:: reorient() { - Fab::reorient(); + Base::reorient(); set_constraints(C[1],C[0],C[2]); } @@ -124,7 +143,7 @@ inline void Constrained_triangulation_face_base_2:: ccw_permute() { - Fab::ccw_permute(); + Base::ccw_permute(); set_constraints(C[2],C[0],C[1]); } @@ -133,30 +152,10 @@ inline void Constrained_triangulation_face_base_2:: cw_permute() { - Fab::cw_permute(); + Base::cw_permute(); set_constraints(C[1],C[2],C[0]); } -template -inline bool -Constrained_triangulation_face_base_2:: -is_valid(bool verbose, int level) const -{ - bool result = Fab::is_valid(verbose, level); - CGAL_triangulation_assertion(result); - if (dimension() == 2) { - for(int i = 0; i < 3; i++) { - Constrained_face_base* n = - static_cast(neighbor(i)); - if(n != NULL){ - int ni = n->face_index(this); - result = result && ( is_constrained(i) == n->is_constrained(ni)); - } - } - } - return (result); -} - CGAL_END_NAMESPACE #endif //CGAL_CONSTRAINED_TRIANGULATION_FACE_BASE_2_H diff --git a/Packages/Triangulation_2/include/CGAL/Delaunay_triangulation_2.h b/Packages/Triangulation_2/include/CGAL/Delaunay_triangulation_2.h index 8e2963e2a6b..8102a3d2d5c 100644 --- a/Packages/Triangulation_2/include/CGAL/Delaunay_triangulation_2.h +++ b/Packages/Triangulation_2/include/CGAL/Delaunay_triangulation_2.h @@ -33,8 +33,7 @@ CGAL_BEGIN_NAMESPACE template < class Gt, class Tds = Triangulation_data_structure_2 < - Triangulation_vertex_base_2, - Triangulation_face_base_2 > > + Triangulation_vertex_base_2 > > class Delaunay_triangulation_2 : public Triangulation_2 { public: diff --git a/Packages/Triangulation_2/include/CGAL/Dummy_tds_2.h b/Packages/Triangulation_2/include/CGAL/Dummy_tds_2.h new file mode 100644 index 00000000000..c37a973cf89 --- /dev/null +++ b/Packages/Triangulation_2/include/CGAL/Dummy_tds_2.h @@ -0,0 +1,51 @@ +// ============================================================================ +// +// Copyright (c) 2003 The CGAL Consortium +// +// This software and related documentation is part of an INTERNAL release +// of the Computational Geometry Algorithms Library (CGAL). It is not +// intended for general use. +// +// ---------------------------------------------------------------------------- +// +// release : +// release_date : +// +// file : include/CGAL/Dummy_tds_2.h +// revision : $Revision$ +// revision_date : $Date$ +// author(s) : Mariette Yvinec +// +// coordinator : INRIA Sophia Antipolis +// +// ============================================================================ + +#ifndef CGAL_TRIANGULATION_DUMMY_TDS_2_H +#define CGAL_TRIANGULATION_DUMMY_TDS_2_H + +#include +#include + +CGAL_BEGIN_NAMESPACE + +// Dummy TDS which provides all types that a vertex_base or cell_base can use. +struct Dummy_tds_2 { + struct Vertex {}; + struct Face {}; + struct Edge {}; + + struct Vertex_handle {}; + struct Face_handle {}; + + struct Vertex_iterator {}; + struct Face_iterator {}; + struct Edge_iterator {}; + + struct Edge_circulator {}; + struct Facet_circulator {}; + struct Vertex_circulator {}; +}; + +CGAL_END_NAMESPACE + +#endif // CGAL_TRIANGULATION_DUMMY_TDS_2_H diff --git a/Packages/Triangulation_2/include/CGAL/Regular_triangulation_2.h b/Packages/Triangulation_2/include/CGAL/Regular_triangulation_2.h index e74cc07ffb7..8ce1b4dd4b6 100644 --- a/Packages/Triangulation_2/include/CGAL/Regular_triangulation_2.h +++ b/Packages/Triangulation_2/include/CGAL/Regular_triangulation_2.h @@ -33,27 +33,27 @@ CGAL_BEGIN_NAMESPACE template < class Gt, class Tds = Triangulation_data_structure_2 < Regular_triangulation_vertex_base_2, - Regular_triangulation_face_base_2 > > + Regular_triangulation_face_base_2<> > > class Regular_triangulation_2 : public Triangulation_2 { - + typedef Regular_triangulation_2 Self; + typedef Triangulation_2 Base; public: - typedef Regular_triangulation_2 Self; - typedef Triangulation_2 Base; - typedef Gt Geom_traits; - typedef typename Gt::Bare_point Bare_point; - typedef typename Gt::Weighted_point Weighted_point; - typedef typename Gt::Weighted_point Point; - typedef typename Gt::Weight Weight; + typedef Tds Triangulation_data_structure; + typedef Gt Geom_traits; + typedef typename Gt::Bare_point Bare_point; + typedef typename Gt::Weighted_point Weighted_point; + typedef typename Gt::Weighted_point Point; + typedef typename Gt::Weight Weight; - typedef typename Base::Face_handle Face_handle; - typedef typename Base::Vertex_handle Vertex_handle; - typedef typename Base::Vertex Vertex; - typedef typename Base::Edge Edge; - typedef typename Base::Locate_type Locate_type; - typedef typename Base::Vertex_circulator Vertex_circulator; + typedef typename Base::Face_handle Face_handle; + typedef typename Base::Vertex_handle Vertex_handle; + typedef typename Base::Vertex Vertex; + typedef typename Base::Edge Edge; + typedef typename Base::Locate_type Locate_type; typedef typename Base::Face_circulator Face_circulator; typedef typename Base::Edge_circulator Edge_circulator; + typedef typename Base::Vertex_circulator Vertex_circulator; typedef typename Base::Finite_edges_iterator Finite_edges_iterator; typedef typename Base::All_edges_iterator All_edges_iterator; typedef typename Base::Finite_faces_iterator Finite_faces_iterator; @@ -68,7 +68,7 @@ private: public: bool operator()(const typename Base::All_vertices_iterator& it){ return it->is_hidden(); - } + } bool operator()(const typename Base::Finite_vertices_iterator& it){ return it->is_hidden(); } @@ -185,7 +185,7 @@ private: Vertex_handle hide_new_vertex(Face_handle f, const Weighted_point& p); void hide_remove_degree_3(Face_handle fh, Vertex_handle vh); void hide_vertex(Face_handle f, Vertex_handle v); - void hide_vertex(Face_handle f, void* ptr); + //void hide_vertex(Face_handle f, void* ptr); void exchange_incidences(Vertex_handle va, Vertex_handle vb); void exchange_hidden(Vertex_handle va, Vertex_handle vb); @@ -255,8 +255,13 @@ copy_triangulation(const Self &tr ) // not good // clear them and next // scan the hidden vertices to retablish the list in faces +<<<<<<< Regular_triangulation_2.h typename Tds::Iterator_base baseit = this->_tds.iterator_base_begin(); for( ; baseit != this->_tds.iterator_base_end(); ++baseit){ +======= + typename Tds::Face_iterator_base baseit=_tds.face_iterator_base_begin(); + for( ; baseit != _tds.face_iterator_base_end(); baseit++){ +>>>>>>> 1.55.2.3 baseit->vertex_list().clear(); } Hidden_vertices_iterator hvit = hidden_vertices_begin(); @@ -375,9 +380,8 @@ is_valid_face(Face_handle fh) const typename Vertex_list::iterator vlit = fh->vertex_list().begin(), vldone = fh->vertex_list().end(); for (; vlit != vldone; vlit++) { - Vertex_handle v(static_cast(*vlit)); - result = result && power_test(fh, v->point()) == ON_NEGATIVE_SIDE; - result = result && (v->face() == fh); + result = result && power_test(fh, (*vlit)->point()) == ON_NEGATIVE_SIDE; + result = result && ((*vlit)->face() == fh); if (!result) show_face(fh); CGAL_triangulation_assertion(result); } @@ -402,9 +406,14 @@ is_valid_vertex(Vertex_handle vh) const loc->neighbor(li)) ); if ( !result) { std::cerr << vh->point() << " " << std::endl; +<<<<<<< Regular_triangulation_2.h std::cerr << "vh_>face " << static_cast(&(*vh->face())) << " " << std::endl; std::cerr << "loc " << static_cast(&(*loc)) +======= + std::cerr << "vh_>face " << &*(vh->face()) << " " << std::endl; + std::cerr << "loc " << &*(loc ) +>>>>>>> 1.55.2.3 << " lt " << lt << " li " << li << std::endl; show_face(vh->face()); show_face(loc); @@ -530,8 +539,7 @@ show_face(Face_handle fh) const std::cerr << " +++++>>> "; for (current= fh->vertex_list().begin(); current!= fh->vertex_list().end() ; current++ ) { - Vertex_handle v(static_cast(*current)); - std::cerr <<"[ "<< (v->point()) << " ] , "; + std::cerr <<"[ "<< ((*current)->point()) << " ] , "; } std::cerr <:: exchange_hidden(Vertex_handle va, Vertex_handle vb) { CGAL_triangulation_assertion (vb->is_hidden()); - CGAL_triangulation_assertion (vb == - static_cast(*(vb->face()->vertex_list().rbegin()))); + CGAL_triangulation_assertion (vb == vb->face()->vertex_list().back()); vb->face()->vertex_list().pop_back(); _hidden_vertices--; hide_vertex(vb->face(), va); @@ -990,7 +997,7 @@ remove(Vertex_handle v ) while (! p_list.empty()) { - Vertex_handle v(static_cast(p_list.front())); + Vertex_handle v(p_list.front()); p_list.pop_front(); if (is_infinite(neighboring)) { neighboring=neighboring->neighbor(neighboring->index(infinite_vertex())); @@ -1191,10 +1198,7 @@ Regular_triangulation_2:: set_face(Vertex_list& vl, const Face_handle& fh) { for(typename Vertex_list::iterator it = vl.begin(); it != vl.end(); it++) - { - Vertex_handle v(static_cast(*it)); - v->set_face(fh); - } + (*it)->set_face(fh); } // add the vertex_list of f2 and f3 to the point list of f1 @@ -1243,10 +1247,9 @@ update_hidden_points_2_2(const Face_handle& f1, const Face_handle& f2) const Weighted_point& a1 = f1->vertex(f1->index(f2))->point(); const Weighted_point& a = f1->vertex(1-f1->index(f2))->point(); while ( ! p_list.empty() ) { - Vertex_handle v(static_cast(p_list.front())); - if ( compare_x(a, v->point()) == + if ( compare_x(a, p_list.front()->point()) == compare_x(a, a1) && - compare_y(a, v->point()) == + compare_y(a, p_list.front()->point()) == compare_y(a, a1)) { hide_vertex(f1, p_list.front()); @@ -1266,8 +1269,7 @@ update_hidden_points_2_2(const Face_handle& f1, const Face_handle& f2) while ( ! p_list.empty() ) { - Vertex_handle v(static_cast(p_list.front())); - if (orientation(v0->point(), v1->point(), v->point()) == + if (orientation(v0->point(), v1->point(), p_list.front()->point()) == COUNTERCLOCKWISE) hide_vertex(f1, p_list.front()); else @@ -1332,7 +1334,7 @@ update_hidden_points_1_3(const Face_handle& f1, const Face_handle& f2, // if here, v1,v2,v3 and v0 are finite vertices while(! p_list.empty()) { - Vertex_handle v(static_cast(p_list.front())); + Vertex_handle v(p_list.front()); // if(orientation(v2->point(),v0->point(), v->point()) != // orientation(v2->point(),v0->point(),v3->point()) ) // { // not in f1 @@ -1400,17 +1402,17 @@ hide_vertex(Face_handle f, Vertex_handle vh) _hidden_vertices++; } vh->set_face(f); - f->vertex_list().push_back(&(*vh)); + f->vertex_list().push_back(vh); } -template < class Gt, class Tds > -void -Regular_triangulation_2:: -hide_vertex(Face_handle f, void* ptr) -{ - Vertex_handle v(static_cast(ptr)); - hide_vertex(f, v); -} +// template < class Gt, class Tds > +// void +// Regular_triangulation_2:: +// hide_vertex(Face_handle f, void* ptr) +// { +// Vertex_handle v(static_cast(ptr)); +// hide_vertex(f, v); +// } diff --git a/Packages/Triangulation_2/include/CGAL/Regular_triangulation_face_base_2.h b/Packages/Triangulation_2/include/CGAL/Regular_triangulation_face_base_2.h index 63fc8471f22..35f09887836 100644 --- a/Packages/Triangulation_2/include/CGAL/Regular_triangulation_face_base_2.h +++ b/Packages/Triangulation_2/include/CGAL/Regular_triangulation_face_base_2.h @@ -12,6 +12,7 @@ // release_date : $CGAL_Date$ // // file : include/CGAL/Regular_triangulation_face_base_2.h +// package : Triangulation_2 // source : $RCSfile$ // revision : $Revision$ // revision_date : $Date$ @@ -31,16 +32,25 @@ CGAL_BEGIN_NAMESPACE -template +template > class Regular_triangulation_face_base_2 - : public Triangulation_face_base_2 + : public Fb { + typedef Fb Fbase; + typedef typename Fbase::Triangulation_data_structure TDS; public: - typedef Gt Geom_traits; - typedef Triangulation_face_base_2 Fbase; - typedef Regular_triangulation_face_base_2 Regular_face_base; - typedef typename Gt::Weighted_point Weighted_point; - typedef std::list Vertex_list; + typedef TDS Triangulation_data_structure; + typedef typename TDS::Vertex_handle Vertex_handle; + typedef typename TDS::Face_handle Face_handle; + + template < typename TDS2 > + struct Rebind_TDS { + typedef typename Fb::template Rebind_TDS::Other Fb2; + typedef Regular_triangulation_face_base_2 Other; + }; + + typedef std::list Vertex_list; + protected: Vertex_list vlist; @@ -49,12 +59,18 @@ public: : Fbase(), vlist() {} - Regular_triangulation_face_base_2(void* v0, void* v1, void* v2) + Regular_triangulation_face_base_2(Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2) : Fbase(v0,v1,v2), vlist() { } - Regular_triangulation_face_base_2(void* v0, void* v1, void* v2, - void* n0, void* n1, void* n2) + Regular_triangulation_face_base_2(Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2, + Face_handle n0, + Face_handle n1, + Face_handle n2) : Fbase(v0,v1,v2,n0,n1,n2), vlist() { } diff --git a/Packages/Triangulation_2/include/CGAL/Regular_triangulation_vertex_base_2.h b/Packages/Triangulation_2/include/CGAL/Regular_triangulation_vertex_base_2.h index ea9f4c089e1..b78113788cc 100644 --- a/Packages/Triangulation_2/include/CGAL/Regular_triangulation_vertex_base_2.h +++ b/Packages/Triangulation_2/include/CGAL/Regular_triangulation_vertex_base_2.h @@ -8,10 +8,11 @@ // // ---------------------------------------------------------------------------- // -// release : -// release_date : +// release : $CGAL_Revision$ +// release_date : $CGAL_Date$ // -// file : Triangulation/include/CGAL/Regular_triangulation_vertex_base_2.h +// file : include/CGAL/Regular_triangulation_vertex_base_2.h +// package : Triangulation_2 // source : $RCSfile$ // revision : $Revision$ // revision_date : $Date$ @@ -29,19 +30,30 @@ CGAL_BEGIN_NAMESPACE -template < class GT > -class Regular_triangulation_vertex_base_2 : - public Triangulation_vertex_base_2 { - +template < class GT, + class Vbb = Triangulation_vertex_base_2 > +class Regular_triangulation_vertex_base_2 + : public Vbb +{ + typedef typename Vbb::Triangulation_data_structure TDS; + typedef Vbb Base; public: - typedef typename GT::Point_2 Point; + typedef typename Base::Point Point; + typedef TDS Triangulation_data_structure; + typedef typename TDS::Face_handle Face_handle; + typedef typename TDS::Vertex_handle Vertex_handle; + + template < typename TDS2 > + struct Rebind_TDS { + typedef typename Vbb::template Rebind_TDS::Other Vb2; + typedef Regular_triangulation_vertex_base_2 Other; + }; Regular_triangulation_vertex_base_2 () - : Triangulation_vertex_base_2(), _hidden(false) - {} + : Base(), _hidden(false) {} - Regular_triangulation_vertex_base_2(const Point & p, void * f = NULL) - : Triangulation_vertex_base_2(p, f), _hidden(false) + Regular_triangulation_vertex_base_2(const Point & p, Face_handle f = NULL) + : Base(p, f), _hidden(false) {} void set_hidden(bool b) { _hidden = b; } diff --git a/Packages/Triangulation_2/include/CGAL/Triangulation_2.h b/Packages/Triangulation_2/include/CGAL/Triangulation_2.h index a688eb54041..2a5befdd630 100644 --- a/Packages/Triangulation_2/include/CGAL/Triangulation_2.h +++ b/Packages/Triangulation_2/include/CGAL/Triangulation_2.h @@ -43,9 +43,7 @@ #include #include -#include #include -#include #include @@ -60,24 +58,20 @@ template < class Gt, class Tds > std::ostream& operator<< template < class Gt, class Tds = Triangulation_data_structure_2 < - Triangulation_vertex_base_2, - Triangulation_face_base_2 > > + Triangulation_vertex_base_2 > > class Triangulation_2 : public Triangulation_cw_ccw_2 { -public: - class Infinite_tester; - typedef Tds Triangulation_data_structure; - typedef Triangulation_2 Self; - friend std::istream& operator>> CGAL_NULL_TMPL_ARGS (std::istream& is, Triangulation_2 &tr); - friend class Triangulation_finite_faces_iterator_2; - friend class Triangulation_finite_vertices_iterator_2; + //friend class Triangulation_finite_faces_iterator_2; + //friend class Triangulation_finite_vertices_iterator_2; + class Infinite_tester; + typedef Triangulation_2 Self; - - - typedef Gt Geom_traits; +public: + typedef Tds Triangulation_data_structure; + typedef Gt Geom_traits; typedef typename Geom_traits::Point_2 Point; typedef typename Geom_traits::Segment_2 Segment; typedef typename Geom_traits::Triangle_2 Triangle; @@ -99,12 +93,23 @@ public: typedef typename Tds::Edge_iterator All_edges_iterator; typedef typename Tds::Vertex_iterator All_vertices_iterator; - typedef Triangulation_finite_faces_iterator_2 - Finite_faces_iterator; - typedef Filter_iterator + typedef Filter_iterator + Finite_faces_iterator_base; + typedef Filter_iterator + Finite_vertices_iterator_base; + typedef Filter_iterator Finite_edges_iterator; - typedef Triangulation_finite_vertices_iterator_2 + typedef Triangulation_iterator_handle_adaptor + Finite_faces_iterator; + typedef Triangulation_iterator_handle_adaptor + Finite_vertices_iterator; + //for backward compatibility typedef Finite_faces_iterator Face_iterator; typedef Finite_edges_iterator Edge_iterator; @@ -122,7 +127,7 @@ public: CGAL_CLIB_STD::ptrdiff_t, std::bidirectional_iterator_tag> Point_iterator; - typedef Point value_type; // to have a back_inserter + typedef Point value_type; // to have a back_inserter typedef const value_type& const_reference; typedef value_type& reference; @@ -360,15 +365,14 @@ private: // This class is used to generate the Finite_*_iterators. -public : +private : friend class Infinite_tester; class Infinite_tester { const Triangulation_2 *t; public: Infinite_tester() {} - Infinite_tester(const Triangulation_2 *tr) - : t(tr) {} + Infinite_tester(const Triangulation_2 *tr) : t(tr) {} bool operator()(const All_vertices_iterator & vit) const { return t->is_infinite(vit->handle()); @@ -1723,7 +1727,9 @@ finite_faces_begin() const { if ( dimension() < 2 ) return finite_faces_end(); - return Finite_faces_iterator(this); + return filter_iterator( all_faces_begin(), + all_faces_end(), + Infinite_tester(this)); } template @@ -1731,7 +1737,10 @@ typename Triangulation_2::Finite_faces_iterator Triangulation_2:: finite_faces_end() const { - return Finite_faces_iterator(this, 1); + return filter_iterator( all_faces_begin(), + all_faces_end(), + Infinite_tester(this), + all_faces_end() ); } template @@ -1741,7 +1750,9 @@ finite_vertices_begin() const { if ( number_of_vertices() <= 0 ) return finite_vertices_end(); - return Finite_vertices_iterator(this); + return filter_iterator(all_vertices_begin(), + all_vertices_end(), + Infinite_tester(this)); } template @@ -1749,7 +1760,10 @@ typename Triangulation_2::Finite_vertices_iterator Triangulation_2:: finite_vertices_end() const { - return Finite_vertices_iterator(this,1); + return filter_iterator(all_vertices_begin(), + all_vertices_end(), + Infinite_tester(this), + all_vertices_end()); } template diff --git a/Packages/Triangulation_2/include/CGAL/Triangulation_data_structure_2.h b/Packages/Triangulation_2/include/CGAL/Triangulation_data_structure_2.h index fad0f76a87d..6b94b40dcee 100644 --- a/Packages/Triangulation_2/include/CGAL/Triangulation_data_structure_2.h +++ b/Packages/Triangulation_2/include/CGAL/Triangulation_data_structure_2.h @@ -38,11 +38,10 @@ #include #include #include -#include -#include +#include +#include #include #include -#include #include #include @@ -50,6 +49,22 @@ #include CGAL_BEGIN_NAMESPACE + +// These two compilers seem to eat the concept checking code. +#if defined __GNUG__ || defined __SUNPRO_CC +template < typename T > +struct vertex_and_cell_base_concept_checker { + template < typename T2 > struct check_for_rebind {}; +}; + +template <> +template < typename T > +struct vertex_and_cell_base_concept_checker::check_for_rebind +{ struct YOU_FORGOT_TO_ADD_A_Rebind_TO_YOUR_OWN_VERTEX_OR_CELL{}; }; +#endif + + + template < class Vb, class Fb> class Triangulation_data_structure_2; @@ -97,32 +112,57 @@ public: -template +template < class Vb = Triangulation_ds_vertex_base_2<>, + class Fb = Triangulation_ds_face_base_2<> > class Triangulation_data_structure_2 :public Triangulation_cw_ccw_2 { -public: typedef Triangulation_data_structure_2 Tds; - friend class Triangulation_ds_face_iterator_2; + typedef typename Vb::template Rebind_TDS::Other Vertex_base; + typedef typename Fb::template Rebind_TDS::Other Face_base; + +#if defined __GNUG__ || defined __SUNPRO_CC + // We verify that the user has not forgotten to add a Rebind_TDS in his own + // Vertex/Cell derived class, by checking that rebinding it to void gives + // the exact same type. + typedef vertex_and_cell_base_concept_checker checker_1; + typedef typename Vb::template Rebind_TDS::Other vb2; + typename checker_1::template check_for_rebind:: + YOU_FORGOT_TO_ADD_A_Rebind_TO_YOUR_OWN_VERTEX_OR_CELL o1; + + typedef vertex_and_cell_base_concept_checker checker_2; + typedef typename Fb::template Rebind_TDS::Other fb2; + typename checker_2::template check_for_rebind:: + YOU_FORGOT_TO_ADD_A_Rebind_TO_YOUR_OWN_VERTEX_OR_CELL o2; +#endif + friend class Triangulation_ds_edge_iterator_2; - friend class Triangulation_ds_vertex_iterator_2; - - typedef Vb Vertex_base; - typedef Fb Face_base; - typedef Triangulation_ds_vertex_2 Vertex; - typedef Triangulation_ds_face_2 Face; + friend class Triangulation_ds_face_circulator_2; + friend class Triangulation_ds_edge_circulator_2; + friend class Triangulation_ds_vertex_circulator_2; + +public: + typedef Triangulation_ds_vertex_2 Vertex; + typedef Triangulation_ds_face_2 Face; typedef CGAL_TRIVIAL_COMPARABLE_ITERATOR_CHECKER_POINTER(Face) Face_handle; typedef CGAL_TRIVIAL_COMPARABLE_ITERATOR_CHECKER_POINTER(Vertex) Vertex_handle; typedef std::pair Edge; +protected: typedef DS_Container Face_container; typedef DS_Container Vertex_container; - typedef typename Face_container::iterator Iterator_base; - typedef Triangulation_ds_face_iterator_2 Face_iterator; + +public: + typedef typename Face_container::iterator Face_iterator_base; + typedef typename Vertex_container::iterator Vertex_iterator_base; + + typedef Triangulation_iterator_handle_adaptor + Face_iterator; + typedef Triangulation_iterator_handle_adaptor + Vertex_iterator; typedef Triangulation_ds_edge_iterator_2 Edge_iterator; - typedef Triangulation_ds_vertex_iterator_2 Vertex_iterator; typedef Triangulation_ds_face_circulator_2 Face_circulator; typedef Triangulation_ds_vertex_circulator_2 Vertex_circulator; @@ -173,34 +213,34 @@ public: // ITERATORS AND CIRCULATORS public: -// The Iterator_base gives the possibility to iterate over all -// in the container independently of the dimension. +// The face_iterator_base_begin gives the possibility to iterate over all +// faces in the container independently of the dimension. // public for the need of file_ouput() of Constrained triangulation - // should be made public later + // should be made private later - Iterator_base iterator_base_begin() const { + Face_iterator face_iterator_base_begin() const { return face_container().begin(); } - Iterator_base iterator_base_end() const { + Face_iterator face_iterator_base_end() const { return face_container().end(); } public: Face_iterator faces_begin() const { if (dimension() < 2) return faces_end(); - return Face_iterator(this); + return face_container().begin(); } Face_iterator faces_end() const { - return Face_iterator(this, 1); + return face_container().end(); } Vertex_iterator vertices_begin() const { - return Vertex_iterator(this); + return vertex_container().begin(); } Vertex_iterator vertices_end() const { - return Vertex_iterator(this,1); + return vertex_container().end(); } Edge_iterator edges_begin() const { @@ -760,7 +800,7 @@ insert_dim_up(Vertex_handle w, bool orient) v->set_face(f1); break; case 0 : - f1 = &(*iterator_base_begin()); + f1 = &(*face_iterator_base_begin()); f2 = create_face(v,Vertex_handle(NULL),Vertex_handle(NULL)); f1->set_neighbor(0,f2); f2->set_neighbor(0,f1); @@ -770,10 +810,10 @@ insert_dim_up(Vertex_handle w, bool orient) case 2 : { std::list faces_list; - Iterator_base ib= iterator_base_begin(); - Iterator_base ib_end = iterator_base_end(); + Face_iterator ib= face_iterator_base_begin(); + Face_iterator ib_end = face_iterator_base_end(); for (; ib != ib_end ; ++ib){ - faces_list.push_back( & (*ib)); + faces_list.push_back( ib); } std::list to_delete; @@ -914,10 +954,10 @@ remove_dim_down(Vertex_handle v) // the other faces are deleted std::list to_delete; std::list to_downgrade; - Iterator_base ib = iterator_base_begin(); - for( ; ib != iterator_base_end(); ++ib ){ - if ( ! ib->has_vertex(v) ) { to_delete.push_back(&(*ib));} - else { to_downgrade.push_back(&(*ib));} + Face_iterator ib = face_iterator_base_begin(); + for( ; ib != face_iterator_base_end(); ++ib ){ + if ( ! ib->has_vertex(v) ) { to_delete.push_back(ib);} + else { to_downgrade.push_back(ib);} } typename std::list::iterator lfit = to_downgrade.begin(); @@ -1228,8 +1268,8 @@ is_valid(bool verbose, int level) const CGAL_triangulation_assertion(result); //count and test the validity of the faces (for positive dimensions) - Iterator_base ib = iterator_base_begin(); - Iterator_base ib_end = iterator_base_end(); + Face_iterator ib = face_iterator_base_begin(); + Face_iterator ib_end = face_iterator_base_end(); int count_stored_faces =0; for ( ; ib != ib_end ; ++ib){ count_stored_faces += 1; @@ -1314,9 +1354,9 @@ copy_tds(const Tds &tds, Vertex_handle vh) //initializes maps std::map vmap; std::map fmap; - Iterator_base it1 = tds.iterator_base_begin(); - Iterator_base it2 = iterator_base_begin(); - for( ; it1 != tds.iterator_base_end(); ++it1,++it2) { + Face_iterator it1 = tds.face_iterator_base_begin(); + Face_iterator it2 = face_iterator_base_begin(); + for( ; it1 != tds.face_iterator_base_end(); ++it1,++it2) { fmap[it1->handle()] = it2->handle(); } Vertex_iterator vit1 = tds.vertices_begin(); @@ -1326,11 +1366,11 @@ copy_tds(const Tds &tds, Vertex_handle vh) } //update pointers - it2 = iterator_base_begin(); + it2 = face_iterator_base_begin(); int j; if (dimension() == -1) it2->set_vertex(0, vmap[it2->vertex(0)]); else { // dimension() >= 0 - for ( ; it2 != iterator_base_end(); ++it2) { + for ( ; it2 != face_iterator_base_end(); ++it2) { for (j = 0; j < dimension()+ 1; ++j) { it2->set_vertex(j, vmap[it2->vertex(j)]); it2->set_neighbor(j, fmap[it2->neighbor(j)]); @@ -1371,7 +1411,8 @@ file_output( std::ostream& os, Vertex_handle v, bool skip_first) const if ( v != NULL) { V[v] = inum++; if( ! skip_first){ - os << v->point(); + // os << v->point(); + os << *v ; if(is_ascii(os)) os << std::endl; } } @@ -1380,7 +1421,8 @@ file_output( std::ostream& os, Vertex_handle v, bool skip_first) const for( Vertex_iterator vit= vertices_begin(); vit != vertices_end() ; ++vit) { if ( vit->handle() != v) { V[vit->handle()] = inum++; - os << vit->point(); + // os << vit->point(); + os << *vit; if(is_ascii(os)) os << std::endl; } } @@ -1389,8 +1431,8 @@ file_output( std::ostream& os, Vertex_handle v, bool skip_first) const // vertices of the faces inum = 0; int dim = (dimension() == -1 ? 1 : dimension() + 1); - for( Iterator_base ib = iterator_base_begin(); - ib != iterator_base_end(); ++ib) { + for( Face_iterator ib = face_iterator_base_begin(); + ib != face_iterator_base_end(); ++ib) { F[&(*ib)] = inum++; for(int j = 0; j < dim ; ++j){ os << V[ib->vertex(j)]; @@ -1402,8 +1444,8 @@ file_output( std::ostream& os, Vertex_handle v, bool skip_first) const } // neighbor pointers of the faces - for( Iterator_base it = iterator_base_begin(); - it != iterator_base_end(); ++it) { + for( Face_iterator it = face_iterator_base_begin(); + it != face_iterator_base_end(); ++it) { for(int j = 0; j < dimension()+1; ++j){ os << F[&(*(it->neighbor(j)))]; if(is_ascii(os)){ @@ -1446,10 +1488,11 @@ file_input( std::istream& is, bool skip_first) ++i; } for( ; i < n; ++i) { - typename Vertex_base::Point p; - is >> p; + // typename Vertex_base::Point p; + // is >> p; V[i] = create_vertex(); - V[i]->set_point(p); + is >> *(V[i]); + //V[i]->set_point(p); } // Creation of the faces @@ -1507,14 +1550,14 @@ vrml_output( std::ostream& os, Vertex_handle v, bool skip_infinite) const int inum = 0; if ( v != NULL) { vmap[v] = inum++; - if( ! skip_infinite) os << "\t\t\t\t" << vit->point() << std::endl; + if( ! skip_infinite) os << "\t\t\t\t" << *vit << std::endl; } //other vertices for( vit= vertices_begin(); vit != vertices_end() ; ++vit) { if ( vit->handle() != v) { vmap[vit->handle()] = inum++; - os << "\t\t\t\t" << vit->point() << std::endl; + os << "\t\t\t\t" << *vit << std::endl; } } diff --git a/Packages/Triangulation_2/include/CGAL/Triangulation_ds_face_2.h b/Packages/Triangulation_2/include/CGAL/Triangulation_ds_face_2.h index f9899d3c936..ef473396bec 100644 --- a/Packages/Triangulation_2/include/CGAL/Triangulation_ds_face_2.h +++ b/Packages/Triangulation_2/include/CGAL/Triangulation_ds_face_2.h @@ -30,13 +30,12 @@ CGAL_BEGIN_NAMESPACE -template < class Tds > +template < class Fb > class Triangulation_ds_face_2 - : public Tds::Face_base + : public Fb { public: - typedef typename Tds::Vertex_base Vb; - typedef typename Tds::Face_base Fb; + typedef typename Fb::Triangulation_data_structure Tds; typedef typename Tds::Vertex Vertex; typedef typename Tds::Face Face; typedef typename Tds::Vertex_handle Vertex_handle; @@ -49,12 +48,12 @@ public : {} Triangulation_ds_face_2(Vertex_handle v0, Vertex_handle v1, Vertex_handle v2) - : Fb(&*v0,&*v1,&*v2) + : Fb(v0,v1,v2) {} Triangulation_ds_face_2(Vertex_handle v0, Vertex_handle v1, Vertex_handle v2, Face_handle n0, Face_handle n1, Face_handle n2) - : Fb(&*v0,&*v1,&*v2,&*n0,&*n1,&*n2) + : Fb(v0,v1,v2,n0,n1,n2) {} Triangulation_ds_face_2( const Face& f) @@ -64,67 +63,19 @@ public : static int ccw(int i) {return Triangulation_cw_ccw_2::ccw(i);} static int cw(int i) {return Triangulation_cw_ccw_2::cw(i);} - //setting - void set_vertex(int i, Vertex_handle v) { Fb::set_vertex(i, &*v);} - void set_neighbor(int i, Face_handle n) { Fb::set_neighbor(i, &*n);} - void set_vertices() { Fb::set_vertices();} - void set_neighbors() { Fb::set_neighbors();} - void set_vertices(Vertex_handle v0, Vertex_handle v1, Vertex_handle v2); - void set_neighbors(Face_handle n0, Face_handle n1, Face_handle n2); - //void reorient(); inherited from Fb - - //Vertex Access Member Functions - Vertex_handle vertex(int i) const; Vertex_handle mirror_vertex(int i) const; - bool has_vertex(Vertex_handle v) const; - bool has_vertex(Vertex_handle v, int& i) const; - int index(Vertex_handle v) const; - - // Neighbors Access Functions - Face_handle neighbor(int i) const; - bool has_neighbor(Face_handle n) const; - bool has_neighbor(Face_handle n, int& i) const; - int index(Face_handle n) const; int mirror_index(int i) const; - //Miscelleanous Face_handle handle() const {return const_cast(this);} Face_handle handle() {return const_cast(this);} bool is_valid(bool verbose = false, int level = 0) const; }; - - -template < class Tds > -inline void -Triangulation_ds_face_2:: -set_vertices(Vertex_handle v0, Vertex_handle v1, Vertex_handle v2) -{ - Fb::set_vertices(&*v0,&*v1,&*v2); -} - -template < class Tds > -inline void -Triangulation_ds_face_2:: -set_neighbors(Face_handle n0, Face_handle n1, Face_handle n2) -{ - Fb::set_neighbors(&*n0,&*n1,&*n2); -} - -template < class Tds > +template < class Fb > inline -typename Triangulation_ds_face_2::Vertex_handle -Triangulation_ds_face_2:: -vertex(int i) const -{ - return(Vertex_handle(static_cast(Fb::vertex(i)))); -} - -template < class Tds > -inline -typename Triangulation_ds_face_2::Vertex_handle -Triangulation_ds_face_2:: +typename Triangulation_ds_face_2::Vertex_handle +Triangulation_ds_face_2:: mirror_vertex(int i) const { CGAL_triangulation_precondition ( neighbor(i) != NULL && dimension() >= 1); @@ -132,9 +83,9 @@ mirror_vertex(int i) const return neighbor(i)->vertex(mirror_index(i)); } -template < class Tds > +template < class Fb > inline int -Triangulation_ds_face_2:: +Triangulation_ds_face_2:: mirror_index(int i) const { // return the index of opposite vertex in neighbor(i); @@ -143,68 +94,10 @@ mirror_index(int i) const return ccw( neighbor(i)->index(vertex(ccw(i)))); } -template < class Tds > -inline bool -Triangulation_ds_face_2:: -has_vertex(Vertex_handle v) const -{ - return (Fb::has_vertex(&*v)); -} - -template < class Tds > -inline bool -Triangulation_ds_face_2:: -has_vertex(Vertex_handle v, int& i) const -{ - return (Fb::has_vertex(&*v,i)); -} - -template < class Tds > -inline int -Triangulation_ds_face_2:: -index(Vertex_handle v) const -{ - return(Fb::vertex_index(&*v)); -} -// Neighbors Access Functions -template < class Tds > -inline -typename Triangulation_ds_face_2::Face_handle -Triangulation_ds_face_2:: -neighbor(int i) const -{ - return (static_cast(Fb::neighbor(i))); -} - -template < class Tds > -inline bool -Triangulation_ds_face_2:: -has_neighbor(Face_handle n) const -{ - return (Fb::has_neighbor(&*n)); -} - -template < class Tds > -inline bool -Triangulation_ds_face_2:: -has_neighbor(Face_handle n, int& i) const -{ - return (Fb::has_neighbor(&*n,i)); -} - -template < class Tds > -inline int -Triangulation_ds_face_2:: -index(Face_handle n) const -{ - return(Fb::face_index(&*n)); -} - -//Miscelleanous -template < class Tds > +template < class Fb > bool -Triangulation_ds_face_2:: +Triangulation_ds_face_2:: is_valid(bool verbose, int level) const { bool result = Fb::is_valid(verbose, level); diff --git a/Packages/Triangulation_2/include/CGAL/Triangulation_ds_face_base_2.h b/Packages/Triangulation_2/include/CGAL/Triangulation_ds_face_base_2.h new file mode 100644 index 00000000000..eba96508964 --- /dev/null +++ b/Packages/Triangulation_2/include/CGAL/Triangulation_ds_face_base_2.h @@ -0,0 +1,352 @@ +// ============================================================================ +// +// Copyright (c) 1997 The CGAL Consortium +// +// This software and related documentation is part of an INTERNAL release +// of the Computational Geometry Algorithms Library (CGAL). It is not +// intended for general use. +// +// ---------------------------------------------------------------------------- +// +// release : +// release_date : +// +// file : Triangulation_ds_face_base_2.h +// source : $RCSfile$ +// revision : $Revision$ +// revision_date : $Date$ +// author(s) : Mariette Yvinec +// +// coordinator : Mariette Yvinec +// +// ============================================================================ + +#ifndef CGAL_TRIANGULATION_DS_FACE_BASE_2_H +#define CGAL_TRIANGULATION_DS_FACE_BASE_2_H + +#include +#include +#include +#include +#include + +CGAL_BEGIN_NAMESPACE + +template < typename TDS = void> +class Triangulation_ds_face_base_2 +{ +public: + typedef TDS Triangulation_data_structure; + typedef typename TDS::Vertex_handle Vertex_handle; + typedef typename TDS::Face_handle Face_handle; + + // Borland requires this. + template + struct Rebind_TDS { typedef Triangulation_ds_face_base_2 Other; }; + +private: + Vertex_handle V[3]; + Face_handle N[3]; + +public: + Triangulation_ds_face_base_2(); + Triangulation_ds_face_base_2(Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2); + Triangulation_ds_face_base_2(Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2, + Face_handle n0, + Face_handle n1, + Face_handle n2); + + Vertex_handle vertex(int i) const; + bool has_vertex(Vertex_handle v) const; + bool has_vertex(Vertex_handle v, int& i) const ; + int index(Vertex_handle v) const ; + + Face_handle neighbor(int i) const ; + bool has_neighbor(Face_handle n) const; + bool has_neighbor(Face_handle n, int& i) const; + int index(Face_handle n) const; + + void set_vertex(int i, Vertex_handle v); + void set_vertices(); + void set_vertices(Vertex_handle v0, Vertex_handle v1, Vertex_handle v2); + void set_neighbor(int i, Face_handle n) ; + void set_neighbors(); + void set_neighbors(Face_handle n0, Face_handle n1, Face_handle n2); + void reorient(); + void ccw_permute(); + void cw_permute(); + + int dimension() const; + //the following trivial is_valid to allow + // the user of derived face base classes + // to add their own purpose checking + bool is_valid(bool /* verbose */ = false, int /* level */ = 0) const + {return true;} + + +}; + +template +Triangulation_ds_face_base_2 :: +Triangulation_ds_face_base_2() +{ + set_vertices(); + set_neighbors(); +} + +template +Triangulation_ds_face_base_2 :: +Triangulation_ds_face_base_2( Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2) +{ + set_vertices(v0, v1, v2); + set_neighbors(); +} + +template +Triangulation_ds_face_base_2 :: +Triangulation_ds_face_base_2(Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2, + Face_handle n0, + Face_handle n1, + Face_handle n2) +{ + set_vertices(v0, v1, v2); + set_neighbors(n0, n1, n2); +} + + +template +inline +typename Triangulation_ds_face_base_2::Vertex_handle +Triangulation_ds_face_base_2:: +vertex(int i) const +{ + CGAL_triangulation_precondition( i == 0 || i == 1 || i == 2); + return V[i]; +} + + +template +inline bool +Triangulation_ds_face_base_2 :: +has_vertex(Vertex_handle v) const +{ + return (V[0] == v) || (V[1] == v) || (V[2]== v); +} + +template +inline bool +Triangulation_ds_face_base_2 :: +has_vertex(Vertex_handle v, int& i) const +{ + if (v == V[0]) { + i = 0; + return true; + } + if (v == V[1]) { + i = 1; + return true; + } + if (v == V[2]) { + i = 2; + return true; + } + return false; +} + +template +inline int +Triangulation_ds_face_base_2 :: +index(Vertex_handle v) const +{ + if (v == V[0]) return 0; + if (v == V[1]) return 1; + CGAL_triangulation_assertion( v == V[2] ); + return 2; +} + +template +inline +typename Triangulation_ds_face_base_2::Face_handle +Triangulation_ds_face_base_2:: +neighbor(int i) const +{ + CGAL_triangulation_precondition( i == 0 || i == 1 || i == 2); + return N[i]; +} + +template +inline bool +Triangulation_ds_face_base_2 :: +has_neighbor(Face_handle n) const +{ + return (N[0] == n) || (N[1] == n) || (N[2] == n); +} + + +template +inline bool +Triangulation_ds_face_base_2 :: +has_neighbor(Face_handle n, int& i) const +{ + if(n == N[0]){ + i = 0; + return true; + } + if(n == N[1]){ + i = 1; + return true; + } + if(n == N[2]){ + i = 2; + return true; + } + return false; +} + + + +template +inline int +Triangulation_ds_face_base_2 :: +index(Face_handle n) const +{ + if (n == N[0]) return 0; + if (n == N[1]) return 1; + CGAL_triangulation_assertion( n == N[2] ); + return 2; +} + +template +inline void +Triangulation_ds_face_base_2 :: +set_vertex(int i, Vertex_handle v) +{ + CGAL_triangulation_precondition( i == 0 || i == 1 || i == 2); + V[i] = v; +} + +template +inline void +Triangulation_ds_face_base_2 :: +set_neighbor(int i, Face_handle n) +{ + CGAL_triangulation_precondition( i == 0 || i == 1 || i == 2); + N[i] = n; +} + +template +inline void +Triangulation_ds_face_base_2 :: +set_vertices() +{ + V[0] = V[1] = V[2] = NULL; +} + +template +inline void +Triangulation_ds_face_base_2 :: +set_vertices(Vertex_handle v0, Vertex_handle v1, Vertex_handle v2) +{ + V[0] = v0; + V[1] = v1; + V[2] = v2; +} + +template +inline void +Triangulation_ds_face_base_2 :: +set_neighbors() +{ + N[0] = N[1] = N[2] = NULL; +} + +template +inline void +Triangulation_ds_face_base_2 :: +set_neighbors(Face_handle n0,Face_handle n1, Face_handle n2) +{ + N[0] = n0; + N[1] = n1; + N[2] = n2; +} + +template +void +Triangulation_ds_face_base_2 :: +reorient() +{ + //exchange the vertices 0 and 1 + set_vertices (V[1],V[0],V[2]); + set_neighbors(N[1],N[0],N[2]); +} + +template +inline void +Triangulation_ds_face_base_2 :: +ccw_permute() +{ + set_vertices (V[2],V[0],V[1]); + set_neighbors(N[2],N[0],N[1]); +} + + +template +inline void +Triangulation_ds_face_base_2 :: +cw_permute() +{ + set_vertices (V[1],V[2],V[0]); + set_neighbors(N[1],N[2],N[0]); +} + + +template < class TDS> +inline int +Triangulation_ds_face_base_2 :: +dimension() const +{ + if (V[2] != NULL) {return 2;} + else return( V[1] != NULL ? 1 : 0); +} + +template < class TDS > +inline +std::istream& +operator>>(std::istream &is, Triangulation_ds_face_base_2 &) + // non combinatorial information. Default = nothing +{ + return is; +} + +template < class TDS > +inline +std::ostream& +operator<<(std::ostream &os, const Triangulation_ds_face_base_2 &) + // non combinatorial information. Default = nothing +{ + return os; +} + +// Specialisation for void. +template <> +class Triangulation_ds_face_base_2 +{ +public: + typedef Dummy_tds_2 Triangulation_data_structure; + template + struct Rebind_TDS { typedef Triangulation_ds_face_base_2 Other; }; +}; + + + +CGAL_END_NAMESPACE + +#endif //CGAL_DS_TRIANGULATION_FACE_BASE_2_H diff --git a/Packages/Triangulation_2/include/CGAL/Triangulation_ds_iterators_2.h b/Packages/Triangulation_2/include/CGAL/Triangulation_ds_iterators_2.h index 127040b1944..9c2f26d4191 100644 --- a/Packages/Triangulation_2/include/CGAL/Triangulation_ds_iterators_2.h +++ b/Packages/Triangulation_2/include/CGAL/Triangulation_ds_iterators_2.h @@ -12,7 +12,7 @@ // release_date : // // file : include/CGAL/Triangulation_ds_iterators_2.h -// package : Triangulation +// package : Triangulation_2 // source : $RCSfile$ // revision : $Revision$ // revision_date : $Date$ @@ -28,65 +28,16 @@ #include #include #include - +#include CGAL_BEGIN_NAMESPACE -// The iterator_base visits all the full dimensional faces -// of the Tds -// whatever may be the dimension of the Tds -// The following iterator visit the 2-faces - -template -class Triangulation_ds_face_iterator_2 - : public Tds::Iterator_base -{ -public: - typedef typename Tds::Iterator_base Base; - typedef typename Tds::Face_handle Face_handle; - typedef Triangulation_ds_face_iterator_2 Face_iterator; - - Triangulation_ds_face_iterator_2() : Base() {} - - Triangulation_ds_face_iterator_2(const Tds * tds) - : Base(tds->face_container().begin()) - {} - - Triangulation_ds_face_iterator_2(const Tds* tds, int) - : Base(tds->face_container().end()) - {} - - operator Face_handle() const {return (*this)->handle();} -}; - - -template < class Tds> -class Triangulation_ds_vertex_iterator_2 - : public Tds::Vertex_container::iterator -{ -public: - typedef typename Tds::Vertex_container::iterator Vertex_iterator_base; - typedef typename Tds::Vertex_handle Vertex_handle; - typedef Triangulation_ds_vertex_iterator_2 Vertex_iterator; - - Triangulation_ds_vertex_iterator_2() : Vertex_iterator_base() {} - - Triangulation_ds_vertex_iterator_2(const Tds* tds) - : Vertex_iterator_base(tds->vertex_container().begin()) {} - - Triangulation_ds_vertex_iterator_2(const Tds* tds, int ) - : Vertex_iterator_base(tds->vertex_container().end()) {} - - operator Vertex_handle() const {return (*this)->handle();} -}; - - template class Triangulation_ds_edge_iterator_2 { public: typedef typename Tds::Edge Edge; - typedef typename Tds::Iterator_base Iterator_base; + typedef typename Tds::Face_iterator Face_iterator; typedef typename Tds::Face_handle Face_handle; typedef Edge value_type; @@ -100,7 +51,7 @@ public: private: const Tds* _tds; -Iterator_base pos; +Face_iterator pos; mutable Edge edge; public: diff --git a/Packages/Triangulation_2/include/CGAL/Triangulation_ds_vertex_2.h b/Packages/Triangulation_2/include/CGAL/Triangulation_ds_vertex_2.h index 56089361ad4..da005d59f08 100644 --- a/Packages/Triangulation_2/include/CGAL/Triangulation_ds_vertex_2.h +++ b/Packages/Triangulation_2/include/CGAL/Triangulation_ds_vertex_2.h @@ -24,37 +24,29 @@ #ifndef CGAL_TRIANGULATION_DS_VERTEX_2_H #define CGAL_TRIANGULATION_DS_VERTEX_2_H +#include #include CGAL_BEGIN_NAMESPACE -template +template class Triangulation_ds_vertex_2 - : public Tds::Vertex_base, - public Triangulation_cw_ccw_2 + : public Vb { + typedef typename Vb::Triangulation_data_structure Tds; public: - typedef typename Tds::Vertex_base Vb; typedef typename Tds::Vertex Vertex; - typedef typename Tds::Face Face; - typedef typename Tds::Edge Edge; typedef typename Tds::Vertex_handle Vertex_handle; typedef typename Tds::Face_handle Face_handle; typedef typename Tds::Vertex_circulator Vertex_circulator; typedef typename Tds::Face_circulator Face_circulator; typedef typename Tds::Edge_circulator Edge_circulator; - //typedef typename Vb::Point Point; //CREATORS Triangulation_ds_vertex_2() : Vb() {} - //SETTING - void set_face(Face_handle f) { Vb::set_face(&*f);} - //ACCESS - //Vertex_handle handle() const {return &*this;} Vertex_handle handle() {return const_cast(this); } - Face_handle face() const {return static_cast(Vb::face()) ;} int degree(); //should be const // the following should be const @@ -100,9 +92,9 @@ degree() //const -template +template bool -Triangulation_ds_vertex_2 :: +Triangulation_ds_vertex_2 :: is_valid(bool verbose, int level) { bool result = Vb::is_valid(verbose, level); diff --git a/Packages/Triangulation_2/include/CGAL/Triangulation_ds_vertex_base_2.h b/Packages/Triangulation_2/include/CGAL/Triangulation_ds_vertex_base_2.h new file mode 100644 index 00000000000..50999abef11 --- /dev/null +++ b/Packages/Triangulation_2/include/CGAL/Triangulation_ds_vertex_base_2.h @@ -0,0 +1,93 @@ +// ============================================================================ +// +// Copyright (c) 1999,2000,2001,2002,2003 The CGAL Consortium +// +// This software and related documentation is part of an INTERNAL release +// of the Computational Geometry Algorithms Library (CGAL). It is not +// intended for general use. +// +// ---------------------------------------------------------------------------- +// +// release : +// release_date : +// +// file : Triangulation/include/CGAL/Triangulation_ds_vertex_base_2.h +// source : $RCSfile$ +// revision : $Revision$ +// revision_date : $Date$ +// author(s) : Mariette Yvinec +// +// coordinator : Mariette Yvinec +// +// ============================================================================ + + +#ifndef CGAL_TRIANGULATION_DS_VERTEX_BASE_2_H +#define CGAL_TRIANGULATION_DS_VERTEX_BASE_2_H + +#include +#include +#include + +CGAL_BEGIN_NAMESPACE + +template < class TDS = void > +class Triangulation_ds_vertex_base_2 +{ + typedef typename TDS::Face_handle Face_handle; +public: + typedef TDS Triangulation_data_structure; + + // Borland seems to require it. + template + struct Rebind_TDS { typedef Triangulation_ds_vertex_base_2 Other; }; + + Triangulation_ds_vertex_base_2 () : _f(NULL) {} + Triangulation_ds_vertex_base_2(Face_handle f) : _f(f) {} + + Face_handle face() const { return _f;} + void set_face(Face_handle f) { _f = f ;} + + //the following trivial is_valid to allow + // the user of derived face base classes + // to add their own purpose checking + bool is_valid(bool /*verbose*/=false, int /*level*/= 0) const + {return face() != NULL;} + +private: + Face_handle _f; + // FIXME : temporary cruft needed for DS_Container (sizeof() too small) : + int i; +}; + +// Specialization for void. +template <> +class Triangulation_ds_vertex_base_2 +{ +public: + typedef Dummy_tds_2 Triangulation_data_structure; + template + struct Rebind_TDS { typedef Triangulation_ds_vertex_base_2 Other; }; +}; + + +template < class TDS > +inline +std::istream& +operator>>(std::istream &is, Triangulation_ds_vertex_base_2 &) + // no combinatorial information. +{ + return is; +} + +template < class TDS > +inline +std::ostream& +operator<<(std::ostream &os, const Triangulation_ds_vertex_base_2 &) + // no combinatorial information. +{ + return os; +} +CGAL_END_NAMESPACE + +#endif //CGAL_TRIANGULATION_DS_VERTEX_BASE_2_H diff --git a/Packages/Triangulation_2/include/CGAL/Triangulation_face_base_2.h b/Packages/Triangulation_2/include/CGAL/Triangulation_face_base_2.h deleted file mode 100644 index 52c61f16238..00000000000 --- a/Packages/Triangulation_2/include/CGAL/Triangulation_face_base_2.h +++ /dev/null @@ -1,304 +0,0 @@ -// ============================================================================ -// -// Copyright (c) 1997 The CGAL Consortium -// -// This software and related documentation is part of an INTERNAL release -// of the Computational Geometry Algorithms Library (CGAL). It is not -// intended for general use. -// -// ---------------------------------------------------------------------------- -// -// release : -// release_date : -// -// file : Triangulation_face_base_2.h -// source : $RCSfile$ -// revision : $Revision$ -// revision_date : $Date$ -// author(s) : Mariette Yvinec -// -// coordinator : Mariette Yvinec -// -// ============================================================================ - -#ifndef CGAL_TRIANGULATION_FACE_BASE_2_H -#define CGAL_TRIANGULATION_FACE_BASE_2_H - - -#include -#include -#include - -CGAL_BEGIN_NAMESPACE - -template < class Gt > -class Triangulation_face_base_2 -{ -public: - typedef Triangulation_face_base_2 Face_base; - -private: - void* V[3]; - void* N[3]; - -public: - Triangulation_face_base_2(); - Triangulation_face_base_2(void* v0, void* v1, void* v2); - Triangulation_face_base_2(void* v0, void* v1, void* v2, - void* n0, void* n1, void* n2); - - void* vertex(int i) const; - bool has_vertex(const void* v) const; - bool has_vertex(const void* v, int& i) const ; - int vertex_index(const void* v) const ; - - void* neighbor(int i) const ; - bool has_neighbor(const void* n) const; - bool has_neighbor(const void* n, int& i) const; - int face_index(const void* n) const; - - void set_vertex(int i, void* v); - void set_vertices(); - void set_vertices(void* v0, void* v1, void* v2); - void set_neighbor(int i, void* n) ; - void set_neighbors(); - void set_neighbors(void* n0, void* n1, void* n2); - void reorient(); - void ccw_permute(); - void cw_permute(); - - int dimension() const; - //the following trivial is_valid to allow - // the user of derived face base classes - // to add their own purpose checking - bool is_valid(bool /* verbose */ = false, int /* level */ = 0) const - {return true;} - - -}; - -template -Triangulation_face_base_2 :: -Triangulation_face_base_2() -{ - set_vertices(); - set_neighbors(); -} - -template -Triangulation_face_base_2 :: -Triangulation_face_base_2( void* v0, void* v1, void* v2) -{ - set_vertices(v0, v1, v2); - set_neighbors(); -} - -template -Triangulation_face_base_2 :: -Triangulation_face_base_2(void* v0, void* v1, void* v2, - void* n0, void* n1, void* n2) -{ - set_vertices(v0, v1, v2); - set_neighbors(n0, n1, n2); -} - - -template -inline void* -Triangulation_face_base_2 :: -vertex(int i) const -{ - CGAL_triangulation_precondition( i == 0 || i == 1 || i == 2); - return V[i]; -} - - -template -inline bool -Triangulation_face_base_2 :: -has_vertex(const void* v) const -{ - return (V[0] == v) || (V[1] == v) || (V[2]== v); -} - -template -inline bool -Triangulation_face_base_2 :: -has_vertex(const void* v, int& i) const -{ - if (v == V[0]) { - i = 0; - return true; - } - if (v == V[1]) { - i = 1; - return true; - } - if (v == V[2]) { - i = 2; - return true; - } - return false; -} - -template -inline int -Triangulation_face_base_2 :: -vertex_index(const void* v) const -{ - if (v == V[0]) return 0; - if (v == V[1]) return 1; - CGAL_triangulation_assertion( v == V[2] ); - return 2; -} - -template -inline void* -Triangulation_face_base_2 :: -neighbor(int i) const -{ - CGAL_triangulation_precondition( i == 0 || i == 1 || i == 2); - return N[i]; -} - -template -inline bool -Triangulation_face_base_2 :: -has_neighbor(const void* n) const -{ - return (N[0] == n) || (N[1] == n) || (N[2] == n); -} - - -template -inline bool -Triangulation_face_base_2 :: -has_neighbor(const void* n, int& i) const -{ - if(n == N[0]){ - i = 0; - return true; - } - if(n == N[1]){ - i = 1; - return true; - } - if(n == N[2]){ - i = 2; - return true; - } - return false; -} - - - -template -inline int -Triangulation_face_base_2 :: -face_index(const void* n) const -{ - if (n == N[0]) return 0; - if (n == N[1]) return 1; - CGAL_triangulation_assertion( n == N[2] ); - return 2; -} - -template -inline void -Triangulation_face_base_2 :: -set_vertex(int i, void* v) -{ - CGAL_triangulation_precondition( i == 0 || i == 1 || i == 2); - V[i] = v; -} - -template -inline void -Triangulation_face_base_2 :: -set_neighbor(int i, void* n) -{ - CGAL_triangulation_precondition( i == 0 || i == 1 || i == 2); - N[i] = n; -} - -template -inline void -Triangulation_face_base_2 :: -set_vertices() -{ - V[0] = V[1] = V[2] = NULL; -} - -template -inline void -Triangulation_face_base_2 :: -set_vertices(void* v0, void* v1, void* v2) -{ - V[0] = v0; - V[1] = v1; - V[2] = v2; -} - -template -inline void -Triangulation_face_base_2 :: -set_neighbors() -{ - N[0] = N[1] = N[2] = NULL; -} - -template -inline void -Triangulation_face_base_2 :: -set_neighbors(void* n0,void* n1, void* n2) -{ - N[0] = n0; - N[1] = n1; - N[2] = n2; -} - -template -void -Triangulation_face_base_2 :: -reorient() -{ - //exchange the vertices 0 and 1 - set_vertices (V[1],V[0],V[2]); - set_neighbors(N[1],N[0],N[2]); -} - -template -inline void -Triangulation_face_base_2 :: -ccw_permute() -{ - set_vertices (V[2],V[0],V[1]); - set_neighbors(N[2],N[0],N[1]); -} - - -template -inline void -Triangulation_face_base_2 :: -cw_permute() -{ - set_vertices (V[1],V[2],V[0]); - set_neighbors(N[1],N[2],N[0]); -} - - -template < class Gt> -inline int -Triangulation_face_base_2 :: -dimension() const -{ - if (V[2] != NULL) {return 2;} - else return( V[1] != NULL ? 1 : 0); -} - - - - -CGAL_END_NAMESPACE - -#endif //CGAL_TRIANGULATION_FACE_BASE_2_H diff --git a/Packages/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h b/Packages/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h index 6d8e34292b7..cfefcefec72 100644 --- a/Packages/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h +++ b/Packages/Triangulation_2/include/CGAL/Triangulation_hierarchy_2.h @@ -12,10 +12,11 @@ // release_date : // // file : include/CGAL/Triangulation_hierarchy_2.h -// revision : -// revision_date : -// package : Triangulation +// revision : $Revision$ +// revision_date : $Date$ +// package : Triangulation_2 // author(s) : Olivier Devillers +// Mariette Yvinec // // coordinator : INRIA Sophia-Antipolis () // @@ -24,46 +25,17 @@ #ifndef CGAL_TRIANGULATION_HIERARCHY_2_H #define CGAL_TRIANGULATION_HIERARCHY_2_H +#include +#include #include +#include #include CGAL_BEGIN_NAMESPACE -template < class Vbb> -class Triangulation_hierarchy_vertex_base_2 - : public Vbb -{ - public: - typedef Vbb V_Base; - typedef typename V_Base::Point Point; - - - Triangulation_hierarchy_vertex_base_2() - : V_Base(), _up(0), _down(0) - {} - Triangulation_hierarchy_vertex_base_2(const Point & p, void* f) - : V_Base(p,f), _up(0), _down(0) - {} - Triangulation_hierarchy_vertex_base_2(const Point & p) - : V_Base(p), _up(0), _down(0) - {} - - public: // for use in Triangulation_hierarchy only - // friend class Triangulation_hierarchy_2; - void* up() {return _up;} - void* down() {return _down;} - void set_up(void *u) {_up=u;} - void set_down(void *d) {if (this) _down=d;} - - - private: - void* _up; // same vertex one level above - void* _down; // same vertex one level below -}; - // parameterization of the hierarchy //const float Triangulation_hierarchy_2__ratio = 30.0; -const int Triangulation_hierarchy_2__ratio = 30; +const int Triangulation_hierarchy_2__ratio = 30; const int Triangulation_hierarchy_2__minsize = 20; const int Triangulation_hierarchy_2__maxlevel = 5; // maximal number of points is 30^5 = 24 millions ! @@ -78,9 +50,10 @@ class Triangulation_hierarchy_2 typedef typename Tr_Base::Point Point; typedef typename Tr_Base::Vertex_handle Vertex_handle; typedef typename Tr_Base::Face_handle Face_handle; - typedef typename Tr_Base::Vertex_iterator Vertex_iterator; typedef typename Tr_Base::Vertex Vertex; typedef typename Tr_Base::Locate_type Locate_type; + typedef typename Tr_Base::Finite_vertices_iterator Finite_vertices_iterator; + //typedef typename Tr_Base::Finite_faces_iterator Finite_faces_iterator; private: // here is the stack of triangulations which form the hierarchy @@ -138,9 +111,10 @@ public: private: void locate_in_all(const Point& p, - Locate_type& lt, - int& li, - Face_handle pos[Triangulation_hierarchy_2__maxlevel]) const; + Locate_type& lt, + int& li, + Face_handle + pos[Triangulation_hierarchy_2__maxlevel]) const; int random_level(); }; @@ -187,7 +161,7 @@ void Triangulation_hierarchy_2:: copy_triangulation(const Triangulation_hierarchy_2 &tr) { - std::map< const void*, void*, std::less > V; + std::map V; { for(int i=0;icopy_triangulation(*tr.hierarchy[i]); @@ -195,21 +169,21 @@ copy_triangulation(const Triangulation_hierarchy_2 &tr) //up and down have been copied in straightforward way // compute a map at lower level { - for( Vertex_iterator it=hierarchy[0]->vertices_begin(); - it != hierarchy[0]->vertices_end(); ++it) { - if (it->up()) V[ ((Vertex*)(it->up()))->down() ] = &(*it); + for( Finite_vertices_iterator it=hierarchy[0]->finite_vertices_begin(); + it != hierarchy[0]->finite_vertices_end(); ++it) { + if (it->up() != NULL) V[ it->up()->down() ] = it; } } { for(int i=1;ivertices_begin(); - it != hierarchy[i]->vertices_end(); ++it) { + for( Finite_vertices_iterator it=hierarchy[i]->finite_vertices_begin(); + it != hierarchy[i]->finite_vertices_end(); ++it) { // down pointer goes in original instead in copied triangulation it->set_down(V[it->down()]); // make reverse link - ((Vertex*)(it->down()))->set_up( &(*it) ); + it->down()->set_up(it); // make map for next level - if (it->up()) V[ ((Vertex*)(it->up()))->down() ] = &(*it); + if (it->up()!= NULL ) V[ it->up()->down() ] = it; } } } @@ -220,9 +194,6 @@ void Triangulation_hierarchy_2:: swap(Triangulation_hierarchy_2 &tr) { -// Tr_Base** h= hierarchy; -// hierarchy = tr.hierarchy; -// tr.hierarchy = h; Tr_Base* temp; Tr_Base::swap(tr); for(int i= 1; iis_valid(verbose,level); //verify that lower level has no down pointers - for( it = hierarchy[0]->vertices_begin(); - it != hierarchy[0]->vertices_end(); ++it) - result = result && ( it->down() == 0 ); - //verify that other levels has down pointer and reciprocal link is fine + for( it = hierarchy[0]->finite_vertices_begin(); + it != hierarchy[0]->finite_vertices_end(); ++it) + result = result && ( it->down() == NULL ); + //verify that other levels have down pointer and reciprocal link is fine for(i=1;ivertices_begin(); - it != hierarchy[i]->vertices_end(); ++it) + for( it = hierarchy[i]->finite_vertices_begin(); + it != hierarchy[i]->finite_vertices_end(); ++it) result = result && - ( ((Vertex*)((Vertex*)it->down())->up()) == &(*it) ); + ( &*(it->down()->up()) == &*(it) ); + //verify that levels have up pointer and reciprocal link is fine + for(i=0;ifinite_vertices_begin(); + it != hierarchy[i]->finite_vertices_end(); ++it) + result = result && ( it->up() == NULL || + &*it == &*(it->up())->down() ); return result; } @@ -296,8 +273,8 @@ insert(const Point &p, Face_handle) int level = 1; while (level <= vertex_level ){ vertex=hierarchy[level]->Tr_Base::insert(p,positions[level]); - vertex->set_down((void *) &*previous);// link with level above - previous->set_up((void *) &*vertex); + vertex->set_down(previous);// link with level above + previous->set_up(vertex); previous=vertex; level++; } @@ -328,8 +305,8 @@ insert(const Point& p, int level = 1; while (level <= vertex_level ){ vertex=hierarchy[level]->Tr_Base::insert(p,positions[level]); - vertex->set_down((void *) &*previous);// link with level above - previous->set_up((void *) &*vertex); + vertex->set_down(previous);// link with level above + previous->set_up(vertex); previous=vertex; level++; } @@ -352,13 +329,13 @@ void Triangulation_hierarchy_2:: remove(Vertex_handle v ) { - void * u=v->up(); + Vertex_handle u=v->up(); int l = 0 ; while(1){ hierarchy[l++]->remove(v); - if (!u) break; + if (u == NULL) break; if(l>Triangulation_hierarchy_2__maxlevel) break; - v=(Vertex*)u; u=v->up(); + v=u; u=v->up(); } } @@ -446,10 +423,10 @@ locate_in_all(const Point& p, if ( ! hierarchy[level]->is_infinite(position->vertex(2))) if ( closer( p, position->vertex(2)->point(), - nearest->point()) == SMALLER) + nearest->point()) == SMALLER ) nearest = position->vertex(2); // go at the same vertex on level below - nearest = (Vertex*)( nearest->down() ); + nearest = nearest->down(); position = nearest->face(); // incident face --level; } diff --git a/Packages/Triangulation_2/include/CGAL/Triangulation_hierarchy_vertex_base_2.h b/Packages/Triangulation_2/include/CGAL/Triangulation_hierarchy_vertex_base_2.h new file mode 100644 index 00000000000..394657e876c --- /dev/null +++ b/Packages/Triangulation_2/include/CGAL/Triangulation_hierarchy_vertex_base_2.h @@ -0,0 +1,75 @@ +// ============================================================================ +// +// Copyright (c) 1998 The CGAL Consortium +// +// This software and related documentation is part of an INTERNAL release +// of the Computational Geometry Algorithms Library (CGAL). It is not +// intended for general use. +// +// ---------------------------------------------------------------------------- +// +// release : +// release_date : +// +// file : include/CGAL/Triangulation_hierarchy_vertex_base_2.h +// revision : $Revision$ +// revision_date : $Date$ +// package : Triangulation_2 +// author(s) : Olivier Devillers +// Mariette Yvinec +// +// coordinator : INRIA Sophia-Antipolis () +// +// ============================================================================ + +#ifndef CGAL_TRIANGULATION_HIERARCHY_VERTEX_BASE_2_H +#define CGAL_TRIANGULATION_HIERARCHY_VERTEX_BASE_2_H + +#include +#include + +CGAL_BEGIN_NAMESPACE + +template < class Vbb> +class Triangulation_hierarchy_vertex_base_2 + : public Vbb +{ + typedef Vbb Base; + typedef typename Base::Triangulation_data_structure Tds; + +public: + typedef typename Base::Point Point; + typedef Tds Triangulation_data_structure; + typedef typename Tds::Vertex_handle Vertex_handle; + typedef typename Tds::Face_handle Face_handle; + + template < typename TDS2 > + struct Rebind_TDS { + typedef typename Vbb::template Rebind_TDS::Other Vb2; + typedef Triangulation_hierarchy_vertex_base_2 Other; + }; + + Triangulation_hierarchy_vertex_base_2() + : Base(), _up(0), _down(0) + {} + Triangulation_hierarchy_vertex_base_2(const Point & p, Face_handle f) + : Base(p,f), _up(0), _down(0) + {} + Triangulation_hierarchy_vertex_base_2(const Point & p) + : Base(p), _up(0), _down(0) + {} + + Vertex_handle up() {return _up;} + Vertex_handle down() {return _down;} + void set_up(Vertex_handle u) {_up=u;} + void set_down(Vertex_handle d) {if (this) _down=d;} + + + private: + Vertex_handle _up; // same vertex one level above + Vertex_handle _down; // same vertex one level below +}; + +CGAL_END_NAMESPACE + +#endif // CGAL_TRIANGULATION_HIERARCHY_VERTEX_BASE_2_H diff --git a/Packages/Triangulation_2/include/CGAL/Triangulation_iterator_adaptator.h b/Packages/Triangulation_2/include/CGAL/Triangulation_iterator_adaptator.h new file mode 100644 index 00000000000..c5cea7719f1 --- /dev/null +++ b/Packages/Triangulation_2/include/CGAL/Triangulation_iterator_adaptator.h @@ -0,0 +1,54 @@ +// ====================================================================== +// +// Copyright (c) 1997 The CGAL Consortium +// +// This software and related documentation is part of an INTERNAL release +// of the Computational Geometry Algorithms Library (CGAL). It is not +// intended for general use. +// +// ---------------------------------------------------------------------- +// +// release : +// release_date : +// +// file : include/CGAL/Triangulation_iterator_adaptator.h +// package : Triangulation_2 +// source : $RCSfile$ +// revision : $Revision$ +// revision_date : $Date$ +// author(s) : Mariette Yvinec +// +// coordinator : Mariette Yvinec +// +// ====================================================================== + +#ifndef CGAL_TRIANGULATION_ITERATOR_ADAPTATOR_H +#define CGAL_TRIANGULATION_ITERATOR_ADAPTATOR_H + +#include +#include + +CGAL_BEGIN_NAMESPACE + +template +struct Triangulation_iterator_handle_adaptor + : public Base +{ + typedef Triangulation_iterator_handle_adaptor Self; + Triangulation_iterator_handle_adaptor() : Base() {} + + Triangulation_iterator_handle_adaptor(const Base & b) + : Base(b) {} + + operator Handle() const {return (*this)->handle();} + Self& operator++() { Base::operator++(); return *this;} + Self& operator--() { Base::operator--(); return *this;} + Self operator++(int) { Self tmp(*this); ++(*this); return tmp; } + Self operator--(int) { Self tmp(*this); --(*this); return tmp; } +}; + + + +CGAL_END_NAMESPACE + +#endif //CGAL_TRIANGULATION_ITERATOR_ADAPTATOR_H diff --git a/Packages/Triangulation_2/include/CGAL/Triangulation_iterators_2.h b/Packages/Triangulation_2/include/CGAL/Triangulation_iterators_2.h deleted file mode 100644 index 26cb7605f48..00000000000 --- a/Packages/Triangulation_2/include/CGAL/Triangulation_iterators_2.h +++ /dev/null @@ -1,107 +0,0 @@ -// ============================================================================ -// -// Copyright (c) 1997 The CGAL Consortium -// -// This software and related documentation is part of an INTERNAL release -// of the Computational Geometry Algorithms Library (CGAL). It is not -// intended for general use. -// -// ---------------------------------------------------------------------------- -// -// release : -// release_date : -// -// file : Triangulation/include/CGAL/Triangulation_iterators_2.h -// source : $RCSfile$ -// revision : $Revision$ -// revision_date : $Date$ -// author(s) : Mariette Yvinec -// -// coordinator : Mariette Yvinec -// -// ============================================================================ - -#ifndef CGAL_TRIANGULATION_ITERATORS_2_H -#define CGAL_TRIANGULATION_ITERATORS_2_H - -#include -#include -#include -#include -#include -#include - -CGAL_BEGIN_NAMESPACE - -template < class Triangulation> -class Triangulation_finite_faces_iterator_2 - : public Filter_iterator< typename Triangulation::All_faces_iterator, - typename Triangulation::Infinite_tester > -{ -public: - typedef typename Triangulation::All_faces_iterator All_faces_iterator; - typedef typename Triangulation::Infinite_tester Infinite_tester; - typedef Filter_iterator Base; - typedef Triangulation_finite_faces_iterator_2 Self; - typedef typename Triangulation::Face_handle Face_handle; - - Triangulation_finite_faces_iterator_2() : Base() {} - - Triangulation_finite_faces_iterator_2(const Triangulation* tr) - : Base( filter_iterator(tr->all_faces_begin(), - tr->all_faces_end(), - tr->infinite_tester())) {} - - Triangulation_finite_faces_iterator_2(const Triangulation* tr, int) - : Base( filter_iterator(tr->all_faces_begin(), - tr->all_faces_end(), - tr->infinite_tester(), - tr->all_faces_end())) {} - - operator Face_handle() const {return (*this)->handle();} - Self& operator++() { Base::operator++(); return *this;} - Self& operator--() { Base::operator--(); return *this; } - Self operator++(int) { Self tmp(*this); ++(*this); return tmp; } - Self operator--(int) { Self tmp(*this); --(*this); return tmp; } -}; - - -template < class Triangulation> -class Triangulation_finite_vertices_iterator_2 - : public Filter_iterator< typename Triangulation::All_vertices_iterator, - typename Triangulation::Infinite_tester > -{ -public: - typedef typename Triangulation::All_vertices_iterator All_vertices_iterator; - typedef typename Triangulation::Infinite_tester Infinite_tester; - typedef Filter_iterator Base; - typedef Triangulation_finite_vertices_iterator_2 Self; - typedef typename Triangulation::Vertex_handle Vertex_handle; - - Triangulation_finite_vertices_iterator_2() : Base() {} - - Triangulation_finite_vertices_iterator_2(const Triangulation *tr) - : Base( filter_iterator(tr->all_vertices_begin(), - tr->all_vertices_end(), - tr->infinite_tester())) {} - - Triangulation_finite_vertices_iterator_2(const Triangulation *tr, int ) - : Base( filter_iterator(tr->all_vertices_begin(), - tr->all_vertices_end(), - tr->infinite_tester(), - tr->all_vertices_end())) {} - - operator Vertex_handle() const {return (*this)->handle();} - Self& operator++() { Base::operator++(); return *this;} - Self& operator--() { Base::operator--(); return *this;} - Self operator++(int) { Self tmp(*this); ++(*this); return tmp; } - Self operator--(int) { Self tmp(*this); --(*this); return tmp; } - -}; - - - -CGAL_END_NAMESPACE - - -#endif //CGAL_TRIANGULATION_ITERATORS_2_H diff --git a/Packages/Triangulation_2/include/CGAL/Triangulation_short_names_2.h b/Packages/Triangulation_2/include/CGAL/Triangulation_short_names_2.h index 93bb4439e1e..9c8694848e5 100644 --- a/Packages/Triangulation_2/include/CGAL/Triangulation_short_names_2.h +++ b/Packages/Triangulation_2/include/CGAL/Triangulation_short_names_2.h @@ -27,9 +27,7 @@ //Define shorter names to please linker (g++/egcs) -// for backward compatibilite -#define Triangulation_default_data_structure_2 TDDS -#define Triangulation_data_structure_using_list_2 TDSUL + #define Triangulation_data_structure_2 TDS #define Triangulation_vertex_base_2 Tvb #define Triangulation_face_base_2 Tfb @@ -40,8 +38,8 @@ #define Triangulation_ds_vertex_2 Tdsv #define Triangulation_ds_face_2 Tdsf -#define Triangulation_dsul_vertex_2 Tdsulv -#define Triangulation_dsul_face_2 Tdsulf +#define Triangulation_ds_face_base_2 Tdsfb +#define Triangulation_ds_vertex_base_2 Tdsvb #define Triangulation_vertex_2 Tv #define Triangulation_face_2 Tf #define Triangulation_vertex_handle_2 Tvh diff --git a/Packages/Triangulation_2/include/CGAL/Triangulation_vertex_base_2.h b/Packages/Triangulation_2/include/CGAL/Triangulation_vertex_base_2.h index 76c9e4cfdab..3d971025517 100644 --- a/Packages/Triangulation_2/include/CGAL/Triangulation_vertex_base_2.h +++ b/Packages/Triangulation_2/include/CGAL/Triangulation_vertex_base_2.h @@ -25,48 +25,74 @@ #ifndef CGAL_TRIANGULATION_VERTEX_BASE_2_H #define CGAL_TRIANGULATION_VERTEX_BASE_2_H +#include #include +#include CGAL_BEGIN_NAMESPACE -template < class GT > -class Triangulation_vertex_base_2 { +template < typename GT, + typename Vb = Triangulation_ds_vertex_base_2<> > +class Triangulation_vertex_base_2 + : public Vb + +{ + typedef typename Vb::Triangulation_data_structure Tds; +public: + typedef GT Geom_traits; + typedef typename GT::Point_2 Point; + typedef Tds Triangulation_data_structure; + typedef typename Tds::Face_handle Face_handle; + typedef typename Tds::Vertex_handle Vertex_handle; + + template < typename TDS2 > + struct Rebind_TDS { + typedef typename Vb::template Rebind_TDS::Other Vb2; + typedef Triangulation_vertex_base_2 Other; + }; + +private: + Point _p; public: - typedef typename GT::Point_2 Point; - - Triangulation_vertex_base_2 () - : _p(Point()), _f(NULL) - {} - - Triangulation_vertex_base_2(const Point & p, void * f = NULL) - : _p(p), _f(f) - {} + Triangulation_vertex_base_2 () : Vb() {} + Triangulation_vertex_base_2(const Point & p) : Vb(), _p(p) {} + Triangulation_vertex_base_2(const Point & p, Face_handle f) + : Vb(f), _p(p) {} void set_point(const Point & p) { _p = p; } - void set_face(void* f) { _f = f ;} - const Point& point() const { return _p; } - void* face() const { return _f;} - + // the non const version of point() is undocument // but needed to make the point iterator works // using Lutz projection scheme Point& point() { return _p; } - //the following trivial is_valid to allow // the user of derived face base classes // to add their own purpose checking bool is_valid(bool /* verbose */ = false, int /* level */ = 0) const {return true;} - -private: - Point _p; - void * _f; - }; +template < class GT, class Vb > +std::istream& +operator>>(std::istream &is, Triangulation_vertex_base_2 &v) + // non combinatorial information. Default = point +{ + return is >> static_cast(v) >> v.point(); +} + +template < class GT, class Vb > +std::ostream& +operator<<(std::ostream &os, const Triangulation_vertex_base_2 &v) + // non combinatorial information. Default = point +{ + return os << static_cast(v) << v.point(); +} + + + CGAL_END_NAMESPACE #endif //CGAL_TRIANGULATION_VERTEX_BASE_2_H diff --git a/Packages/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_regular_triangulation_2.C b/Packages/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_regular_triangulation_2.C index 998847ac4c4..448b7b3472c 100644 --- a/Packages/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_regular_triangulation_2.C +++ b/Packages/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_regular_triangulation_2.C @@ -539,6 +539,7 @@ _test_cls_reg_triangulation_2( const Triangulation & ) fc2 = TT.line_walk(Bare_point(0,0),Bare_point(1,1),loc); if (fc != fc2) { + TT.show_all(); TT.show_face(loc); TT.show_face(fc); TT.show_face(fc2); diff --git a/Packages/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_tds_2.C b/Packages/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_tds_2.C index 45fa7c53991..3b88463d27d 100644 --- a/Packages/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_tds_2.C +++ b/Packages/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_tds_2.C @@ -29,9 +29,9 @@ -template +template void -_test_cls_tds_2( const Tds &, const Gt &) +_test_cls_tds_2( const Tds &) { typedef typename Tds::Vertex Vertex; @@ -48,11 +48,10 @@ _test_cls_tds_2( const Tds &, const Gt &) typedef typename Tds::Face_circulator Face_circulator; typedef typename Tds::Edge_circulator Edge_circulator; - typedef typename Gt::Point_2 Point; - + // Test subclasses - CGAL::_test_cls_tds_vertex( Vertex(), Gt() ); - CGAL::_test_cls_tds_face( Face(), Gt() ); + CGAL::_test_cls_tds_vertex( Vertex()); + CGAL::_test_cls_tds_face( Face()); // Test constructors std::cout << " constructors" << std::endl; @@ -116,33 +115,21 @@ _test_cls_tds_2( const Tds &, const Gt &) Vertex_handle w4 = tds4.insert_first(); Vertex_handle v4_1 = tds4.insert_second(); Vertex_handle v4_2 = tds4.insert_dim_up(w4,true); - // from now on, coordinates have to be introduced for - // the ierators in is_valid() to work - Point p1(0,0); - Point p2(2,0); - Point p3(1,2); - Point p3bis(1,-2); - Point p4(1,1); - Point p5(1,0); - v4_1->set_point(p1); - v4_2->set_point(p2); //test insert_dim_up, remove _dim_down from dimsension 1 to 2 Vertex_handle v4_3 = tds4.insert_dim_up(w4,false); - v4_3->set_point(p3bis); assert(tds4.dimension()== 2); assert(tds4.number_of_vertices() == 4); assert(tds4.is_valid() ); tds4.remove_dim_down(v4_3); assert(tds4.is_valid() ); v4_3 = tds4.insert_dim_up(w4,true); - v4_3->set_point(p3); assert(tds4.is_valid() ); // test insert-in-face, insert_in_egde dim==2 // Find the face v4_1 v4_2 v4_3 for insertion Face_circulator fc= v4_1->incident_faces(); while( ! (fc->has_vertex(v4_2) && fc->has_vertex(v4_3)) ) fc++; Vertex_handle v4_4 = tds4.insert_in_face(&( *fc)); - v4_4->set_point(p4); + assert(v4_4->degree() == 3); assert(tds4.is_valid() ); // Find the edge v4_1v4_2 for insertion fc = v4_1->incident_faces(); @@ -150,7 +137,6 @@ _test_cls_tds_2( const Tds &, const Gt &) while(! (fc->has_vertex(v4_2, ic ) && ic == fc->ccw(fc->index(v4_1)))) fc++; Vertex_handle v4_5 = tds4.insert_in_edge(&(*fc), ic); - v4_5->set_point(p5); assert(tds4.is_valid() ); assert(tds4.dimension()== 2); assert(tds4.number_of_vertices() == 6); @@ -288,18 +274,7 @@ _test_cls_tds_2( const Tds &, const Gt &) //test input, output - // first set_point to vertices which have not been set - //for clean input output of points - w1->set_point(p1); - w2->set_point(p1); - v2->set_point(p1); - w3->set_point(p1); - v3->set_point(p1); - w4->set_point(p1); - vit = tds3.vertices_begin(); - for ( ; vit != tds3.vertices_end(); vit++) { - vit->set_point(p1); - } + std::cout << " output to a file" << std::endl; std::ofstream of0("file_tds0"); CGAL::set_ascii_mode(of0); @@ -435,7 +410,6 @@ _test_tds_iterators( const Tds& tds) typedef typename Tds::Vertex_iterator Vertex_iterator; typedef typename Tds::Face_iterator Face_iterator; typedef typename Tds::Edge_iterator Edge_iterator; - typedef typename Tds::Iterator_base Iterator_base; int nv, ne, nf; nv = ne = nf = 0; diff --git a/Packages/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_tds_face.C b/Packages/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_tds_face.C index baf5e4fb897..f9375b84937 100644 --- a/Packages/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_tds_face.C +++ b/Packages/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_tds_face.C @@ -25,15 +25,17 @@ CGAL_BEGIN_NAMESPACE -template +template void -_test_cls_tds_face( const Face &, const Gt & ) +_test_cls_tds_face( const Ftds ) { std::cout << " face" << std::endl; - typedef typename Face::Vertex Vertex; - typedef typename Face::Face_handle Face_handle; - typedef typename Face::Vertex_handle Vertex_handle; + typedef typename Ftds::Tds Tds; + typedef typename Ftds::Vertex Vertex; + typedef typename Ftds::Face Face; + typedef typename Ftds::Face_handle Face_handle; + typedef typename Ftds::Vertex_handle Vertex_handle; // Build a few objects int i; diff --git a/Packages/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_tds_vertex.C b/Packages/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_tds_vertex.C index 2c14a4dd467..7dde946b404 100644 --- a/Packages/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_tds_vertex.C +++ b/Packages/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_tds_vertex.C @@ -24,44 +24,32 @@ #include CGAL_BEGIN_NAMESPACE -template +template void -_test_cls_tds_vertex( const Vertex &, const Gt & ) +_test_cls_tds_vertex( const Vtds&) { std::cout << " vertex" << std::endl; - typedef typename Vertex::Point Point; - typedef typename Vertex::Face Face; - typedef typename Vertex::Edge Edge; - typedef typename Vertex::Face_handle Face_handle; - typedef typename Vertex::Vertex_handle Vertex_handle; + typedef typename Vtds::Face_handle Face_handle; + typedef typename Vtds::Vertex_handle Vertex_handle; - typedef typename Vertex::Vertex_circulator Vertex_circulator; - typedef typename Vertex::Face_circulator Face_circulator; - typedef typename Vertex::Edge_circulator Edge_circulator; + typedef typename Vtds::Vertex_circulator Vertex_circulator; + typedef typename Vtds::Face_circulator Face_circulator; + typedef typename Vtds::Edge_circulator Edge_circulator; + typedef typename Vtds::Tds Tds; + typedef typename Tds::Face Face; + typedef typename Vtds::Vertex Vertex; - // Build a few objects - // Build a few objects - Point p2(1,2); - Point p3(2,3); Face f3; Face_handle fh3 = f3.handle(); // Test constructors Vertex v1; - // Vertex v2(p2); -// Vertex v3(p3,fh3); Vertex v2, v3; - v2.set_point(p2); - v3.set_point(p3); v3.set_face(f3.handle()); - - // Test point() - // assert( Gt().compare_x_2_object()(v2.point(),p2) == CGAL::EQUAL && -// Gt().compare_y_2_object()(v2.point(),p2) == CGAL::EQUAL) ; -// assert( Gt().compare_x_2_object()(v3.point(),p3) == CGAL::EQUAL && -// Gt().compare_y_2_object()(v3.point(),p3) == CGAL::EQUAL) ; + v3.set_face(f3.handle()); + // Test face() assert( v3.face() == fh3 ); // to avoid "unused variable warning @@ -71,18 +59,13 @@ _test_cls_tds_vertex( const Vertex &, const Gt & ) v2.set_face(fh3); assert( v2.face() == fh3 ); - // Test set_point() - v1.set_point(p3); - assert( Gt().compare_x_2_object()(v1.point(),p3) == CGAL::EQUAL && - Gt().compare_y_2_object()(v1.point(),p3) == CGAL::EQUAL) ; - - // Test ccw() and cw() - assert( v1.ccw(0) == 1 ); - assert( v1.ccw(1) == 2 ); - assert( v1.ccw(2) == 0 ); - assert( v1.cw(0) == 2 ); - assert( v1.cw(1) == 0 ); - assert( v1.cw(2) == 1 ); +// // Test ccw() and cw() +// assert( v1.ccw(0) == 1 ); +// assert( v1.ccw(1) == 2 ); +// assert( v1.ccw(2) == 0 ); +// assert( v1.cw(0) == 2 ); +// assert( v1.cw(1) == 0 ); +// assert( v1.cw(2) == 1 ); // The functions degree(), incident_faces(), incident_vertices(), // incident_edges() and is_valid() need a vertex in some diff --git a/Packages/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_triangulation_2.C b/Packages/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_triangulation_2.C index f90055a1c77..1433866308f 100644 --- a/Packages/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_triangulation_2.C +++ b/Packages/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_triangulation_2.C @@ -249,7 +249,7 @@ _test_cls_triangulation_2( const Triangul & ) Vertex_handle v2_3_4 = T2_3.insert(p4); assert( T2_3.dimension() == 2 ); Vertex_handle v2_3_6 = T2_3.insert(p6, T2_3.finite_faces_begin()); - Vertex_handle v2_3_0 = T2_3.insert(p0, ++T2_3.finite_faces_begin()); + Vertex_handle v2_3_0 = T2_3.insert(p0, ++T2_3.finite_faces_begin()); Vertex_handle v2_3_5 = T2_3.insert(p5); Vertex_handle v2_3_7 = T2_3.insert(p7); loc = T2_3.locate(p10,lt,li); diff --git a/Packages/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_triangulation_vertex.C b/Packages/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_triangulation_vertex.C index 49a002a14f8..0c6f67c48e9 100644 --- a/Packages/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_triangulation_vertex.C +++ b/Packages/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_triangulation_vertex.C @@ -23,25 +23,29 @@ #include -template +template void -_test_cls_triangulation_vertex( const Vertex & ) +_test_cls_triangulation_vertex( const Ve & ) { std::cout << " vertex" << std::endl; - //typedef typename Vertex::Geom_traits Gt; + typedef typename Ve::Point Point; + typedef typename Ve::Triangulation_data_structure Tds; - typedef typename Vertex::Point Point; + typedef typename Tds::Face Face; + typedef typename Tds::Edge Edge; + typedef typename Tds::Vertex Vertex; + typedef typename Tds::Vertex_handle Vertex_handle; + typedef typename Tds::Face_handle Face_handle; - typedef typename Vertex::Face Face; - typedef typename Vertex::Edge Edge; + typedef typename Tds::Vertex_circulator Vertex_circulator; + typedef typename Tds::Face_circulator Face_circulator; + typedef typename Tds::Edge_circulator Edge_circulator; - typedef typename Vertex::Vertex_handle Vertex_handle; - typedef typename Vertex::Face_handle Face_handle; - - typedef typename Vertex::Vertex_circulator Vertex_circulator; - typedef typename Vertex::Face_circulator Face_circulator; - typedef typename Vertex::Edge_circulator Edge_circulator; + + typedef typename Tds::Face Face; + + // Build a few objects Point p2(5,6,1); @@ -75,12 +79,12 @@ _test_cls_triangulation_vertex( const Vertex & ) assert( v2.face() == f3.handle() ); // Test ccw() and cw() - assert( v1.ccw(0) == 1 ); - assert( v1.ccw(1) == 2 ); - assert( v1.ccw(2) == 0 ); - assert( v1.cw(0) == 2 ); - assert( v1.cw(1) == 0 ); - assert( v1.cw(2) == 1 ); +// assert( v1.ccw(0) == 1 ); +// assert( v1.ccw(1) == 2 ); +// assert( v1.ccw(2) == 0 ); +// assert( v1.cw(0) == 2 ); +// assert( v1.cw(1) == 0 ); +// assert( v1.cw(2) == 1 ); // The functions degree(), incident_faces(), incident_vertices(), // incident_edges() need a vertex in some triangulation, diff --git a/Packages/Triangulation_2/test/Triangulation_2/test_triangulation_2.C b/Packages/Triangulation_2/test/Triangulation_2/test_triangulation_2.C index c19e946c759..be1b7bb5fda 100644 --- a/Packages/Triangulation_2/test/Triangulation_2/test_triangulation_2.C +++ b/Packages/Triangulation_2/test/Triangulation_2/test_triangulation_2.C @@ -45,7 +45,7 @@ int main() std::cout << " with Euclidean_traits_2 : " << std::endl ; typedef CGAL::Triangulation_euclidean_traits_2 Gt1; typedef CGAL::Triangulation_vertex_base_2 Vb1; - typedef CGAL::Triangulation_face_base_2 Fb1; + typedef CGAL::Triangulation_ds_face_base_2<> Fb1; typedef CGAL::Triangulation_data_structure_2 Tds1; typedef CGAL::Triangulation_2 Cls1; _test_cls_triangulation_2( Cls1() ); diff --git a/Packages/Triangulation_2/test/Triangulation_2/test_triangulation_2_bis.C b/Packages/Triangulation_2/test/Triangulation_2/test_triangulation_2_bis.C index 9f026dd4404..75231a8915a 100644 --- a/Packages/Triangulation_2/test/Triangulation_2/test_triangulation_2_bis.C +++ b/Packages/Triangulation_2/test/Triangulation_2/test_triangulation_2_bis.C @@ -43,7 +43,7 @@ int main() std::cout << " this use double type coordinates " << std::endl; typedef CGAL::_Triangulation_test_traits Gt2; typedef CGAL::Triangulation_vertex_base_2 Vb2; - typedef CGAL::Triangulation_face_base_2 Fb2; + typedef CGAL::Triangulation_ds_face_base_2<> Fb2; typedef CGAL::Triangulation_data_structure_2 Tds2; typedef CGAL::Triangulation_2 Cls2; _test_cls_triangulation_short_2( Cls2() ); diff --git a/Packages/Triangulation_2/test/Triangulation_2/test_triangulation_tds.C b/Packages/Triangulation_2/test/Triangulation_2/test_triangulation_tds.C index 6a82e85f1d2..5ae5218c285 100644 --- a/Packages/Triangulation_2/test/Triangulation_2/test_triangulation_tds.C +++ b/Packages/Triangulation_2/test/Triangulation_2/test_triangulation_tds.C @@ -24,8 +24,6 @@ #include #include -#include -#include #include #include @@ -33,8 +31,8 @@ -typedef CGAL::Triangulation_vertex_base_2 Vb; -typedef CGAL::Triangulation_face_base_2 Fb; +typedef CGAL::Triangulation_ds_vertex_base_2<> Vb; +typedef CGAL::Triangulation_ds_face_base_2<> Fb; // Explicit instantiation : // does not work because of off_file_input @@ -44,24 +42,22 @@ int main() { std::cout << "Testing Triangulation_data_structure_2" << std::endl << std::endl; - typedef CGAL::_Triangulation_test_traits Gt; - typedef CGAL::Triangulation_vertex_base_2 Vb; - typedef CGAL::Triangulation_face_base_2 Fb; - typedef CGAL::Triangulation_data_structure_2 Cls1; - _test_cls_tds_2( Cls1(), Gt() ); + typedef CGAL::Triangulation_data_structure_2<> Cls1; + _test_cls_tds_2( Cls1()); std::cout << "Testing bakward compatibility" << std::endl; std::cout << "Testing Triangulation_defaut_data_structure_2" << std::endl; + typedef CGAL::_Triangulation_test_traits Gt; + typedef CGAL::Triangulation_ds_vertex_base_2<> Vb; + typedef CGAL::Triangulation_ds_face_base_2<> Fb; typedef CGAL::Triangulation_default_data_structure_2 Cls2; - _test_cls_tds_2( Cls2(), Gt() ); + _test_cls_tds_2( Cls2()); std::cout << "Testing Triangulation_data_structure_using_list_2" << std::endl; typedef CGAL::Triangulation_data_structure_using_list_2 Cls3; - _test_cls_tds_2( Cls3(), Gt() ); - - + _test_cls_tds_2( Cls3()); return 0; } diff --git a/Packages/Triangulation_2/test/Triangulation_2_Delaunay/test_delaunay_hierarchy_2.C b/Packages/Triangulation_2/test/Triangulation_2_Delaunay/test_delaunay_hierarchy_2.C index e80cc897178..52bfe693268 100644 --- a/Packages/Triangulation_2/test/Triangulation_2_Delaunay/test_delaunay_hierarchy_2.C +++ b/Packages/Triangulation_2/test/Triangulation_2_Delaunay/test_delaunay_hierarchy_2.C @@ -43,7 +43,7 @@ typedef double Coord_type; typedef CGAL::Cartesian Gt; typedef CGAL::Triangulation_vertex_base_2 Vbb; typedef CGAL::Triangulation_hierarchy_vertex_base_2 Vb; -typedef CGAL::Triangulation_face_base_2 Fb; +typedef CGAL::Triangulation_ds_face_base_2<> Fb; typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Delaunay_triangulation_2 Dt; // Explicit instantiation of the whole class : diff --git a/Packages/Triangulation_2/test/Triangulation_2_Delaunay/test_delaunay_triangulation_2.C b/Packages/Triangulation_2/test/Triangulation_2_Delaunay/test_delaunay_triangulation_2.C index d0c55166ab2..da6fe243d6f 100644 --- a/Packages/Triangulation_2/test/Triangulation_2_Delaunay/test_delaunay_triangulation_2.C +++ b/Packages/Triangulation_2/test/Triangulation_2_Delaunay/test_delaunay_triangulation_2.C @@ -40,10 +40,7 @@ int main() std::cout << "Testing Delaunay Triangulation_2 " << std::endl; std::cout << " with Euclidean cartesian points : " << std::endl; typedef CGAL::Triangulation_euclidean_traits_2 Gt1; - typedef CGAL::Triangulation_vertex_base_2 Vb1; - typedef CGAL::Triangulation_face_base_2 Fb1; - typedef CGAL::Triangulation_data_structure_2 Tds1; - typedef CGAL::Delaunay_triangulation_2 Cls1; + typedef CGAL::Delaunay_triangulation_2 Cls1; _test_cls_delaunay_triangulation_2( Cls1() ); @@ -51,10 +48,7 @@ int main() std::cout << "Testing Delaunay Triangulation_2 "<< std::endl; std::cout << " with Triangulation_test_traits : " << std::endl; typedef CGAL::_Triangulation_test_traits Gt; - typedef CGAL::Triangulation_vertex_base_2 Vb; - typedef CGAL::Triangulation_face_base_2 Fb; - typedef CGAL::Triangulation_data_structure_2 Tds; - typedef CGAL::Delaunay_triangulation_2 Cls; + typedef CGAL::Delaunay_triangulation_2 Cls; _test_cls_delaunay_triangulation_2( Cls() ); @@ -72,10 +66,7 @@ int main() std::cout << " using Kernel_traits : " << std::endl; std::cout << " and Homogeneous Points " << std::endl; typedef CGAL::Homogeneous Gt4; - typedef CGAL::Triangulation_vertex_base_2 Vb4; - typedef CGAL::Triangulation_face_base_2 Fb4; - typedef CGAL::Triangulation_data_structure_2 Tds4; - typedef CGAL::Delaunay_triangulation_2 Cls4; + typedef CGAL::Delaunay_triangulation_2 Cls4; _test_cls_delaunay_triangulation_2( Cls4() ); diff --git a/Packages/Triangulation_2/test/Triangulation_2_Delaunay/test_regular_hierarchy_2.C b/Packages/Triangulation_2/test/Triangulation_2_Delaunay/test_regular_hierarchy_2.C index 4440cd8f1da..1071cd1cabd 100644 --- a/Packages/Triangulation_2/test/Triangulation_2_Delaunay/test_regular_hierarchy_2.C +++ b/Packages/Triangulation_2/test/Triangulation_2_Delaunay/test_regular_hierarchy_2.C @@ -26,18 +26,21 @@ #include #include -#include #include #include #include -#include +#include -typedef CGAL::Regular_triangulation_euclidean_traits_2 RGt; +//#include + +//typedef CGAL::Regular_triangulation_euclidean_traits_2 RGt; +typedef CGAL::Regular_triangulation_euclidean_traits_2 RGt; typedef CGAL::Regular_triangulation_vertex_base_2 Vbb; typedef CGAL::Triangulation_hierarchy_vertex_base_2 Vb; -typedef CGAL::Regular_triangulation_face_base_2 Fb; +typedef CGAL::Regular_triangulation_face_base_2<> Fb; typedef CGAL::Triangulation_data_structure_2 Tds; typedef CGAL::Regular_triangulation_2 Rt; typedef CGAL::Triangulation_hierarchy_2 Regular_hierarchy_cartesian; @@ -55,7 +58,7 @@ int main() std::cout << "using Cartesian points " << std::endl; std::cout << "Testing hierarchy" << std::endl; - _test_cls_regular_hierarchy_2( Regular_hierarchy_cartesian() ); + _test_cls_reg_triangulation_2( Regular_hierarchy_cartesian() ); return 0; diff --git a/Packages/Triangulation_2/test/Triangulation_2_constrained/test_const_triang_plus_2.C b/Packages/Triangulation_2/test/Triangulation_2_constrained/test_const_triang_plus_2.C index 0394c76aa11..d7f0d28017e 100644 --- a/Packages/Triangulation_2/test/Triangulation_2_constrained/test_const_triang_plus_2.C +++ b/Packages/Triangulation_2/test/Triangulation_2_constrained/test_const_triang_plus_2.C @@ -43,13 +43,10 @@ int main() std::cout << "Testing constrained_triangulation_plus_2 "<< std::endl; std::cout << " with Exact_predicates_tag : " << std::endl; typedef CGAL::Triangulation_vertex_base_2 Vb; - typedef CGAL::Constrained_triangulation_face_base_2 Fb; - //typedef CGAL::Triangulation_vertex_base_2 Vb; - //typedef CGAL::Constrained_triangulation_face_base_2 Fb; + typedef CGAL::Constrained_triangulation_face_base_2<> Fb; typedef CGAL::Triangulation_data_structure_2 TDS; typedef CGAL::Exact_predicates_tag Itag; typedef CGAL::Constrained_Delaunay_triangulation_2 CDt; - //typedef CGAL::Constrained_Delaunay_triangulation_2 CDt; typedef CGAL::Constrained_triangulation_plus_2 CDtplus; @@ -59,7 +56,7 @@ int main() std::cout << "Testing constrained_triangulation_plus_2 "<< std::endl; std::cout << " with Exact_intersections_tag : " << std::endl; typedef CGAL::Triangulation_vertex_base_2 Vbb; - typedef CGAL::Constrained_triangulation_face_base_2 Fbb; + typedef CGAL::Constrained_triangulation_face_base_2<> Fbb; typedef CGAL::Triangulation_data_structure_2 TDSS; typedef CGAL::Exact_intersections_tag EItag; typedef CGAL::Constrained_Delaunay_triangulation_2 CDtei; diff --git a/Packages/Triangulation_2/test/Triangulation_2_constrained/test_constrained_triangulation_2.C b/Packages/Triangulation_2/test/Triangulation_2_constrained/test_constrained_triangulation_2.C index 1d7f9ef3893..051c0784a82 100644 --- a/Packages/Triangulation_2/test/Triangulation_2_constrained/test_constrained_triangulation_2.C +++ b/Packages/Triangulation_2/test/Triangulation_2_constrained/test_constrained_triangulation_2.C @@ -42,7 +42,7 @@ int main() std::cout << "Testing constrained_triangulation "<< std::endl; std::cout << " with Exact_predicates_tag : " << std::endl; typedef CGAL::Triangulation_vertex_base_2 Vb; - typedef CGAL::Constrained_triangulation_face_base_2 Fb; + typedef CGAL::Constrained_triangulation_face_base_2<> Fb; typedef CGAL::Triangulation_data_structure_2 TDS; typedef CGAL::Exact_predicates_tag Itag; typedef CGAL::Constrained_triangulation_2 Ctwi; @@ -51,7 +51,7 @@ int main() std::cout << "Testing constrained_triangulation "<< std::endl; std::cout << " with Exact_intersections_tag : " << std::endl; typedef CGAL::Triangulation_vertex_base_2 Vbb; - typedef CGAL::Constrained_triangulation_face_base_2 Fbb; + typedef CGAL::Constrained_triangulation_face_base_2<> Fbb; typedef CGAL::Triangulation_data_structure_2 TDSS; typedef CGAL::Exact_intersections_tag EItag; typedef CGAL::Constrained_triangulation_2 Ctwei; diff --git a/Packages/Triangulation_2/test/Triangulation_2_newd/Makefile b/Packages/Triangulation_2/test/Triangulation_2_newd/Makefile deleted file mode 100644 index 1dd11c6462b..00000000000 --- a/Packages/Triangulation_2/test/Triangulation_2_newd/Makefile +++ /dev/null @@ -1,65 +0,0 @@ -# Created by the script create_makefile -# This is the makefile for compiling a CGAL application. - -#---------------------------------------------------------------------# -# include platform specific settings -#---------------------------------------------------------------------# -# Choose the right include file from the /make directory. - -CGAL_MAKEFILE = /0/prisme_util/CGAL/CGAL-I/make/makefile_i686_Linux-2.2.18_g++-2.95_LEDA -include $(CGAL_MAKEFILE) - -#---------------------------------------------------------------------# -# compiler flags -#---------------------------------------------------------------------# - -CXXFLAGS = \ - -I../../include \ - $(TESTSUITE_CXXFLAGS) \ - $(EXTRA_FLAGS) \ - $(CGAL_CXXFLAGS) \ - $(LONG_NAME_PROBLEM_CXXFLAGS) \ - $(DEBUG_OPT) - -#---------------------------------------------------------------------# -# linker flags -#---------------------------------------------------------------------# - -LIBPATH = \ - $(TESTSUITE_LIBPATH) \ - $(CGAL_LIBPATH) - -LDFLAGS = \ - $(TESTSUITE_LDFLAGS) \ - $(LONG_NAME_PROBLEM_LDFLAGS) \ - $(CGAL_LDFLAGS) - -#---------------------------------------------------------------------# -# target entries -#---------------------------------------------------------------------# - -all: \ - example_1$(EXE_EXT) \ - example_2$(EXE_EXT) - -example_1$(EXE_EXT): example_1$(OBJ_EXT) - $(CGAL_CXX) $(LIBPATH) $(EXE_OPT)example_1 example_1$(OBJ_EXT) $(LDFLAGS) - -example_2$(EXE_EXT): example_2$(OBJ_EXT) - $(CGAL_CXX) $(LIBPATH) $(EXE_OPT)example_2 example_2$(OBJ_EXT) $(LDFLAGS) - -clean: \ - example_1.clean \ - example_2.clean - -realclean: clean - - rm -f Program* Error* Compiler* error* - - -#---------------------------------------------------------------------# -# suffix rules -#---------------------------------------------------------------------# - -.C$(OBJ_EXT): - $(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) $< - diff --git a/Packages/Triangulation_2/test/Triangulation_2_newd/Triangulation_data_structure_2.h b/Packages/Triangulation_2/test/Triangulation_2_newd/Triangulation_data_structure_2.h deleted file mode 100644 index 54a11b18899..00000000000 --- a/Packages/Triangulation_2/test/Triangulation_2_newd/Triangulation_data_structure_2.h +++ /dev/null @@ -1,1701 +0,0 @@ -// ====================================================================== -// -// Copyright (c) 1997 The CGAL Consortium -// -// This software and related documentation is part of an INTERNAL release -// of the Computational Geometry Algorithms Library (CGAL). It is not -// intended for general use. -// -// ---------------------------------------------------------------------- -// -// release : $CGAL_Revision$ -// release_date : $CGAL_Date$ -// -// file : include/CGAL/Triangulation_data_structure_2.h -// source : $RCSfile$ -// revision : $Revision$ -// revision_date : $Date$ -// author(s) : Mariette Yvinec -// -// coordinator : Mariette Yvinec -// -// ============================================================================ - -#ifndef CGAL_TRIANGULATION_DATA_STRUCTURE_2_H -#define CGAL_TRIANGULATION_DATA_STRUCTURE_2_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -CGAL_BEGIN_NAMESPACE -template < class Vb, class Fb> -class Triangulation_data_structure_2; - -template < class Vb, class Fb> -std::istream& operator>> -(std::istream& is, Triangulation_data_structure_2& - tds); - -template < class Vb, class Fb> -std::ostream& operator<< -( std::ostream& os, - const Triangulation_data_structure_2& tds); - - - -template -class Triangulation_data_structure_2 - :public Triangulation_cw_ccw_2 -{ -public: - typedef Triangulation_data_structure_2 Tds; - - friend class Triangulation_ds_face_iterator_2; - friend class Triangulation_ds_edge_iterator_2; - friend class Triangulation_ds_vertex_iterator_2; - - //typedef Vb Vertex_base; - //typedef Fb Face_base; - typedef typename Vb::template TDS_rebind::Rebound Vertex_base; - typedef typename Fb::template TDS_rebind::Rebound Face_base; - - // Je laisse ca provisoirement - // par la suite Vertex_base et Face_base devront satisfaire - // le Concept TdsVertex et TdsFace - typedef Triangulation_ds_vertex_2 Vertex; - typedef Triangulation_ds_face_2 Face; - - typedef CGAL_TRIVIAL_COMPARABLE_ITERATOR_CHECKER_POINTER(Face) Face_handle; - typedef CGAL_TRIVIAL_COMPARABLE_ITERATOR_CHECKER_POINTER(Vertex) - Vertex_handle; - typedef std::pair Edge; - - typedef DS_Container Face_container; - typedef DS_Container Vertex_container; - typedef typename Face_container::iterator Iterator_base; - typedef Triangulation_ds_face_iterator_2 Face_iterator; - typedef Triangulation_ds_edge_iterator_2 Edge_iterator; - typedef Triangulation_ds_vertex_iterator_2 Vertex_iterator; - - typedef Triangulation_ds_face_circulator_2 Face_circulator; - typedef Triangulation_ds_vertex_circulator_2 Vertex_circulator; - typedef Triangulation_ds_edge_circulator_2 Edge_circulator; - typedef std::list List_edges; - -protected: - int _number_of_vertices; - int _dimension; - Face_container _face_container; - Vertex_container _vertex_container; - - //CREATORS - DESTRUCTORS -public: - Triangulation_data_structure_2(); - Triangulation_data_structure_2(const Tds &tds); - ~Triangulation_data_structure_2(); - Tds& operator= (const Tds &tds); - void swap(Tds &tds); - - //ACCESS FUNCTIONS -private: - Face_container& face_container() { return _face_container;} - const Face_container& face_container() const { return _face_container;} - Vertex_container& vertex_container() {return _vertex_container;} - const Vertex_container& vertex_container() const - {return _vertex_container;} - -public: - int dimension() const { return _dimension; } - int number_of_vertices() const {return _number_of_vertices;} - int number_of_faces() const ; - int number_of_edges() const; - int number_of_full_dim_faces() const; //number of faces stored by tds - - // TEST FEATURES - bool is_vertex(const Vertex_handle v) const; - bool is_edge(const Vertex_handle va, const Vertex_handle vb) const; - bool is_edge(const Vertex_handle va, const Vertex_handle vb, - Face_handle& fr, int& i) const; - bool is_face(const Vertex_handle v1, - const Vertex_handle v2, - const Vertex_handle v3) const; - bool is_face(const Vertex_handle v1, - const Vertex_handle v2, - const Vertex_handle v3, - Face_handle& fr) const; - - // ITERATORS AND CIRCULATORS -public: -// The Iterator_base gives the possibility to iterate over all -// in the container independently of the dimension. - // public for the need of file_ouput() of Constrained triangulation - // should be made public later - - Iterator_base iterator_base_begin() const { - return face_container().begin(); - } - Iterator_base iterator_base_end() const { - return face_container().end(); - } - -public: - Face_iterator faces_begin() const { - if (dimension() < 2) return faces_end(); - return Face_iterator(this); - } - - Face_iterator faces_end() const { - return Face_iterator(this, 1); - } - - Vertex_iterator vertices_begin() const { - return Vertex_iterator(this); - } - - Vertex_iterator vertices_end() const { - return Vertex_iterator(this,1); - } - - Edge_iterator edges_begin() const { - return Edge_iterator(this); - } - - Edge_iterator edges_end() const { - return Edge_iterator(this,1); - } - - Face_circulator incident_faces(Vertex_handle v, - Face_handle f = Face_handle(NULL)) const{ - return v->incident_faces(f); - } - Vertex_circulator incident_vertices(Vertex_handle v, - Face_handle f = Face_handle(NULL)) const - { - return v->incident_vertices(f); - } - - Edge_circulator incident_edges(Vertex_handle v, - Face_handle f = Face_handle(NULL)) const{ - return v->incident_edges(f); - } - - // MODIFY - void flip(Face_handle f, int i); - - Vertex_handle insert_first(); - Vertex_handle insert_second(); - Vertex_handle insert_in_face(Face_handle f); - Vertex_handle insert_in_edge(Face_handle f, int i); - Vertex_handle insert_dim_up(Vertex_handle w = Vertex_handle(NULL), - bool orient=true); - - void remove_degree_3(Vertex_handle v, Face_handle f = Face_handle(NULL)); - void remove_1D(Vertex_handle v); - - void remove_second(Vertex_handle v); - void remove_first(Vertex_handle v); - void remove_dim_down(Vertex_handle v); - - Vertex_handle star_hole(List_edges& hole); - void star_hole(Vertex_handle v, List_edges& hole); - void make_hole(Vertex_handle v, List_edges& hole); - -// template< class EdgeIt> -// Vertex_handle star_hole(EdgeIt edge_begin,EdgeIt edge_end); - -// template< class EdgeIt> -// void star_hole(Vertex_handle v, EdgeIt edge_begin, EdgeIt edge_end); - -// template< class EdgeIt, class FaceIt> -// Vertex_handle star_hole(EdgeIt edge_begin, -// EdgeIt edge_end, -// FaceIt face_begin, -// FaceIt face_end); - -// template< class EdgeIt, class FaceIt> -// void star_hole(Vertex_handle v, -// EdgeIt edge_begin, -// EdgeIt edge_end, -// FaceIt face_begin, -// FaceIt face_end); - - Vertex_handle create_vertex(); - Face_handle create_face(Face_handle f1, int i1, - Face_handle f2, int i2, - Face_handle f3, int i3); - Face_handle create_face(Face_handle f1, int i1, - Face_handle f2, int i2); - Face_handle create_face(Face_handle f1, int i1, Vertex_handle v); - Face_handle create_face(Vertex_handle v1, - Vertex_handle v2, - Vertex_handle v3); - Face_handle create_face(Vertex_handle v1, - Vertex_handle v2, - Vertex_handle v3, - Face_handle f1, - Face_handle f2, - Face_handle f3); - Face_handle create_face(Face_handle f); //calls copy constructor of Face - Face_handle create_face(); - void set_adjacency(Face_handle f0, int i0, Face_handle f1, int i1) const; - void delete_face(Face_handle); - void delete_vertex(Vertex_handle); - - // CHECKING - bool is_valid(bool verbose = false, int level = 0) const; - - // HELPING -private: - typedef std::pair Vh_pair; - void set_adjacency(Face_handle fh, - int ih, - std::map< Vh_pair, Edge>& edge_map); - void reorient_faces(); - -public: - void clear(); - Vertex_handle copy_tds(const Tds &tds, Vertex_handle = Vertex_handle(NULL)); - - // I/O - Vertex_handle file_input(std::istream& is, bool skip_first=false); - void file_output(std::ostream& os, - Vertex_handle v = Vertex_handle(NULL), - bool skip_first=false) const; - Vertex_handle off_file_input(std::istream& is, bool verbose=false); - void vrml_output(std::ostream& os, - Vertex_handle v = Vertex_handle(NULL), - bool skip_first=false) const; - - - // SETTING (had to make them public for use in remove from Triangulations) - void set_number_of_vertices(int n) {_number_of_vertices = n;} - void set_dimension (int n) {_dimension = n ;} - - // template members definition -public: - template< class EdgeIt> - Vertex_handle star_hole(EdgeIt edge_begin, EdgeIt edge_end) - // creates a new vertex - // and stars from it - // the hole described by the range [edge_begin,edge_end[ - // the triangulation is assumed to have dim=2 - // hole is supposed to be ccw oriented - { - Vertex_handle newv = create_vertex(); - star_hole(newv, edge_begin, edge_end); - return newv; - } - - template< class EdgeIt> - void star_hole(Vertex_handle v, EdgeIt edge_begin, EdgeIt edge_end) - // uses vertex v - // to star the hole described by the range [edge_begin,edge_end[ - // the triangulation is assumed to have dim=2 - // the hole is supposed to be ccw oriented - { - std::list empty_list; - star_hole(v, - edge_begin, - edge_end, - empty_list.begin(), - empty_list.end()); - return; - } - - - template< class EdgeIt, class FaceIt> - Vertex_handle star_hole(EdgeIt edge_begin, - EdgeIt edge_end, - FaceIt face_begin, - FaceIt face_end) - // creates a new vertex - // and stars from it - // the hole described by the range [edge_begin,edge_end[ - // reusing the faces in the range [face_begin,face_end[ - // the triangulation is assumed to have dim=2 - // the hole is supposed to be ccw oriented - { - Vertex_handle newv = create_vertex(); - star_hole(newv, edge_begin, edge_end, face_begin, face_end); - return newv; - } - - template< class EdgeIt, class FaceIt> - void star_hole(Vertex_handle newv, - EdgeIt edge_begin, - EdgeIt edge_end, - FaceIt face_begin, - FaceIt face_end) - // uses vertex v - // to star the hole described by the range [edge_begin,edge_end[ - // reusing the faces in the range [face_begin,face_end[ - // the triangulation is assumed to have dim=2 - // hole is supposed to be ccw oriented - { - CGAL_triangulation_precondition(dimension() == 2); - EdgeIt eit = edge_begin; - FaceIt fit = face_begin; - - Face_handle fn = (*eit).first; - int in = (*eit).second; - fn->vertex(cw(in))->set_face(fn); - Face_handle first_f = reset_or_create_face(fn, in , newv, fit, face_end); - Face_handle previous_f=first_f, next_f; - ++eit; - - for( ; eit != edge_end ; eit++) { - fn = (*eit).first; - in = (*eit).second; - fn->vertex(cw(in))->set_face(fn); - next_f = reset_or_create_face(fn, in , newv, fit, face_end); - next_f->set_neighbor(1, previous_f); - previous_f->set_neighbor(0, next_f); - previous_f=next_f; - } - - next_f->set_neighbor(0, first_f); - first_f->set_neighbor(1, next_f); - newv->set_face(first_f); - return; - } - -private: - template< class FaceIt> - Face_handle reset_or_create_face(Face_handle fn, - int in, - Vertex_handle v, - FaceIt& fit, - const FaceIt& face_end) - { - if (fit == face_end) return create_face(fn, in, v); - (*fit)->set_vertices(fn->vertex(cw(in)), fn->vertex(ccw(in)), v); - (*fit)->set_neighbors(0,0,fn); - fn->set_neighbor(in, *fit); - return &(**fit++); - } - -}; - -template < class Vb, class Fb> -Triangulation_data_structure_2 :: -Triangulation_data_structure_2() - : _number_of_vertices(0),_dimension(-2) -{ } - -template < class Vb, class Fb> -Triangulation_data_structure_2 :: -Triangulation_data_structure_2(const Tds &tds) -{ - copy_tds(tds); -} - -template < class Vb, class Fb> -Triangulation_data_structure_2 :: -~Triangulation_data_structure_2() -{ - clear(); -} - -//assignement -template < class Vb, class Fb> -Triangulation_data_structure_2& -Triangulation_data_structure_2 :: -operator= (const Tds &tds) -{ - copy_tds(tds); - return *this; -} - -template < class Vb, class Fb> -void -Triangulation_data_structure_2:: -clear() -{ - face_container().clear(); - vertex_container().clear(); - - set_number_of_vertices(0); - set_dimension(-2); - - return; -} - -template < class Vb, class Fb> -void -Triangulation_data_structure_2:: -swap(Tds &tds) -{ - CGAL_triangulation_expensive_precondition(tds.is_valid() && is_valid()); - std::swap(_dimension, tds._dimension); - std::swap(_number_of_vertices, tds._number_of_vertices); - face_container().swap(tds.face_container()); - vertex_container().swap(tds.vertex_container()); - return; -} - -//ACCESS FUNCTIONS -template -inline int -Triangulation_data_structure_2 :: -number_of_faces() const -{ - if (dimension() < 2) return 0; - return face_container().size(); -} - -template -int -Triangulation_data_structure_2:: -number_of_edges() const -{ - switch (dimension()) { - case 1: return number_of_vertices(); - case 2: return 3*number_of_faces()/2; - default: return 0; - } -} - -template -int -Triangulation_data_structure_2:: -number_of_full_dim_faces() const -{ -// switch (dimension()) { -// case -2: return 0; -// case -1: return 1; -// case 0: return 2; -// case 1: return number_of_edges(); -// case 2: return number_of_faces(); -// default: return 0; -// } - return face_container().size(); -} - -template -inline bool -Triangulation_data_structure_2:: -is_vertex(const Vertex_handle v) const -{ - return vertex_container().is_element(&*v); -} - -template -bool -Triangulation_data_structure_2:: -is_edge(const Vertex_handle va, const Vertex_handle vb) const -// returns true (false) if the line segment ab is (is not) an edge of t -//It is assumed that va is a vertex of t -{ - Vertex_circulator vc= va->incident_vertices(), done(vc); - if ( vc == 0) return false; - do { - if( vb == vc->handle() ) {return true;} - } while (++vc != done); - return false; -} - - -template -bool -Triangulation_data_structure_2:: -is_edge(const Vertex_handle va, const Vertex_handle vb, - Face_handle &fr, int & i) const -// assume va is a vertex of t -// returns true (false) if the line segment ab is (is not) an edge of t -// if true is returned (fr,i) is the edge ab -// with face fr on the right of a->b -{ - Face_handle fc = va->face(); - Face_handle start = fc; - if (fc == 0) return false; - int inda, indb; - do { - inda=fc->index(va); - indb = (dimension() == 2 ? cw(inda) : 1-inda); - if(fc->vertex(indb) == vb) { - fr=fc; - i = 3 - inda - indb; //works in dim 1 or 2 - return true; - } - fc=fc->neighbor(indb); //turns ccw around va - } while (fc != start); - return false; -} - - -template -inline bool -Triangulation_data_structure_2:: -is_face(const Vertex_handle v1, - const Vertex_handle v2, - const Vertex_handle v3) const -{ - Face_handle f; - return is_face(v1,v2,v3,f); -} - -template -bool -Triangulation_data_structure_2:: -is_face(const Vertex_handle v1, - const Vertex_handle v2, - const Vertex_handle v3, - Face_handle &f) const -{ - if (dimension() != 2) return false; - int i; - bool b = is_edge(v1,v2,f,i); - if (!b) return false; - else if (v3== f->vertex(i)) return true; - f = f-> neighbor(i); - int ind1= f->index(v1); - int ind2= f->index(v2); - if (v3 == f->vertex(3-ind1-ind2)) { return true;} - return false; -} - -template -void -Triangulation_data_structure_2:: -flip(Face_handle f, int i) -{ - CGAL_triangulation_precondition( dimension()==2); - Face_handle n = f->neighbor(i); - int ni = f->mirror_index(i); //ni = n->index(f); - - Vertex_handle v_cw = f->vertex(cw(i)); - Vertex_handle v_ccw = f->vertex(ccw(i)); - - // bl == bottom left, tr == top right - Face_handle tr = f->neighbor(ccw(i)); - int tri = f->mirror_index(ccw(i)); - Face_handle bl = n->neighbor(ccw(ni)); - int bli = n->mirror_index(ccw(ni)); - - f->set_vertex(cw(i), n->vertex(ni)); - n->set_vertex(cw(ni), f->vertex(i)); - - // update the neighborhood relations - f->set_neighbor(i, bl); - bl->set_neighbor(bli, f); - - f->set_neighbor(ccw(i), n); - n->set_neighbor(ccw(ni), f); - - n->set_neighbor(ni, tr); - tr->set_neighbor(tri, n); - - if(v_cw->face() == f) { - v_cw->set_face(n); - } - - if(v_ccw->face() == n) { - v_ccw->set_face(f); - } -} - -template < class Vb, class Fb> -typename Triangulation_data_structure_2::Vertex_handle -Triangulation_data_structure_2:: -insert_first( ) -{ - CGAL_triangulation_precondition( number_of_vertices() == 0 && - dimension()==-2 ); - return insert_dim_up(); -} - -template < class Vb, class Fb> -typename Triangulation_data_structure_2::Vertex_handle -Triangulation_data_structure_2:: -insert_second() -{ - CGAL_triangulation_precondition( number_of_vertices() == 1 && - dimension()==-1 ); - return insert_dim_up(); - -} - - -template < class Vb, class Fb> -typename Triangulation_data_structure_2::Vertex_handle -Triangulation_data_structure_2:: -insert_in_face(Face_handle f) - // New vertex will replace f->vertex(0) in face f -{ - CGAL_triangulation_precondition( f != NULL && dimension()== 2); - Vertex_handle v = create_vertex(); - - Vertex_handle v0 = f->vertex(0); - Vertex_handle v2 = f->vertex(2); - Vertex_handle v1 = f->vertex(1); - - Face_handle n1 = f->neighbor(1); - Face_handle n2 = f->neighbor(2); - - Face_handle f1 = create_face(v0, v, v2, f, n1, NULL); - Face_handle f2 = create_face(v0, v1, v, f, NULL, n2); - - f1->set_neighbor(2, f2); - f2->set_neighbor(1, f1); - if (n1 != NULL) { - int i1 = f->mirror_index(1); //int i1 = n1->index(f); - n1->set_neighbor(i1,f1); - } - if (n2 != NULL) { - int i2 = f->mirror_index(2);//int i2 = n2->index(f); - n2->set_neighbor(i2,f2);} - - f->set_vertex(0, v); - f->set_neighbor(1, f1); - f->set_neighbor(2, f2); - - if( v0->face() == f ) { v0->set_face(f2); } - v->set_face(f); - - return v; -} - - -template < class Vb, class Fb> -typename Triangulation_data_structure_2::Vertex_handle -Triangulation_data_structure_2:: -insert_in_edge(Face_handle f, int i) - //insert in the edge opposite to vertex i of face f -{ - CGAL_triangulation_precondition(f != NULL && dimension() >= 1); - if (dimension() == 1) {CGAL_triangulation_precondition(i == 2);} - if (dimension() == 2) {CGAL_triangulation_precondition(i == 0 || - i == 1 || - i == 2);} - Vertex_handle v; - if (dimension() == 1) { - v = create_vertex(); - Face_handle ff = f->neighbor(0); - Vertex_handle vv = f->vertex(1); - Face_handle g = create_face(v,vv,NULL,ff, f, NULL); - f->set_vertex(1,v);f->set_neighbor(0,g); - ff->set_neighbor(1,g); - v->set_face(g); - vv->set_face(ff); - } - - else { //dimension() ==2 - Face_handle n = f->neighbor(i); - int in = f->mirror_index(i); //n->index(f); - v = insert_in_face(f); - flip(n,in); - } - - return v; -} - - -template < class Vb, class Fb> -typename Triangulation_data_structure_2::Vertex_handle -Triangulation_data_structure_2:: -insert_dim_up(Vertex_handle w, bool orient) -{ - // the following function insert - // a vertex v which is outside the affine hull of Tds - // The triangulation will be starred from v and w - // ( geometrically w= // the infinite vertex ) - // w=NULL for first and second insertions - // orient governs the orientation of the resulting triangulation - - Vertex_handle v = create_vertex(); - set_dimension(dimension() + 1); - Face_handle f1; - Face_handle f2; - - switch (dimension()) { //it is the resulting dimension - case -1: - f1 = create_face(v,Vertex_handle(NULL),Vertex_handle(NULL)); - v->set_face(f1); - break; - case 0 : - f1 = &(*iterator_base_begin()); - f2 = create_face(v,Vertex_handle(NULL),Vertex_handle(NULL)); - f1->set_neighbor(0,f2); - f2->set_neighbor(0,f1); - v->set_face(f2); - break; - case 1 : - case 2 : - { - std::list faces_list; - Iterator_base ib= iterator_base_begin(); - Iterator_base ib_end = iterator_base_end(); - for (; ib != ib_end ; ++ib){ - faces_list.push_back( & (*ib)); - } - - std::list to_delete; - typename std::list::iterator lfit = faces_list.begin(); - int i = dimension(); // maximun non NULL index in faces - Face_handle f, g; - - for ( ; lfit != faces_list.end() ; ++lfit) { - f = * lfit; - g = create_face(f); //calls copy constructor of face - f->set_vertex(i,v); f->set_neighbor(i,g); - g->set_vertex(i,w); g->set_neighbor(i,f); - if (f->has_vertex(w)) to_delete.push_back(g); // flat face to delete - } - - lfit = faces_list.begin(); - for ( ; lfit != faces_list.end() ; ++lfit) { - f = * lfit; - g = f->neighbor(i); - for(int j = 0; j < i ; ++j) { - g->set_neighbor(j, f->neighbor(j)->neighbor(i)); - } - } - - // couldn't unify the code for reorientation mater - lfit = faces_list.begin() ; - if (dimension() == 1){ - if (orient) { - (*lfit)->reorient(); ++lfit ; (*lfit)->neighbor(1)->reorient(); - } - else { - (*lfit)->neighbor(1)->reorient(); ++lfit ; (*lfit)->reorient(); - } - } - else { // dimension == 2 - for( ;lfit != faces_list.end(); ++lfit ) { - if (orient) {(*lfit)->neighbor(2)->reorient();} - else { (*lfit)->reorient();} - } - } - - lfit = to_delete.begin(); - int i1, i2; - for ( ;lfit != to_delete.end(); ++lfit){ - f = *lfit ; - int j ; - if (f->vertex(0) == w) {j=0;} - else {j=1;} - f1= f->neighbor(i); i1= f->mirror_index(i); //f1->index(f); - f2= f->neighbor(j); i2= f->mirror_index(j); //f2->index(f); - f1->set_neighbor(i1,f2); - f2->set_neighbor(i2,f1); - delete_face(f); - } - - v->set_face( *(faces_list.begin())); - } - break; - default: - CGAL_triangulation_assertion(false); - break; - } - return v; -} - - -template -void -Triangulation_data_structure_2:: -remove_degree_3(Vertex_handle v, Face_handle f) -// remove a vertex of degree 3 -{ - CGAL_triangulation_precondition(v != NULL); - CGAL_triangulation_precondition(v->degree() == 3); - - if (f == NULL) {f= v->face();} - else { CGAL_triangulation_assertion( f->has_vertex(v));} - - int i = f->index(v); - Face_handle left = f->neighbor(cw(i)); - int li = f->mirror_index(cw(i)); - Face_handle right = f->neighbor(ccw(i)); - int ri = f->mirror_index(ccw(i)); - - Face_handle ll, rr; - Vertex_handle q = left->vertex(li); - CGAL_triangulation_assertion( left->vertex(li) == right->vertex(ri)); - - ll = left->neighbor(cw(li)); - if(ll != NULL) { - int lli = left->mirror_index(cw(li)); - ll->set_neighbor(lli, f); - } - f->set_neighbor(cw(i), ll); - if (f->vertex(ccw(i))->face() == left) f->vertex(ccw(i))->set_face(f); - - rr = right->neighbor(ccw(ri)); - if(rr != NULL) { - int rri = right->mirror_index(ccw(ri)); //rr->index(right); - rr->set_neighbor(rri, f); - } - f->set_neighbor(ccw(i), rr); - if (f->vertex(cw(i))->face() == right) f->vertex(cw(i))->set_face(f); - - f->set_vertex(i, q); - if (q->face() == right || q->face() == left) { - q->set_face(f); - } - delete_face(right); - delete_face(left); - - delete_vertex(v); -} - - - -template -void -Triangulation_data_structure_2:: -remove_dim_down(Vertex_handle v) -{ - Face_handle f; - switch( dimension()){ - case -1: - delete_face(v->face()); - break; - case 0: - f = v->face(); - f->neighbor(0)->set_neighbor(0,NULL); - delete_face(v->face()); - break; - case 1: - case 2: - CGAL_triangulation_precondition ( - (dimension() == 1 && number_of_vertices() == 3) || - (dimension() == 2 && number_of_vertices() > 3) ); - // the faces incident to v are down graded one dimension - // the other faces are deleted - std::list to_delete; - std::list to_downgrade; - Iterator_base ib = iterator_base_begin(); - for( ; ib != iterator_base_end(); ++ib ){ - if ( ! ib->has_vertex(v) ) { to_delete.push_back(&(*ib));} - else { to_downgrade.push_back(&(*ib));} - } - - typename std::list::iterator lfit = to_downgrade.begin(); - int j; - for( ; lfit != to_downgrade.end() ; ++lfit) { - f = *lfit; j = f->index(v); - if (dimension() == 1) { - if (j == 0) f->reorient(); - f->set_vertex(1,NULL); - f->set_neighbor(1,NULL); - } - else { //dimension() == 2 - if (j == 0) f->cw_permute(); - else if(j == 1) f->ccw_permute(); - f->set_vertex(2,NULL); - f->set_neighbor(2,NULL); - } - f->vertex(0)->set_face(f); - } - - lfit = to_delete.begin(); - for( ; lfit != to_delete.end() ; ++lfit) { - delete_face(*lfit); - } - } - delete_vertex(v); - //set_number_of_vertices(number_of_vertices() -1); - set_dimension(dimension() -1); - return; -} - -template < class Vb, class Fb> -void -Triangulation_data_structure_2:: -remove_1D(Vertex_handle v) -{ - CGAL_triangulation_precondition( dimension() == 1 && - number_of_vertices() > 3); - Face_handle f = v->face(); - int i = f->index(v); - if (i==0) {f = f->neighbor(1);} - CGAL_triangulation_assertion( f->index(v) == 1); - Face_handle g= f->neighbor(0); - f->set_vertex(1, g->vertex(1)); - f->set_neighbor(0,g->neighbor(0)); - g->neighbor(0)->set_neighbor(1,f); - g->vertex(1)->set_face(f); - delete_face(g); - delete_vertex(v); - return; -} - - - -template -inline void -Triangulation_data_structure_2:: -remove_second(Vertex_handle v) -{ - CGAL_triangulation_precondition(number_of_vertices()== 2 && - dimension() == 0); - remove_dim_down(v); - return; -} - - -template -inline void -Triangulation_data_structure_2:: -remove_first(Vertex_handle v) -{ - CGAL_triangulation_precondition(number_of_vertices()== 1 && - dimension() == -1); - remove_dim_down(v); - return; -} - -template -inline -typename Triangulation_data_structure_2::Vertex_handle -Triangulation_data_structure_2:: -star_hole(List_edges& hole) -{ - Vertex_handle newv = create_vertex(); - star_hole(newv, hole); - return newv; -} - -template -void -Triangulation_data_structure_2:: -star_hole(Vertex_handle newv, List_edges& hole) - // star the hole represented by hole around newv - // the triangulation is assumed to have dim=2 - // hole is supposed to be ccw oriented -{ - - star_hole(newv, hole.begin(), hole.end()); - return; -} - -template -void -Triangulation_data_structure_2:: -make_hole(Vertex_handle v, List_edges& hole) - // delete the faces incident to v and v - // and return the dscription of the hole in hole -{ - CGAL_triangulation_precondition(dimension() == 2); - std::list to_delete; - - Face_handle f, fn; - int i =0, in =0; - Vertex_handle vv; - - Face_circulator fc = v->incident_faces(); - Face_circulator done(fc); - do { - f = &(*fc); - i = f->index(v); - fn = f->neighbor(i); - in = f->mirror_index(i); //fn->index(f); - vv = f->vertex(cw(i)); - if( vv->face()== f) vv->set_face(fn); - vv = fc->vertex(ccw(i)); - if( vv->face()== f) vv->set_face(fn); - fn->set_neighbor(in, NULL); - hole.push_back(Edge(fn,in)); - to_delete.push_back(f); - } - while(++fc != done); - - while (! to_delete.empty()){ - delete_face(to_delete.front()); - to_delete.pop_front(); - } - delete_vertex(v); - return; -} - - -template -inline -typename Triangulation_data_structure_2::Vertex_handle -Triangulation_data_structure_2:: -create_vertex() -{ - ++_number_of_vertices; - return vertex_container().get_new_element(); -} - -template -typename Triangulation_data_structure_2::Face_handle -Triangulation_data_structure_2:: -create_face(Face_handle f1, int i1, - Face_handle f2, int i2, - Face_handle f3, int i3) -{ - Face_handle newf = create_face(); - newf->set_vertices(f1->vertex(cw(i1)), - f2->vertex(cw(i2)), - f3->vertex(cw(i3))); - newf->set_neighbors(f2, f3, f1); - // new Face(f1->vertex(cw(i1)), -// f2->vertex(cw(i2)), -// f3->vertex(cw(i3)), -// f2, f3, f1); - f1->set_neighbor(i1,newf); - f2->set_neighbor(i2,newf); - f3->set_neighbor(i3,newf); - // add_face(newf); - return newf; -} - -template -typename Triangulation_data_structure_2::Face_handle -Triangulation_data_structure_2:: -create_face(Face_handle f1, int i1, Face_handle f2, int i2) -{ - Face_handle newf = create_face(); - newf->set_vertices(f1->vertex(cw(i1)), - f2->vertex(cw(i2)), - f2->vertex(ccw(i2))); - newf->set_neighbors(f2, NULL, f1); -// new Face(f1->vertex(cw(i1)), -// f2->vertex(cw(i2)), -// f2->vertex(ccw(i2)), -// f2, NULL, f1); - f1->set_neighbor(i1,newf); - f2->set_neighbor(i2,newf); - // add_face(newf); - return newf; -} - -template -typename Triangulation_data_structure_2::Face_handle -Triangulation_data_structure_2:: -create_face(Face_handle f1, int i1, Vertex_handle v) -{ - Face_handle newf = create_face(); - newf->set_vertices(f1->vertex(cw(i1)), f1->vertex(ccw(i1)), v); - newf->set_neighbors(NULL, NULL, f1); -// new Face(f1->vertex(cw(i1)), f1->vertex(ccw(i1)),v, -// NULL, NULL, f1); - f1->set_neighbor(i1,newf); - // add_face(newf); - return newf; -} - -template -typename Triangulation_data_structure_2::Face_handle -Triangulation_data_structure_2:: -create_face() -{ - Face_handle newf = face_container().get_new_element(); - return newf; -} - -template -typename Triangulation_data_structure_2::Face_handle -Triangulation_data_structure_2:: -create_face( Face_handle f) -{ - Face_handle newf = create_face(); - *newf = *f; - //new Face(*f); //calls copy constructor - //add_face(newf); - return newf; -} - -template -typename Triangulation_data_structure_2::Face_handle -Triangulation_data_structure_2:: -create_face(Vertex_handle v1, Vertex_handle v2, Vertex_handle v3) -{ - Face_handle newf = create_face(); - newf->set_vertices(v1, v2, v3); - //new Face(v1, v2, v3); - //add_face(newf); - return newf; -} - -template -typename Triangulation_data_structure_2::Face_handle -Triangulation_data_structure_2:: -create_face(Vertex_handle v1, Vertex_handle v2, Vertex_handle v3, - Face_handle f1, Face_handle f2, Face_handle f3) -{ - Face_handle newf = create_face(); - newf->set_vertices(v1, v2, v3); - newf->set_neighbors(f1, f2, f3); - //new Face( v1, v2, v3, f1, f2, f3); - //add_face(newf); - return(newf); -} - -template -inline void -Triangulation_data_structure_2:: -set_adjacency(Face_handle f0, int i0, Face_handle f1, int i1) const -{ - CGAL_triangulation_assertion(i0 >= 0 && i0 <= dimension()); - CGAL_triangulation_assertion(i1 >= 0 && i1 <= dimension()); - CGAL_triangulation_assertion(f0 != f1); - f0->set_neighbor(i0,f1); - f1->set_neighbor(i1,f0); -} - -template -inline void -Triangulation_data_structure_2:: -delete_face(Face_handle f) -{ - CGAL_triangulation_expensive_precondition( face_container().is_element(&*f)); - face_container().release_element(&*f); -// f->previous()->set_next(f->next()); -// f->next()->set_previous(f->previous()); -// delete &*f; -} - - - -template -inline void -Triangulation_data_structure_2:: -delete_vertex(Vertex_handle v) -{ - CGAL_triangulation_expensive_precondition( is_vertex(v) ); - --_number_of_vertices; - vertex_container().release_element(&*v); - // delete &*v; -// set_number_of_vertices(number_of_vertices() -1); -// return; -} - -// CHECKING -template < class Vb, class Fb> -bool -Triangulation_data_structure_2:: -is_valid(bool verbose, int level) const -{ - if(number_of_vertices() == 0){ - return (dimension() == -2); - } - - - bool result = (dimension()>= -1); - CGAL_triangulation_assertion(result); - - //count and test the validity of the faces (for positive dimensions) - Iterator_base ib = iterator_base_begin(); - Iterator_base ib_end = iterator_base_end(); - int count_stored_faces =0; - for ( ; ib != ib_end ; ++ib){ - count_stored_faces += 1; - if (dimension()>= 0) { - result = result && ib->is_valid(verbose,level); - CGAL_triangulation_assertion(result); - } - } - - result = result && (count_stored_faces == number_of_full_dim_faces()); - CGAL_triangulation_assertion( - count_stored_faces == number_of_full_dim_faces()); - - // vertex count - int vertex_count = 0; - for(Vertex_iterator vit = vertices_begin(); vit != vertices_end(); - ++vit) { - CGAL_triangulation_assertion( vit->face() != NULL); - result = result && vit->is_valid(verbose,level); - CGAL_triangulation_assertion( result ); - ++vertex_count; - } - result = result && (number_of_vertices() == vertex_count); - CGAL_triangulation_assertion( number_of_vertices() == vertex_count ); - - //edge count - int edge_count = 0; - for(Edge_iterator eit = edges_begin(); eit != edges_end(); ++eit) { - ++edge_count; - } - - // face count - int face_count = 0; - for(Face_iterator fit = faces_begin(); fit != faces_end(); ++fit) { - ++face_count; - } - - switch(dimension()) { - case -1: - result = result && vertex_count == 1 && face_count == 0 - && edge_count == 0; - CGAL_triangulation_assertion(result); - break; - case 0: - result = result && vertex_count == 2 && face_count == 0 - && edge_count == 0; - CGAL_triangulation_assertion(result); - break; - case 1: - result = result && edge_count == vertex_count; - CGAL_triangulation_assertion(result); - result = result && face_count == 0; - CGAL_triangulation_assertion(result); - break; - case 2: - result = result && edge_count == 3*face_count/2 ; - CGAL_triangulation_assertion(edge_count == 3*face_count/2); - break; - default: - result = false; - CGAL_triangulation_assertion(result); - } - return result; -} - - - -template < class Vb, class Fb> -typename Triangulation_data_structure_2::Vertex_handle -Triangulation_data_structure_2:: -copy_tds(const Tds &tds, Vertex_handle vh) -{ - if (this == &tds) return Vertex_handle(NULL); - if (vh != NULL) - CGAL_triangulation_precondition( tds.is_vertex(vh)); - _number_of_vertices = tds.number_of_vertices(); - _dimension = tds.dimension(); - _face_container = tds.face_container(); - _vertex_container = tds.vertex_container(); - - if(tds.number_of_vertices() == 0){return Vertex_handle(NULL);} - //initializes maps - std::map vmap; - std::map fmap; - Iterator_base it1 = tds.iterator_base_begin(); - Iterator_base it2 = iterator_base_begin(); - for( ; it1 != tds.iterator_base_end(); ++it1,++it2) { - fmap[it1->handle()] = it2->handle(); - } - Vertex_iterator vit1 = tds.vertices_begin(); - Vertex_iterator vit2 = vertices_begin(); - for( ; vit1 != tds.vertices_end(); ++vit1,++vit2) { - vmap[vit1->handle()] = vit2->handle(); - } - - //update pointers - it2 = iterator_base_begin(); - int j; - if (dimension() == -1) it2->set_vertex(0, vmap[it2->vertex(0)]); - else { // dimension() >= 0 - for ( ; it2 != iterator_base_end(); ++it2) { - for (j = 0; j < dimension()+ 1; ++j) { - it2->set_vertex(j, vmap[it2->vertex(j)]); - it2->set_neighbor(j, fmap[it2->neighbor(j)]); - } - } - } - vit2 = vertices_begin(); - for ( ; vit2 != vertices_end(); vit2++) { - vit2->set_face(fmap[vit2->face()]); - } - - if (vh == Vertex_handle(NULL)) return Vertex_handle(NULL); - return vmap[vh]; -} - - -template < class Vb, class Fb> -void -Triangulation_data_structure_2:: -file_output( std::ostream& os, Vertex_handle v, bool skip_first) const -{ - // ouput to a file - // if non NULL, v is the vertex to be output first - // if skip_first is true, the point in the first vertex is not output - // (it may be for instance the infinite vertex of the triangulation) - - int n = number_of_vertices(); - int m = number_of_full_dim_faces(); - if(is_ascii(os)) os << n << ' ' << m << ' ' << dimension() << std::endl; - else os << n << m << dimension(); - if (n==0) return; - - std::map V; - std::map F; - - // first vertex - int inum = 0; - if ( v != NULL) { - V[v] = inum++; - if( ! skip_first){ - os << v->point(); - if(is_ascii(os)) os << std::endl; - } - } - - // other vertices - for( Vertex_iterator vit= vertices_begin(); vit != vertices_end() ; ++vit) { - if ( vit->handle() != v) { - V[vit->handle()] = inum++; - os << vit->point(); - if(is_ascii(os)) os << std::endl; - } - } - //if(is_ascii(os)) os << "\n"; - - // vertices of the faces - inum = 0; - int dim = (dimension() == -1 ? 1 : dimension() + 1); - for( Iterator_base ib = iterator_base_begin(); - ib != iterator_base_end(); ++ib) { - F[&(*ib)] = inum++; - for(int j = 0; j < dim ; ++j){ - os << V[ib->vertex(j)]; - if(is_ascii(os)){ - if(j== dimension()) os << "\n"; - else os << ' '; - } - } - } - - // neighbor pointers of the faces - for( Iterator_base it = iterator_base_begin(); - it != iterator_base_end(); ++it) { - for(int j = 0; j < dimension()+1; ++j){ - os << F[&(*(it->neighbor(j)))]; - if(is_ascii(os)){ - if(j== dimension()) os << "\n"; - else os << ' '; - } - } - } - - return ; -} - - -template < class Vb, class Fb> -typename Triangulation_data_structure_2::Vertex_handle -Triangulation_data_structure_2:: -file_input( std::istream& is, bool skip_first) -{ - //input from file - //return a pointer to the first input vertex - // if skip_first is true, a first vertex is added (infinite_vertex) - //set this first vertex as infinite_Vertex - if(number_of_vertices() != 0) clear(); - - int n, m, d; - is >> n >> m >> d; - - if (n==0){ return NULL;} - - //set_number_of_vertices(n); - set_dimension(d); - - std::vector V(n); - std::vector F(m); - - // read vertices - int i = 0; - if(skip_first){ - V[0] = create_vertex(); - ++i; - } - for( ; i < n; ++i) { - typename Vertex_base::Point p; - is >> p; - V[i] = create_vertex(); - V[i]->set_point(p); - } - - // Creation of the faces - int index; - int dim = (dimension() == -1 ? 1 : dimension() + 1); - { - for(i = 0; i < m; ++i) { - F[i] = create_face() ; - for(int j = 0; j < dim ; ++j){ - is >> index; - F[i]->set_vertex(j, V[index]); - // The face pointer of vertices is set too often, - // but otherwise we had to use a further map - V[index]->set_face(F[i]); - } - } - } - - // Setting the neighbor pointers - { - for(i = 0; i < m; ++i) { - for(int j = 0; j < dimension()+1; ++j){ - is >> index; - F[i]->set_neighbor(j, F[index]); - } - } - } - - return V[0]; -} - - -template < class Vb, class Fb> -void -Triangulation_data_structure_2:: -vrml_output( std::ostream& os, Vertex_handle v, bool skip_infinite) const -{ - // ouput to a vrml file style - // Point are assumed to be 3d points with a stream oprator << - // if non NULL, v is the vertex to be output first - // if skip_inf is true, the point in the first vertex is not output - // and the faces incident to v are not output - // (it may be for instance the infinite vertex of the terrain) - os << "#VRML V2.0 utf8" << std::endl; - os << "Shape {" << std::endl; - os << "\tgeometry IndexedFaceSet {" << std::endl; - os << "\t\tcoord Coordinate {" << std::endl; - os << "\t\t\tpoint [" << std::endl; - - std::map vmap; - Vertex_iterator vit; - Face_iterator fit; - - //first vertex - int inum = 0; - if ( v != NULL) { - vmap[v] = inum++; - if( ! skip_infinite) os << "\t\t\t\t" << vit->point() << std::endl; - } - - //other vertices - for( vit= vertices_begin(); vit != vertices_end() ; ++vit) { - if ( vit->handle() != v) { - vmap[vit->handle()] = inum++; - os << "\t\t\t\t" << vit->point() << std::endl; - } - } - - os << "\t\t\t]" << std::endl; - os << "\t\t}" << std::endl; - os << "\t\tcoordIndex [" << std::endl; - - // faces - for(fit= faces_begin(); fit != faces_end(); ++fit) { - if (!skip_infinite || !fit->has_vertex(v)) { - os << "\t\t\t"; - os << vmap[(*fit).vertex(0)] << ", "; - os << vmap[(*fit).vertex(1)] << ", "; - os << vmap[(*fit).vertex(2)] << ", "; - os << "-1, " << std::endl; - } - } - os << "\t\t]" << std::endl; - os << "\t}" << std::endl; - os << "}" << std::endl; - return; -} - -template < class Vb, class Fb> -typename Triangulation_data_structure_2::Vertex_handle -Triangulation_data_structure_2:: -off_file_input( std::istream& is, bool verbose) -{ - // input from an OFF file - // assume a dimension 2 triangulation - // create an infinite-vertex and infinite faces with the - // boundary edges if any. - // return the infinite vertex if created - Vertex_handle vinf(NULL); - File_scanner_OFF scanner(is, verbose); - if (! is) { - if (scanner.verbose()) { - std::cerr << " " << std::endl; - std::cerr << "TDS::off_file_input" << std::endl; - std::cerr << " input error: file format is not OFF." << std::endl; - } - return vinf; - } - - if(number_of_vertices() != 0) clear(); - int dim = 2; - set_dimension(dim); - - std::vector vvh(scanner.size_of_vertices()); - std::map edge_map; - typedef typename Vb::Point Point; - - // read vertices - int i; - for ( i = 0; i < scanner.size_of_vertices(); i++) { - Point p; - file_scan_vertex( scanner, p); - vvh[i] = create_vertex(); - vvh[i]->set_point(p); - scanner.skip_to_next_vertex( i); - } - if ( ! is ) { - is.clear( std::ios::badbit); - return vinf; - } - //vinf = vvh[0]; - - // create the facets - for ( i = 0; i < scanner.size_of_facets(); i++) { - Face_handle fh = create_face(); - Integer32 no; - scanner.scan_facet( no, i); - if( ! is || no != 3) { - if ( scanner.verbose()) { - std::cerr << " " << std::endl; - std::cerr << "TDS::off_file_input" << std::endl; - std::cerr << "facet " << i << "does not have 3 vertices." - << std::endl; - } - is.clear( std::ios::badbit); - return vinf; - } - - for ( int j = 0; j < no; ++j) { - Integer32 index; - scanner.scan_facet_vertex_index( index, i); - fh->set_vertex(j, vvh[index]); - vvh[index]->set_face(fh); - } - - for (int ih = 0; ih < no; ++ih) { - set_adjacency(fh, ih, edge_map); - } - } - - // deal with boundaries - if ( !edge_map.empty()) { - vinf = create_vertex(); - std::map inf_edge_map; - while (!edge_map.empty()) { - Face_handle fh = edge_map.begin()->second.first; - int ih = edge_map.begin()->second.second; - Face_handle fn = create_face( vinf, - fh->vertex(cw(ih)), - fh->vertex(ccw(ih))); - vinf->set_face(fn); - set_adjacency(fn, 0, fh, ih); - set_adjacency(fn, 1, inf_edge_map); - set_adjacency(fn, 2, inf_edge_map); - edge_map.erase(edge_map.begin()); - } - CGAL_triangulation_assertion(inf_edge_map.empty()); - } - - - // coherent orientation - reorient_faces(); - return vinf; -} - - -template < class Vb, class Fb> -void -Triangulation_data_structure_2:: -set_adjacency(Face_handle fh, - int ih, - std::map< Vh_pair, Edge>& edge_map) -{ - // set adjacency to (fh,ih) using the the map edge_map - // or insert (fh,ih) in edge map - Vertex_handle vhcw = fh->vertex(cw(ih)); - Vertex_handle vhccw = fh->vertex(ccw(ih)); - Vh_pair vhp = vhcw < vhccw ? - std::make_pair(vhcw, vhccw) - : std::make_pair(vhccw, vhcw) ; - typename std::map::iterator emapit = edge_map.find(vhp); - if (emapit == edge_map.end()) {// not found, insert edge - edge_map.insert(std::make_pair(vhp, Edge(fh,ih))); - } - else { //found set adjacency and erase - Edge e = emapit->second; - set_adjacency( fh,ih, e.first, e.second); - edge_map.erase(emapit); - } -} - - - -template < class Vb, class Fb> -void -Triangulation_data_structure_2:: -reorient_faces() -{ - // reorient the faces of a triangulation - // needed for example in off_file_input - // because the genus is not known, the number of faces - std::set oriented_set; - std::stack st; - Face_iterator fit = faces_begin(); - int nf = std::distance(faces_begin(),faces_end()); - - while (static_cast(oriented_set.size()) != nf) { - while ( oriented_set.find(fit->handle()) != oriented_set.end()){ - ++fit; // find a germ for non oriented components - } - // orient component - oriented_set.insert(fit->handle()); - st.push(fit->handle()); - while ( ! st.empty()) { - Face_handle fh = st.top(); - st.pop(); - for(int ih = 0 ; ih < 3 ; ++ih){ - Face_handle fn = fh->neighbor(ih); - if (oriented_set.find(fn) == oriented_set.end()){ - int in = fn->index(fh); - if (fn->vertex(cw(in)) != fh->vertex(ccw(ih))) fn->reorient(); - oriented_set.insert(fn); - st.push(fn); - } - } - } - - } - return; -} - - -template < class Vb, class Fb> -std::istream& -operator>>(std::istream& is, - Triangulation_data_structure_2& tds) -{ - tds.file_input(is); - return is; -} - - -template < class Vb, class Fb> -std::ostream& -operator<<(std::ostream& os, - const Triangulation_data_structure_2 &tds) -{ - tds.file_output(os); - return os; -} - -CGAL_END_NAMESPACE - -#endif //CGAL_TRIANGULATION_DATA_STRUCTURE_2_H diff --git a/Packages/Triangulation_2/test/Triangulation_2_newd/example_1.C b/Packages/Triangulation_2/test/Triangulation_2_newd/example_1.C deleted file mode 100644 index 4f8a3cd133d..00000000000 --- a/Packages/Triangulation_2/test/Triangulation_2_newd/example_1.C +++ /dev/null @@ -1,166 +0,0 @@ -// Try to make deferred instantiation at the level of the Tds - - -#include -#include -#include -#include - -#define Cartesian Ca -#define Homogeneous Ho - -#include -#include -#include - -CGAL_BEGIN_NAMESPACE - -template -class My_vertex : public Triangulation_vertex_base_2 -{ -public: - typedef typename Gt::Point_2 Point; - typedef Triangulation_vertex_base_2 Vertex_base; - - typedef typename Ref::Face Face; - typedef typename Ref::Vertex Vertex; - typedef typename Ref::Face_handle Face_handle; - typedef typename Ref::Vertex_handle Vertex_handle; - - My_vertex() : Vertex_base (){} - - My_vertex (const Point & p, void * f = NULL) : Vertex_base (p, f) {} - - void set_v (Vertex* v) {_v = v;} - void set_f (Face* f) {_f = f;} - void set_vh(Vertex_handle vh) { _v = &(*vh);} - void set_fh(Face_handle fh) {_f = &(*fh);} - - Vertex* get_v() { return _v;} - Face* get_f() { return _f;} - Vertex_handle get_vh() {return Vertex_handle(_v) ;} - Face_handle get_fh() {return Face_handle(_f);} - -private: - Vertex* _v; - Face* _f; -}; - - -template -class My_face : public Triangulation_face_base_2 -{ -public: - typedef Triangulation_face_base_2 Face_base; - - typedef typename Ref::Face Face; - typedef typename Ref::Vertex Vertex; - typedef typename Ref::Face_handle Face_handle; - typedef typename Ref::Vertex_handle Vertex_handle; - - My_face() : Face_base (){} - - My_face (void* v0, void* v1, void* v2) : Face_base (v0, v1, v2){} - - My_face (void* v0, void* v1, void* v2, - void* n0, void* n1, void* n2) - : Face_base (v0, v1, v2, n0, n1, n2){} - - void set_v (Vertex* v) {_v = v;} - void set_f (Face* f) {_f = f;} - void set_vh(Vertex_handle vh) { _v = &(*vh);} - void set_fh(Face_handle fh) {_f = &(*fh);} - - Vertex* get_v() { return _v;} - Face* get_f() { return _f;} - Vertex_handle get_vh() {return Vertex_handle(_v) ;} - Face_handle get_fh() {return Face_handle(_f);} - -private: - Vertex* _v; - Face* _f; -}; - -// -//The user who wants to use its own face or own vertex -// has to rewrite this class -template -class My_TDS: - public Triangulation_data_structure_2 < My_vertex > , - My_face > > -{ -public: // CREATION - My_TDS() {} -}; - -CGAL_END_NAMESPACE - -typedef double coord_type; -typedef CGAL::Cartesian Rpst; -typedef CGAL::Triangulation_euclidean_traits_2 Gt; -typedef CGAL::My_TDS My_tds; -typedef CGAL::Triangulation_2 Triangulation; - -typedef Gt::Point_2 Point; -typedef Triangulation::Face Face; -typedef Triangulation::Vertex Vertex; -typedef Triangulation::Face_handle Face_handle; -typedef Triangulation::Vertex_handle Vertex_handle; - -typedef Triangulation::Face_circulator Face_circulator; -typedef Triangulation::Vertex_circulator Vertex_circulator; - -typedef Triangulation::Locate_type Locate_type; - -typedef Triangulation::Face_iterator Face_iterator; -typedef Triangulation::Vertex_iterator Vertex_iterator; -typedef Triangulation::Edge_iterator Edge_iterator; -typedef Triangulation::Line_face_circulator Line_face_circulator; - - -int main() -{ - Triangulation T; - std::vector points; - - points.push_back(Point(0,0)); - points.push_back(Point(1,1)); - points.push_back(Point(2,2)); - - for (unsigned int i = 0; i < points.size(); i++) - T.insert(points[i]); - - Vertex_iterator v0_iter = T.finite_vertices_begin(); - - Vertex_handle vertex = T.finite_vertex(); - Face_handle face = v0_iter->face(); - - for (Vertex_iterator v_iter = T.finite_vertices_begin(); - v_iter != T.finite_vertices_end(); - v_iter++){ - v_iter->set_v(&(*vertex)); - v_iter->set_vh(vertex); - v_iter->set_f(&(*face)); - v_iter->set_fh(face); - } - - for (Face_iterator f_iter = T.faces_begin(); - f_iter != T.faces_end(); - f_iter++){ - f_iter->set_v(&(*vertex)); - f_iter->set_vh(vertex); - f_iter->set_f(&(*face)); - f_iter->set_fh(face); - } - - - Vertex_iterator v_it = T.finite_vertices_begin(); - std::cout<< v_it->get_v()->point()<<"\n"; - std::cout<< v_it->get_vh()->point()<<"\n"; - - return 0; -} - - - - diff --git a/Packages/Triangulation_2/test/Triangulation_2_newd/example_2.C b/Packages/Triangulation_2/test/Triangulation_2_newd/example_2.C deleted file mode 100644 index 938d9ece659..00000000000 --- a/Packages/Triangulation_2/test/Triangulation_2_newd/example_2.C +++ /dev/null @@ -1,170 +0,0 @@ -// Try to make deferred instantiation at the level of the Triangulation - - -#include -#include -#include -#include - -#define Cartesian Ca -#define Homogeneous Ho - -#include -#include -#include -#include - -CGAL_BEGIN_NAMESPACE - -template -class My_vertex : public Triangulation_vertex_base_2 -{ -public: - typedef typename Gt::Point_2 Point; - typedef Triangulation_vertex_base_2 Vertex_base; - - typedef typename Ref::Face Face; - typedef typename Ref::Vertex Vertex; - typedef typename Ref::Vertex_handle Vertex_handle; - typedef typename Ref::Face_handle Face_handle; - - My_vertex() : Vertex_base (){} - - My_vertex (const Point & p, void * f = NULL) : Vertex_base (p, f) {} - - void set_v (Vertex* v) {_vh = Vertex_handle(v);} - void set_f (Face* f) {_fh = Face_handle(f);} - void set_vh(Vertex_handle vh) { _vh = vh;} - void set_fh(Face_handle fh) {_fh = fh;} - - Vertex* get_v() { return &(*_vh);} - Face* get_f() { return &(*_fh);} - Vertex_handle get_vh() {return _vh ;} - Face_handle get_fh() {return _fh;} - - -private: - Vertex_handle _vh; - Face_handle _fh; -}; - - -template -class My_face : public Triangulation_face_base_2 -{ -public: - typedef Triangulation_face_base_2 Face_base; - - typedef typename Ref::Face Face; - typedef typename Ref::Vertex Vertex; - typedef typename Ref::Vertex_handle Vertex_handle; - typedef typename Ref::Face_handle Face_handle; - - My_face() : Face_base (){} - - My_face (void* v0, void* v1, void* v2) : Face_base (v0, v1, v2){} - - My_face (void* v0, void* v1, void* v2, - void* n0, void* n1, void* n2) - : Face_base (v0, v1, v2, n0, n1, n2){} - - void set_v (Vertex* v) {_vh = Vertex_handle(v);} - void set_f (Face* f) {_fh = Face_handle(f);} - void set_vh(Vertex_handle vh) { _vh = vh;} - void set_fh(Face_handle fh) {_fh = fh;} - - Vertex* get_v() { return &(*_vh);} - Face* get_f() { return &(*_fh);} - Vertex_handle get_vh() {return _vh ;} - Face_handle get_fh() {return _fh;} - - -private: - Vertex_handle _vh; - Face_handle _fh; -}; - - -template -class My_TDS: - public Triangulation_data_structure_2 < - My_vertex > > , - My_face > > - > - -{ -public: // CREATION - My_TDS() {} -}; - -CGAL_END_NAMESPACE - -typedef double coord_type; -typedef CGAL::Cartesian Rpst; -typedef CGAL::Triangulation_euclidean_traits_2 Gt; -typedef CGAL::My_TDS My_tds; -typedef CGAL::Triangulation_2 Triangulation; - -typedef Gt::Point_2 Point; -typedef Triangulation::Face Face; -typedef Triangulation::Vertex Vertex; -typedef Triangulation::Face_handle Face_handle; -typedef Triangulation::Vertex_handle Vertex_handle; - -typedef Triangulation::Face_circulator Face_circulator; -typedef Triangulation::Vertex_circulator Vertex_circulator; - -typedef Triangulation::Locate_type Locate_type; - -typedef Triangulation::Face_iterator Face_iterator; -typedef Triangulation::Vertex_iterator Vertex_iterator; -typedef Triangulation::Edge_iterator Edge_iterator; -typedef Triangulation::Line_face_circulator Line_face_circulator; - - -int main() -{ - Triangulation T; - std::vector points; - - points.push_back(Point(0,0)); - points.push_back(Point(1,1)); - points.push_back(Point(2,2)); - - for (unsigned int i = 0; i < points.size(); i++) - T.insert(points[i]); - - Vertex_iterator v0_iter = T.finite_vertices_begin(); - - Vertex_handle vertex = T.finite_vertex(); - Face_handle face = v0_iter->face(); - - for (Vertex_iterator v_iter = T.finite_vertices_begin(); - v_iter != T.finite_vertices_end(); - v_iter++){ - v_iter->set_v(&(*vertex)); - v_iter->set_vh(vertex); - v_iter->set_f(&(*face)); - v_iter->set_fh(face); - } - - for (Face_iterator f_iter = T.faces_begin(); - f_iter != T.faces_end(); - f_iter++){ - f_iter->set_v(&(*vertex)); - f_iter->set_vh(vertex); - f_iter->set_f(&(*face)); - f_iter->set_fh(face); - } - - - Vertex_iterator v_it = T.finite_vertices_begin(); - std::cout<< v_it->get_v()->point()<<"\n"; - std::cout<< v_it->get_vh()->point()<<"\n"; - - return 0; -} - - - - diff --git a/Packages/Triangulation_2/test/Triangulation_2_newd/example_3.C b/Packages/Triangulation_2/test/Triangulation_2_newd/example_3.C deleted file mode 100644 index 68f544ad7bd..00000000000 --- a/Packages/Triangulation_2/test/Triangulation_2_newd/example_3.C +++ /dev/null @@ -1,177 +0,0 @@ -// Try Sylvain proposal for a fully flexible design -// using the rebind trick - - -#include -#include -#include -#include - -#define Cartesian Ca -#define Homogeneous Ho - -#include "Triangulation_data_structure_2.h" -#include -#include -#include - - -CGAL_BEGIN_NAMESPACE - -struct TDS_Bidon { - typedef int Vertex_handle; - typedef int Face_handle; -}; - - - -template -class Vertex_base_2 : public Triangulation_vertex_base_2 -{ -public: - typedef typename Gt::Point_2 Point; - typedef Triangulation_vertex_base_2 Base; - - typedef typename TDS::Face_handle Face_handle; - typedef typename TDS::Vertex_handle Vertex_handle; - - template < class My_TDS> - struct TDS_rebind { typedef Vertex_base_2 Rebound;}; - - Vertex_base_2() : Base (){} - Vertex_base_2(const Point & p, void * f = NULL) : Base(p,f) {} - - void set_vh(Vertex_handle vh) { _vh = vh;} - void set_fh(Face_handle fh) {_fh = fh ;} - - Vertex_handle get_vh() {return _vh ;} - Face_handle get_fh() {return _fh ;} - -private: - Vertex_handle _vh; - Face_handle _fh; -}; - - -template -class Face_base_2 : public Triangulation_face_base_2 -{ -public: - typedef Triangulation_face_base_2 Base; - - typedef typename TDS::Face_handle Face_handle; - typedef typename TDS::Vertex_handle Vertex_handle; - - template < class My_TDS> - struct TDS_rebind { typedef Face_base_2 Rebound; }; - - - Face_base_2() : Base (){} - - Face_base_2 (void* v0, void* v1, void* v2) : Base (v0, v1, v2){} - - Face_base_2 (void* v0, void* v1, void* v2, - void* n0, void* n1, void* n2) - : Base (v0, v1, v2, n0, n1, n2){} - - void set_vh(Vertex_handle vh) { _vh = vh;} - void set_fh(Face_handle fh) {_fh = fh;} - - Vertex_handle get_vh() {return _vh ;} - Face_handle get_fh() {return _fh ;} - -private: - Vertex_handle _vh; - Face_handle _fh; -}; - -CGAL_END_NAMESPACE - -// -// A user defined Vertex -template -class My_vertex : public CGAL::Vertex_base_2 -{ -public: - typedef CGAL::Vertex_base_2 Base; - typedef typename Base::Point Point; - typedef typename TDS::Face_handle Face_handle; - typedef typename TDS::Vertex_handle Vertex_handle; - - template < class My_TDS> - struct TDS_rebind { typedef My_vertex Rebound;}; - - My_vertex() : Base (){} - My_vertex(const Point & p, void * f = NULL) : Base(p,f) {} - - void set_wahou(Vertex_handle vh) { wahou = vh;} - Vertex_handle get_wahou() {return wahou ;} - -private: - Vertex_handle wahou; -}; - - -typedef CGAL::Cartesian K; -typedef My_vertex MyVb; -typedef CGAL::Vertex_base_2 Vb; -typedef CGAL::Face_base_2 Fb; -//typedef CGAL::Triangulation_data_structure_2 Tds; -typedef CGAL::Triangulation_data_structure_2 Tds; -typedef CGAL::Triangulation_2 Triangulation; - -typedef K::Point_2 Point; -typedef Triangulation::Face_handle Face_handle; -typedef Triangulation::Vertex_handle Vertex_handle; - -typedef Triangulation::Finite_faces_iterator Face_iterator; -typedef Triangulation::Finite_vertices_iterator Vertex_iterator; -typedef Triangulation::Finite_edges_iterator Edge_iterator; - - -int main() -{ - Triangulation T; - std::vector points; - - points.push_back(Point(0,0)); - points.push_back(Point(1,1)); - points.push_back(Point(2,2)); - - for (unsigned int i = 0; i < points.size(); i++) - T.insert(points[i]); - - Vertex_iterator v0_iter = T.finite_vertices_begin(); - - Vertex_handle vertex = T.finite_vertex(); - Face_handle face = v0_iter->face(); - - for (Vertex_iterator v_iter = T.finite_vertices_begin(); - v_iter != T.finite_vertices_end(); - v_iter++){ - v_iter->set_vh(vertex); - v_iter->set_fh(face); - vertex = v_iter; - face = v_iter->face(); - v_iter->set_wahou(v_iter); - } - - for (Face_iterator f_iter = T.faces_begin(); - f_iter != T.faces_end(); - f_iter++){ - f_iter->set_vh(vertex); - f_iter->set_fh(face); - } - - - for (Vertex_iterator v_it = T.finite_vertices_begin(); - v_it != T.finite_vertices_end(); - v_it++){ - std::cerr << v_it->point() << " " << v_it->get_wahou()->point()<<"\n"; - } - return 0; -} - - - - diff --git a/Packages/Triangulation_2/test/Triangulation_2_newd/example_4.C b/Packages/Triangulation_2/test/Triangulation_2_newd/example_4.C deleted file mode 100644 index 8d319e17a0d..00000000000 --- a/Packages/Triangulation_2/test/Triangulation_2_newd/example_4.C +++ /dev/null @@ -1,106 +0,0 @@ -// Try Sylvain proposal for a fully flexible design -// using the rebind trick -// try a general example (not in CGAL), first -#include - -struct TDS_Bidon { - typedef int Vertex_handle; -}; - -template -class TDS_2 { -public: - typedef TDS_2 Self; - typedef typename Vb::template TDS_rebind::Rebound Vertex; - - typedef std::list Vertex_container; - typedef Vertex* Vertex_handle; - -protected: - Vertex_container container; - -public: - Vertex_handle create_vertex(Vertex_handle vh){ - Vertex* vv = new Vertex(vh); - container.push_back(*vv); - return vv; - } -}; - - - - -//template -template -class Vertex_base -{ -public: - typedef typename TDS::Vertex_handle Vertex_handle; - - template < class My_TDS> - struct TDS_rebind { typedef Vertex_base Rebound;}; - - Vertex_base() : _vh(0){} - Vertex_base(Vertex_handle vh) : _vh(vh) {} - void set_vh(Vertex_handle vh) { _vh = vh;} - Vertex_handle get_vh() {return _vh ;} - -private: - Vertex_handle _vh; -}; - - - -// -// A user defined Vertex -template -class My_vertex_base : public Vertex_base -{ -public: - typedef Vertex_base Base; - typedef typename TDS::Vertex_handle Vertex_handle; - - template < class My_TDS> - struct TDS_rebind { typedef My_vertex_base Rebound;}; - - My_vertex_base() : Base (){} - My_vertex_base(Vertex_handle vh) : Base(vh) {} - - void set_wahou(Vertex_handle vh) { wahou = vh;} - Vertex_handle get_wahou() {return wahou ;} - -private: - Vertex_handle wahou; -}; - - -typedef Vertex_base<> Vb; -typedef TDS_2 Tds; -typedef My_vertex_base<> Myvb; -typedef TDS_2 Mytds; - -typedef Tds::Vertex Vertex; -typedef Tds::Vertex_handle Vertex_handle; -typedef Mytds::Vertex My_vertex; -typedef Mytds::Vertex_handle My_vertex_handle; - -int main() -{ - Tds tds; - Vertex_handle vh = new Vertex; - for(int i = 0 ; i < 10 ; i++) { - vh = tds.create_vertex(vh); - } - - Mytds mytds; - My_vertex_handle myvh = new My_vertex; - for(int i = 0 ; i < 10 ; i++) { - myvh = mytds.create_vertex(myvh); - myvh->set_wahou(myvh); - } - return 0; -} - - - -