diff --git a/Circular_kernel_3/include/CGAL/Circle_3.h b/Circular_kernel_3/include/CGAL/Circle_3.h new file mode 100644 index 00000000000..9da37f5aa80 --- /dev/null +++ b/Circular_kernel_3/include/CGAL/Circle_3.h @@ -0,0 +1,133 @@ +// Copyright (c) 2005 INRIA Sophia-Antipolis (France) +// All rights reserved. +// +// Authors : Monique Teillaud +// Sylvain Pion +// Julien Hazebrouck +// Damien Leroy +// +// Partially supported by the IST Programme of the EU as a Shared-cost +// RTD (FET Open) Project under Contract No IST-2000-26473 +// (ECG - Effective Computational Geometry for Curves and Surfaces) +// and a STREP (FET Open) Project under Contract No IST-006413 +// (ACS -- Algorithms for Complex Shapes) + +#ifndef CGAL_CIRCLE_3_H +#define CGAL_CIRCLE_3_H + +namespace CGAL { + template + class Circle_3 + : public SK::Kernel_base::Circle_3 + { + + typedef typename SK::RT RT; + typedef typename SK::FT FT; + typedef typename SK::Point_3 Point_3; + typedef typename SK::Plane_3 Plane_3; + typedef typename SK::Sphere_3 Sphere_3; + typedef typename SK::Vector_3 Vector_3; + typedef typename SK::Direction_3 Direction_3; + typedef typename SK::Kernel_base::Circle_3 RCircle_3; + + + public: + typedef RCircle_3 Rep; + typedef SK R; + + const Rep& rep() const + { + return *this; + } + + Rep& rep() + { + return *this; + } + + Circle_3() + : RCircle_3(typename R::Construct_circle_3()()) + {} + + Circle_3(const Point_3& c, const FT& sr, const Plane_3& p) + : RCircle_3(typename R::Construct_circle_3()(c,sr,p)) + {} + + Circle_3(const Point_3& c, const FT& sr, const Direction_3& d) + : RCircle_3(typename R::Construct_circle_3()(c,sr,d)) + {} + + Circle_3(const Point_3& c, const FT& sr, const Vector_3& v) + : RCircle_3(typename R::Construct_circle_3()(c,sr,v)) + {} + + Circle_3(const Sphere_3& s1, const Sphere_3& s2) + : RCircle_3(typename R::Construct_circle_3()(s1,s2)) + {} + + Circle_3(const Sphere_3& s, const Plane_3& p) + : RCircle_3(typename R::Construct_circle_3()(s,p)) + {} + + Circle_3(const Plane_3& p, const Sphere_3& s) + : RCircle_3(typename R::Construct_circle_3()(p,s)) + {} + + Circle_3(const RCircle_3& r) + : RCircle_3(r) + {} + + typename Qualified_result_of + ::type + //const Sphere_3 & + diametral_sphere() const + { + return typename R::Construct_diametral_sphere_3()(*this); + } + + Point_3 center() const + { + return typename R::Construct_diametral_sphere_3()(*this).center(); + } + + FT squared_radius() const + { + return typename R::Construct_diametral_sphere_3()(*this).squared_radius(); + } + + typename Qualified_result_of + ::type + //const Plane_3 & + supporting_plane() const + { + return typename R::Construct_supporting_plane_3()(*this); + } + + Bbox_3 bbox() const + { return typename R::Construct_bbox_3()(*this); } + + }; + +template < typename SK > +inline +bool +operator==(const Circle_3 &p, + const Circle_3 &q) +{ + return SK().equal_3_object()(p, q); +} + +template < typename SK > +inline +bool +operator!=(const Circle_3 &p, + const Circle_3 &q) +{ + return ! (p == q); +} + + + +} + +#endif diff --git a/Circular_kernel_3/include/CGAL/Circular_arc_point_3.h b/Circular_kernel_3/include/CGAL/Circular_arc_point_3.h new file mode 100644 index 00000000000..bb4442ec2eb --- /dev/null +++ b/Circular_kernel_3/include/CGAL/Circular_arc_point_3.h @@ -0,0 +1,209 @@ +// Copyright (c) 2005 INRIA Sophia-Antipolis (France) +// All rights reserved. +// +// Authors : Monique Teillaud +// Sylvain Pion +// Julien Hazebrouck +// Damien Leroy +// +// Partially supported by the IST Programme of the EU as a Shared-cost +// RTD (FET Open) Project under Contract No IST-2000-26473 +// (ECG - Effective Computational Geometry for Curves and Surfaces) +// and a STREP (FET Open) Project under Contract No IST-006413 +// (ACS -- Algorithms for Complex Shapes) + + +#ifndef CGAL_CIRCULAR_ARC_POINT_3_H +#define CGAL_CIRCULAR_ARC_POINT_3_H +namespace CGAL { + +template < typename SphericalKernel > +class Circular_arc_point_3 + : public SphericalKernel::Kernel_base::Circular_arc_point_3 +{ + typedef typename SphericalKernel::Kernel_base::Circular_arc_point_3 + RCircular_arc_point_3; + + typedef typename SphericalKernel::Root_of_2 Root_of_2; + typedef typename SphericalKernel::Point_3 Point_3; + typedef typename SphericalKernel::Plane_3 Plane_3; + typedef typename SphericalKernel::Line_3 Line_3; + typedef typename SphericalKernel::Circle_3 Circle_3; + typedef typename SphericalKernel::Sphere_3 Sphere_3; + +public: + typedef typename SphericalKernel::Root_for_spheres_2_3 + Root_for_spheres_2_3; + typedef SphericalKernel R; + typedef RCircular_arc_point_3 Rep; + + const Rep& rep() const + { + return *this; + } + + Rep& rep() + { + return *this; + } + + Circular_arc_point_3() + : RCircular_arc_point_3( + typename R::Construct_circular_arc_point_3()()) + {} + + Circular_arc_point_3(const Root_of_2 & x, + const Root_of_2 & y, + const Root_of_2 & z) + : RCircular_arc_point_3( + typename R::Construct_circular_arc_point_3()(x,y,z)) + {} + + + Circular_arc_point_3(const Root_for_spheres_2_3 & np) + : RCircular_arc_point_3( + typename R::Construct_circular_arc_point_3()(np)) + {} + + Circular_arc_point_3(const RCircular_arc_point_3 & p) + : RCircular_arc_point_3(p) + {} + + Circular_arc_point_3(const Point_3 & p) + : RCircular_arc_point_3( + typename R::Construct_circular_arc_point_3()(p)) + {} + + Circular_arc_point_3(const Sphere_3 & s1, + const Sphere_3 & s2, + const Sphere_3 & s3, + const bool less_xyz = true) + : RCircular_arc_point_3( + typename R::Construct_circular_arc_point_3()(s1,s2,s3,less_xyz)) + {} + + Circular_arc_point_3(const Plane_3 & p, + const Sphere_3 & s1, + const Sphere_3 & s2, + const bool less_xyz = true) + : RCircular_arc_point_3( + typename R::Construct_circular_arc_point_3()(p,s1,s2,less_xyz)) + {} + + Circular_arc_point_3(const Sphere_3 & s1, + const Plane_3 & p, + const Sphere_3 & s2, + const bool less_xyz = true) + : RCircular_arc_point_3( + typename R::Construct_circular_arc_point_3()(s1,p,s2,less_xyz)) + {} + + Circular_arc_point_3(const Sphere_3 & s1, + const Sphere_3 & s2, + const Plane_3 & p, + const bool less_xyz = true) + : RCircular_arc_point_3( + typename R::Construct_circular_arc_point_3()(s1,s2,p,less_xyz)) + {} + + Circular_arc_point_3(const Plane_3 & p1, + const Plane_3 & p2, + const Sphere_3 & s, + const bool less_xyz = true) + : RCircular_arc_point_3( + typename R::Construct_circular_arc_point_3()(p1,p2,s,less_xyz)) + {} + + Circular_arc_point_3(const Plane_3 & p1, + const Sphere_3 & s, + const Plane_3 & p2, + const bool less_xyz = true) + : RCircular_arc_point_3( + typename R::Construct_circular_arc_point_3()(p1,s,p2,less_xyz)) + {} + + Circular_arc_point_3(const Sphere_3 & s, + const Plane_3 & p1, + const Plane_3 & p2, + const bool less_xyz = true) + : RCircular_arc_point_3( + typename R::Construct_circular_arc_point_3()(s,p1,p2,less_xyz)) + {} + + Circular_arc_point_3(const Line_3 & l, + const Sphere_3 & s, + const bool less_xyz = true) + : RCircular_arc_point_3( + typename R::Construct_circular_arc_point_3()(l,s,less_xyz)) + {} + + Circular_arc_point_3(const Sphere_3 & s, + const Line_3 & l, + const bool less_xyz = true) + : RCircular_arc_point_3( + typename R::Construct_circular_arc_point_3()(s,l,less_xyz)) + {} + + Circular_arc_point_3(const Circle_3 & c, + const Sphere_3 & s, + const bool less_xyz = true) + : RCircular_arc_point_3( + typename R::Construct_circular_arc_point_3()(c,s,less_xyz)) + {} + + Circular_arc_point_3(const Sphere_3 & s, + const Circle_3 & c, + const bool less_xyz = true) + : RCircular_arc_point_3( + typename R::Construct_circular_arc_point_3()(s,c,less_xyz)) + {} + + Circular_arc_point_3(const Circle_3 & c, + const Plane_3 & p, + const bool less_xyz = true) + : RCircular_arc_point_3( + typename R::Construct_circular_arc_point_3()(c,p,less_xyz)) + {} + + Circular_arc_point_3(const Sphere_3 & s, + const Plane_3 & p, + const bool less_xyz = true) + : RCircular_arc_point_3( + typename R::Construct_circular_arc_point_3()(s,p,less_xyz)) + {} + + + + typename Qualified_result_of::type + //const Root_of_2 & + x() const + { return typename R::Compute_circular_x_3()(*this);} + + typename Qualified_result_of::type + //const Root_of_2 & + y() const + { return typename R::Compute_circular_y_3()(*this);} + + typename Qualified_result_of::type + //const Root_of_2 & + z() const + { return typename R::Compute_circular_z_3()(*this);} + + Bbox_3 bbox() const + { return typename R::Construct_bbox_3()(*this); } + +}; + + template < class SK > +std::ostream& +operator<<(std::ostream &os, const Circular_arc_point_3 &p) +{ + //I can make it because I know the output format of Root_for_circle + return os << p.x() << " " << p.y() << " " << p.z() << " " ; +} + + + + +} +#endif diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/Circle_3.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/Circle_3.h new file mode 100644 index 00000000000..3c15bd7e5d4 --- /dev/null +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/Circle_3.h @@ -0,0 +1,171 @@ +// Copyright (c) 2005 INRIA Sophia-Antipolis (France) +// All rights reserved. +// +// Authors : Monique Teillaud +// Sylvain Pion +// Julien Hazebrouck +// Damien Leroy +// +// Partially supported by the IST Programme of the EU as a Shared-cost +// RTD (FET Open) Project under Contract No IST-2000-26473 +// (ECG - Effective Computational Geometry for Curves and Surfaces) +// and a STREP (FET Open) Project under Contract No IST-006413 +// (ACS -- Algorithms for Complex Shapes) + +#ifndef CGAL_SPHERICAL_KERNEL_CIRCLE_3_H +#define CGAL_SPHERICAL_KERNEL_CIRCLE_3_H + +#include + +namespace CGAL { + namespace CGALi{ + template class Circle_3 { + + typedef typename SK::Plane_3 Plane_3; + typedef typename SK::Sphere_3 Sphere_3; + typedef typename SK::Point_3 Point_3; + typedef typename SK::Vector_3 Vector_3; + typedef typename SK::Direction_3 Direction_3; + typedef typename SK::FT FT; + + private: + typedef std::pair Rep; + typedef typename SK::template Handle::type Base; + + Base base; + + public: + Circle_3() {} + + Circle_3(const Point_3& center, const FT& squared_r, const Direction_3& d) + { + // It is not allowed non-positive radius + // Should we keep this pre-condition? + CGAL_kernel_assertion(squared_r > 0); + base = Rep(Sphere_3(center,squared_r), + plane_from_point_direction(center, d)); + } + + Circle_3(const Point_3& center, const FT& squared_r, const Vector_3& normal) + { + // It is not allowed non-positive radius + // Should we keep this pre-condition? + CGAL_kernel_assertion(squared_r > 0); + base = Rep(Sphere_3(center,squared_r), + plane_from_point_direction(center, normal.direction())); + } + + Circle_3(const Point_3& center, const FT& squared_r, const Plane_3& p) + { + // the plane contains the center + CGAL_kernel_assertion((p.a() * center.x() + + p.b() * center.y() + + p.c() * center.z() + + p.d()) == ZERO); + // It is not allowed non-positive radius + // Should we keep this pre-condition? + CGAL_kernel_assertion(squared_r > 0); + base = Rep(Sphere_3(center,squared_r), p); + } + + Circle_3(const Sphere_3 &s1, + const Sphere_3 &s2) { + std::vector sols; + SK().intersect_3_object()(s1, s2, std::back_inserter(sols)); + // s1,s2 must intersect + CGAL_kernel_precondition(sols.size() != 0); + typename SK::Circle_3 circle; + // the intersection must be a circle (no point allowed) + CGAL_kernel_precondition(assign(circle,sols[0])); + assign(circle,sols[0]); + *this = circle.rep(); + } + + Circle_3(const Plane_3 &p, + const Sphere_3 &s) { + std::vector sols; + SK().intersect_3_object()(p, s, std::back_inserter(sols)); + // s1,s2 must intersect + CGAL_kernel_precondition(sols.size() != 0); + typename SK::Circle_3 circle; + // the intersection must be a circle (no point allowed) + CGAL_kernel_precondition(assign(circle,sols[0])); + assign(circle,sols[0]); + *this = circle.rep(); + } + + const Plane_3& supporting_plane() const { + return get(base).second; + } + + Point_3 center() const { + return get(base).first.center(); + } + + FT squared_radius() const { + return get(base).first.squared_radius(); + } + + const Sphere_3& diametral_sphere() const { + return get(base).first; + } + + // this bbox function + // can be optimize by doing different cases + // for each variable = 0 (cases with is_zero) + const CGAL::Bbox_3 bbox() const { + typedef CGAL::Interval_nt Interval; + CGAL::Interval_nt::Protector ip; + const Plane_3 &plane = supporting_plane(); + const Point_3 &p = center(); + const FT &sq_r = squared_radius(); + const Interval a = CGAL::to_interval(plane.a()); + const Interval b = CGAL::to_interval(plane.b()); + const Interval c = CGAL::to_interval(plane.c()); + const Interval x = CGAL::to_interval(p.x()); + const Interval y = CGAL::to_interval(p.y()); + const Interval z = CGAL::to_interval(p.z()); + const Interval r2 = CGAL::to_interval(sq_r); + const Interval r = CGAL::sqrt(r2); // maybe we can work with r2 + // in order to save this operation + // but if the coefficients are to high + // the multiplication would lead to inf results + const Interval a2 = CGAL::square(a); + const Interval b2 = CGAL::square(b); + const Interval c2 = CGAL::square(c); + const Interval sqr_sum = a2 + b2 + c2; + const Interval mx = r * CGAL::sqrt((sqr_sum - a2)/sqr_sum); + const Interval my = r * CGAL::sqrt((sqr_sum - b2)/sqr_sum); + const Interval mz = r * CGAL::sqrt((sqr_sum - c2)/sqr_sum); + return CGAL::Bbox_3((x-mx).inf(),(y-my).inf(), (z-mz).inf(), + (x+mx).sup(),(y+my).sup(), (z+mz).sup()); + } + + bool operator==(const Circle_3 &) const; + bool operator!=(const Circle_3 &) const; + + }; + + template < class SK > + CGAL_KERNEL_INLINE + bool + Circle_3::operator==(const Circle_3 &t) const + { + if (CGAL::identical(base, t.base)) + return true; + return CGAL::SphericalFunctors::non_oriented_equal(*this, t); + } + + template < class SK > + CGAL_KERNEL_INLINE + bool + Circle_3::operator!=(const Circle_3 &t) const + { + return !(*this == t); + } + + } +} + +#endif + diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/Circular_arc_point_3.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/Circular_arc_point_3.h new file mode 100644 index 00000000000..dd608245b4a --- /dev/null +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/Circular_arc_point_3.h @@ -0,0 +1,251 @@ +// Copyright (c) 2005 INRIA Sophia-Antipolis (France) +// All rights reserved. +// +// Authors : Monique Teillaud +// Sylvain Pion +// Julien Hazebrouck +// Damien Leroy +// +// Partially supported by the IST Programme of the EU as a Shared-cost +// RTD (FET Open) Project under Contract No IST-2000-26473 +// (ECG - Effective Computational Geometry for Curves and Surfaces) +// and a STREP (FET Open) Project under Contract No IST-006413 +// (ACS -- Algorithms for Complex Shapes) + + +#ifndef CGAL_SPHERICAL_KERNEL_CIRCULAR_ARC_POINT_3_H +#define CGAL_SPHERICAL_KERNEL_CIRCULAR_ARC_POINT_3_H + +#include +#include + +//#include +// fixme, devrait +// appeler fonction de global_functions_on_circular_arcs + +namespace CGAL { + namespace CGALi { + +template +class Circular_arc_point_3 +{ + typedef typename SK::FT FT; + typedef typename SK::Root_of_2 Root_of_2; + typedef typename SK::Point_3 Point_3; + typedef typename SK::Algebraic_kernel AK; + typedef typename AK::Polynomial_for_spheres_2_3 Polynomial_for_spheres_2_3; + typedef typename AK::Polynomial_1_3 Polynomial_1_3; + typedef typename AK::Polynomials_for_line_3 Polynomials_for_line_3; + typedef typename SK::Line_3 Line_3; + typedef typename SK::Plane_3 Plane_3; + typedef typename SK::Sphere_3 Sphere_3; + typedef typename SK::Circle_3 Circle_3; + typedef typename SK::Root_for_spheres_2_3 Root_for_spheres_2_3; + + typedef Root_for_spheres_2_3 Rep; + typedef typename SK::template Handle::type Base; + + Base base; + +public: + + Circular_arc_point_3() {} + + Circular_arc_point_3(const Root_of_2 & x, + const Root_of_2 & y, + const Root_of_2 & z) + : base(x,y,z){} + + Circular_arc_point_3(const Root_for_spheres_2_3 & np) + : base(np){} + + Circular_arc_point_3(const Point_3 & p) + : base(p.x(),p.y(),p.z()){} + + Circular_arc_point_3(const Sphere_3 &s1, + const Sphere_3 &s2, + const Sphere_3 &s3, + const bool less_xyz = true) { + std::vector sols; + SK().intersect_3_object()(s1, s2, s3, std::back_inserter(sols)); + // s1,s2,s3 must intersect + CGAL_kernel_precondition(sols.size() != 0); + if(sols.size() == 1) { + std::pair pair; + // the intersection must be a point + CGAL_kernel_precondition(assign(pair,sols[0])); + assign(pair,sols[0]); + *this = pair.first.rep(); + } else { + std::pair pair; + // the intersections must be a point + CGAL_kernel_precondition(assign(pair,sols[0])); + CGAL_kernel_precondition(assign(pair,sols[1])); + assign(pair,sols[less_xyz?0:1]); + *this = pair.first.rep(); + } + } + + Circular_arc_point_3(const Plane_3 &p, + const Sphere_3 &s1, + const Sphere_3 &s2, + const bool less_xyz = true) { + std::vector sols; + SK().intersect_3_object()(p, s1, s2, std::back_inserter(sols)); + // s1,s2,s3 must intersect + CGAL_kernel_precondition(sols.size() != 0); + if(sols.size() == 1) { + std::pair pair; + // the intersection must be a point + CGAL_kernel_precondition(assign(pair,sols[0])); + assign(pair,sols[0]); + *this = pair.first.rep(); + } else { + std::pair pair; + // the intersections must be a point + CGAL_kernel_precondition(assign(pair,sols[0])); + CGAL_kernel_precondition(assign(pair,sols[1])); + assign(pair,sols[less_xyz?0:1]); + *this = pair.first.rep(); + } + } + + Circular_arc_point_3(const Plane_3 &p1, + const Plane_3 &p2, + const Sphere_3 &s, + const bool less_xyz = true) { + std::vector sols; + SK().intersect_3_object()(p1, p2, s, std::back_inserter(sols)); + // s1,s2,s3 must intersect + CGAL_kernel_precondition(sols.size() != 0); + if(sols.size() == 1) { + std::pair pair; + // the intersection must be a point + CGAL_kernel_precondition(assign(pair,sols[0])); + assign(pair,sols[0]); + *this = pair.first.rep(); + } else { + std::pair pair; + // the intersections must be a point + CGAL_kernel_precondition(assign(pair,sols[0])); + CGAL_kernel_precondition(assign(pair,sols[1])); + assign(pair,sols[less_xyz?0:1]); + *this = pair.first.rep(); + } + } + + Circular_arc_point_3(const Line_3 &l, + const Sphere_3 &s, + const bool less_xyz = true) { + std::vector sols; + SK().intersect_3_object()(l, s, std::back_inserter(sols)); + // s1,s2,s3 must intersect + CGAL_kernel_precondition(sols.size() != 0); + if(sols.size() == 1) { + std::pair pair; + // the intersection must be a point + CGAL_kernel_precondition(assign(pair,sols[0])); + assign(pair,sols[0]); + *this = pair.first.rep(); + } else { + std::pair pair; + // the intersections must be a point + CGAL_kernel_precondition(assign(pair,sols[0])); + CGAL_kernel_precondition(assign(pair,sols[1])); + assign(pair,sols[less_xyz?0:1]); + *this = pair.first.rep(); + } + } + + Circular_arc_point_3(const Circle_3 &c, + const Plane_3 &p, + const bool less_xyz = true) { + std::vector sols; + SK().intersect_3_object()(c, p, std::back_inserter(sols)); + // s1,s2,s3 must intersect + CGAL_kernel_precondition(sols.size() != 0); + if(sols.size() == 1) { + std::pair pair; + // the intersection must be a point + CGAL_kernel_precondition(assign(pair,sols[0])); + assign(pair,sols[0]); + *this = pair.first.rep(); + } else { + std::pair pair; + // the intersections must be a point + CGAL_kernel_precondition(assign(pair,sols[0])); + CGAL_kernel_precondition(assign(pair,sols[1])); + assign(pair,sols[less_xyz?0:1]); + *this = pair.first.rep(); + } + } + + Circular_arc_point_3(const Circle_3 &c, + const Sphere_3 &s, + const bool less_xyz = true) { + std::vector sols; + SK().intersect_3_object()(c, s, std::back_inserter(sols)); + // s1,s2,s3 must intersect + CGAL_kernel_precondition(sols.size() != 0); + if(sols.size() == 1) { + std::pair pair; + // the intersection must be a point + CGAL_kernel_precondition(assign(pair,sols[0])); + assign(pair,sols[0]); + *this = pair.first.rep(); + } else { + std::pair pair; + // the intersections must be a point + CGAL_kernel_precondition(assign(pair,sols[0])); + CGAL_kernel_precondition(assign(pair,sols[1])); + assign(pair,sols[less_xyz?0:1]); + *this = pair.first.rep(); + } + } + + const Root_of_2 & x() const { return get(base).x(); } + const Root_of_2 & y() const { return get(base).y(); } + const Root_of_2 & z() const { return get(base).z(); } + + const Root_for_spheres_2_3 & coordinates() const { return get(base); } + + const CGAL::Bbox_3 bbox() const { + return get(base).bbox(); + } + + bool operator==(const Circular_arc_point_3 &) const; + bool operator!=(const Circular_arc_point_3 &) const; + +}; + +template < class SK > +CGAL_KERNEL_INLINE +bool +Circular_arc_point_3::operator==(const Circular_arc_point_3 &t) const +{ + if (CGAL::identical(base, t.base)) + return true; + return x() == t.x() && + y() == t.y() && + z() == t.z(); +} + +template < class SK > +CGAL_KERNEL_INLINE +bool +Circular_arc_point_3::operator!=(const Circular_arc_point_3 &t) const +{ + return !(*this == t); +} + +template < typename SK > +std::ostream & +print(std::ostream & os, const Circular_arc_point_3 &p) +{ + return os << "CirclArcEndPoint_3(" << p.x() << ", " << p.y() << ')' << std::endl; +} + + } // namespace CGALi +} // namespace CGAL + +#endif // CGAL_SPHERICAL_KERNEL_CIRCULAR_ARC_POINT_3_H diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/Line_arc_3.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/Line_arc_3.h new file mode 100644 index 00000000000..4aa4489e60b --- /dev/null +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/Line_arc_3.h @@ -0,0 +1,220 @@ +// Copyright (c) 2005 INRIA Sophia-Antipolis (France) +// All rights reserved. +// +// Authors : Monique Teillaud +// Sylvain Pion +// Julien Hazebrouck +// Damien Leroy +// +// Partially supported by the IST Programme of the EU as a Shared-cost +// RTD (FET Open) Project under Contract No IST-2000-26473 +// (ECG - Effective Computational Geometry for Curves and Surfaces) +// and a STREP (FET Open) Project under Contract No IST-006413 +// (ACS -- Algorithms for Complex Shapes) + +#ifndef CGAL_SPHERICAL_KERNEL_LINE_ARC_3_H +#define CGAL_SPHERICAL_KERNEL_LINE_ARC_3_H + +#include + +namespace CGAL { + namespace CGALi{ + template class Line_arc_3 { + + typedef typename SK::Plane_3 Plane_3; + typedef typename SK::Sphere_3 Sphere_3; + typedef typename SK::Point_3 Point_3; + typedef typename SK::Segment_3 Segment_3; + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef typename SK::Line_3 Line_3; + typedef typename SK::FT FT; + + private: + typedef Triple Rep; + typedef typename SK::template Handle::type Base; + + Base base; + mutable unsigned char begin_less_xyz_than_end_flag; + + bool begin_less_xyz_than_end() const { + if(begin_less_xyz_than_end_flag == 0) { + if(SK().compare_xyz_3_object()(source(), target()) < 0) + begin_less_xyz_than_end_flag = 2; + else begin_less_xyz_than_end_flag = 1; + } return begin_less_xyz_than_end_flag == 2; + } + + public: + Line_arc_3() + : begin_less_xyz_than_end_flag(0) + {} + + Line_arc_3(const Line_3 &l, + const Circular_arc_point_3 &s, + const Circular_arc_point_3 &t) + : begin_less_xyz_than_end_flag(0) + { + // l must pass through s and t, and s != t + CGAL_kernel_precondition(SK().has_on_3_object()(l,s)); + CGAL_kernel_precondition(SK().has_on_3_object()(l,t)); + CGAL_kernel_precondition(s != t); + base = Rep(l,s,t); + } + + Line_arc_3(const Segment_3 &s) + : begin_less_xyz_than_end_flag(0) + { + base = Rep(s.supporting_line(), + s.source(), + s.target()); + } + + Line_arc_3(const Line_3 &l, + const Point_3 &s, + const Point_3 &t) + : begin_less_xyz_than_end_flag(0) + { + // l must pass through s and t, and s != t + CGAL_kernel_precondition(SK().has_on_3_object()(l,s)); + CGAL_kernel_precondition(SK().has_on_3_object()(l,t)); + CGAL_kernel_precondition(Circular_arc_point_3(s) != + Circular_arc_point_3(t)); + base = Rep(l,s,t); + } + + Line_arc_3(const Line_3 &l, + const Point_3 &s, + const Circular_arc_point_3 &t) + : begin_less_xyz_than_end_flag(0) + { + // l must pass through s and t, and s != t + CGAL_kernel_precondition(SK().has_on_3_object()(l,s)); + CGAL_kernel_precondition(SK().has_on_3_object()(l,t)); + CGAL_kernel_precondition(Circular_arc_point_3(s) != t); + base = Rep(l,s,t); + } + + Line_arc_3(const Line_3 &l, + const Circular_arc_point_3 &s, + const Point_3 &t) + : begin_less_xyz_than_end_flag(0) + { + // l must pass through s and t, and s != t + CGAL_kernel_precondition(SK().has_on_3_object()(l,s)); + CGAL_kernel_precondition(SK().has_on_3_object()(l,t)); + CGAL_kernel_precondition(s != Circular_arc_point_3(t)); + base = Rep(l,s,t); + } + + Line_arc_3(const Line_3 &l, + const Sphere_3 &s, + bool less_xyz_first = true) + { + std::vector sols; + SK().intersect_3_object()(l, s, std::back_inserter(sols)); + // l must intersect s in 2 points + std::pair pair1, pair2; + CGAL_kernel_precondition(sols.size() == 2); + assign(pair1,sols[0]); + assign(pair2,sols[1]); + if(less_xyz_first) { + *this = Line_arc_3(l, pair1.first, pair2.first); + } else { + *this = Line_arc_3(l, pair2.first, pair1.first); + } + } + + Line_arc_3(const Line_3 &l, + const Sphere_3 &s1, bool less_xyz_s1, + const Sphere_3 &s2, bool less_xyz_s2) + { + std::vector sols1, sols2; + SK().intersect_3_object()(l, s1, std::back_inserter(sols1)); + SK().intersect_3_object()(l, s2, std::back_inserter(sols2)); + std::pair pair1, pair2; + // l must intersect s1 and s2 + CGAL_kernel_precondition(sols1.size() > 0); + CGAL_kernel_precondition(sols2.size() > 0); + assign(pair1,sols1[(sols1.size()==1)?(0):(less_xyz_s1?0:1)]); + assign(pair2,sols2[(sols2.size()==1)?(0):(less_xyz_s2?0:1)]); + // the source and target must be different + CGAL_kernel_precondition(pair1.first != pair2.first); + *this = Line_arc_3(l, pair1.first, pair2.first); + } + + Line_arc_3(const Line_3 &l, + const Plane_3 &p1, + const Plane_3 &p2) + { + // l must not be on p1 or p2 + CGAL_kernel_precondition(!SK().has_on_3_object()(p1,l)); + CGAL_kernel_precondition(!SK().has_on_3_object()(p2,l)); + typename SK::Point_3 point1, point2; + // l must intersect p1 and p2 + assert(assign(point1,SK().intersect_3_object()(l, p1))); + assert(assign(point2,SK().intersect_3_object()(l, p2))); + assign(point1,SK().intersect_3_object()(l, p1)); + assign(point2,SK().intersect_3_object()(l, p2)); + // the source and target must be different + CGAL_kernel_precondition(point1 != point2); + *this = Line_arc_3(l, point1, point2); + } + + const Line_3& supporting_line() const + { + return get(base).first; + } + + const Circular_arc_point_3& source() const + { + return get(base).second; + } + + const Circular_arc_point_3& target() const + { + return get(base).third; + } + + const Circular_arc_point_3& lower_xyz_extremity() const + { + return begin_less_xyz_than_end() ? source() : target(); + } + + const Circular_arc_point_3& higher_xyz_extremity() const + { + return begin_less_xyz_than_end() ? target() : source(); + } + + const CGAL::Bbox_3 bbox() const { + return source().bbox() + target().bbox(); + } + + bool operator==(const Line_arc_3 &) const; + bool operator!=(const Line_arc_3 &) const; + + }; + + template < class SK > + CGAL_KERNEL_INLINE + bool + Line_arc_3::operator==(const Line_arc_3 &t) const + { + if (CGAL::identical(base, t.base)) + return true; + return CGAL::SphericalFunctors::non_oriented_equal(*this, t); + } + + template < class SK > + CGAL_KERNEL_INLINE + bool + Line_arc_3::operator!=(const Line_arc_3 &t) const + { + return !(*this == t); + } + + } +} + +#endif + diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/function_objects_polynomial_sphere.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/function_objects_polynomial_sphere.h new file mode 100644 index 00000000000..a6358a6b34f --- /dev/null +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/function_objects_polynomial_sphere.h @@ -0,0 +1,1162 @@ +// Copyright (c) 2005 INRIA Sophia-Antipolis (France) +// All rights reserved. +// +// Authors : Monique Teillaud +// Sylvain Pion +// Julien Hazebrouck +// Damien Leroy +// +// Partially supported by the IST Programme of the EU as a Shared-cost +// RTD (FET Open) Project under Contract No IST-2000-26473 +// (ECG - Effective Computational Geometry for Curves and Surfaces) +// and a STREP (FET Open) Project under Contract No IST-006413 +// (ACS -- Algorithms for Complex Shapes) + +#ifndef CGAL_SPHERICAL_KERNEL_FUNCTION_OBJECTS_POLYNOMIAL_SPHERE_H +#define CGAL_SPHERICAL_KERNEL_FUNCTION_OBJECTS_POLYNOMIAL_SPHERE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace CGAL { +namespace SphericalFunctors { + + template < class SK > + class Compare_x_3 + : public SK::Linear_kernel::Compare_x_3 + { + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef typename SK::Point_3 Point_3; + + public: + typedef CGAL::Comparison_result result_type; + typedef Arity_tag<2> Arity; + + using SK::Linear_kernel::Compare_x_3::operator(); + + result_type + operator() (const Circular_arc_point_3 &p0, + const Circular_arc_point_3 &p1) const + { return compare_x(p0, p1);} + + result_type + operator() (const Circular_arc_point_3 &p0, + const Point_3 &p1) const + { return compare_x(p0, p1);} + + result_type + operator() (const Point_3 &p0, + const Circular_arc_point_3 &p1) const + { return compare_x(p0, p1);} + + }; + + template < class SK > + class Compare_y_3 + : public SK::Linear_kernel::Compare_y_3 + { + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef typename SK::Point_3 Point_3; + + public: + typedef CGAL::Comparison_result result_type; + typedef Arity_tag<2> Arity; + + using SK::Linear_kernel::Compare_x_3::operator(); + + result_type + operator() (const Circular_arc_point_3 &p0, + const Circular_arc_point_3 &p1) const + { return compare_y(p0, p1);} + + result_type + operator() (const Circular_arc_point_3 &p0, + const Point_3 &p1) const + { return compare_y(p0, p1);} + + result_type + operator() (const Point_3 &p0, + const Circular_arc_point_3 &p1) const + { return compare_y(p0, p1);} + + }; + + template < class SK > + class Compare_z_3 + : public SK::Linear_kernel::Compare_z_3 + { + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef typename SK::Point_3 Point_3; + + public: + typedef CGAL::Comparison_result result_type; + typedef Arity_tag<2> Arity; + + using SK::Linear_kernel::Compare_x_3::operator(); + + result_type + operator() (const Circular_arc_point_3 &p0, + const Circular_arc_point_3 &p1) const + { return compare_z(p0, p1);} + + result_type + operator() (const Circular_arc_point_3 &p0, + const Point_3 &p1) const + { return compare_z(p0, p1);} + + result_type + operator() (const Point_3 &p0, + const Circular_arc_point_3 &p1) const + { return compare_z(p0, p1);} + + }; + + template < class SK > + class Compare_xy_3 + : public SK::Linear_kernel::Compare_xy_3 + { + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef typename SK::Point_3 Point_3; + + public: + typedef CGAL::Comparison_result result_type; + typedef Arity_tag<2> Arity; + + using SK::Linear_kernel::Compare_xy_3::operator(); + + result_type + operator() (const Circular_arc_point_3 &p0, + const Circular_arc_point_3 &p1) const + { return compare_xy(p0, p1);} + + result_type + operator() (const Circular_arc_point_3 &p0, + const Point_3 &p1) const + { return compare_xy(p0, p1);} + + result_type + operator() (const Point_3 &p0, + const Circular_arc_point_3 &p1) const + { return compare_xy(p0, p1);} + + }; + +template < class SK > + class Compare_xyz_3 + : public SK::Linear_kernel::Compare_xyz_3 + { + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef typename SK::Point_3 Point_3; + + public: + typedef CGAL::Comparison_result result_type; + typedef Arity_tag<2> Arity; + + using SK::Linear_kernel::Compare_xyz_3::operator(); + + result_type + operator() (const Circular_arc_point_3 &p0, + const Circular_arc_point_3 &p1) const + { return compare_xyz(p0, p1);} + + result_type + operator() (const Circular_arc_point_3 &p0, + const Point_3 &p1) const + { return compare_xyz(p0, p1);} + + result_type + operator() (const Point_3 &p0, + const Circular_arc_point_3 &p1) const + { return compare_xyz(p0, p1);} + + }; + + template + class Compute_circular_x_3: Has_qrt + { + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef typename SK::Root_of_2 Root_of_2; + + public: + + typedef Root_of_2 result_type; + typedef const result_type & qualified_result_type; + typedef Arity_tag<1> Arity; + + qualified_result_type operator() (const Circular_arc_point_3 & a) const + { + return (a.rep().x()); + } + }; + +template + class Compute_circular_y_3: Has_qrt + { + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef typename SK::Root_of_2 Root_of_2; + + public: + + typedef Root_of_2 result_type; + typedef const result_type & qualified_result_type; + typedef Arity_tag<1> Arity; + + qualified_result_type operator() (const Circular_arc_point_3 & a) const + { + return (a.rep().y()); + } + }; + +template + class Compute_circular_z_3: Has_qrt + { + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef typename SK::Root_of_2 Root_of_2; + + public: + + typedef Root_of_2 result_type; + typedef const result_type & qualified_result_type; + typedef Arity_tag<1> Arity; + + qualified_result_type operator() (const Circular_arc_point_3 & a) const + { + return (a.rep().z()); + } + }; + +template < class SK > + class Equal_3 + : public SK::Linear_kernel::Equal_3 + { + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef typename SK::Circle_3 Circle_3; + typedef typename SK::Line_arc_3 Line_arc_3; + public: + typedef bool result_type; + typedef Arity_tag<2> Arity; + + using SK::Linear_kernel::Equal_3::operator(); + + // Our Circle_3 dont have orientation + result_type + operator() (const Circle_3 &c0, + const Circle_3 &c1) const + { return equal(c0, c1); } + + result_type + operator() (const Circular_arc_point_3 &c0, + const Circular_arc_point_3 &c1) const + { return equal(c0, c1); } + + // Our Line_arc_3 dont have orientation + result_type + operator() (const Line_arc_3 &l0, + const Line_arc_3 &l1) const + { return equal(l0, l1); } + + }; + +template < class SK > + class Construct_circular_arc_point_3 + { + typedef typename SK::Point_3 Point_3; + typedef typename SK::Plane_3 Plane_3; + typedef typename SK::Line_3 Line_3; + typedef typename SK::Circle_3 Circle_3; + typedef typename SK::Sphere_3 Sphere_3; + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef typename SK::Kernel_base::Circular_arc_point_3 RCircular_arc_point_3; + typedef typename SK::Root_of_2 Root_of_2; + typedef typename Circular_arc_point_3::Rep Rep; + typedef typename Circular_arc_point_3::Root_for_spheres_2_3 Root_for_spheres_2_3; + + public: + typedef Circular_arc_point_3 result_type; + typedef Arity_tag<1> Arity; + + + result_type + operator()(void) + { return Rep(); } + + result_type + operator()(const Root_of_2 & x, + const Root_of_2 & y, + const Root_of_2 & z + ) const + { return Rep(x,y,z); } + + result_type + operator()(const Root_for_spheres_2_3 & np) const + { return Rep(np); } + + result_type + operator()(const Point_3 & p) const + { return Rep(p); } + + result_type + operator()(const Sphere_3 & s1, + const Sphere_3 & s2, + const Sphere_3 & s3, + const bool less_xyz = true) const + { return Rep(s1,s2,s3,less_xyz); } + + result_type + operator()(const Plane_3 & p, + const Sphere_3 & s1, + const Sphere_3 & s2, + const bool less_xyz = true) const + { return Rep(p,s1,s2,less_xyz); } + + result_type + operator()(const Sphere_3 & s1, + const Plane_3 & p, + const Sphere_3 & s2, + const bool less_xyz = true) const + { return Rep(p,s1,s2,less_xyz); } + + result_type + operator()(const Sphere_3 & s1, + const Sphere_3 & s2, + const Plane_3 & p, + const bool less_xyz = true) const + { return Rep(p,s1,s2,less_xyz); } + + result_type + operator()(const Plane_3 & p1, + const Plane_3 & p2, + const Sphere_3 & s, + const bool less_xyz = true) const + { return Rep(p1,p2,s,less_xyz); } + + result_type + operator()(const Plane_3 & p1, + const Sphere_3 & s, + const Plane_3 & p2, + const bool less_xyz = true) const + { return Rep(p1,p2,s,less_xyz); } + + result_type + operator()(const Sphere_3 & s, + const Plane_3 & p1, + const Plane_3 & p2, + const bool less_xyz = true) const + { return Rep(p1,p2,s,less_xyz); } + + result_type + operator()(const Line_3 & l, + const Sphere_3 & s, + const bool less_xyz = true) const + { return Rep(l,s,less_xyz); } + + result_type + operator()(const Sphere_3 & s, + const Line_3 & l, + const bool less_xyz = true) const + { return Rep(l,s,less_xyz); } + + result_type + operator()(const Circle_3 & c, + const Sphere_3 & s, + const bool less_xyz = true) const + { return Rep(c,s,less_xyz); } + + result_type + operator()(const Sphere_3 & s, + const Circle_3 & c, + const bool less_xyz = true) const + { return Rep(c,s,less_xyz); } + + result_type + operator()(const Circle_3 & c, + const Plane_3 & p, + const bool less_xyz = true) const + { return Rep(c,p,less_xyz); } + + result_type + operator()(const Plane_3 & p, + const Circle_3 & c, + const bool less_xyz = true) const + { return Rep(c,p,less_xyz); } + + }; + +template < class SK > + class Construct_sphere_3 : public SK::Linear_kernel::Construct_sphere_3 + { + public: + + typedef typename SK::Sphere_3 result_type; + typedef Arity_tag<1> Arity; + + using SK::Linear_kernel::Construct_sphere_3::operator(); + + result_type + operator() ( const typename SK::Polynomial_for_spheres_2_3 &eq ) + { + return construct_sphere_3(eq); + } + }; + +template < class SK > + class Construct_plane_3 : public SK::Linear_kernel::Construct_plane_3 + { + public: + + typedef typename SK::Plane_3 result_type; + typedef Arity_tag<1> Arity; + + using SK::Linear_kernel::Construct_plane_3::operator(); + + result_type + operator() ( const typename SK::Polynomial_1_3 &eq ) + { + return construct_plane_3(eq); + } + }; + +template < class SK > + class Construct_line_3 : public SK::Linear_kernel::Construct_line_3 + { + public: + + typedef typename SK::Line_3 result_type; + typedef Arity_tag<1> Arity; + + using SK::Linear_kernel::Construct_line_3::operator(); + + result_type + operator() ( const typename SK::Polynomials_for_line_3 &eq ) + { + return construct_line_3(eq); + } + }; + +template < class SK > + class Construct_circle_3 + { + public: + + typedef typename SK::FT FT; + typedef typename SK::Point_3 Point_3; + typedef typename SK::Plane_3 Plane_3; + typedef typename SK::Sphere_3 Sphere_3; + typedef typename SK::Circle_3 Circle_3; + typedef typename SK::Vector_3 Vector_3; + typedef typename SK::Direction_3 Direction_3; + typedef typename SK::Kernel_base::Circle_3 RCircle_3; + typedef typename Circle_3::Rep Rep; + + typedef Circle_3 result_type; + typedef Arity_tag<1> Arity; + + result_type + operator()(void) + { return Rep(); } + + result_type + operator()(const Circle_3 &c) const + { return Rep(c); } + + result_type + operator() ( const typename SK::Polynomials_for_circle_3 &eq ) + { return Rep(construct_circle_3(eq)); } + + result_type + operator() (const Point_3& p, const FT& sr, const Plane_3& plane) + { return Rep(p,sr,plane); } + + result_type + operator() (const Point_3& p, const FT& sr, const Vector_3& v) + { return Rep(p,sr,v); } + + result_type + operator() (const Point_3& p, const FT& sr, const Direction_3& d) + { return Rep(p,sr,d); } + + result_type + operator() (const Sphere_3& s1, const Sphere_3& s2) + { return Rep(s1,s2); } + + result_type + operator() (const Plane_3& p, const Sphere_3& s) + { return Rep(p,s); } + + result_type + operator() (const Sphere_3& s, const Plane_3& p) + { return Rep(p,s); } + }; + +template + class Construct_supporting_plane_3//: Has_qrt + { + typedef typename SK::Plane_3 Plane_3; + typedef typename SK::Circle_3 Circle_3; + + public: + + typedef Plane_3 result_type; + typedef const Plane_3& qualified_result_type; + typedef Arity_tag<1> Arity; + + qualified_result_type operator() (const Circle_3 & c) const + { + return c.rep().supporting_plane(); + } + }; + +template + class Construct_diametral_sphere_3//: Has_qrt + { + typedef typename SK::Sphere_3 Sphere_3; + typedef typename SK::Circle_3 Circle_3; + + public: + + typedef Sphere_3 result_type; + typedef const Sphere_3& qualified_result_type; + typedef Arity_tag<1> Arity; + + qualified_result_type operator() (const Circle_3 & c) const + { + return c.rep().diametral_sphere(); + } + }; + +template < class SK > + class Construct_line_arc_3 + { + + typedef typename SK::Line_3 Line_3; + typedef typename SK::Point_3 Point_3; + typedef typename SK::Segment_3 Segment_3; + typedef typename SK::Sphere_3 Sphere_3; + typedef typename SK::Plane_3 Plane_3; + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef typename SK::Line_arc_3 Line_arc_3; + typedef typename SK::Kernel_base::Line_arc_3 RLine_arc_3; + typedef typename Line_arc_3::Rep Rep; + + public: + typedef Line_arc_3 result_type; + typedef Arity_tag<3> Arity; // It is not true that each constructor has + // 3 operands, maybe we should remove this + + result_type + operator()(void) const + { return Rep(); } + + result_type + operator()(const Line_3 &l, + const Circular_arc_point_3 &s, + const Circular_arc_point_3 &t) const + { return Rep(l,s,t); } + + result_type + operator()(const Line_3 &l, + const Point_3 &s, + const Circular_arc_point_3 &t) const + { return Rep(l,s,t); } + + result_type + operator()(const Line_3 &l, + const Circular_arc_point_3 &s, + const Point_3 &t) const + { return Rep(l,s,t); } + + result_type + operator()(const Line_3 &l, + const Point_3 &s, + const Point_3 &t) const + { return Rep(l,s,t); } + + result_type + operator()(const Segment_3 &s) const + { return Rep(s); } + + result_type + operator()(const Line_3 &l, + const Sphere_3 &s, + bool less_xyz_first = true) const + { return Rep(l,s,less_xyz_first); } + + result_type + operator()(const Sphere_3 &s, + const Line_3 &l, + bool less_xyz_first = true) const + { return Rep(l,s,less_xyz_first); } + + result_type + operator()(const Line_3 &l, + const Sphere_3 &s1, bool less_xyz_s1, + const Sphere_3 &s2, bool less_xyz_s2) const + { return Rep(l,s1,less_xyz_s1, + s2,less_xyz_s2); } + + result_type + operator()(const Sphere_3 &s1, bool less_xyz_s1, + const Sphere_3 &s2, bool less_xyz_s2, + const Line_3 &l) const + { return Rep(l,s1,less_xyz_s1, + s2,less_xyz_s2); } + + result_type + operator()(const Line_3 &l, + const Plane_3 &p1, + const Plane_3 &p2) const + { return Rep(l,p1,p2); } + + result_type + operator()(const Plane_3 &p1, + const Plane_3 &p2, + const Line_3 &l) const + { return Rep(l,p1,p2); } + + }; + + +template + class Construct_circular_min_vertex_3 : Has_qrt + { + typedef typename SK::Line_arc_3 Line_arc_3; + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + + public: + + typedef Circular_arc_point_3 result_type; + typedef const result_type & qualified_result_type; + typedef Arity_tag<1> Arity; + + qualified_result_type operator() (const Line_arc_3 & a) const + { + return (a.rep().lower_xyz_extremity()); + } + + }; + +template + class Construct_circular_max_vertex_3 : Has_qrt + { + typedef typename SK::Line_arc_3 Line_arc_3; + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + + public: + + typedef Circular_arc_point_3 result_type; + typedef const result_type & qualified_result_type; + typedef Arity_tag<1> Arity; + + qualified_result_type operator() (const Line_arc_3 & a) const + { + return (a.rep().higher_xyz_extremity()); + } + + }; + +template + class Construct_circular_source_vertex_3 : Has_qrt + { + typedef typename SK::Line_arc_3 Line_arc_3; + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + + public: + + typedef Circular_arc_point_3 result_type; + typedef const result_type & qualified_result_type; + typedef Arity_tag<1> Arity; + + qualified_result_type operator() (const Line_arc_3 & a) const + { + return (a.rep().source()); + } + + }; + +template + class Construct_circular_target_vertex_3 : Has_qrt + { + typedef typename SK::Line_arc_3 Line_arc_3; + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + + public: + + typedef Circular_arc_point_3 result_type; + typedef const result_type & qualified_result_type; + typedef Arity_tag<1> Arity; + + qualified_result_type operator() (const Line_arc_3 & a) const + { + return (a.rep().target()); + } + + }; + +template + class Construct_supporting_line_3 : Has_qrt + { + typedef typename SK::Line_arc_3 Line_arc_3; + typedef typename SK::Line_3 Line_3; + + public: + + typedef Line_3 result_type; + typedef const result_type & qualified_result_type; + typedef Arity_tag<1> Arity; + + qualified_result_type operator() (const Line_arc_3 & a) const + { + return (a.rep().supporting_line()); + } + + }; + +template < class SK > + class Has_on_3 + : public SK::Linear_kernel::Has_on_3 + { + typedef typename SK::Point_3 Point_3; + typedef typename SK::Sphere_3 Sphere_3; + typedef typename SK::Plane_3 Plane_3; + typedef typename SK::Line_3 Line_3; + typedef typename SK::Line_arc_3 Line_arc_3; + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef typename SK::Circle_3 Circle_3; + + + public: + typedef bool result_type; + typedef Arity_tag<2> Arity; + + using SK::Linear_kernel::Has_on_3::operator(); + + // Some of the has_on here have better to be moved to the Linear_Kernel + + result_type + operator()(const Sphere_3 &a, const Point_3 &p) const + { return has_on(a, p); } + + result_type + operator()(const Point_3 &p, const Sphere_3 &a) const + { return false; } + + result_type + operator()(const Sphere_3 &a, const Circular_arc_point_3 &p) const + { + return has_on(a, p); + } + + result_type + operator()(const Circular_arc_point_3 &p, const Sphere_3 &a) const + { return false; } + + result_type + operator()(const Plane_3 &a, const Point_3 &p) const + { return has_on(a, p); } + + result_type + operator()(const Point_3 &p, const Plane_3 &a) const + { return false; } + + result_type + operator()(const Plane_3 &a, const Circular_arc_point_3 &p) const + { return has_on(a, p); } + + result_type + operator()(const Circular_arc_point_3 &p, const Plane_3 &a) const + { return false; } + + result_type + operator()(const Line_3 &a, const Point_3 &p) const + { return has_on(a, p); } + + result_type + operator()(const Point_3 &p, const Line_3 &a) const + { return false; } + + result_type + operator()(const Line_3 &a, const Circular_arc_point_3 &p) const + { return has_on(a, p); } + + result_type + operator()(const Circular_arc_point_3 &p, const Line_3 &a) const + { return false; } + + result_type + operator()(const Circle_3 &a, const Point_3 &p) const + { return has_on(a, p); } + + result_type + operator()(const Point_3 &p, const Circle_3 &a) const + { return false; } + + result_type + operator()(const Circle_3 &a, const Circular_arc_point_3 &p) const + { return has_on(a, p); } + + result_type + operator()(const Circular_arc_point_3 &p, const Circle_3 &a) const + { return false; } + + result_type + operator()(const Sphere_3 &a, const Circle_3 &p) const + { return has_on(a, p); } + + result_type + operator()(const Circle_3 &p, const Sphere_3 &a) const + { return false; } + + result_type + operator()(const Plane_3 &a, const Line_3 &p) const + { return has_on(a, p); } + + result_type + operator()(const Line_3 &a, const Plane_3 &p) const + { return false; } + + result_type + operator()(const Plane_3 &a, const Circle_3 &p) const + { return has_on(a, p); } + + result_type + operator()(const Circle_3 &p, const Plane_3 &a) const + { return false; } + + // We assume Spheres cannot be points, should we? + result_type + operator()(const Sphere_3 &a, const Plane_3 &p) const + { return false; } + + result_type + operator()(const Plane_3 &a, const Sphere_3 &p) const + { return false; } + + result_type + operator()(const Sphere_3 &a, const Line_3 &p) const + { return false; } + + result_type + operator()(const Line_arc_3 &a, const Circular_arc_point_3 &p, + const bool already_know_point_on_line = false) const + { return has_on(a, p, already_know_point_on_line); } + + result_type + operator()(const Circular_arc_point_3 &a, const Line_arc_3 &p) const + { return false; } + + result_type + operator()(const Line_arc_3 &a, const Point_3 &p, + const bool already_know_point_on_line = false) const + { return has_on(a, p, already_know_point_on_line); } + + result_type + operator()(const Point_3 &a, const Line_arc_3 &p) const + { return false; } + + result_type + operator()(const Plane_3 &p, const Line_arc_3 &a) const + { return has_on(p, a); } + + result_type + operator()(const Line_arc_3 &p, const Plane_3 &a) const + { return false; } + + result_type + operator()(const Sphere_3 &a, const Line_arc_3 &p) const + { return false; } + + result_type + operator()(const Line_arc_3 &a, const Sphere_3 &p) const + { return false; } + + result_type + operator()(const Circle_3 &a, const Line_arc_3 &p) const + { return false; } + + result_type + operator()(const Line_arc_3 &a, const Circle_3 &p) const + { return false; } + + result_type + operator()(const Line_3 &a, const Line_arc_3 &p) const + { return has_on(a, p); } + + result_type + operator()(const Line_arc_3 &a, const Line_3 &p) const + { return false; } + + }; + +template < class SK > + class Intersect_3 + : public SK::Linear_kernel::Intersect_3 + { + + typedef typename SK::Sphere_3 Sphere_3; + typedef typename SK::Line_3 Line_3; + typedef typename SK::Line_arc_3 Line_arc_3; + typedef typename SK::Plane_3 Plane_3; + typedef typename SK::Circle_3 Circle_3; + + public: + + typedef void result_type; + //typedef Arity_tag<2> Arity; // The Arity can be 2 and 3 + // Is there some solution for this problem?? + typedef typename SK::Object_3 Object_3; + + using SK::Linear_kernel::Intersect_3::operator(); + + template < class OutputIterator > + OutputIterator + operator()(const Sphere_3 & s1, const Sphere_3 & s2, + OutputIterator res) const + { return intersect_3 (s1,s2,res); } + + template < class OutputIterator > + OutputIterator + operator()(const Plane_3 & p, const Sphere_3 & s, + OutputIterator res) const + { return intersect_3 (p,s,res); } + + template < class OutputIterator > + OutputIterator + operator()(const Sphere_3 & s, const Plane_3 & p, + OutputIterator res) const + { return intersect_3 (p,s,res); } + + template < class OutputIterator > + OutputIterator + operator()(const Sphere_3 & s, const Line_3 & l, + OutputIterator res) const + { return intersect_3 (s,l,res); } + + template < class OutputIterator > + OutputIterator + operator()(const Line_3 & l,const Sphere_3 & s, + OutputIterator res) const + { return intersect_3 (s,l,res); } + + template < class OutputIterator > + OutputIterator + operator()(const Sphere_3 & s1, const Sphere_3 & s2, + const Sphere_3 & s3, OutputIterator res) const + { return intersect_3 (s1,s2,s3,res); } + + template < class OutputIterator > + OutputIterator + operator()(const Sphere_3 & s1, const Sphere_3 & s2, + const Plane_3 & p, OutputIterator res) const + { return intersect_3 (p,s1,s2,res); } + + template < class OutputIterator > + OutputIterator + operator()(const Plane_3 & p, const Sphere_3 & s1, + const Sphere_3 & s2, OutputIterator res) const + { return intersect_3 (p,s1,s2,res); } + + template < class OutputIterator > + OutputIterator + operator()(const Plane_3 & p1, const Plane_3 & p2, + const Sphere_3 & s, OutputIterator res) const + { return intersect_3 (p1,p2,s,res); } + + template < class OutputIterator > + OutputIterator + operator()(const Sphere_3 & s, const Plane_3 & p1, + const Plane_3 & p2, OutputIterator res) const + { return intersect_3 (p1,p2,s,res); } + + // INTERSECTIONS WITH CIRCLE + template < class OutputIterator > + OutputIterator + operator()(const Circle_3 & c, const Plane_3 & p, + OutputIterator res) const + { return intersect_3 (c,p,res); } + + template < class OutputIterator > + OutputIterator + operator()(const Plane_3 & p, const Circle_3 & c, + OutputIterator res) const + { return intersect_3 (c,p,res); } + + template < class OutputIterator > + OutputIterator + operator()(const Circle_3 & c, const Sphere_3 & s, + OutputIterator res) const + { return intersect_3 (c,s,res); } + + template < class OutputIterator > + OutputIterator + operator()(const Sphere_3 & s, const Circle_3 & c, + OutputIterator res) const + { return intersect_3 (c,s,res); } + + template < class OutputIterator > + OutputIterator + operator()(const Circle_3 & c1, const Circle_3 & c2, + OutputIterator res) const + { return intersect_3 (c1,c2,res); } + + template < class OutputIterator > + OutputIterator + operator()(const Circle_3 & c, const Line_3 & l, + OutputIterator res) const + { return intersect_3 (c,l,res); } + + template < class OutputIterator > + OutputIterator + operator()(const Line_3 & l, const Circle_3 & c, + OutputIterator res) const + { return intersect_3 (c,l,res); } + + // INTERSECTION LINE-LINE + // obs: This intersection should be moved to the Linear Kernel + // we need it + // For instance I won't put on the Algebraic Kernel for Spheres + // this function, I will solve locally + // I wont build tests for them, by the way I build tests for + // intersect_3(Line_arc, Line_arc) which should do + // this intersection also dont take care with orientation + Object_3 + operator()(const Line_3 & l1, const Line_3 & l2) const + { return intersect_3 (l1,l2); } + + // INTERSECTIONS WITH LINE_ARC + template < class OutputIterator > + OutputIterator + operator()(const Line_arc_3 & l1, const Line_arc_3 & l2, + OutputIterator res) const + { return intersect_3 (l1,l2,res); } + + template < class OutputIterator > + OutputIterator + operator()(const Line_3 & l, const Line_arc_3 & la) const + { return intersect_3 (l,la); } + + template < class OutputIterator > + OutputIterator + operator()(const Line_arc_3 & la, const Line_3 & l) const + { return intersect_3 (l,la); } + + template < class OutputIterator > + OutputIterator + operator()(const Circle_3 & c, const Line_arc_3 & l, + OutputIterator res) const + { return intersect_3 (c,l,res); } + + template < class OutputIterator > + OutputIterator + operator()(const Line_arc_3 & l, const Circle_3 & c, + OutputIterator res) const + { return intersect_3 (c,l,res); } + + + template < class OutputIterator > + OutputIterator + operator()(const Sphere_3 & s, const Line_arc_3 & l, + OutputIterator res) const + { return intersect_3 (s,l,res); } + + template < class OutputIterator > + OutputIterator + operator()(const Line_arc_3 & l,const Sphere_3 & s, + OutputIterator res) const + { return intersect_3 (s,l,res); } + + template < class OutputIterator > + OutputIterator + operator()(const Plane_3 & s, const Line_arc_3 & l, + OutputIterator res) const + { return intersect_3 (s,l,res); } + + template < class OutputIterator > + OutputIterator + operator()(const Line_arc_3 & l,const Plane_3 & s, + OutputIterator res) const + { return intersect_3 (s,l,res); } + + }; + +// If 2 line_arc have the same supporting line +// if they intersect only at a point +// even in this case we consider that the 2 line_arc overlap +template < class SK > + class Do_overlap_3 + { + typedef typename SK::Line_arc_3 Line_arc_3; + + public: + typedef bool result_type; + typedef Arity_tag<2> Arity; + + result_type + operator() (const Line_arc_3 &l1, const Line_arc_3 &l2) const + { return do_overlap(l1, l2); } + + }; + + template < class SK > + class Split_3 + { + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef typename SK::Line_arc_3 Line_arc_3; + + public: + + typedef void result_type; + typedef Arity_tag<4> Arity; + + result_type + operator()(const Line_arc_3 &l, + const Circular_arc_point_3 &p, + Line_arc_3 &ca1, Line_arc_3 &ca2) const + { return split(l, p, ca1, ca2); } + + }; + +template + class Construct_bbox_3 + : public SK::Linear_kernel::Construct_bbox_2 + { + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef typename SK::Circle_3 Circle_3; + typedef typename SK::Line_arc_3 Line_arc_3; + + public: + + typedef CGAL::Bbox_3 result_type; + typedef Arity_tag<1> Arity; + + using SK::Linear_kernel::Construct_bbox_2::operator(); + + result_type operator() (const Circular_arc_point_3 & c) const + { + return c.rep().bbox(); + } + + result_type operator() (const Circle_3 & c) const + { + return c.rep().bbox(); + } + + result_type operator() (const Line_arc_3 & l) const + { + return l.rep().bbox(); + } + + }; + +} // namespace SphericalFunctors +} // namespace CGAL + +#endif // CGAL_SPHERICAL_KERNEL_FUNCTION_OBJECTS_POLYNOMIAL_SPHERE_H diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/functions_on_circle_3.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/functions_on_circle_3.h new file mode 100644 index 00000000000..60daa30fe76 --- /dev/null +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/functions_on_circle_3.h @@ -0,0 +1,76 @@ +// Copyright (c) 2003-2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org); you may redistribute it under +// the terms of the Q Public License version 1.0. +// See the file LICENSE.QPL distributed with CGAL. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// Author(s) : Monique Teillaud, Sylvain Pion + +// Partially supported by the IST Programme of the EU as a Shared-cost +// RTD (FET Open) Project under Contract No IST-2000-26473 +// (ECG - Effective Computational Geometry for Curves and Surfaces) +// and a STREP (FET Open) Project under Contract No IST-006413 +// (ACS -- Algorithms for Complex Shapes) + +#ifndef CGAL_SPHERICAL_KERNEL_FUNCTIONS_ON_CIRCLE_3_H +#define CGAL_SPHERICAL_KERNEL_FUNCTIONS_ON_CIRCLE_3_H + +namespace CGAL { + + // At the moment we dont need those functions + // But in the future maybe (some make_x_monotone? etc..) + template + typename SK::Circular_arc_point_3 + x_extremal_point(const Circle_3 & c, bool i) + { + return SphericalFunctors::x_extremal_point(c,i); + } + + template + OutputIterator + x_extremal_points(const Circle_3 & c, OutputIterator res) + { + return SphericalFunctors::x_extremal_point(c,res); + } + + template + typename SK::Circular_arc_point_3 + y_extremal_point(const Circle_3 & c, bool i) + { + return SphericalFunctors::y_extremal_point(c,i); + } + + template + OutputIterator + y_extremal_points(const Circle_3 & c, OutputIterator res) + { + return SphericalFunctors::y_extremal_point(c,res); + } + + template + typename SK::Circular_arc_point_3 + z_extremal_point(const Circle_3 & c, bool i) + { + return SphericalFunctors::z_extremal_point(c,i); + } + + template + OutputIterator + z_extremal_points(const Circle_3 & c, OutputIterator res) + { + return SphericalFunctors::z_extremal_point(c,res); + } + +} // namespace CGAL + +#endif // CGAL_SPHERICAL_KERNEL_FUNCTIONS_ON_CIRCLE_3_H diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/functions_on_sphere_3.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/functions_on_sphere_3.h new file mode 100644 index 00000000000..70d5f521fc2 --- /dev/null +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/functions_on_sphere_3.h @@ -0,0 +1,76 @@ +// Copyright (c) 2003-2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org); you may redistribute it under +// the terms of the Q Public License version 1.0. +// See the file LICENSE.QPL distributed with CGAL. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// Author(s) : Monique Teillaud, Sylvain Pion + +// Partially supported by the IST Programme of the EU as a Shared-cost +// RTD (FET Open) Project under Contract No IST-2000-26473 +// (ECG - Effective Computational Geometry for Curves and Surfaces) +// and a STREP (FET Open) Project under Contract No IST-006413 +// (ACS -- Algorithms for Complex Shapes) + +#ifndef CGAL_SPHERICAL_KERNEL_FUNCTIONS_ON_SPHERE_3_H +#define CGAL_SPHERICAL_KERNEL_FUNCTIONS_ON_SPHERE_3_H + +namespace CGAL { + + // At the moment we dont need those functions + // But in the future maybe (some make_x_monotone? etc..) + template + typename SK::Circular_arc_point_3 + x_extremal_point(const Sphere_3 & c, bool i) + { + return SphericalFunctors::x_extremal_point(c,i); + } + + template + OutputIterator + x_extremal_points(const Sphere_3 & c, OutputIterator res) + { + return SphericalFunctors::x_extremal_point(c,res); + } + + template + typename SK::Circular_arc_point_3 + y_extremal_point(const Sphere_3 & c, bool i) + { + return SphericalFunctors::y_extremal_point(c,i); + } + + template + OutputIterator + y_extremal_points(const Sphere_3 & c, OutputIterator res) + { + return SphericalFunctors::y_extremal_point(c,res); + } + + template + typename SK::Circular_arc_point_3 + z_extremal_point(const Sphere_3 & c, bool i) + { + return SphericalFunctors::z_extremal_point(c,i); + } + + template + OutputIterator + z_extremal_points(const Sphere_3 & c, OutputIterator res) + { + return SphericalFunctors::z_extremal_point(c,res); + } + +} // namespace CGAL + +#endif // CGAL_CURVED_KERNEL_FUNCTIONS_ON_SPHERE_3_H diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/get_equation_object_on_curved_kernel_3.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/get_equation_object_on_curved_kernel_3.h new file mode 100644 index 00000000000..f8303891b77 --- /dev/null +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/get_equation_object_on_curved_kernel_3.h @@ -0,0 +1,72 @@ +// Copyright (c) 2005 INRIA Sophia-Antipolis (France) +// All rights reserved. +// +// Authors : Monique Teillaud +// Sylvain Pion +// Julien Hazebrouck +// Damien Leroy +// +// Partially supported by the IST Programme of the EU as a Shared-cost +// RTD (FET Open) Project under Contract No IST-2000-26473 +// (ECG - Effective Computational Geometry for Curves and Surfaces) +// and a STREP (FET Open) Project under Contract No IST-006413 +// (ACS -- Algorithms for Complex Shapes) + + + +#ifndef CGAL_SPHERICAL_KERNEL_GET_EQUATION_OBJECT_3_H +#define CGAL_SPHERICAL_KERNEL_GET_EQUATION_OBJECT_3_H + +#include +#include +#include +#include +// to be removed when CGAL::Kernel has a Get_equation + +namespace CGAL { + namespace SphericalFunctors { + + template < class SK > + class Get_equation //: public LinearFunctors::Get_equation + { + public: + + typedef void result_type; // should we keep this? + + typedef typename SK::Polynomial_for_spheres_2_3 result_type_for_sphere; + typedef typename SK::Polynomial_1_3 result_type_for_plane; + typedef typename SK::Polynomials_for_line_3 result_type_for_line; + typedef typename SK::Polynomials_for_circle_3 result_type_for_circle; + //using LinearFunctors::Get_equation::operator(); + + + result_type_for_sphere + operator() ( const typename SK::Sphere_3 & s ) + { + return get_equation(s); + } + + result_type_for_plane + operator() ( const typename SK::Plane_3 & p ) + { + return get_equation(p); + } + + result_type_for_line + operator() ( const typename SK::Line_3 & l ) + { + return get_equation(l); + } + + result_type_for_circle + operator() ( const typename SK::Circle_3 & c ) + { + return get_equation(c); + } + + }; + + } // namespace SphericalFunctors +} // namespace CGAL + +#endif // CGAL_SPHERICAL_KERNEL_GET_EQUATION_OBJECT_3_H diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/interface_macros.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/interface_macros.h new file mode 100644 index 00000000000..346bc4685c2 --- /dev/null +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/interface_macros.h @@ -0,0 +1,63 @@ +// Copyright (c) 2000-2004 Utrecht University (The Netherlands), +// ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany), +// INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg +// (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria), +// and Tel-Aviv University (Israel). All rights reserved. +// +// This file is part of CGAL (www.cgal.org); you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; version 2.1 of the License. +// See the file LICENSE.LGPL distributed with CGAL. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $Source: /CVSROOT/CGAL/Packages/Circular_kernel/include/CGAL/Circular_kernel/interface_macros.h,v $ +// $Revision$ $Date$ +// $Name: $ +// +// Author(s) : Herve Bronnimann, Sylvain Pion, Susan Hert + +// This file is intentionally not protected against re-inclusion. +// It's aimed at being included from within a kernel traits class, this +// way we share more code. + +// It is the responsability of the including file to correctly set the 2 +// macros CGAL_Kernel_pred and CGAL_Kernel_cons. +// And they are #undefed at the end of this file. + + CGAL_Spherical_Kernel_cons(Get_equation, get_equation_object) + CGAL_Spherical_Kernel_cons(Construct_circular_arc_point_3, construct_circular_arc_point_3_object) + CGAL_Spherical_Kernel_cons(Construct_sphere_3, construct_sphere_3_object) + CGAL_Spherical_Kernel_cons(Construct_plane_3, construct_plane_3_object) + CGAL_Spherical_Kernel_cons(Construct_line_3, construct_line_3_object) + CGAL_Spherical_Kernel_cons(Construct_line_arc_3, construct_line_arc_3_object) + CGAL_Spherical_Kernel_cons(Construct_circle_3, construct_circle_3_object) + CGAL_Spherical_Kernel_cons(Construct_diametral_sphere_3, construct_diametral_sphere_3_object) + CGAL_Spherical_Kernel_cons(Construct_supporting_plane_3, construct_supporting_plane_3_object) + CGAL_Spherical_Kernel_cons(Compute_circular_x_3, compute_circular_x_3_object) + CGAL_Spherical_Kernel_cons(Compute_circular_y_3, compute_circular_y_3_object) + CGAL_Spherical_Kernel_cons(Compute_circular_z_3, compute_circular_z_3_object) + CGAL_Spherical_Kernel_cons(Construct_circular_min_vertex_3, construct_circular_min_vertex_3_object) + CGAL_Spherical_Kernel_cons(Construct_circular_max_vertex_3, construct_circular_max_vertex_3_object) + CGAL_Spherical_Kernel_cons(Construct_circular_source_vertex_3, construct_circular_source_vertex_3_object) + CGAL_Spherical_Kernel_cons(Construct_circular_target_vertex_3, construct_circular_target_vertex_3_object) + CGAL_Spherical_Kernel_cons(Construct_supporting_line_3, construct_supporting_line_3_object) + CGAL_Spherical_Kernel_cons(Intersect_3, intersect_3_object) + CGAL_Spherical_Kernel_cons(Construct_bbox_3, construct_bbox_3_object) + CGAL_Spherical_Kernel_cons(Split_3, split_3_object) + + CGAL_Spherical_Kernel_pred(Compare_x_3, compare_x_3_object) + CGAL_Spherical_Kernel_pred(Compare_y_3, compare_y_3_object) + CGAL_Spherical_Kernel_pred(Compare_z_3, compare_z_3_object) + CGAL_Spherical_Kernel_pred(Compare_xy_3, compare_xy_3_object) + CGAL_Spherical_Kernel_pred(Compare_xyz_3, compare_xyz_3_object) + CGAL_Spherical_Kernel_pred(Equal_3, equal_3_object) + CGAL_Spherical_Kernel_pred(Has_on_3, has_on_3_object) + CGAL_Spherical_Kernel_pred(Do_overlap_3, do_overlap_3_object) + +#undef CGAL_Spherical_Kernel_pred +#undef CGAL_Spherical_Kernel_cons diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_function_compare_spherical_kernel.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_function_compare_spherical_kernel.h new file mode 100644 index 00000000000..bea9d28e8f3 --- /dev/null +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_function_compare_spherical_kernel.h @@ -0,0 +1,79 @@ +// Copyright (c) 2005 INRIA Sophia-Antipolis (France) +// All rights reserved. +// +// Authors : Monique Teillaud +// Sylvain Pion +// Julien Hazebrouck +// Damien Leroy +// +// Partially supported by the IST Programme of the EU as a Shared-cost +// RTD (FET Open) Project under Contract No IST-2000-26473 +// (ECG - Effective Computational Geometry for Curves and Surfaces) +// and a STREP (FET Open) Project under Contract No IST-006413 +// (ACS -- Algorithms for Complex Shapes) + +#ifndef CGAL_SPHERICAL_KERNEL_PREDICATES_COMPARE_3_H +#define CGAL_SPHERICAL_KERNEL_PREDICATES_COMPARE_3_H + +namespace CGAL { + namespace SphericalFunctors { + + // we can optimize those functions by comparing + // the references before doing the comparison + // as in CK + template < class SK > + inline + Comparison_result + compare_x(const typename SK::Circular_arc_point_3 &p0, + const typename SK::Circular_arc_point_3 &p1) + { + typedef typename SK::Algebraic_kernel AK; + return AK().compare_x_object()(p0.coordinates(), p1.coordinates()); + } + + template < class SK > + inline + Comparison_result + compare_y(const typename SK::Circular_arc_point_3 &p0, + const typename SK::Circular_arc_point_3 &p1) + { + typedef typename SK::Algebraic_kernel AK; + return AK().compare_y_object()(p0.coordinates(), p1.coordinates()); + } + + template < class SK > + inline + Comparison_result + compare_z(const typename SK::Circular_arc_point_3 &p0, + const typename SK::Circular_arc_point_3 &p1) + { + typedef typename SK::Algebraic_kernel AK; + return AK().compare_z_object()(p0.coordinates(), p1.coordinates()); + } + + template < class SK > + inline + Comparison_result + compare_xy(const typename SK::Circular_arc_point_3 &p0, + const typename SK::Circular_arc_point_3 &p1) + { + typedef typename SK::Algebraic_kernel AK; + return AK().compare_xy_object()(p0.coordinates(), p1.coordinates()); + } + + template < class SK > + inline + Comparison_result + compare_xyz(const typename SK::Circular_arc_point_3 &p0, + const typename SK::Circular_arc_point_3 &p1) + { + typedef typename SK::Algebraic_kernel AK; + return AK().compare_xyz_object()(p0.coordinates(), p1.coordinates()); + } + + }//SphericalFunctors +}//CGAL + + + +#endif //CGAL_SPHERICAL_KERNEL_PREDICATES_COMPARE_3_H diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_function_has_on_spherical_kernel.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_function_has_on_spherical_kernel.h new file mode 100644 index 00000000000..3663a2c5de2 --- /dev/null +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_function_has_on_spherical_kernel.h @@ -0,0 +1,193 @@ +// Copyright (c) 2005 INRIA Sophia-Antipolis (France) +// All rights reserved. +// +// Authors : Monique Teillaud +// Sylvain Pion +// Julien Hazebrouck +// Damien Leroy +// +// Partially supported by the IST Programme of the EU as a Shared-cost +// RTD (FET Open) Project under Contract No IST-2000-26473 +// (ECG - Effective Computational Geometry for Curves and Surfaces) +// and a STREP (FET Open) Project under Contract No IST-006413 +// (ACS -- Algorithms for Complex Shapes) + +#ifndef CGAL_SPHERICAL_KERNEL_PREDICATES_HAS_ON_3_H +#define CGAL_SPHERICAL_KERNEL_PREDICATES_HAS_ON_3_H + +namespace CGAL { + namespace SphericalFunctors { + + template + inline + bool + has_on(const typename SK::Sphere_3 &a, + const typename SK::Point_3 &p) + { + return a.rep().has_on_boundary(p); + } + + template + inline + bool + has_on(const typename SK::Sphere_3 &a, + const typename SK::Circular_arc_point_3 &p) + { + typedef typename SK::AK AK; + typedef typename SK::Polynomial_for_spheres_2_3 Equation; + Equation equation = get_equation(a); + return (AK().sign_at_object()(equation,p.coordinates()) == ZERO); + } + + template + inline + bool + has_on(const typename SK::Plane_3 &a, + const typename SK::Point_3 &p) + { + return a.rep().has_on(p); + } + + template + inline + bool + has_on(const typename SK::Plane_3 &a, + const typename SK::Circular_arc_point_3 &p) + { + typedef typename SK::AK AK; + typedef typename SK::Polynomial_1_3 Equation; + Equation equation = get_equation(a); + return (AK().sign_at_object()(equation,p.coordinates()) == ZERO); + } + + template + inline + bool + has_on(const typename SK::Line_3 &a, + const typename SK::Point_3 &p) + { + return a.rep().has_on(p); + } + + template + inline + bool + has_on(const typename SK::Line_3 &a, + const typename SK::Circular_arc_point_3 &p) + { + typedef typename SK::AK AK; + typedef typename SK::Polynomials_for_line_3 Equation; + Equation equation = get_equation(a); + return p.coordinates().is_on_line(equation); + } + + template + inline + bool + has_on(const typename SK::Circle_3 &a, + const typename SK::Point_3 &p) + { + return has_on(a.diametral_sphere(),p) && + has_on(a.supporting_plane(),p); + } + + template + inline + bool + has_on(const typename SK::Circle_3 &a, + const typename SK::Circular_arc_point_3 &p) + { + return has_on(a.diametral_sphere(),p) && + has_on(a.supporting_plane(),p); + } + + template + inline + bool + has_on(const typename SK::Sphere_3 &a, + const typename SK::Circle_3 &p) + { + typedef typename SK::Point_3 Point_3; + typedef typename SK::FT FT; + Point_3 proj = p.supporting_plane().projection(a.center()); + if(!(proj == p.center())) return false; + const FT d2 = CGAL::square(a.center().x() - p.center().x()) + + CGAL::square(a.center().y() - p.center().y()) + + CGAL::square(a.center().z() - p.center().z()); + return ((a.squared_radius() - d2) == p.squared_radius()); + } + + template + inline + bool + has_on(const typename SK::Plane_3 &a, + const typename SK::Line_3 &p) + { + return a.rep().has_on(p); + } + + template + inline + bool + has_on(const typename SK::Plane_3 &a, + const typename SK::Circle_3 &p) + { + return non_oriented_equal(a,p.supporting_plane()); + } + + template + inline + bool + has_on(const typename SK::Line_arc_3 &l, + const typename SK::Circular_arc_point_3 &p, + const bool has_on_supporting_line = false) + { + if(!has_on_supporting_line) { + if(!has_on(l.supporting_line(), p)) { + return false; + } + } + return SK().compare_xyz_3_object()(l.lower_xyz_extremity(),p) <= ZERO && + SK().compare_xyz_3_object()(p,l.higher_xyz_extremity()) <= ZERO; + } + + template + inline + bool + has_on(const typename SK::Line_arc_3 &l, + const typename SK::Point_3 &p, + const bool has_on_supporting_line = false) + { + if(!has_on_supporting_line) { + if(!has_on(l.supporting_line(), p)) { + return false; + } + } + return SK().compare_xyz_3_object()(l.lower_xyz_extremity(),p) <= ZERO && + SK().compare_xyz_3_object()(p,l.higher_xyz_extremity()) <= ZERO; + } + + template + inline + bool + has_on(const typename SK::Plane_3 &p, + const typename SK::Line_arc_3 &l) + { + return SK().has_on_3_object()(p, l.supporting_line()); + } + + template + inline + bool + has_on(const typename SK::Line_3 &l, + const typename SK::Line_arc_3 &la) + { + return non_oriented_equal(l, la.supporting_line()); + } + + }//SphericalFunctors +}//CGAL + + + +#endif //CGAL_SPHERICAL_KERNEL_PREDICATES_HAS_ON_3_H diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_circle_3.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_circle_3.h new file mode 100644 index 00000000000..0da5864eb89 --- /dev/null +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_circle_3.h @@ -0,0 +1,104 @@ +// Copyright (c) 2005 INRIA Sophia-Antipolis (France) +// All rights reserved. +// +// Authors : Monique Teillaud +// Sylvain Pion +// Julien Hazebrouck +// Damien Leroy +// +// Partially supported by the IST Programme of the EU as a Shared-cost +// RTD (FET Open) Project under Contract No IST-2000-26473 +// (ECG - Effective Computational Geometry for Curves and Surfaces) +// and a STREP (FET Open) Project under Contract No IST-006413 +// (ACS -- Algorithms for Complex Shapes) + +#ifndef CGAL_SPHERICAL_KERNEL_PREDICATES_ON_CIRCLE_3_H +#define CGAL_SPHERICAL_KERNEL_PREDICATES_ON_CIRCLE_3_H + +namespace CGAL { + namespace SphericalFunctors { + + template < class SK > + typename SK::Circle_3 + construct_circle_3(const typename SK::Polynomials_for_circle_3 &eq) + { + typedef typename SK::Point_3 Point_3; + typedef typename SK::Plane_3 Plane_3; + typedef typename SK::Circle_3 Circle_3; + typedef typename SK::Sphere_3 Sphere_3; + typedef typename SK::FT FT; + Sphere_3 s = construct_sphere_3(eq.first); + Plane_3 p = construct_plane_3(eq.second); + const FT d2 = CGAL::square(p.a()*s.center().x() + + p.b()*s.center().y() + + p.c()*s.center().z() + p.d()) / + (CGAL::square(p.a()) + CGAL::square(p.b()) + CGAL::square(p.c())); + // We do not accept circles with radius 0 (should we?) + CGAL_kernel_precondition(d2 < s.squared_radius()); + // d2 < s.squared_radius() + Point_3 center = p.projection(s.center()); + return Circle_3(center,s.squared_radius() - d2,p); + } + + template< class SK> + bool + equal( const typename SK::Circle_3 &p1, + const typename SK::Circle_3 &p2) + { + return p1.rep() == p2.rep(); + } + + template + typename SK::Circular_arc_point_3 + x_extremal_point(const typename SK::Circle_3 & c, bool i) + { + typedef typename SK::Algebraic_kernel AK; + return AK().x_critical_points_object()(typename SK::Get_equation()(c),i); + } + + template + OutputIterator + x_extremal_points(const typename SK::Circle_3 & c, OutputIterator res) + { + typedef typename SK::Algebraic_kernel AK; + return AK().x_critical_points_object()(typename SK::Get_equation()(c),res); + } + + template + typename SK::Circular_arc_point_3 + y_extremal_point(const typename SK::Circle_3 & c, bool i) + { + typedef typename SK::Algebraic_kernel AK; + return AK().y_critical_points_object()(typename SK::Get_equation()(c),i); + } + + template + OutputIterator + y_extremal_points(const typename SK::Circle_3 & c, OutputIterator res) + { + typedef typename SK::Algebraic_kernel AK; + return AK().y_critical_points_object()(typename SK::Get_equation()(c),res); + } + + template + typename SK::Circular_arc_point_3 + z_extremal_point(const typename SK::Circle_3 & c, bool i) + { + typedef typename SK::Algebraic_kernel AK; + return AK().z_critical_points_object()(typename SK::Get_equation()(c),i); + } + + template + OutputIterator + z_extremal_points(const typename SK::Circle_3 & c, OutputIterator res) + { + typedef typename SK::Algebraic_kernel AK; + return AK().z_critical_points_object()(typename SK::Get_equation()(c),res); + } + + }//SphericalFunctors +}//CGAL + + + +#endif //CGAL_SPHERICAL_KERNEL_PREDICATES_ON_CIRCLE_3_H diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_circular_arc_point_3.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_circular_arc_point_3.h new file mode 100644 index 00000000000..fcf7ed8a1fe --- /dev/null +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_circular_arc_point_3.h @@ -0,0 +1,35 @@ +// Copyright (c) 2005 INRIA Sophia-Antipolis (France) +// All rights reserved. +// +// Authors : Monique Teillaud +// Sylvain Pion +// Julien Hazebrouck +// Damien Leroy +// +// Partially supported by the IST Programme of the EU as a Shared-cost +// RTD (FET Open) Project under Contract No IST-2000-26473 +// (ECG - Effective Computational Geometry for Curves and Surfaces) +// and a STREP (FET Open) Project under Contract No IST-006413 +// (ACS -- Algorithms for Complex Shapes) + +#ifndef CGAL_SPHERICAL_KERNEL_PREDICATES_ON_CIRCULAR_ARC_POINT_3_H +#define CGAL_SPHERICAL_KERNEL_PREDICATES_ON_CIRCULAR_ARC_POINT_3_H + +namespace CGAL { + namespace SphericalFunctors { + + template< class SK> + bool + equal( const typename SK::Circular_arc_point_3 &p1, + const typename SK::Circular_arc_point_3 &p2) + { + return p1.rep() == p2.rep(); + } + + + }//SphericalFunctors +}//CGAL + + + +#endif //CGAL_SPHERICAL_KERNEL_PREDICATES_ON_CIRCULAR_ARC_POINT_3_H diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_line_3.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_line_3.h new file mode 100644 index 00000000000..e07cd278242 --- /dev/null +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_line_3.h @@ -0,0 +1,37 @@ +// Copyright (c) 2005 INRIA Sophia-Antipolis (France) +// All rights reserved. +// +// Authors : Monique Teillaud +// Sylvain Pion +// Julien Hazebrouck +// Damien Leroy +// +// Partially supported by the IST Programme of the EU as a Shared-cost +// RTD (FET Open) Project under Contract No IST-2000-26473 +// (ECG - Effective Computational Geometry for Curves and Surfaces) +// and a STREP (FET Open) Project under Contract No IST-006413 +// (ACS -- Algorithms for Complex Shapes) + +#ifndef CGAL_SPHERICAL_KERNEL_PREDICATES_ON_LINE_3_H +#define CGAL_SPHERICAL_KERNEL_PREDICATES_ON_LINE_3_H + +namespace CGAL { + namespace SphericalFunctors { + + template < class SK > + typename SK::Line_3 + construct_line_3(const typename SK::Polynomials_for_line_3 &eq) + { + typedef typename SK::Line_3 Line_3; + typedef typename SK::Point_3 Point_3; + typedef typename SK::Vector_3 Vector_3; + return Line_3(Point_3(eq.b1(),eq.b2(),eq.b3()), + Vector_3(eq.a1(),eq.a2(),eq.a3())); + } + + }//SphericalFunctors +}//CGAL + + + +#endif //CGAL_SPHERICAL_KERNEL_PREDICATES_ON_LINE_3_H diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_line_arc_3.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_line_arc_3.h new file mode 100644 index 00000000000..de4a460c6e2 --- /dev/null +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_line_arc_3.h @@ -0,0 +1,286 @@ +// Copyright (c) 2005 INRIA Sophia-Antipolis (France) +// All rights reserved. +// +// Authors : Monique Teillaud +// Sylvain Pion +// Julien Hazebrouck +// Damien Leroy +// +// Partially supported by the IST Programme of the EU as a Shared-cost +// RTD (FET Open) Project under Contract No IST-2000-26473 +// (ECG - Effective Computational Geometry for Curves and Surfaces) +// and a STREP (FET Open) Project under Contract No IST-006413 +// (ACS -- Algorithms for Complex Shapes) + +#ifndef CGAL_SPHERICAL_KERNEL_PREDICATES_ON_LINE_ARC_3_H +#define CGAL_SPHERICAL_KERNEL_PREDICATES_ON_LINE_ARC_3_H + +namespace CGAL { + namespace SphericalFunctors { + + template< class SK> + bool + equal( const typename SK::Line_arc_3 &l1, + const typename SK::Line_arc_3 &l2) + { + return l1.rep() == l2.rep(); + } + + template + inline + bool + do_overlap(const typename SK::Line_arc_3 &l1, + const typename SK::Line_arc_3 &l2) + { + if (!non_oriented_equal(l1.supporting_line(), + l2.supporting_line())) + return false; + + return SK().compare_xyz_3_object()(l1.higher_xyz_extremity(), + l2.lower_xyz_extremity()) >= 0 + && SK().compare_xyz_3_object()(l1.lower_xyz_extremity(), + l2.higher_xyz_extremity()) <= 0; + } + + template < class SK > + void + split(const typename SK::Line_arc_3 &l, + const typename SK::Circular_arc_point_3 &p, + typename SK::Line_arc_3 &l1, + typename SK::Line_arc_3 &l2) + { + typedef typename SK::Line_arc_3 Line_arc_3; + CGAL_kernel_precondition(SK().has_on_3_object()(l, p)); + // It doesn't make sense to split an arc on an extremity + CGAL_kernel_precondition(l.source() != p); + CGAL_kernel_precondition(l.target() != p); + if(SK().compare_xyz_3_object()(l.source(),p) == SMALLER) { + l1 = Line_arc_3(l.supporting_line(),l.source(),p); + l2 = Line_arc_3(l.supporting_line(),p,l.target()); + } else { + l1 = Line_arc_3(l.supporting_line(),p,l.target()); + l2 = Line_arc_3(l.supporting_line(),l.source(),p); + } + } + + // It is the vectorial product of 2 3D vectors + // Maybe there is already this function somewhere, + // but i didn't find + template < class SK > + typename SK::Vector_3 + vp(const typename SK::Vector_3 & v1, + const typename SK::Vector_3 & v2) { + return typename SK::Vector_3((v1.y()*v2.z()-v1.z()*v2.y()), + (v1.z()*v2.x()-v1.x()*v2.z()), + (v1.x()*v2.y()-v1.y()*v2.x())); + } + + template < class SK > + typename SK::Object_3 + intersect_3(const typename SK::Line_3 & l1, + const typename SK::Line_3 & l2, + const bool not_equal_lines = false) + { + typedef typename SK::Vector_3 Vector_3; + typedef typename SK::Line_3 Line_3; + typedef typename SK::Point_3 Point_3; + typedef typename SK::Object_3 Object_3; + typedef typename SK::FT FT; + if(!not_equal_lines) { + if(non_oriented_equal(l1,l2)) + return make_object(l1); + } + if(SK().are_parallel_3_object()(l1,l2)) return Object(); + const Point_3 &p1 = l1.point(); + const Point_3 &p3 = l2.point(); + const Vector_3 &v1 = l1.to_vector(); + const Vector_3 &v2 = l2.to_vector(); + const Point_3 p2 = p1 + v1; + const Point_3 p4 = p2 + v2; + if(!SK().coplanar_3_object()(p1,p2,p3,p4)) return Object(); + const Vector_3 v3 = p3 - p1; + const Vector_3 v3v2 = vp(v3,v2); + const Vector_3 v1v2 = vp(v1,v2); + const FT t = ((v3v2.x()*v1v2.x()) + (v3v2.y()*v1v2.y()) + (v3v2.z()*v1v2.z())) / + (v1v2.squared_length()); + return make_object(p1 + (v1 * t)); + } + + template < class SK, class OutputIterator > + OutputIterator + intersect_3(const typename SK::Line_arc_3 & l1, + const typename SK::Line_arc_3 & l2, + OutputIterator res) + { + typedef typename SK::Point_3 Point_3; + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef typename SK::Line_3 Line_3; + typedef typename SK::Line_arc_3 Line_arc_3; + + if(non_oriented_equal(l1.supporting_line(), + l2.supporting_line())) { + + if(SK().compare_xyz_3_object()(l1.lower_xyz_extremity(), + l2.lower_xyz_extremity()) < 0) { + int comparison = + SK().compare_xyz_3_object()(l2.lower_xyz_extremity(), + l1.higher_xyz_extremity()); + if(comparison < 0) { + if(SK().compare_xyz_3_object()(l1.higher_xyz_extremity(), + l2.higher_xyz_extremity()) <= 0) { + *res++ = make_object + (Line_arc_3(l1.supporting_line(), + l2.lower_xyz_extremity(), + l1.higher_xyz_extremity())); + } else { + *res++ = make_object(l2); + } + } else if (comparison == 0) { + *res++ = make_object(std::make_pair(l2.lower_xyz_extremity(),1u)); + } + return res; + } + else { + int comparison = + SK().compare_xyz_3_object()(l1.lower_xyz_extremity(), + l2.higher_xyz_extremity()); + if(comparison < 0){ + if(SK().compare_xyz_3_object()(l1.higher_xyz_extremity(), + l2.higher_xyz_extremity()) <= 0) { + *res++ = make_object(l1); + } else { + *res++ = make_object + (Line_arc_3(l1.supporting_line(), + l1.lower_xyz_extremity(), + l2.higher_xyz_extremity() )); + } + } + else if (comparison == 0){ + *res++ = make_object(std::make_pair(l1.lower_xyz_extremity(),1u)); + } + return res; + } + } + + Point_3 inters_p; + if(assign(inters_p,intersect_3(l1.supporting_line(), + l2.supporting_line(), true))) { + Circular_arc_point_3 p = inters_p; + if(!SK().has_on_3_object()(l1,p,true)) return res; + if(!SK().has_on_3_object()(l2,p,true)) return res; + *res++ = make_object(std::make_pair(p,1u)); + } + + return res; + } + + template < class SK, class OutputIterator > + OutputIterator + intersect_3(const typename SK::Line_3 & l, + const typename SK::Line_arc_3 & la, + OutputIterator res) + { + typedef typename SK::Point_3 Point_3; + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef typename SK::Line_3 Line_3; + typedef typename SK::Line_arc_3 Line_arc_3; + + if(non_oriented_equal(l, la.supporting_line())) { + *res++ = make_object(la); + } + + Point_3 inters_p; + if(assign(inters_p,intersect_3(l, la.supporting_line(), true))) { + Circular_arc_point_3 p = inters_p; + if(!SK().has_on_3_object()(la,p,true)) return res; + *res++ = make_object(std::make_pair(p,1u)); + } + + } + + template < class SK, class OutputIterator > + OutputIterator + intersect_3(const typename SK::Circle_3 & c, + const typename SK::Line_arc_3 & l, + OutputIterator res) + { + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef std::vector solutions_container; + typedef std::pair Solution; + solutions_container solutions; + SK().intersect_3_object()(l.supporting_line(), c, + std::back_inserter(solutions) ); + if(solutions.size() == 0) return res; + if(solutions.size() == 1) { + Solution sol; + assign(sol, solutions[0]); + if(SK().has_on_3_object()(l,sol.first,true)) + *res++ = solutions[0]; + } else { + Solution sol1, sol2; + assign(sol1, solutions[0]); + assign(sol2, solutions[1]); + if(SK().has_on_3_object()(l,sol1.first,true)) + *res++ = solutions[0]; + if(SK().has_on_3_object()(l,sol2.first,true)) + *res++ = solutions[1]; + } + return res; + } + + template < class SK, class OutputIterator > + OutputIterator + intersect_3(const typename SK::Sphere_3 & s, + const typename SK::Line_arc_3 & l, + OutputIterator res) + { + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef std::vector solutions_container; + typedef std::pair Solution; + solutions_container solutions; + SK().intersect_3_object()(l.supporting_line(), s, + std::back_inserter(solutions) ); + if(solutions.size() == 0) return res; + if(solutions.size() == 1) { + Solution sol; + assign(sol, solutions[0]); + if(SK().has_on_3_object()(l,sol.first,true)) + *res++ = solutions[0]; + } else { + Solution sol1, sol2; + assign(sol1, solutions[0]); + assign(sol2, solutions[1]); + if(SK().has_on_3_object()(l,sol1.first,true)) + *res++ = solutions[0]; + if(SK().has_on_3_object()(l,sol2.first,true)) + *res++ = solutions[1]; + } + return res; + } + + template < class SK, class OutputIterator > + OutputIterator + intersect_3(const typename SK::Plane_3 & p, + const typename SK::Line_arc_3 & l, + OutputIterator res) + { + typedef typename SK::Point_3 Point_3; + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + if(SK().has_on_3_object()(p,l.supporting_line())) { + *res++ = make_object(l); + } + Point_3 sol; + if(!assign(sol,SK().intersect_3_object()(p,l.supporting_line()))) + return res; + if(!SK().has_on_3_object()(l,sol)) return res; + Circular_arc_point_3 point = sol; + *res++ = make_object(std::make_pair(point,1u)); + return res; + } + + }//SphericalFunctors +}//CGAL + + + +#endif //CGAL_SPHERICAL_KERNEL_PREDICATES_ON_LINE_ARC_3_H diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_plane_3.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_plane_3.h new file mode 100644 index 00000000000..4dd2aacd2c6 --- /dev/null +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_plane_3.h @@ -0,0 +1,34 @@ +// Copyright (c) 2005 INRIA Sophia-Antipolis (France) +// All rights reserved. +// +// Authors : Monique Teillaud +// Sylvain Pion +// Julien Hazebrouck +// Damien Leroy +// +// Partially supported by the IST Programme of the EU as a Shared-cost +// RTD (FET Open) Project under Contract No IST-2000-26473 +// (ECG - Effective Computational Geometry for Curves and Surfaces) +// and a STREP (FET Open) Project under Contract No IST-006413 +// (ACS -- Algorithms for Complex Shapes) + +#ifndef CGAL_SPHERICAL_KERNEL_PREDICATES_ON_PLANE_3_H +#define CGAL_SPHERICAL_KERNEL_PREDICATES_ON_PLANE_3_H + +namespace CGAL { + namespace SphericalFunctors { + + template < class SK > + typename SK::Plane_3 + construct_plane_3(const typename SK::Polynomial_1_3 &eq) + { + typedef typename SK::Plane_3 Plane_3; + return Plane_3(eq.a(),eq.b(),eq.c(),eq.d()); + } + + }//SphericalFunctors +}//CGAL + + + +#endif //CGAL_SPHERICAL_KERNEL_PREDICATES_ON_PLANE_3_H diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_sphere_3.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_sphere_3.h new file mode 100644 index 00000000000..dc97a14ad8a --- /dev/null +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/internal_functions_on_sphere_3.h @@ -0,0 +1,535 @@ +// Copyright (c) 2005 INRIA Sophia-Antipolis (France) +// All rights reserved. +// +// Authors : Monique Teillaud +// Sylvain Pion +// Julien Hazebrouck +// Damien Leroy +// +// Partially supported by the IST Programme of the EU as a Shared-cost +// RTD (FET Open) Project under Contract No IST-2000-26473 +// (ECG - Effective Computational Geometry for Curves and Surfaces) +// and a STREP (FET Open) Project under Contract No IST-006413 +// (ACS -- Algorithms for Complex Shapes) + +#ifndef CGAL_SPHERICAL_KERNEL_PREDICATES_ON_SPHERE_3_H +#define CGAL_SPHERICAL_KERNEL_PREDICATES_ON_SPHERE_3_H + +namespace CGAL { + namespace SphericalFunctors { + + template < class SK > + typename SK::Algebraic_kernel::Polynomials_for_line_3 + get_equation( const typename SK::Line_3 & l) + { + typedef typename SK::Algebraic_kernel AK; + return AK().construct_polynomials_for_line_3_object() + (l.to_vector().x(), l.point().x(), + l.to_vector().y(), l.point().y(), + l.to_vector().z(), l.point().z()); + } + + template < class SK > + typename SK::Polynomial_1_3 + get_equation( const typename SK::Plane_3 & s ) + { + typedef typename SK::Algebraic_kernel AK; + return AK().construct_polynomial_1_3_object() + ( s.a(), s.b(), s.c(), s.d() ); + } + + template < class SK > + typename SK::Polynomial_for_spheres_2_3 + get_equation( const typename SK::Sphere_3 & s ) + { + typedef typename SK::RT RT; + typedef typename SK::Point_3 Point_3; + typedef typename SK::Algebraic_kernel AK; + Point_3 center = s.center(); + return AK().construct_polynomial_for_spheres_2_3_object() + ( center.x(), center.y(), center.z(), s.squared_radius() ); + } + + template < class SK > + typename SK::Polynomials_for_circle_3 + get_equation( const typename SK::Circle_3 & c ) + { + typedef typename SK::Algebraic_kernel AK; + return std::make_pair ( AK().construct_polynomial_for_spheres_2_3_object() + (c.center().x(), c.center().y(), + c.center().z(), c.squared_radius()), + AK().construct_polynomial_1_3_object() + (c.supporting_plane().a(), + c.supporting_plane().b(), + c.supporting_plane().c(), + c.supporting_plane().d())); + } + + template < class SK > + typename SK::Sphere_3 + construct_sphere_3(const typename SK::Polynomial_for_spheres_2_3 &eq) + { + typedef typename SK::Sphere_3 Sphere_3; + typedef typename SK::Point_3 Point_3; + return Sphere_3(Point_3(eq.a(),eq.b(),eq.c()),eq.r_sq()); + } + + template < class SK > + inline + bool + non_oriented_equal(const typename SK::Sphere_3 & s1, + const typename SK::Sphere_3 & s2) { + // Should we compare anyway even if they are degenerated? + CGAL_kernel_assertion(!(s1.is_degenerate() || s2.is_degenerate())); + return s1.center() == s2.center() && + s1.squared_radius() == s2.squared_radius(); + } + + template < class SK > + inline + bool + non_oriented_equal(const typename SK::Plane_3 & p1, + const typename SK::Plane_3 & p2) { + // Should we compare anyway even if they are degenerated? + CGAL_kernel_assertion(!(p1.is_degenerate() || p2.is_degenerate())); + if(is_zero(p1.a())) { + if(!is_zero(p2.a())) return false; + if(is_zero(p1.b())) { + if(!is_zero(p2.b())) return false; + return p1.c() * p2.d() == p1.d() * p2.c(); + } + return (p2.c() * p1.b() == p1.c() * p2.b()) && + (p2.d() * p1.b() == p1.d() * p2.b()); + } + return (p2.b() * p1.a() == p1.b() * p2.a()) && + (p2.c() * p1.a() == p1.c() * p2.a()) && + (p2.d() * p1.a() == p1.d() * p2.a()); + } + + template < class SK > + inline + bool + non_oriented_equal(const typename SK::Circle_3 & c1, + const typename SK::Circle_3 & c2) { + // We see degeneracies on the other non_oriented_equal functions + if(!non_oriented_equal(c1.diametral_sphere(), + c2.diametral_sphere())) return false; + if(!non_oriented_equal(c1.supporting_plane(), + c2.supporting_plane())) return false; + return true; + } + + template< class SK> + bool + non_oriented_equal( const typename SK::Line_3 &l1, + const typename SK::Line_3 &l2) + { + typedef typename SK::Vector_3 Vector_3; + if(!SK().has_on_3_object()(l1, l2.point())) return false; + + const Vector_3& v1 = l1.to_vector(); + const Vector_3& v2 = l2.to_vector(); + + if(v1.x() * v2.y() != v1.y() * v2.x()) return false; + if(v1.x() * v2.z() != v1.z() * v2.x()) return false; + if(v1.y() * v2.z() != v1.z() * v2.y()) return false; + + return true; + } + + template< class SK> + bool + non_oriented_equal( const typename SK::Line_arc_3 &l1, + const typename SK::Line_arc_3 &l2) + { + if(!non_oriented_equal(l1.supporting_line(), + l2.supporting_line())) return false; + return (l1.lower_xyz_extremity() == l2.lower_xyz_extremity()) && + (l1.higher_xyz_extremity() == l2.higher_xyz_extremity()); + } + + template < class SK> + inline + typename SK::Plane_3 + radical_plane(const typename SK::Sphere_3 & s1, + const typename SK::Sphere_3 & s2) + { + typedef typename SK::Plane_3 Plane_3; + typedef typename SK::Point_3 Point_3; + typedef typename SK::FT FT; + const FT a = 2*(s2.center().x() - s1.center().x()); + const FT b = 2*(s2.center().y() - s1.center().y()); + const FT c = 2*(s2.center().z() - s1.center().z()); + const FT d = CGAL::square(s1.center().x()) + + CGAL::square(s1.center().y()) + + CGAL::square(s1.center().z()) - s1.squared_radius() - + CGAL::square(s2.center().x()) - + CGAL::square(s2.center().y()) - + CGAL::square(s2.center().z()) + s2.squared_radius(); + return Plane_3(a, b, c, d); + } + + template < class SK, class OutputIterator > + OutputIterator + intersect_3(const typename SK::Plane_3 & p, + const typename SK::Sphere_3 & s, + OutputIterator res) + { + typedef typename SK::AK AK; + typedef typename SK::Sphere_3 Sphere_3; + typedef typename SK::Polynomial_for_spheres_2_3 Polynomial_for_spheres_2_3; + typedef typename SK::Polynomial_1_3 Polynomial_1_3; + typedef typename SK::Circle_3 Circle_3; + typedef typename SK::Plane_3 Plane_3; + typedef typename SK::Point_3 Point_3; + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef typename SK::Root_for_spheres_2_3 Root_for_spheres_2_3; + typedef typename SK::FT FT; + + const FT d2 = CGAL::square(p.a()*s.center().x() + + p.b()*s.center().y() + + p.c()*s.center().z() + p.d()) / + (CGAL::square(p.a()) + CGAL::square(p.b()) + CGAL::square(p.c())); + + // do not intersect + if(d2 > s.squared_radius()) return res; + // tangent + if(d2 == s.squared_radius()) { + Polynomial_for_spheres_2_3 e1 = get_equation(s); + Polynomial_1_3 e2 = get_equation(p); + typedef std::vector< std::pair < Root_for_spheres_2_3, unsigned > > + solutions_container; + solutions_container solutions; + AK().solve_object()(e1, e1, e2, std::back_inserter(solutions)); + // only 1 solution + typename solutions_container::iterator it = solutions.begin(); + *res++ = make_object(std::make_pair(Circular_arc_point_3(it->first), + it->second )); + return res; + } + // d2 < s.squared_radius() + Point_3 center = p.projection(s.center()); + *res++ = make_object(Circle_3(center,s.squared_radius() - d2,p)); + return res; + } + + namespace CGALi { + template < class SK > + inline + bool + do_intersect(const typename SK::Sphere_3 & s1, + const typename SK::Sphere_3 & s2) + { + typedef typename SK::Root_of_2 Root_of_2; + typedef typename SK::FT FT; + const FT dx = s2.center().x() - s1.center().x(); + const FT dy = s2.center().y() - s1.center().y(); + const FT dz = s2.center().z() - s1.center().z(); + const FT d2 = CGAL::square(dx) + + CGAL::square(dy) + + CGAL::square(dz); + const FT sq_r1r2 = s1.squared_radius()*s2.squared_radius(); + const FT sq_r1_p_sq_r2 = s1.squared_radius() + s2.squared_radius(); + Root_of_2 left_1 = make_root_of_2(d2,-2,sq_r1r2); + if(left_1 > sq_r1_p_sq_r2) return false; + Root_of_2 left_2 = make_root_of_2(d2,2,sq_r1r2); + if(left_2 < sq_r1_p_sq_r2) return false; + return true; + } + } + + template < class SK, class OutputIterator > + OutputIterator + intersect_3(const typename SK::Sphere_3 & s1, + const typename SK::Sphere_3 & s2, + OutputIterator res) + { + typedef typename SK::Plane_3 Plane_3; + typedef typename SK::Sphere_3 Sphere_3; + if(non_oriented_equal(s1,s2)) { + *res++ = make_object(s1); + return res; + } + if(!CGALi::do_intersect(s1,s2)) return res; + Plane_3 p = radical_plane(s1,s2); + return intersect_3(p,s1,res); + } + + template < class SK, class OutputIterator > + OutputIterator + intersect_3(const typename SK::Sphere_3 & s, + const typename SK::Line_3 & l, + OutputIterator res) + { + typedef typename SK::AK AK; + typedef typename SK::Polynomial_for_spheres_2_3 Equation_sphere; + typedef typename SK::Polynomials_for_line_3 Equation_line; + typedef typename SK::Root_for_spheres_2_3 Root_for_spheres_2_3; + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + Equation_sphere e1 = get_equation(s); + Equation_line e2 = get_equation(l); + typedef std::vector< std::pair < Root_for_spheres_2_3, unsigned > > + solutions_container; + solutions_container solutions; + AK().solve_object()(e1, e2, std::back_inserter(solutions)); + for ( typename solutions_container::iterator it = solutions.begin(); + it != solutions.end(); ++it ) { + *res++ = make_object(std::make_pair(Circular_arc_point_3(it->first), + it->second )); + } + return res; + } + + template < class SK, class OutputIterator > + OutputIterator + intersect_3(const typename SK::Sphere_3 & s1, + const typename SK::Sphere_3 & s2, + const typename SK::Sphere_3 & s3, + OutputIterator res) + { + typedef typename SK::Polynomial_for_spheres_2_3 Equation_sphere; + typedef typename SK::Root_for_spheres_2_3 Root_for_spheres_2_3; + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef typename SK::Circle_3 Circle_3; + typedef typename SK::AK AK; + typedef std::vector< Object > solutions_container; + if(non_oriented_equal(s1,s2) && non_oriented_equal(s2,s3)) { + *res++ = make_object(s1); + return res; + } + if(non_oriented_equal(s1,s2)) { + return intersect_3(s1,s3,res); + } + if((non_oriented_equal(s1,s3)) || + (non_oriented_equal(s2,s3))) { + return intersect_3(s1,s2,res); + } + if(SK().collinear_3_object()(s1.center(),s2.center(),s3.center())) { + solutions_container solutions; + intersect_3(s1, s2, std::back_inserter(solutions)); + if(solutions.size() == 0) return res; + std::pair pair; + if(assign(pair,solutions[0])) { + if(SK().has_on_3_object()(s3,pair.first)) { + *res++ = solutions[0]; + return res; + } else return res; + } + // must be a circle + Circle_3 c; + assign(c,solutions[0]); + if(SK().has_on_3_object()(s3,c)) { + *res++ = solutions[0]; + return res; + } + return res; + } + Equation_sphere e1 = get_equation(s1); + Equation_sphere e2 = get_equation(s2); + Equation_sphere e3 = get_equation(s3); + typedef std::vector< std::pair < Root_for_spheres_2_3, unsigned > > + algebraic_solutions_container; + algebraic_solutions_container solutions; + AK().solve_object()(e1, e2, e3, std::back_inserter(solutions)); + for ( typename algebraic_solutions_container::iterator it = + solutions.begin(); it != solutions.end(); ++it ) { + *res++ = make_object(std::make_pair(Circular_arc_point_3(it->first), + it->second )); + } + return res; + } + + template < class SK, class OutputIterator > + OutputIterator + intersect_3(const typename SK::Plane_3 & p, + const typename SK::Sphere_3 & s1, + const typename SK::Sphere_3 & s2, + OutputIterator res) + { + typedef typename SK::Root_for_spheres_2_3 Root_for_spheres_2_3; + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef typename SK::Polynomial_for_spheres_2_3 Equation_sphere; + typedef typename SK::Polynomial_1_3 Equation_plane; + typedef typename SK::Plane_3 Plane_3; + typedef typename SK::AK AK; + if(non_oriented_equal(s1,s2)) { + return intersect_3(p,s1,res); + } + Plane_3 radical_p = radical_plane(s1,s2); + if(non_oriented_equal(p,radical_p)) { + return intersect_3(p,s1,res); + } + Equation_sphere e1 = get_equation(s1); + Equation_sphere e2 = get_equation(s2); + Equation_plane e3 = get_equation(p); + typedef std::vector< std::pair < Root_for_spheres_2_3, unsigned > > + algebraic_solutions_container; + algebraic_solutions_container solutions; + AK().solve_object()(e1, e2, e3, std::back_inserter(solutions)); + for ( typename algebraic_solutions_container::iterator it = + solutions.begin(); it != solutions.end(); ++it ) { + *res++ = make_object(std::make_pair(Circular_arc_point_3(it->first), + it->second )); + } + return res; + } + + template < class SK, class OutputIterator > + OutputIterator + intersect_3(const typename SK::Plane_3 & p1, + const typename SK::Plane_3 & p2, + const typename SK::Sphere_3 & s, + OutputIterator res) + { + typedef typename SK::Root_for_spheres_2_3 Root_for_spheres_2_3; + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef typename SK::Polynomial_for_spheres_2_3 Equation_sphere; + typedef typename SK::Polynomial_1_3 Equation_plane; + typedef typename SK::AK AK; + if(non_oriented_equal(p1,p2)) { + return intersect_3(p1,s,res); + } + Equation_plane e1 = get_equation(p1); + Equation_plane e2 = get_equation(p2); + Equation_sphere e3 = get_equation(s); + typedef std::vector< std::pair < Root_for_spheres_2_3, unsigned > > + algebraic_solutions_container; + algebraic_solutions_container solutions; + AK().solve_object()(e1, e2, e3, std::back_inserter(solutions)); + for ( typename algebraic_solutions_container::iterator it = + solutions.begin(); it != solutions.end(); ++it ) { + *res++ = make_object(std::make_pair(Circular_arc_point_3(it->first), + it->second )); + } + return res; + } + + template < class SK, class OutputIterator > + OutputIterator + intersect_3(const typename SK::Circle_3 & c, + const typename SK::Plane_3 & p, + OutputIterator res) + { + return intersect_3(p,c.supporting_plane(),c.diametral_sphere(),res); + } + + template < class SK, class OutputIterator > + OutputIterator + intersect_3(const typename SK::Circle_3 & c, + const typename SK::Sphere_3 & s, + OutputIterator res) + { + return intersect_3(c.supporting_plane(),s,c.diametral_sphere(),res); + } + + template < class SK, class OutputIterator > + OutputIterator + intersect_3(const typename SK::Circle_3 & c1, + const typename SK::Circle_3 & c2, + OutputIterator res) + { + typedef typename SK::Root_for_spheres_2_3 Root_for_spheres_2_3; + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef typename SK::Polynomials_for_circle_3 Equation_circle; + typedef typename SK::Circle_3 Circle_3; + typedef typename SK::AK AK; + if(non_oriented_equal(c1,c2)) { + *res++ = make_object(c1); + return res; + } + Equation_circle e1 = get_equation(c1); + Equation_circle e2 = get_equation(c2); + typedef std::vector< std::pair < Root_for_spheres_2_3, unsigned > > + algebraic_solutions_container; + algebraic_solutions_container solutions; + AK().solve_object()(e1, e2, std::back_inserter(solutions)); + for ( typename algebraic_solutions_container::iterator it = + solutions.begin(); it != solutions.end(); ++it ) { + *res++ = make_object(std::make_pair(Circular_arc_point_3(it->first), + it->second )); + } + return res; + } + + template < class SK, class OutputIterator > + OutputIterator + intersect_3(const typename SK::Circle_3 & c, + const typename SK::Line_3 & l, + OutputIterator res) + { + typedef typename SK::Root_for_spheres_2_3 Root_for_spheres_2_3; + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef typename SK::Polynomials_for_circle_3 Equation_circle; + typedef typename SK::Polynomials_for_line_3 Equation_line; + typedef typename SK::Circle_3 Circle_3; + typedef typename SK::AK AK; + Equation_circle e1 = get_equation(c); + Equation_line e2 = get_equation(l); + typedef std::vector< std::pair < Root_for_spheres_2_3, unsigned > > + algebraic_solutions_container; + algebraic_solutions_container solutions; + AK().solve_object()(e1, e2, std::back_inserter(solutions)); + for ( typename algebraic_solutions_container::iterator it = + solutions.begin(); it != solutions.end(); ++it ) { + *res++ = make_object(std::make_pair(Circular_arc_point_3(it->first), + it->second )); + } + return res; + } + + // At the moment we dont need those functions + // But in the future maybe (some make_x_monotone? etc..) + template + typename SK::Circular_arc_point_3 + x_extremal_point(const typename SK::Sphere_3 & c, bool i) + { + typedef typename SK::Algebraic_kernel AK; + return AK().x_critical_points_object()(typename SK::Get_equation()(c),i); + } + + template + OutputIterator + x_extremal_points(const typename SK::Sphere_3 & c, OutputIterator res) + { + typedef typename SK::Algebraic_kernel AK; + return AK().x_critical_points_object()(typename SK::Get_equation()(c),res); + } + + template + typename SK::Circular_arc_point_3 + y_extremal_point(const typename SK::Sphere_3 & c, bool i) + { + typedef typename SK::Algebraic_kernel AK; + return AK().y_critical_points_object()(typename SK::Get_equation()(c),i); + } + + template + OutputIterator + y_extremal_points(const typename SK::Sphere_3 & c, OutputIterator res) + { + typedef typename SK::Algebraic_kernel AK; + return AK().y_critical_points_object()(typename SK::Get_equation()(c),res); + } + + template + typename SK::Circular_arc_point_3 + z_extremal_point(const typename SK::Sphere_3 & c, bool i) + { + typedef typename SK::Algebraic_kernel AK; + return AK().z_critical_points_object()(typename SK::Get_equation()(c),i); + } + + template + OutputIterator + z_extremal_points(const typename SK::Sphere_3 & c, OutputIterator res) + { + typedef typename SK::Algebraic_kernel AK; + return AK().z_critical_points_object()(typename SK::Get_equation()(c),res); + } + + }//SphericalFunctors +}//CGAL + + + +#endif //CGAL_SPHERICAL_KERNEL_PREDICATES_ON_SPHERE_3_H diff --git a/Circular_kernel_3/include/CGAL/Line_arc_3.h b/Circular_kernel_3/include/CGAL/Line_arc_3.h new file mode 100644 index 00000000000..e57aca76a86 --- /dev/null +++ b/Circular_kernel_3/include/CGAL/Line_arc_3.h @@ -0,0 +1,185 @@ +// Copyright (c) 2005 INRIA Sophia-Antipolis (France) +// All rights reserved. +// +// Authors : Monique Teillaud +// Sylvain Pion +// Julien Hazebrouck +// Damien Leroy +// +// Partially supported by the IST Programme of the EU as a Shared-cost +// RTD (FET Open) Project under Contract No IST-2000-26473 +// (ECG - Effective Computational Geometry for Curves and Surfaces) +// and a STREP (FET Open) Project under Contract No IST-006413 +// (ACS -- Algorithms for Complex Shapes) + +#ifndef CGAL_LINE_ARC_3_H +#define CGAL_LINE_ARC_3_H + +namespace CGAL { + template + class Line_arc_3 + : public SK::Kernel_base::Line_arc_3 + { + + typedef typename SK::RT RT; + typedef typename SK::FT FT; + typedef typename SK::Line_3 Line_3; + typedef typename SK::Point_3 Point_3; + typedef typename SK::Plane_3 Plane_3; + typedef typename SK::Sphere_3 Sphere_3; + typedef typename SK::Segment_3 Segment_3; + typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; + typedef typename SK::Kernel_base::Line_arc_3 RLine_arc_3; + + + public: + typedef RLine_arc_3 Rep; + typedef SK R; + + const Rep& rep() const + { + return *this; + } + + Rep& rep() + { + return *this; + } + + Line_arc_3() + : RLine_arc_3(typename R::Construct_line_arc_3()()) + {} + + Line_arc_3(const Line_3& l, + const Circular_arc_point_3& s, + const Circular_arc_point_3& t) + : RLine_arc_3(typename R::Construct_line_arc_3()(l,s,t)) + {} + + Line_arc_3(const Line_3& l, + const Point_3& s, + const Circular_arc_point_3& t) + : RLine_arc_3(typename R::Construct_line_arc_3()(l,s,t)) + {} + + Line_arc_3(const Line_3& l, + const Circular_arc_point_3& s, + const Point_3& t) + : RLine_arc_3(typename R::Construct_line_arc_3()(l,s,t)) + {} + + Line_arc_3(const Line_3& l, + const Point_3& s, + const Point_3& t) + : RLine_arc_3(typename R::Construct_line_arc_3()(l,s,t)) + {} + + Line_arc_3(const Segment_3 &s) + : RLine_arc_3(typename R::Construct_line_arc_3()(s)) + {} + + Line_arc_3(const Line_3 &l, + const Sphere_3 &s, + bool less_xyz_first = true) + : RLine_arc_3(typename R::Construct_line_arc_3()(l,s,less_xyz_first)) + {} + + Line_arc_3(const Sphere_3 &s, + const Line_3 &l, + bool less_xyz_first = true) + : RLine_arc_3(typename R::Construct_line_arc_3()(s,l,less_xyz_first)) + {} + + Line_arc_3(const Line_3 &l, + const Sphere_3 &s1, bool less_xyz_s1, + const Sphere_3 &s2, bool less_xyz_s2) + : RLine_arc_3(typename R::Construct_line_arc_3()(l,s1,less_xyz_s1, + s2,less_xyz_s2)) + {} + + Line_arc_3(const Sphere_3 &s1, bool less_xyz_s1, + const Sphere_3 &s2, bool less_xyz_s2, + const Line_3 &l) + : RLine_arc_3(typename R::Construct_line_arc_3()(s1,less_xyz_s1, + s2,less_xyz_s2,l)) + {} + + Line_arc_3(const Line_3 &l, + const Plane_3 &p1, + const Plane_3 &p2) + : RLine_arc_3(typename R::Construct_line_arc_3()(l,p1,p2)) + {} + + Line_arc_3(const Plane_3 &p1, + const Plane_3 &p2, + const Line_3 &l) + : RLine_arc_3(typename R::Construct_line_arc_3()(p1,p2,l)) + {} + + Line_arc_3(const RLine_arc_3 &a) + : RLine_arc_3(a) + {} + + typename Qualified_result_of + ::type + source() const + { + return typename R::Construct_circular_source_vertex_3()(*this); + } + + typename Qualified_result_of + ::type + target() const + { + return typename R::Construct_circular_target_vertex_3()(*this); + } + + typename Qualified_result_of + ::type + lower_xyz_extremity() const + { + return typename R::Construct_circular_min_vertex_3()(*this); + } + + typename Qualified_result_of + ::type + higher_xyz_extremity() const + { + return typename R::Construct_circular_max_vertex_3()(*this); + } + + typename Qualified_result_of + ::type + supporting_line() const + { + return typename R::Construct_supporting_line_3()(*this); + } + + Bbox_3 bbox() const + { return typename R::Construct_bbox_3()(*this); } + + }; + +template < typename SK > +inline +bool +operator==(const Line_arc_3 &p, + const Line_arc_3 &q) +{ + return SK().equal_3_object()(p, q); +} + +template < typename SK > +inline +bool +operator!=(const Line_arc_3 &p, + const Line_arc_3 &q) +{ + return ! (p == q); +} + + + +} + +#endif diff --git a/Circular_kernel_3/include/CGAL/Simple_spherical_kernel_3.h b/Circular_kernel_3/include/CGAL/Simple_spherical_kernel_3.h new file mode 100644 index 00000000000..393fb3d5d95 --- /dev/null +++ b/Circular_kernel_3/include/CGAL/Simple_spherical_kernel_3.h @@ -0,0 +1,95 @@ +// Copyright (c) 2005 INRIA Sophia-Antipolis (France) +// All rights reserved. +// +// Authors : Monique Teillaud +// Sylvain Pion +// Julien Hazebrouck +// Damien Leroy +// +// Partially supported by the IST Programme of the EU as a Shared-cost +// RTD (FET Open) Project under Contract No IST-2000-26473 +// (ECG - Effective Computational Geometry for Curves and Surfaces) +// and a STREP (FET Open) Project under Contract No IST-006413 +// (ACS -- Algorithms for Complex Shapes) + +#ifndef CGAL_SPHERICAL_KERNEL_3_H +#define CGAL_SPHERICAL_KERNEL_3_H + +#include +#include + +#include +#include + +#include +#include + +#include + +#include + +#include + +namespace CGAL { + namespace CGALi { + + template < class SphericalKernel, class LinearKernelBase > + struct Spherical_kernel_base_no_ref_count: public LinearKernelBase + // takes classes in internal sub-namespace + { + typedef CGALi::Circular_arc_point_3 Circular_arc_point_3; + typedef CGALi::Circle_3 Circle_3; + typedef CGALi::Line_arc_3 Line_arc_3; + + // The mecanism that allows to specify reference-counting or not. + template < typename T > + struct Handle { typedef T type; }; + + #define CGAL_Spherical_Kernel_pred(Y,Z) typedef SphericalFunctors::Y Y; \ + Y Z() const { return Y(); } + #define CGAL_Spherical_Kernel_cons(Y,Z) CGAL_Spherical_Kernel_pred(Y,Z) + + #include + }; + + } // namespace CGALi + + template < class LinearKernel, class AlgebraicKernel > + struct Spherical_kernel_3 + : // there should be a derivation from + // LinearKernel::Kernel_base to have types equalities for + // the Linearkernel types + public Spherical_kernel_type_equality_wrapper, + typename LinearKernel::template Base >::Type >, + Spherical_kernel_3 > + { + typedef Spherical_kernel_3 Self; + + typedef typename LinearKernel::template Base >::Type Linear_kernel; + typedef AlgebraicKernel Algebraic_kernel; + + // //Please remove this if you consider it to be sloppy + struct Circular_tag{}; + typedef Circular_tag Definition_tag; + // //////////////////////////////////////////////////// + + + typedef typename LinearKernel::RT RT; + typedef typename LinearKernel::FT FT; + typedef Algebraic_kernel AK; + typedef typename AK::Root_of_2 Root_of_2; + typedef typename AK::Root_for_spheres_2_3 Root_for_spheres_2_3; + typedef typename AK::Polynomial_for_spheres_2_3 Polynomial_for_spheres_2_3; + typedef typename AK::Polynomial_1_3 Polynomial_1_3; + typedef typename AK::Polynomials_for_line_3 Polynomials_for_line_3; + typedef std::pair< Polynomial_for_spheres_2_3, Polynomial_1_3 > + Polynomials_for_circle_3; + + // public classes + typedef CGAL::Object Object_3; + + }; + +} // namespace CGAL + +#endif // CGAL_SPHERICAL_KERNEL_3_H diff --git a/Circular_kernel_3/include/CGAL/Spherical_kernel_3.h b/Circular_kernel_3/include/CGAL/Spherical_kernel_3.h new file mode 100644 index 00000000000..c7f279e200b --- /dev/null +++ b/Circular_kernel_3/include/CGAL/Spherical_kernel_3.h @@ -0,0 +1,95 @@ +// Copyright (c) 2005 INRIA Sophia-Antipolis (France) +// All rights reserved. +// +// Authors : Monique Teillaud +// Sylvain Pion +// Julien Hazebrouck +// Damien Leroy +// +// Partially supported by the IST Programme of the EU as a Shared-cost +// RTD (FET Open) Project under Contract No IST-2000-26473 +// (ECG - Effective Computational Geometry for Curves and Surfaces) +// and a STREP (FET Open) Project under Contract No IST-006413 +// (ACS -- Algorithms for Complex Shapes) + +#ifndef CGAL_SPHERICAL_KERNEL_3_H +#define CGAL_SPHERICAL_KERNEL_3_H + +#include +#include + +#include +#include + +#include +#include + +#include + +#include + +#include + +namespace CGAL { + namespace CGALi { + + template < class SphericalKernel, class LinearKernelBase > + struct Spherical_kernel_base_ref_count: public LinearKernelBase + // takes classes in internal sub-namespace + { + typedef CGALi::Circular_arc_point_3 Circular_arc_point_3; + typedef CGALi::Circle_3 Circle_3; + typedef CGALi::Line_arc_3 Line_arc_3; + + // The mecanism that allows to specify reference-counting or not. + template < typename T > + struct Handle { typedef Handle_for type; }; + + #define CGAL_Spherical_Kernel_pred(Y,Z) typedef SphericalFunctors::Y Y; \ + Y Z() const { return Y(); } + #define CGAL_Spherical_Kernel_cons(Y,Z) CGAL_Spherical_Kernel_pred(Y,Z) + + #include + }; + + } // namespace CGALi + + template < class LinearKernel, class AlgebraicKernel > + struct Spherical_kernel_3 + : // there should be a derivation from + // LinearKernel::Kernel_base to have types equalities for + // the Linearkernel types + public Spherical_kernel_type_equality_wrapper, + typename LinearKernel::template Base >::Type >, + Spherical_kernel_3 > + { + typedef Spherical_kernel_3 Self; + + typedef typename LinearKernel::template Base >::Type Linear_kernel; + typedef AlgebraicKernel Algebraic_kernel; + + // //Please remove this if you consider it to be sloppy + struct Circular_tag{}; + typedef Circular_tag Definition_tag; + // //////////////////////////////////////////////////// + + + typedef typename LinearKernel::RT RT; + typedef typename LinearKernel::FT FT; + typedef Algebraic_kernel AK; + typedef typename AK::Root_of_2 Root_of_2; + typedef typename AK::Root_for_spheres_2_3 Root_for_spheres_2_3; + typedef typename AK::Polynomial_for_spheres_2_3 Polynomial_for_spheres_2_3; + typedef typename AK::Polynomial_1_3 Polynomial_1_3; + typedef typename AK::Polynomials_for_line_3 Polynomials_for_line_3; + typedef std::pair< Polynomial_for_spheres_2_3, Polynomial_1_3 > + Polynomials_for_circle_3; + + // public classes + typedef CGAL::Object Object_3; + + }; + +} // namespace CGAL + +#endif // CGAL_SPHERICAL_KERNEL_3_H diff --git a/Circular_kernel_3/include/CGAL/Spherical_kernel_type_equality_wrapper.h b/Circular_kernel_3/include/CGAL/Spherical_kernel_type_equality_wrapper.h new file mode 100644 index 00000000000..7ba0c579474 --- /dev/null +++ b/Circular_kernel_3/include/CGAL/Spherical_kernel_type_equality_wrapper.h @@ -0,0 +1,38 @@ +// Copyright (c) 2005 INRIA Sophia-Antipolis (France) +// All rights reserved. +// +// Authors : Monique Teillaud +// Sylvain Pion +// Julien Hazebrouck +// Damien Leroy +// +// Partially supported by the IST Programme of the EU as a Shared-cost +// RTD (FET Open) Project under Contract No IST-2000-26473 +// (ECG - Effective Computational Geometry for Curves and Surfaces) +// and a STREP (FET Open) Project under Contract No IST-006413 +// (ACS -- Algorithms for Complex Shapes) + +#ifndef CGAL_SPHERICAL_KERNEL_TYPE_EQUALITY_WRAPPER_H +#define CGAL_SPHERICAL_KERNEL_TYPE_EQUALITY_WRAPPER_H + +#include +#include + + +namespace CGAL { + +template < typename K_base, typename Kernel > +struct Spherical_kernel_type_equality_wrapper + : public Type_equality_wrapper +{ + typedef K_base Kernel_base; + typedef CGAL::Circle_3 Circle_3; + typedef CGAL::Circular_arc_point_3 Circular_arc_point_3; + //typedef CGAL::Circular_arc_3 Circular_arc_3; + typedef CGAL::Line_arc_3 Line_arc_3; + typedef CGAL::Root_of_2 Root_of_2; +}; + +} + +#endif // CGAL_SPHERICAL_KERNEL_TYPE_EQUALITY_WRAPPER_H