diff --git a/Triangulation_on_sphere_2/include/CGAL/Projection_sphere_traits_3.h b/Triangulation_on_sphere_2/include/CGAL/Projection_sphere_traits_3.h new file mode 100644 index 00000000000..11238a4fa5e --- /dev/null +++ b/Triangulation_on_sphere_2/include/CGAL/Projection_sphere_traits_3.h @@ -0,0 +1,333 @@ + +#ifndef CGAL_PROJECTION_SPHERE-TRAITS_3_H +#define CGAL_PROJECTION_SPHERE-TRAITS_3_H + +#include +#include +#include + +namespace CGAL { + + + template + struct Projector { + static typename K::FT x(const typename K::Point_3& p) {return p.x();} + static typename K::FT y(const typename K::Point_3& p) {return p.y();} + static typename K::FT z(const typename K::Point_3& p) {return p.z();} + }; + + + template + class Power_test_2 + { + public: + typedef typename K::Point_2 Point_2; + typedef typename K::Oriented_side Oriented_side; + typedef typename K::Comparison_result Comparison_result; + + + typename K::FT x(const Point_2 &p) const { return Projector::x(p); } + typename K::FT y(const Point_2 &p) const { return Projector::y(p); } + typename K::FT z(const Point_2 &p) const { return Projector::z(p); } + + typename K::Point_2 project(const Point_2& p) const + { + return typename K::Point_2(x(p),y(p),z(p)); + } + + + + Power_test_2(const Point_2& sphere); + + Oriented_side operator() (const Point_2& p, + const Point_2& q, + const Point_2& r, + const Point_2& s) const + { + return orientation(project(p),project(q),project(r),project(s)); + + } + + + Oriented_side operator() (const Point_2& p, + const Point_2& q, + const Point_2& r) const + { + return -coplanar_orientation(project(p),project(q),project,_sphere,project(r)); + } + + + Oriented_side operator() (const Point_2& p, + const Point_2& q) const + { + Comparison_result pq=compare_xyz(project(p),project(q)); + + if(pq==EQUAL){ + return ON_ORIENTED_BOUNDARY; + } + Comparison_result sq=compare_xyz(_sphere,project(q)); + if(pq==sq){ + return ON_POSITIVE_SIDE; + } + return ON_NEGATIVE_SIDE; + } + + protected: + Point_2 _sphere; + }; + + + template < typename K > + class Orientation_sphere_1 + { + public: + typedef typename K::Point_2 Point_2; + typedef typename K::Comparison_result Comparison_result; + + Orientation_sphere_1(const Point_2& sphere); + + typename K::FT x(const Point_2 &p) const { return Projector::x(p); } + typename K::FT y(const Point_2 &p) const { return Projector::y(p); } + typename K::FT z(const Point_2 &p) const { return Projector::z(p); } + + typename K::Point_2 project(const Point_2& p) const + { + return typename K::Point_2(x(p),y(p),z(p)); + } + + + + + Comparison_result operator()(const Point_2& p, const Point_2& q) const + { + return coplanar_orientation(_sphere,project(p),project(q)); + } + + Comparison_result operator()(const Point_2& p, const Point_2& q, const Point_2& r) const + { + + return coplanar_orientation(project(p),project(q),project(r),_sphere); + } + + Comparison_result operator()(const Point_2& p, const Point_2& q, const Point_2& r,const Point_2& s) const + { + return coplanar_orientation(project(p),project(q),project(r),project(s)); + + } + + protected : + Point_2 _sphere; + }; + + template < typename K > + Orientation_sphere_1:: + Orientation_sphere_1(const Point_2& sphere) + : _sphere(sphere) + {} + + + + template < typename K > + class Orientation_sphere_2 + { + public: + typedef typename K::Point_2 Point_2; + typedef typename K::Comparison_result Comparison_result; + + typedef Comparison_result result_type; + + typename K::FT x(const Point_2 &p) const { return Projector::x(p); } + typename K::FT y(const Point_2 &p) const { return Projector::y(p); } + typename K::FT z(const Point_2 &p) const { return Projector::z(p); } + + typename K::Point_2 project(const Point_2& p) const + { + return typename K::Point_2(x(p),y(p),z(p)); + } + + + + Orientation_sphere_2(const Point_2& sphere); + + Comparison_result operator()(const Point_2& p, + const Point_2& q, + const Point_2& test) const + { + return orientation(_sphere,project(p),project(q),project(test)); + } + + Comparison_result operator()(const Point_2& p, const Point_2& q, + const Point_2& r, const Point_2 & s) const + { + return orientation(project(p),project(q),project(r),project(s)); + } + + + + protected : + Point_2 _sphere; + }; + template < typename K > + Orientation_sphere_2:: + Orientation_sphere_2(const Point_2& sphere) + : _sphere(sphere) + {} + + + template < typename K > + class Coradial_sphere_2 + { + public: + typedef typename K::Point_2 Point_2; + + Coradial_sphere_2(const Point_2& sphere); + + typename K::FT x(const Point_2 &p) const { return Projector::x(p); } + typename K::FT y(const Point_2 &p) const { return Projector::y(p); } + typename K::FT z(const Point_2 &p) const { return Projector::z(p); } + + typename K::Point_2 project(const Point_2& p) const + { + return typename K::Point_2(x(p),y(p),z(p)); + } + + + + bool operator()(const Point_2& p, const Point_2 q) const + { + return collinear(_sphere,project(p),project(q)) && + ( are_ordered_along_line(_sphere,project(p),project(q)) || are_ordered_along_line(_sphere,project(q),project(p)) ); + } + + protected : + Point_2 _sphere; + }; + + template < typename K > + Coradial_sphere_2:: + Coradial_sphere_2(const Point_2& sphere) + : _sphere(sphere) + {} + + + template < typename K > + class Inside_cone_2 + { + public: + typedef typename K::Point_2 Point_2; + + Inside_cone_2(const Point_2& sphere); + + typename K::FT x(const Point_2 &p) const { return Projector::x(p); } + typename K::FT y(const Point_2 &p) const { return Projector::y(p); } + typename K::FT z(const Point_2 &p) const { return Projector::z(p); } + + typename K::Point_2 project(const Point_2& p) const + { + return typename K::Point_2(x(p),y(p),z(p)); + } + + + bool operator()(const Point_2& p, const Point_2& q, const Point_2& r) const + { + if( collinear(_sphere,project(p),project(r))|| + collinear(_sphere,project(q),project(r))||orientation(_sphere,project(p),project(q),project(r))!=COLLINEAR) + return false; + if( collinear(_sphere,project(p),project(q)) ) + return true; + return coplanar_orientation(_sphere,project(p),project(q),project(r)) == + ( POSITIVE==coplanar_orientation(_sphere,project(q),project(p),project(r)) ); + } + + protected : + Point_2 _sphere; + }; + + template < typename K > + Inside_cone_2:: + Inside_cone_2(const Point_2& sphere) + : _sphere(sphere) + {} + + + template < typename K > + Power_test_2:: + Power_test_2(const Point_2& sphere) + : _sphere(sphere) + {} + + + + template < class R > + class Projection_sphere_traits_3 + : public R + { + public: + typedef typename R::Point_3 Point_2; + typedef typename R::Point_3 Weighted_point_2; + + + typedef Projection_sphere_traits_3 Self; + typedef CGAL::Power_test_2 Power_test_2; + typedef CGAL::Orientation_sphere_2 Orientation_2; + typedef CGAL::Coradial_sphere_2 Coradial_sphere_2; + typedef CGAL::Inside_cone_2 Inside_cone_2; + typedef CGAL::Orientation_sphere_1 Orientation_1; + + + typedef boost::false_type requires_test; + + + + Projection_sphere_traits_3(const Point_2& sphere=Point_2(0,0,0)); + + Orientation_2 + orientation_2_object()const + {return Orientation_2(_sphere);} + + Orientation_1 + orientation_1_object() const { + return Orientation_1(_sphere); + } + + Power_test_2 + power_test_2_object() const + { return Power_test_2(_sphere);} + + Coradial_sphere_2 + coradial_sphere_2_object() const + {return Coradial_sphere_2(_sphere);} + + Inside_cone_2 + inside_cone_2_object() const { + return Inside_cone_2(_sphere); + } + + protected : + Point_2 _sphere; + + }; + + template < class R > + Projection_sphere_traits_3 :: + Projection_sphere_traits_3(const Point_2& sphere) + : _sphere(sphere) + {} + + +} //namespace CGAL + +#endif // CGAL_Reg_TRIANGULATION_SPHERE_TRAITS_2_H + + + + + + + + + + + + + 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 a913eccfe87..0537b130668 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 @@ -972,8 +972,9 @@ bool Regular_triangulation_on_sphere_2:: 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 - std::cout<first; Vertex_handle v1=f->vertex(0); Vertex_handle v2=f->vertex(1); diff --git a/Triangulation_on_sphere_2/test/test_random.cpp b/Triangulation_on_sphere_2/test/test_random.cpp index 34ca7a49ab1..96619da3169 100644 --- a/Triangulation_on_sphere_2/test/test_random.cpp +++ b/Triangulation_on_sphere_2/test/test_random.cpp @@ -1,16 +1,18 @@ #include -#include +//#include +#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_sphere_traits_2 Gt; +typedef CGAL::Projection_sphere_traits_3 Gt; typedef CGAL::Regular_triangulation_on_sphere_2 RTOS; typedef RTOS::Vertex_handle Vertex_handle; typedef RTOS::Face_handle Face_handle; @@ -82,8 +84,8 @@ bool are_equal(RTOS triA, RTOS triB){ int main(){ int nu_of_pts; double radius; - nu_of_pts =100; - radius=100; + nu_of_pts =1000000; + radius=6000000; double minDist = radius * pow (2, -25); double minDist2 = pow(minDist, 2); int invalid = 0;