diff --git a/.gitattributes b/.gitattributes index 5be3d8b59ff..42680c0d1e8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4574,8 +4574,8 @@ Triangulation_on_sphere_2/include/CGAL/Triangulation_sphere_traits_2.h -text Triangulation_on_sphere_2/include/CGAL/algebraic_kernel_for_spheres_extensions_ntC3.h -text Triangulation_on_sphere_2/include/CGAL/static_in_cone_ntC3.h -text Triangulation_on_sphere_2/test/bugs_minimal_examples.cpp -text +Triangulation_on_sphere_2/test/test_random.cpp -text Triangulation_on_sphere_2/test/test_regular_sphere_traits.cpp -text -Triangulation_on_sphere_2/test/test_regular_triangulation_on_sphere_2.cpp -text Triangulation_on_sphere_2/test/test_triangulation_on_sphere_2.cpp -text Voronoi_diagram_2/doc_tex/Voronoi_diagram_2/voronoi.png -text wininst/developer_scripts/CGAL.bmp -text svneol=unset#image/bmp diff --git a/Triangulation_on_sphere_2/include/CGAL/Regular_triangulation_on_sphere_2.h b/Triangulation_on_sphere_2/include/CGAL/Regular_triangulation_on_sphere_2.h index 096c538d2e5..3d23fb6ab31 100644 --- a/Triangulation_on_sphere_2/include/CGAL/Regular_triangulation_on_sphere_2.h +++ b/Triangulation_on_sphere_2/include/CGAL/Regular_triangulation_on_sphere_2.h @@ -31,7 +31,7 @@ class Regular_triangulation_on_sphere_2 { typedef Regular_triangulation_on_sphere_2 Self; - typedef Triangulation_on_sphere_2 Base; + typedef Triangulation_on_sphere_2 Base; @@ -41,7 +41,6 @@ public: typedef Tds Triangulation_data_structure; typedef Gt Geom_traits; typedef typename Gt::Point_2 Point; - typedef typename Base::size_type size_type; typedef typename Base::Face_handle Face_handle; typedef typename Base::Vertex_handle Vertex_handle; @@ -80,6 +79,7 @@ public: using Base ::show_face; using Base ::show_vertex; using Base::clear; + using Base::delete_faces; #endif public: @@ -93,10 +93,10 @@ public: bool is_valid(bool verbose = false, int level = 0) const; bool is_valid_face(Face_handle fh,bool verbose = false, int level = 0 ) const; bool is_valid_vertex(Vertex_handle fh, bool verbose = false, int level = 0) const; + bool is_plane() const; - bool test_conflict(const Point &p, Face_handle fh) const; - bool update_negative_faces(Vertex_handle v=Vertex_handle()); + bool check_neighboring() { @@ -137,53 +137,22 @@ public: Vertex_handle insert_hole_approach_2(const Point &p, Locate_type lt, Face_handle loc, int li) ; Vertex_handle insert_in_plane_triangulation(const Point &p); + bool test_conflict(const Point &p, Face_handle fh) const; + bool update_negative_faces(Vertex_handle v=Vertex_handle()); + //REMOVAL void remove_degree_3(Vertex_handle v, Face_handle f = Face_handle()); void remove(Vertex_handle v); void remove_1D(Vertex_handle v); void remove_2D(Vertex_handle v); bool test_dim_down(Vertex_handle v); - bool test_dim_up(Point p); + bool test_dim_up(const Point &p)const; void fill_hole_regular(std::list & hole); //TEMPLATE MEMBERS //----------------------------------------------------------------------HOLE APPROACH - -template < class InputIterator > -int insert(InputIterator first, InputIterator last) - { - int n = number_of_vertices(); - - std::vector points (first, last); - std::random_shuffle (points.begin(), points.end()); - //~ spatial_sort (points.begin(), points.end(), geom_traits()); - spatial_sort (points.begin(), points.end()); - - Face_handle hint; - for (typename std::vector::const_iterator p = points.begin(), - end = points.end(); - p != end; ++p) - hint = insert (*p, hint)->face(); - - return number_of_vertices() - n; - } - - -template -void delete_faces(FaceIt face_begin, FaceIt face_end) - { - FaceIt fit=face_begin; - for(;fit!=face_end;++fit) - { - delete_face(*fit); - } - } - - - - template Stream &write_vertices(Stream &out,std::vector &t) { @@ -198,11 +167,11 @@ Stream &write_vertices(Stream &out,std::vector &t) return out; } - template - Stream &write_triangulation_to_off_2(Stream &out,Stream &out2){ +template + Stream &write_triangulation_to_off_2(Stream &out,Stream &out2){ // Points of triangulation - for (Faces_iterator it = this->_tds.face_iterator_base_begin(); it != faces_end(); it++) { + for (Faces_iterator it = this->_tds.face_iterator_base_begin(); it != faces_end(); it++) { if(!it->is_negative() /*(t.orientation(it->vertex(0)->point(),it->vertex(1)->point(),it->vertex(2)->point())==1)*/ ){//assert(orientation(it)==POSITIVE); @@ -306,18 +275,31 @@ Stream &write_edges_to_off(Stream &out,FaceIt face_begin, FaceIt face_end){ return out; } - +template < class InputIterator > +int insert(InputIterator first, InputIterator last) +{ + int n = number_of_vertices(); + + std::vector points (first, last); + std::random_shuffle (points.begin(), points.end()); + //~ spatial_sort (points.begin(), points.end(), geom_traits()); + spatial_sort (points.begin(), points.end()); + + Face_handle hint; + for (typename std::vector::const_iterator p = points.begin(),end = points.end(); p != end; ++p) + hint = insert (*p, hint)->face(); + + return number_of_vertices() - n; +} template std::pair get_conflicts_and_boundary(const Point &p, OutputItFaces fit, OutputItBoundaryEdges eit, - Face_handle start ) const { + Face_handle fh ) const { CGAL_triangulation_precondition( dimension() == 2); - Face_handle fh = start; - CGAL_triangulation_precondition(test_conflict(p,fh)); + CGAL_triangulation_precondition(test_conflict(p,fh)); - Face_handle tmp; - *fit++ = fh; //put fh in OutputItFaces + *fit++ = fh; //put fh in OutputItFaces fh->set_in_conflict_flag(1); std::pair pit = std::make_pair(fit,eit); @@ -351,65 +333,84 @@ propagate_conflicts (const Point &p, Face_handle fh, int i, } return pit; } - }; //----------------------------------------------------------------------CHECK---------------------------------------------------------------// +template +bool +Regular_triangulation_on_sphere_2:: +is_plane()const{ + bool plane = true; + + if(dimension()==2) + return false; + + if(number_of_vertices() > 3){ + Vertices_iterator it1 = vertices_begin(), + it2(it1), it3(it1), it4(it1); + ++it2; + ++it3; ++it3; + ++it4; ++it4; ++it4; + while( it4 != vertices_end()) { + Orientation s = Base ::power_test( it1->point(),it2->point(),it3->point(), it4->point()); + plane = plane && s == ON_ORIENTED_BOUNDARY ; + ++it1 ; ++it2; ++it3;++it4; + if (!plane) + return plane; + }return true; + } + + + if(number_of_vertices()==3) + return true; + + + + return plane; +} + + + + + + + + template < class Gt, class Tds > bool Regular_triangulation_on_sphere_2:: - is_valid(bool verbose, int level ) const //int level +is_valid(bool verbose, int level ) const //int level { bool result = true; if ( !this-> _tds.is_valid(verbose,level) ) { if (verbose) std::cerr << "invalid data structure" << std::endl; - CGAL_triangulation_assertion(false); - return false; + CGAL_triangulation_assertion(false); + return false; } - - - for(Faces_iterator fit = faces_begin(); fit != faces_end(); ++fit) { - result = result && is_valid_face(fit, verbose, level); - CGAL_triangulation_assertion(result); - } - - for(Vertices_iterator vit = vertices_begin(); vit != vertices_end(); ++vit) { - result = result && is_valid_vertex(vit); - }CGAL_triangulation_assertion(result); + + for(Faces_iterator fit = faces_begin(); fit != faces_end(); ++fit) + is_valid_face(fit, verbose, level); + + for(Vertices_iterator vit = vertices_begin(); vit != vertices_end(); ++vit) + is_valid_vertex(vit); + switch(dimension()) { case 0 : break; case 1: - if (number_of_vertices() > 3 ) { - Vertices_iterator it1 = vertices_begin(), - it2(it1), it3(it1), it4(it1); - ++it2; - ++it3; ++it3; - ++it4; ++it4; ++it4; - while( it4 != vertices_end()) { - - Orientation s = Base ::power_test( it1->point(),it2->point(),it3->point(), it4->point()); - result = result && s == ON_ORIENTED_BOUNDARY ; - CGAL_triangulation_assertion(result); - ++it1 ; ++it2; ++it3;++it4; - } - } - break; + CGAL_triangulation_assertion(this->is_plane()); + break; case 2 : for(Faces_iterator it=faces_begin(); it!=faces_end(); it++) { Orientation s = orientation(it->vertex(0)->point(), it->vertex(1)->point(), it->vertex(2)->point()); result = result && ( s == LEFT_TURN || it->is_negative()); - - CGAL_triangulation_assertion(result); - - - - } + CGAL_triangulation_assertion(result); + } result = result && (number_of_faces() == 2*(number_of_vertices()) - 4 ); CGAL_triangulation_assertion( result); @@ -417,10 +418,9 @@ Regular_triangulation_on_sphere_2:: } // in any dimension - if(verbose) { - std::cerr << " number of vertices " << number_of_vertices() << "\t" - << std::endl; - } + if(verbose) + std::cerr << " number of vertices " << number_of_vertices() << "\t" << std::endl; + CGAL_triangulation_assertion( result); return result; } @@ -431,20 +431,19 @@ bool Regular_triangulation_on_sphere_2:: is_valid_vertex(Vertex_handle vh, bool verbose, int level) const { - bool result = true; - result = result && vh->face()->has_vertex(vh); - - if ( !result ) - if(verbose) { - std::cerr << " from is_valid_vertex " << std::endl; + bool result = vh->face()->has_vertex(vh); + if ( !result ) { + if(verbose) { + std::cerr << " from is_valid_vertex " << std::endl; std::cerr << "normal vertex " << &(*vh) << std::endl; std::cerr << vh->point() << " " << std::endl; std::cerr << "vh_>face " << &*(vh->face()) << " " << std::endl; - show_face(vh->face()); + show_face(vh->face()); } - - CGAL_triangulation_assertion(result); - return result; + CGAL_triangulation_assertion(false); + return false; + } +return true; } template < class Gt, class Tds > @@ -452,23 +451,19 @@ bool Regular_triangulation_on_sphere_2:: is_valid_face(Face_handle fh, bool verbose, int level) const { - bool result = true; - CGAL_triangulation_assertion(result); - - result = fh->get_in_conflict_flag()==0; - - typename Vertex_list::iterator vlit = fh->vertex_list().begin(), - vldone = fh->vertex_list().end(); - for (; vlit != vldone; vlit++) { - result = result && Base::power_test(fh, (*vlit)->point()) == ON_NEGATIVE_SIDE; + bool result = fh->get_in_conflict_flag()==0; + for (int i = 0; i<+2; i++) { + Orientation test = Base::power_test(fh, fh->vertex(i)->point()); + result = result && test == ON_ORIENTED_BOUNDARY; CGAL_triangulation_assertion(result); - - result = result && ((*vlit)->face() == fh); - if (!result) - if (verbose) - show_face(fh); + } + if (!result) + if (verbose){ + std::cerr<<" from is_valid_face "< typename Regular_triangulation_on_sphere_2::Vertex_handle Regular_triangulation_on_sphere_2:: @@ -490,16 +487,18 @@ insert(const Point &p, Face_handle start) { Locate_type lt; int li; - Face_handle loc = locate(p, lt, li, start); + Face_handle loc = Base::locate(p, lt, li, start); + return insert_hole_approach_2(p, lt, loc, li); - } + template < class Gt, class Tds> typename Regular_triangulation_on_sphere_2::Vertex_handle Regular_triangulation_on_sphere_2:: insert_in_plane_triangulation(const Point &p){ - + + CGAL_triangulation_precondition(!test_dim_up(p)); CGAL_triangulation_precondition(dimension()==1); Face_handle loc; Edges_iterator eit=edges_begin(); @@ -509,10 +508,9 @@ insert_in_plane_triangulation(const Point &p){ Vertex_handle v2 = f -> vertex(1); if(orientation(v1->point(), v2->point(), p)==RIGHT_TURN){ loc = f; - break; + break; - } - eit++; + } eit++; }while( eit!=edges_end()); Vertex_handle v0 = loc->vertex(0); @@ -545,7 +543,7 @@ Regular_triangulation_on_sphere_2:: insert_first(const Point& p) { CGAL_triangulation_precondition(number_of_vertices() == 0); - Vertex_handle v =this-> _tds.insert_first(); + Vertex_handle v =this->_tds.insert_first(); v->set_point(p); return v; } @@ -556,8 +554,7 @@ Regular_triangulation_on_sphere_2:: insert_second(const Point& p) { CGAL_triangulation_precondition(number_of_vertices() == 1); - - Vertex_handle v =this-> _tds.insert_second(); + Vertex_handle v =this->_tds.insert_second(); v->set_point(p); return v; } @@ -570,18 +567,20 @@ Regular_triangulation_on_sphere_2:: insert_hole_approach_2(const Point &p, Locate_type lt, Face_handle loc, int li) { //!!!!!!!!!!!!TODO point is valide!!!!!!!!!!!!!!!!!!!!!!!! - Vertex_handle v; - if( dimension() == -2) + + Vertex_handle v; + switch (dimension()){ + case -2 : return insert_first(p); - if( dimension() == -1) + case -1: return insert_second(p); - if( dimension() == 0) + case 0: return insert_outside_affine_hull_regular(p); - if(dimension() == 1){ + case 1: if(test_dim_up(p)){ Face_handle f=edges_begin()->first; Vertex_handle v1=f->vertex(0); @@ -591,24 +590,17 @@ insert_hole_approach_2(const Point &p, Locate_type lt, Face_handle loc, int li) v = insert_outside_affine_hull_regular(p,orient==COLLINEAR); return v; } - else { v= insert_in_plane_triangulation(p); - return v; - } - } - - if (dimension()==2){ + return v; + } + + case 2: std::vector faces; std::vector edges; - - - faces.reserve(32); edges.reserve(32); - - - + get_conflicts_and_boundary(p, std::back_inserter(faces), std::back_inserter(edges), loc); v =this->_tds.star_hole(edges.begin(), edges.end()); v->set_point(p); @@ -618,11 +610,9 @@ insert_hole_approach_2(const Point &p, Locate_type lt, Face_handle loc, int li) //if( lt != FACE ) update_negative_faces(v); - return v; - } - } - - + return v; + } +} template typename Triangulation_on_sphere_2::Vertex_handle @@ -737,16 +727,15 @@ update_negative_faces(Vertex_handle v) Face_circulator fc=incident_faces(v,v->face()); Face_circulator done(fc); - //bool neg_found=false; - + do{ if(orientation(fc)==NEGATIVE){ - fc->negative()=true; - neg_found=true; - this->_negative=fc; + fc->negative()=true; + neg_found=true; + this->_negative=fc; } else{ - fc->negative()=false; + fc->negative()=false; } }while(++fc!=done); @@ -777,15 +766,15 @@ Regular_triangulation_on_sphere_2:: remove(Vertex_handle v ) { CGAL_triangulation_precondition( v != Vertex_handle() ); - if(number_of_vertices()<=3){ + if(number_of_vertices()<=3) this->_tds.remove_dim_down(v); - } - else if(dimension()==2) { + + else if(dimension()==2) remove_2D (v); - } - else { + + else remove_1D(v); - } + } @@ -817,7 +806,7 @@ remove_2D(Vertex_handle v) std::list hole; make_hole(v, hole); fill_hole_regular(hole); - delete_vertex(v); + //delete_vertex(v); } return; } @@ -852,7 +841,7 @@ test_dim_down(Vertex_handle v) template bool Regular_triangulation_on_sphere_2:: -test_dim_up(Point p){ +test_dim_up(const Point &p) const{ // dimension of triangulation increase from 1 to 2 iff the new vertex in not coplanar with the old vertices //first three points of triangulation diff --git a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h index e76ff1b31f5..9d8300f61a6 100644 --- a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h +++ b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h @@ -23,12 +23,13 @@ #include #include +#include //TO DO -//oriented_side -//insertion, location, removal dim 0,1 + +//, location, dim 0,1 //March locate 2D improve code and cases Vertex and Edge of boundary //Line face circulator & marchlocate LFC //includes_edge @@ -58,10 +59,14 @@ class Triangulation_on_sphere_2 friend std::istream& operator>> <> (std::istream& is, Triangulation_on_sphere_2 &tr); typedef Triangulation_on_sphere_2 Self; + public: typedef Tds Triangulation_data_structure; typedef Gt Geom_traits; +typedef Triangulation_2 Triangulation_2; + + typedef typename Geom_traits::Point_2 Point; typedef typename Geom_traits::Orientation_2 Orientation_2; typedef typename Geom_traits::Coradial_sphere_2 Coradial_sphere_2; @@ -158,8 +163,8 @@ size_type number_of_faces() const{return _tds.number_of_faces();} Oriented_side power_test(const Point &p, const Point &r) const; Oriented_side power_test(const Face_handle &f,const Point &p) const; Oriented_side power_test(const Face_handle& f, int i, const Point &p) const; - Oriented_side oriented_side(const Point &p0, const Point &p1,const Point &p2, const Point &p) const; - Bounded_side bounded_side(const Point &p0, const Point &p1,const Point &p2, const Point &p) const; + //Oriented_side oriented_side(const Point &p0, const Point &p1,const Point &p2, const Point &p) const; + //Bounded_side bounded_side(const Point &p0, const Point &p1,const Point &p2, const Point &p) const; Oriented_side oriented_side(Face_handle f, const Point &p) const; bool xy_equal(const Point& p, const Point& q) const; bool collinear_between(const Point& p, const Point& q, const Point& r) const; @@ -258,13 +263,8 @@ size_type number_of_faces() const{return _tds.number_of_faces();} { FaceIt fit=face_begin; for(;fit!=face_end;++fit) - { - delete_face(*fit); - } + delete_face(*fit); } - - - }; @@ -331,8 +331,6 @@ swap(Triangulation_on_sphere_2 &tr) tr._gt = t; } -//ACCESS FUNCTION - //CHECKING template @@ -397,10 +395,7 @@ is_face(Vertex_handle v1, Vertex_handle v2, Vertex_handle v3) const template inline bool Triangulation_on_sphere_2:: -is_face(Vertex_handle v1, - Vertex_handle v2, - Vertex_handle v3, - Face_handle &fr) const +is_face(Vertex_handle v1, Vertex_handle v2, Vertex_handle v3,Face_handle &fr) const { return _tds.is_face(v1, v2, v3, fr); } @@ -410,9 +405,7 @@ is_face(Vertex_handle v1, template typename Triangulation_on_sphere_2::Face_handle Triangulation_on_sphere_2:: -march_locate_1D(const Point& t, - Locate_type& lt, - int& li) const +march_locate_1D(const Point& t, Locate_type& lt, int& li) const { Face_handle f = edges_begin()->first; @@ -542,10 +535,6 @@ march_locate_2D(Face_handle c, } } - - - - // Instead of testing c's edges in a random order we do the following // until we find a neighbor to go further: // As we come from prev we do not have to check the edge leading to prev @@ -855,154 +844,48 @@ orientation(const Face_handle f) const return orientation(f->vertex(0)->point(),f->vertex(1)->point(),f->vertex(2)->point()); } - - -/* -template +template < class Gt, class Tds > Oriented_side -Triangulation_on_sphere_2:: -oriented_side(const Point &p0, const Point &p1,const Point &p2, const Point &p) const { - Orientation o1 = orientation(p0, p1, p), - o2 = orientation(p1, p2, p), - o3 = orientation(p2, p0, p); - - if(orientation(p0, p1, p2)==POSITIVE){ - if(o1==POSITIVE) - if(o2==POSITIVE) - if(o3==POSITIVE) - return ON_POSITIVE_SIDE; - - if (o1 == COLLINEAR){ - if (o2 == COLLINEAR || o3 == COLLINEAR) return ON_ORIENTED_BOUNDARY; - return ON_NEGATIVE_SIDE; - } - if (o2 == COLLINEAR){ - if (o1 == COLLINEAR || o3 == COLLINEAR) return ON_ORIENTED_BOUNDARY; - return ON_NEGATIVE_SIDE; - } - if (o3 == COLLINEAR){ - if (o2 == COLLINEAR || o1 == COLLINEAR) return ON_ORIENTED_BOUNDARY; - return ON_NEGATIVE_SIDE; - } - - if(o1 == COLLINEAR || o2==COLLINEAR || o3==COLLINEAR) - return ON_ORIENTED_BOUNDARY; - return ON_NEGATIVE_SIDE; - - }else{ - if(o1==POSITIVE && o2==POSITIVE && o3==POSITIVE) - return ON_POSITIVE_SIDE; - - if(o1==NEGATIVE && o2==NEGATIVE && o3==NEGATIVE ) - return ON_NEGATIVE_SIDE; - else - return ON_NEGATIVE_SIDE; - } -}*/ +Triangulation_on_sphere_2:: +power_test(const Face_handle &f, const Point &p) const +{ +return power_test(f->vertex(0)->point(), f->vertex(1)->point(), f->vertex(2)->point(),p); +} - - - template < class Gt, class Tds > - Oriented_side - Triangulation_on_sphere_2:: - power_test(const Face_handle &f, const Point &p) const - { - return power_test(f->vertex(0)->point(), - f->vertex(1)->point(), - f->vertex(2)->point(),p); - } - - template < class Gt, class Tds > - Oriented_side - Triangulation_on_sphere_2:: - power_test(const Face_handle& f, int i, - const Point &p) const - { - CGAL_triangulation_precondition ( - orientation(f->vertex(ccw(i))->point(), - f->vertex( cw(i))->point(), - p) +template < class Gt, class Tds > +Oriented_side +Triangulation_on_sphere_2:: +power_test(const Face_handle& f, int i, const Point &p) const +{ + CGAL_triangulation_precondition ( orientation(f->vertex(ccw(i))->point(), + f->vertex( cw(i))->point(), p) == COLLINEAR); - return power_test(f->vertex(ccw(i))->point(), - f->vertex( cw(i))->point(), - p); - } - template < class Gt, class Tds > - inline - Oriented_side - Triangulation_on_sphere_2:: - power_test(const Point &p, - const Point &q, - const Point &r, - const Point &s) const - { - return geom_traits().power_test_2_object()(p,q,r,s); - } + return power_test(f->vertex(ccw(i))->point(), f->vertex( cw(i))->point(), p); +} - template < class Gt, class Tds > - inline - Oriented_side - Triangulation_on_sphere_2:: - power_test(const Point &p, - const Point &q, - const Point &r) const - { - if(number_of_vertices()==2) - if(orientation_1(p,q)==COLLINEAR) +template < class Gt, class Tds > +inline +Oriented_side +Triangulation_on_sphere_2:: +power_test(const Point &p, const Point &q, const Point &r, const Point &s) const +{ + return geom_traits().power_test_2_object()(p,q,r,s); +} + +template < class Gt, class Tds > +inline +Oriented_side +Triangulation_on_sphere_2:: +power_test(const Point &p, const Point &q, const Point &r) const +{ + if(number_of_vertices()==2) + if(orientation_1(p,q)==COLLINEAR) return ON_POSITIVE_SIDE; - return geom_traits().power_test_2_object()(p,q,r); - } + return geom_traits().power_test_2_object()(p,q,r); +} -/* -template -Bounded_side -Triangulation_on_sphere_2:: -bounded_side(const Point &p0, const Point &p1, - const Point &p2, const Point &p) const -{ - // return position of point p with respect to triangle p0p1p2, depends on the orientation of the vertives - CGAL_triangulation_precondition( orientation(p0, p1, p2) != COLLINEAR); - Orientation o1 = orientation(p0, p1, p), - o2 = orientation(p1, p2, p), - o3 = orientation(p2, p0, p); - - if (o1 == COLLINEAR){ - if (o2 == COLLINEAR || o3 == COLLINEAR) return ON_BOUNDARY; - if (o2 == ON_NEGATIVE_SIDE && o3 == ON_NEGATIVE_SIDE) return ON_BOUNDARY; - return ON_UNBOUNDED_SIDE; - } - - if (o2 == COLLINEAR){ - if (o3 == COLLINEAR) return ON_BOUNDARY; - if (o3 == ON_NEGATIVE_SIDE && o1 == ON_NEGATIVE_SIDE) return ON_BOUNDARY; - return ON_UNBOUNDED_SIDE; - } - - if (o3 == COLLINEAR){ - if (o1 == ON_NEGATIVE_SIDE && o2 == ON_NEGATIVE_SIDE) return ON_BOUNDARY; - return ON_UNBOUNDED_SIDE; - } - - // from here none ot, o1, o2 and o3 are known to be non null - if (o1 == o2 && o2 == o3) return ON_BOUNDED_SIDE; - return ON_UNBOUNDED_SIDE; -} - - -template -Oriented_side -Triangulation_on_sphere_2:: -oriented_side(Face_handle f, const Point &p) const -{ - CGAL_triangulation_precondition ( dimension()==2); - return oriented_side(f->vertex(0)->point(), - f->vertex(1)->point(), - f->vertex(2)->point(), - p); -} -*/ template bool Triangulation_on_sphere_2:: @@ -1015,8 +898,7 @@ template bool Triangulation_on_sphere_2:: collinear_between(const Point& p, const Point& q, const Point& r) const -{ - // return true if r lies inside the cone defined by trait.sphere, p and q +{ // return true if r lies inside the cone defined by trait.sphere, p and q return geom_traits().inside_cone_2_object()(p,q,r); } //------------------------------------------------------------------------------DEBUG------------------------------------------------- @@ -1026,6 +908,7 @@ void Triangulation_on_sphere_2:: show_all() const { + //Triangulation_2::show_all(); std::cerr<< "AFFICHE TOUTE LA TRIANGULATION :"< "<< this; std::cerr << " dimension " << dimension() << std::endl; @@ -1071,7 +954,8 @@ number_of_negative_faces() { int nb=0; for(Faces_iterator it=faces_begin();it!=faces_end();++it) - {if(it->is_negative())nb++;} + if(it->is_negative()) + nb++; return nb; } @@ -1152,36 +1036,10 @@ template void Triangulation_on_sphere_2:: make_hole ( Vertex_handle v, std::list & hole) -{ - std::list to_delete; - - Face_handle f, fn; - int i, in ; - Vertex_handle vv; - - Face_circulator fc = incident_faces(v); - Face_circulator done(fc); - do { - f = fc; fc++; - i = f->index(v); - fn = f->neighbor(i); - in = fn->index(f); - vv = f->vertex(cw(i)); - if( vv->face()== f) vv->set_face(fn); - vv = f->vertex(ccw(i)); - if( vv->face()== f) vv->set_face(fn); - fn->set_neighbor(in, Face_handle()); - 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(); - } - return; +{ + return this->_tds.make_hole(v, hole); } + template inline void diff --git a/Triangulation_on_sphere_2/test/bugs_minimal_examples.cpp b/Triangulation_on_sphere_2/test/bugs_minimal_examples.cpp index 23d1501d630..217d47bd979 100644 --- a/Triangulation_on_sphere_2/test/bugs_minimal_examples.cpp +++ b/Triangulation_on_sphere_2/test/bugs_minimal_examples.cpp @@ -63,10 +63,7 @@ Vertex_handle v4 = rtos.insert(p4); rtos.is_valid(); rtos.remove(v5);*/ - - - - + //insert coplanar Points. Points are coplanar but not coplanar with the center of the sphere rtos.clear(); Point_3 p0 = Point_3(0,0,radius); @@ -82,7 +79,7 @@ Vertex_handle v4 = rtos.insert(p4); Vertex_handle v22 = rtos.insert(p22); Vertex_handle v23 = rtos.insert(p23); rtos.show_vertex(v23); - + Vertex_handle v24 = rtos.insert(p24); @@ -133,6 +130,11 @@ Vertex_handle v4 = rtos.insert(p4); rtos.show_all(); + rtos.remove(v27); + + + + diff --git a/Triangulation_on_sphere_2/test/test_random.cpp b/Triangulation_on_sphere_2/test/test_random.cpp new file mode 100644 index 00000000000..2bdc49bb986 --- /dev/null +++ b/Triangulation_on_sphere_2/test/test_random.cpp @@ -0,0 +1,145 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef CGAL::Regular_triangulation_sphere_traits_2 Gt; +typedef CGAL::Regular_triangulation_on_sphere_2 RTOS; +typedef RTOS::Vertex_handle Vertex_handle; +typedef RTOS::Face_handle Face_handle; +typedef RTOS::Point Point; +typedef RTOS::Faces_iterator Face_iterator; +typedef RTOS::Vertices_iterator Vertex_iterator; +typedef RTOS::Locate_type Locate_type; +typedef RTOS::Edge Edge; + + + + + +bool is_ok(K::Point_3 p, std::vector po, double minDist2, int ind) +{ + bool ok= true; + for(int j= 0; j Creator; + CGAL::Random_points_on_sphere_3 on_sphere(radius); + RTOS tos; + + std::vector points; + std::vector vertices; + vertices.reserve(nu_of_pts*2); + + + + for (int count=0; count #include #include diff --git a/Triangulation_on_sphere_2/test/test_regular_triangulation_on_sphere_2.cpp b/Triangulation_on_sphere_2/test/test_regular_triangulation_on_sphere_2.cpp deleted file mode 100644 index 195941ff067..00000000000 --- a/Triangulation_on_sphere_2/test/test_regular_triangulation_on_sphere_2.cpp +++ /dev/null @@ -1,867 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef CGAL::Regular_triangulation_sphere_traits_2 Gt; -typedef CGAL::Regular_triangulation_on_sphere_2 RTOS; -typedef RTOS::Vertex_handle Vertex_handle; -typedef RTOS::Face_handle Face_handle; -typedef RTOS::Point Point; -typedef RTOS::Faces_iterator Face_iterator; -typedef RTOS::Vertices_iterator Vertex_iterator; -typedef RTOS::Locate_type Locate_type; -typedef RTOS::Edge Edge; -typedef RTOS::Hidden_vertices_iterator Hidden_points_iterator; - -template -Stream &write_vertices(Stream &out,std::vector &t); - -template -Stream &write_vertices(Stream &out, Triangulation &t); - -template -Stream &write_points(Stream &out,std::vector &t); - -template -Stream &write_face_to_off(Stream &out, Face_handle loc); - -template -Stream &write_triangulation_to_off_2(Stream &out,Stream &out2, Triangulation &t); - -template -Stream &write_hpts_to_off(Stream &out, Triangulation &t); - -template -Stream &write_triangulation_to_off(Stream &out, Triangulation &t); - - -int main() -{ - RTOS tr_2_h; - RTOS tr_2_s; - RTOS tr; - RTOS tr2_1; - RTOS tr2_2; - RTOS tr2_3; - RTOS tr1_1; - RTOS tr0_1; - Locate_type lt; - int li; - Face_handle Loc_result; - Face_handle start; - - std::ofstream verts("verts.off"); - std::ofstream pos("pos.off"); - std::ofstream neg("neg.off"); - //std::ofstream pos2("pos2.off"); - //std::ofstream neg2("neg2.off"); - std::ofstream hpts("hpts.off"); - //std::ofstream hpts2("hpts2.off"); - - - /*--------------------------*/ - // TEST INPUTS // - /*--------------------------*/ - // SPHERES - Point S1=Point(0,0,0); - - - // POINTS - Point p1(1,0,0); - Point p2(0,1,0); - Point p3(0,0,1); - Point p4(-1/sqrt(3.),-1/sqrt(3.),-1/sqrt(3.)); - - //on a circle z=0 - Point P0=Point(1,0,0); - Point P1=Point(1/sqrt(2.),1/sqrt(2.),0); - Point P2=Point(0,1,0); - Point P3=Point(-1/sqrt(2.),1/sqrt(2.),0); - Point P4=Point(-1,0,0); - Point P5=Point(-1/sqrt(2.),-1/sqrt(2.),0); - Point P6=Point(1/sqrt(2.),-1/sqrt(2.),0); - Point P30=Point(0.5,0,0); - Point P31=Point(0.25,0.25,0); - Point P32=Point(0.5,0.25,0); - Point P33=Point(2,-0.25,0); - //on a line - Point P34=Point(1,1,0); - Point P35=Point(1,-1,0); - Point P36=Point(1,0.5,0); - Point P37=Point(2,2,0); - - //top tetrahedron - Point P15=Point(1/sqrt(2.),0,1/sqrt(2.)); - Point P9=Point(-0.5,-0.5,1/sqrt(2.)); - Point P10=Point(0,1/sqrt(2.),1/sqrt(2.)); - Point P11=Point(0,0,1); - Point P12=Point(-0.5,0.5,1/sqrt(2.)); - Point P13=Point(0.5,-0.5,1/sqrt(2.)); - Point P14=Point(0,-0.5,1/sqrt(2.));//edge P9,P13 - //Point P15=Point(0.25/sqrt(2.),0.25/sqrt(2.),0.5/sqrt(2.));//under edge - Point P16=Point(-0.5,0.5*(1+sqrt(2.)),2/sqrt(2.));//over edge - Point P17=Point(0.5,0,0.5); - Point P18=Point(-1/sqrt(2.),0,-1/sqrt(2.)); - Point P19=Point(0,0,-1); - Point P40=Point(-0.25,-0.25,0.5/sqrt(2.)); - Point P41=Point(-1,-1,2/sqrt(2.)); - Point P42=Point(0,0,0.5); - Point P43=Point(2,-0.5,1); - - Point P20=Point(0.5,0,0); - Point P21=Point(1,0,0); - Point P22=Point(2,0,0); - Vertex_handle v20; - Vertex_handle v21; - Vertex_handle v22; - - Point P23=Point(0,0.25,0.25); - Point P24=Point(0,0.5,0.5); - Vertex_handle v23; - Vertex_handle v24; - - Point P25=Point(0.75,0.25,0.1); - Point P26=Point(0.5,0.5,0.5); - Point P27=Point(1,1,1); - Vertex_handle v25; - Vertex_handle v26; - Vertex_handle v27; - Vertex_handle v0; - Vertex_handle vv1; - Vertex_handle vv0; - Vertex_handle v1; - Vertex_handle v2; - Vertex_handle v3; - Vertex_handle v4; - Vertex_handle v01; - Vertex_handle vv2; - Vertex_handle vv3; - Vertex_handle vv4; - Vertex_handle v5; - Vertex_handle v6; - Vertex_handle v7; - Vertex_handle v8; - Vertex_handle v9; - Vertex_handle v10; - Vertex_handle v11; - Vertex_handle v12; - Vertex_handle v13; - Vertex_handle v14; - Vertex_handle v15; - Vertex_handle v33; - Vertex_handle v16; - Vertex_handle v31; - Vertex_handle v34; - Vertex_handle v32; - Vertex_handle v19; - Vertex_handle v42; - Vertex_handle v37; - Vertex_handle vv33; - Vertex_handle vv34; - Vertex_handle vv31; - - std::list l; l.push_back(P15); - l.push_back(P9); l.push_back(P10); l.push_back(P19); - l.push_back(P0); l.push_back(P1); l.push_back(P2); - - std::vector v; v.push_back(P15); - v.push_back(P9); v.push_back(P10); v.push_back(P19); - v.push_back(P0); v.push_back(P1); v.push_back(P2); - - /*------------------------------*/ - /* INSERTION */ - /*------------------------------*/ - - - //dim-1 - std::cout<<"test insertion dim-1"<