* Circular_kernel is now Object free, doesn't compile with Lazy yet,

* hack for ternary function
This commit is contained in:
Philipp Möller 2011-08-25 21:40:12 +00:00
parent a79bcb9e57
commit b07e2df018
19 changed files with 386 additions and 320 deletions

View File

@ -172,7 +172,7 @@ namespace internal {
_begin = CGAL::circle_intersect<CK>(c, c1, b_1);
_end = CGAL::circle_intersect<CK>(c, c2, b_2);
} else {
typedef std::vector<typename IT2<CK, typename CK::Circle_2,
typedef std::vector<typename IT<CK, typename CK::Circle_2,
typename CK::Circle_2>::result_type>
solutions_container;

View File

@ -74,7 +74,7 @@ public:
intersect(const Line_2 & l, const Circle_2 & c, const bool b)
{
typedef std::vector<typename IT2<CK, Line_2, Circle_2>::result_type>
typedef std::vector<typename IT<CK, Line_2, Circle_2>::result_type>
solutions_container;
solutions_container solutions;
@ -129,7 +129,7 @@ public:
CGAL_kernel_precondition(do_intersect(support, l1));
CGAL_kernel_precondition(do_intersect(support, l2));
//typedef typename Root_of_2::RT RT_2;
typename IT2<CK, Line_2, Line_2>::result_type
typename IT<CK, Line_2, Line_2>::result_type
v = CGAL::internal::intersection(support, l1, CK());
CGAL_assertion(v);

View File

@ -517,8 +517,6 @@ namespace CircularFunctors {
public:
typedef typename CK::Linear_kernel::Intersect_2::result_type result_type;
using CK::Linear_kernel::Intersect_2::operator();
template < class OutputIterator >

View File

@ -34,7 +34,7 @@ circle_intersect( const typename CK::Circle_2 & c1,
const typename CK::Circle_2 & c2,
bool b )
{
typedef std::vector<typename IT2<CK, typename CK::Circle_2,
typedef std::vector<typename IT<CK, typename CK::Circle_2,
typename CK::Circle_2>::result_type> solutions_container;
solutions_container solutions;
@ -123,7 +123,7 @@ namespace CircularFunctors {
const typename CK::Circle_2 & c2,
OutputIterator res )
{
typedef typename IT2<CK, typename CK::Circle_2, typename CK::Circle_2>
typedef typename IT<CK, typename CK::Circle_2, typename CK::Circle_2>
::result_type result_type;
typedef typename CK::Algebraic_kernel AK;
typedef typename CK::Polynomial_for_circles_2_2 Equation;

View File

@ -542,7 +542,7 @@ namespace CircularFunctors {
const typename CK::Circular_arc_2 &a2,
OutputIterator res )
{
typedef typename IT2<CK, typename CK::Circular_arc_2,
typedef typename IT<CK, typename CK::Circular_arc_2,
typename CK::Circular_arc_2 >::result_type result_type;
typedef std::vector<CGAL::Object> solutions_container;

View File

@ -381,7 +381,7 @@ namespace CircularFunctors {
const typename CK::Circle_2 & c,
OutputIterator res )
{
typedef typename IT2<CK, typename CK::Line_2, typename CK::Circle_2>
typedef typename IT<CK, typename CK::Line_2, typename CK::Circle_2>
::result_type result_type;
typedef typename CK::Algebraic_kernel AK;
typedef typename CK::Polynomial_1_2 Equation_line;
@ -416,7 +416,7 @@ namespace CircularFunctors {
const typename CK::Line_arc_2 &a2,
OutputIterator res )
{
typedef typename IT2<CK, typename CK::Line_arc_2, typename CK::Line_arc_2>
typedef typename IT<CK, typename CK::Line_arc_2, typename CK::Line_arc_2>
::result_type result_type;
typedef typename CK::Circular_arc_point_2 Circular_arc_point_2;
typedef typename CK::Line_arc_2 Line_arc_2;
@ -483,7 +483,7 @@ namespace CircularFunctors {
}
}
typename IT2<CK, typename CK::Line_2, typename CK::Line_2>::result_type
typename IT<CK, typename CK::Line_2, typename CK::Line_2>::result_type
v = CGAL::internal::intersection(a1.supporting_line(), a2.supporting_line(), CK());
if(!v) return res;
@ -516,7 +516,7 @@ namespace CircularFunctors {
const typename CK::Circle_2 &c,
OutputIterator res )
{
typedef std::vector<typename IT2<CK, typename CK::Line_2, typename CK::Circle_2>::result_type>
typedef std::vector<typename IT<CK, typename CK::Line_2, typename CK::Circle_2>::result_type>
solutions_container;
solutions_container solutions;
@ -547,7 +547,7 @@ namespace CircularFunctors {
const typename CK::Circular_arc_2 &c,
OutputIterator res )
{
typedef typename IT2<CK, typename CK::Line_arc_2, typename CK::Circular_arc_2 >
typedef typename IT<CK, typename CK::Line_arc_2, typename CK::Circular_arc_2 >
::result_type result_type;
typedef typename CK::Circular_arc_2 Circular_arc_2;
typedef typename CK::Circular_arc_point_2 Circular_arc_point_2;
@ -628,7 +628,7 @@ namespace CircularFunctors {
*res++ = result_type(std::make_pair(q,1u));
return res;
} else { //Case 4b
typedef std::vector<typename IT2<CK, typename CK::Line_2, typename CK::Circle_2>::result_type>
typedef std::vector<typename IT<CK, typename CK::Line_2, typename CK::Circle_2>::result_type>
container;
container solutions;
CGAL::CircularFunctors::intersect_2<CK>( l.supporting_line(), c.supporting_circle(),
@ -754,13 +754,13 @@ namespace CircularFunctors {
typedef typename CK::Line_2 Line_2;
typedef typename CK::Root_of_2 Root_of_2;
typedef typename CK::Root_for_circles_2_2 Root_for_circles_2_2;
typedef typename IT2<CK, Line_2, Line_arc_2>::result_type result_type;
typedef typename IT<CK, Line_2, Line_arc_2>::result_type result_type;
if(LinearFunctors::non_oriented_equal<CK>(l, la.supporting_line())) {
*res++ = result_type(la);
}
typename IT2<CK, Line_2, Line_2>::result_type
typename IT<CK, Line_2, Line_2>::result_type
v = intersection(l, la.supporting_line());
if(!v) return res;
@ -785,7 +785,7 @@ namespace CircularFunctors {
typedef typename CK::Circular_arc_2 Circular_arc_2;
typedef typename CK::Circular_arc_point_2 Circular_arc_point_2;
typedef typename CK::Line_2 Line_2;
typedef std::vector< typename IT2<CK, Line_2, typename CK::Circle_2 >::result_type>
typedef std::vector< typename IT<CK, Line_2, typename CK::Circle_2 >::result_type>
solutions_container;
solutions_container solutions;

View File

@ -46,7 +46,7 @@ namespace internal { \
bool \
do_intersect(const typename K::A &c1, const typename K::B &c2, const K&) \
{ \
std::vector< typename IT2<K, typename K::A, typename K::B >::result_type > res; \
std::vector< typename IT<K, typename K::A, typename K::B >::result_type > res; \
typename K::Intersect_2()(c1,c2,std::back_inserter(res)); \
return !res.empty(); \
} \

View File

@ -596,7 +596,6 @@ public:
typedef typename BK::Circle_2 Circle;
typedef typename BK::Line_2 Line_2;
typedef typename CK_Intersect_2::result_type result_type;
using CK_Intersect_2::operator();
template < class OutputIterator >

View File

@ -163,7 +163,8 @@ namespace CGAL {
const Sphere_3 &s1, bool less_xyz_s1,
const Sphere_3 &s2, bool less_xyz_s2)
{
std::vector<Object> sols1, sols2;
typedef typename IT<SK, Circle_3, Sphere_3>::result_type result_type;
std::vector<result_type> sols1, sols2;
// The spheres must not include the circle
CGAL_kernel_precondition(!SK().has_on_3_object()(s1,c));
CGAL_kernel_precondition(!SK().has_on_3_object()(s2,c));
@ -173,11 +174,11 @@ namespace CGAL {
CGAL_kernel_precondition(sols1.size() > 0);
CGAL_kernel_precondition(sols2.size() > 0);
const std::pair<typename SK::Circular_arc_point_3, unsigned>& pair1=
*object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(
*boost::get<std::pair<typename SK::Circular_arc_point_3, unsigned> >(
&sols1[(sols1.size()==1)?(0):(less_xyz_s1?0:1)]
);
const std::pair<typename SK::Circular_arc_point_3, unsigned>& pair2=
*object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(
*boost::get<std::pair<typename SK::Circular_arc_point_3, unsigned> >(
&sols2[(sols2.size()==1)?(0):(less_xyz_s2?0:1)]
);
// the source and target must be different
@ -189,7 +190,8 @@ namespace CGAL {
const Plane_3 &p1, bool less_xyz_p1,
const Plane_3 &p2, bool less_xyz_p2)
{
std::vector<Object> sols1, sols2;
typedef typename IT<SK, Circle_3, Plane_3>::result_type result_type;
std::vector<result_type> sols1, sols2;
// The planes must not include the circle
CGAL_kernel_precondition(!SK().has_on_3_object()(p1,c));
CGAL_kernel_precondition(!SK().has_on_3_object()(p2,c));
@ -199,11 +201,11 @@ namespace CGAL {
CGAL_kernel_precondition(sols1.size() > 0);
CGAL_kernel_precondition(sols2.size() > 0);
const std::pair<typename SK::Circular_arc_point_3, unsigned>& pair1=
*object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(
*boost::get<std::pair<typename SK::Circular_arc_point_3, unsigned> >(
&sols1[(sols1.size()==1)?(0):(less_xyz_p1?0:1)]
);
const std::pair<typename SK::Circular_arc_point_3, unsigned>& pair2=
*object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(
*boost::get<std::pair<typename SK::Circular_arc_point_3, unsigned> >(
&sols2[(sols2.size()==1)?(0):(less_xyz_p2?0:1)]
);
// the source and target must be different

View File

@ -73,20 +73,20 @@ public:
const Sphere_3 &s2,
const Sphere_3 &s3,
const bool less_xyz = true) {
std::vector<Object> sols;
std::vector<typename ITs<SK>::result_type> 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) {
// the intersection must be a point
const std::pair<typename SK::Circular_arc_point_3, unsigned>* pair=
object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[0]);
boost::get<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[0]);
CGAL_kernel_precondition(pair!=NULL);
*this = pair->first.rep();
} else {
// the intersections must be a point
const std::pair<typename SK::Circular_arc_point_3, unsigned>* pair=
object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[less_xyz?0:1]);
boost::get<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[less_xyz?0:1]);
CGAL_kernel_precondition(pair!=NULL);
*this = pair->first.rep();
}
@ -96,20 +96,20 @@ public:
const Sphere_3 &s1,
const Sphere_3 &s2,
const bool less_xyz = true) {
std::vector<Object> sols;
std::vector<typename ITs<SK>::result_type> 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) {
// the intersection must be a point
const std::pair<typename SK::Circular_arc_point_3, unsigned>* pair=
object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[0]);
boost::get<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[0]);
CGAL_kernel_precondition(pair!=NULL);
*this = pair->first.rep();
} else {
// the intersections must be a point
const std::pair<typename SK::Circular_arc_point_3, unsigned>* pair=
object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[less_xyz?0:1]);
boost::get<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[less_xyz?0:1]);
CGAL_kernel_precondition(pair!=NULL);
*this = pair->first.rep();
}
@ -119,20 +119,20 @@ public:
const Plane_3 &p2,
const Sphere_3 &s,
const bool less_xyz = true) {
std::vector<Object> sols;
std::vector<typename ITs<SK>::result_type> 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) {
// the intersection must be a point
const std::pair<typename SK::Circular_arc_point_3, unsigned>* pair=
object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[0]);
boost::get<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[0]);
CGAL_kernel_precondition(pair!=NULL);
*this = pair->first.rep();
} else {
// the intersections must be a point
const std::pair<typename SK::Circular_arc_point_3, unsigned>* pair=
object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[less_xyz?0:1]);
boost::get<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[less_xyz?0:1]);
CGAL_kernel_precondition(pair!=NULL);
*this = pair->first.rep();
}
@ -141,20 +141,20 @@ public:
Circular_arc_point_3(const Line_3 &l,
const Sphere_3 &s,
const bool less_xyz = true) {
std::vector<Object> sols;
std::vector<typename IT<SK, Line_3, Sphere_3>::result_type> 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) {
// the intersection must be a point
const std::pair<typename SK::Circular_arc_point_3, unsigned>* pair=
object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[0]);
boost::get<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[0]);
CGAL_kernel_precondition(pair!=NULL);
*this = pair->first.rep();
} else {
// the intersections must be a point
const std::pair<typename SK::Circular_arc_point_3, unsigned>* pair=
object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[less_xyz?0:1]);
boost::get<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[less_xyz?0:1]);
CGAL_kernel_precondition(pair!=NULL);
*this = pair->first.rep();
}
@ -163,20 +163,20 @@ public:
Circular_arc_point_3(const Circle_3 &c,
const Plane_3 &p,
const bool less_xyz = true) {
std::vector<Object> sols;
std::vector<typename IT<SK, Circle_3, Plane_3>::result_type> 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) {
// the intersection must be a point
const std::pair<typename SK::Circular_arc_point_3, unsigned>* pair=
object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[0]);
boost::get<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[0]);
CGAL_kernel_precondition(pair!=NULL);
*this = pair->first.rep();
} else {
// the intersections must be a point
const std::pair<typename SK::Circular_arc_point_3, unsigned>* pair=
object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[less_xyz?0:1]);
boost::get<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[less_xyz?0:1]);
CGAL_kernel_precondition(pair!=NULL);
*this = pair->first.rep();
}
@ -185,20 +185,20 @@ public:
Circular_arc_point_3(const Circle_3 &c,
const Sphere_3 &s,
const bool less_xyz = true) {
std::vector<Object> sols;
std::vector<typename IT<SK, Circle_3, Sphere_3>::result_type> 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) {
// the intersection must be a point
const std::pair<typename SK::Circular_arc_point_3, unsigned>* pair=
object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[0]);
boost::get<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[0]);
CGAL_kernel_precondition(pair!=NULL);
*this = pair->first.rep();
} else {
// the intersections must be a point
const std::pair<typename SK::Circular_arc_point_3, unsigned>* pair=
object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[less_xyz?0:1]);
boost::get<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[less_xyz?0:1]);
CGAL_kernel_precondition(pair!=NULL);
*this = pair->first.rep();
}

View File

@ -92,14 +92,14 @@ namespace CGAL {
const Sphere_3 &s,
bool less_xyz_first = true)
{
std::vector<Object> sols;
std::vector<typename IT<SK, Line_3, Sphere_3>::result_type> sols;
SK().intersect_3_object()(l, s, std::back_inserter(sols));
// l must intersect s in 2 points
CGAL_kernel_precondition(sols.size() == 2);
const std::pair<typename SK::Circular_arc_point_3, unsigned>& pair1=
*object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[0]);
*boost::get<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[0]);
const std::pair<typename SK::Circular_arc_point_3, unsigned>& pair2=
*object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[1]);
*boost::get<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols[1]);
if(less_xyz_first) {
*this = Line_arc_3(l, pair1.first, pair2.first);
} else {
@ -111,16 +111,16 @@ namespace CGAL {
const Sphere_3 &s1, bool less_xyz_s1,
const Sphere_3 &s2, bool less_xyz_s2)
{
std::vector<Object> sols1, sols2;
std::vector<typename IT<SK, Line_3, Sphere_3>::result_type> sols1, sols2;
SK().intersect_3_object()(l, s1, std::back_inserter(sols1));
SK().intersect_3_object()(l, s2, std::back_inserter(sols2));
// l must intersect s1 and s2
CGAL_kernel_precondition(sols1.size() > 0);
CGAL_kernel_precondition(sols2.size() > 0);
const std::pair<typename SK::Circular_arc_point_3, unsigned>& pair1=
*object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols1[(sols1.size()==1)?(0):(less_xyz_s1?0:1)]);
*boost::get<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols1[(sols1.size()==1)?(0):(less_xyz_s1?0:1)]);
const std::pair<typename SK::Circular_arc_point_3, unsigned>& pair2=
*object_cast<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&sols2[(sols2.size()==1)?(0):(less_xyz_s2?0:1)]);
*boost::get<std::pair<typename SK::Circular_arc_point_3, unsigned> >(&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);
@ -134,8 +134,11 @@ namespace CGAL {
CGAL_kernel_precondition(!SK().has_on_3_object()(p1,l));
CGAL_kernel_precondition(!SK().has_on_3_object()(p2,l));
// l must intersect p1 and p2
const typename SK::Point_3* point1=object_cast<typename SK::Point_3>( & SK().intersect_3_object()(l, p1) );
const typename SK::Point_3* point2=object_cast<typename SK::Point_3>( & SK().intersect_3_object()(l, p2) );
typedef typename IT<SK, Line_3, Plane_3>::result_type Intersection;
Intersection i1 = SK().intersect_3_object()(l, p1);
Intersection i2 = SK().intersect_3_object()(l, p2);
const typename SK::Point_3* point1=boost::get<typename SK::Point_3>( & *i1 );
const typename SK::Point_3* point2=boost::get<typename SK::Point_3>( & *i2 );
CGAL_assertion(point1!=NULL);
CGAL_assertion(point2!=NULL);
// the source and target must be different

View File

@ -37,8 +37,6 @@
#include <CGAL/Circular_kernel_3/internal_function_has_on_spherical_kernel.h>
#include <CGAL/Circular_kernel_3/internal_function_compare_spherical_kernel.h>
#include <CGAL/Circular_kernel_3/internal_function_compare_to_right_spherical_kernel.h>
#include <CGAL/Object.h>
namespace CGAL {
@ -1096,6 +1094,7 @@ template < class SK > \
typedef typename SK::Circular_arc_3 Circular_arc_3;
typedef typename SK::Plane_3 Plane_3;
typedef typename SK::Circle_3 Circle_3;
typedef typename SK::Circle_3 Circular_arc_point_3;
public:
@ -1106,14 +1105,14 @@ template < class SK > \
#define CGAL_SPHERICAL_KERNEL_MACRO_DO_INTERSECTION_3_2(A,B) \
result_type \
operator()(const A & c1, const B & c2) const \
{ std::vector< Object > res; \
{ std::vector< typename IT<SK, A, B>::result_type > res; \
typename SK::Intersect_3()(c1,c2,std::back_inserter(res)); \
return res.size() != 0; }
#define CGAL_SPHERICAL_KERNEL_MACRO_DO_INTERSECTION_3_3(A,B,C) \
result_type \
operator()(const A & c1, const B & c2, const C & c3) const \
{ std::vector< Object > res; \
{ std::vector< typename ITs<SK>::result_type > res; \
typename SK::Intersect_3()(c1,c2,c3,std::back_inserter(res)); \
return res.size() != 0; }
@ -1168,8 +1167,6 @@ template < class SK > \
public:
typedef typename SK::Linear_kernel::Intersect_3::result_type result_type;
typedef typename SK::Object_3 Object_3;
using SK::Linear_kernel::Intersect_3::operator();

View File

@ -119,13 +119,13 @@ namespace CGAL {
typename SK::FT z_coord=extremal_points_z_coordinate<SK>(circle,sphere);
typename SK::Plane_3 plane(0,0,1,-z_coord);
std::vector<CGAL::Object> inters;
std::vector<typename IT<SK, typename SK::Circle_3, typename SK::Plane_3>::result_type > inters;
intersect_3<SK>(circle,plane,std::back_inserter(inters));
CGAL_kernel_precondition(inters.size()==2);
const std::pair<typename SK::Circular_arc_point_3,unsigned>* pt[2]={NULL,NULL};
pt[0]=object_cast<std::pair<typename SK::Circular_arc_point_3,unsigned> >(&inters[0]);
pt[1]=object_cast<std::pair<typename SK::Circular_arc_point_3,unsigned> >(&inters[1]);
pt[0]=boost::get<std::pair<typename SK::Circular_arc_point_3,unsigned> >(&inters[0]);
pt[1]=boost::get<std::pair<typename SK::Circular_arc_point_3,unsigned> >(&inters[1]);
CGAL_kernel_precondition(pt[0]!=NULL);
CGAL_kernel_precondition(pt[1]!=NULL);

View File

@ -87,7 +87,7 @@ namespace CGAL {
OutputIterator res)
{
typedef typename SK::Circular_arc_point_3 Circular_arc_point_3;
typedef std::vector<CGAL::Object> solutions_container;
typedef std::vector<typename IT<SK, typename SK::Line_3, typename SK::Circle_3 >::result_type > solutions_container;
typedef std::pair<Circular_arc_point_3, unsigned> Solution;
solutions_container solutions;
@ -96,12 +96,12 @@ namespace CGAL {
std::back_inserter(solutions) );
if(solutions.size() == 0) return res;
if(solutions.size() == 1) {
const Solution& sol=*object_cast<Solution>(&solutions[0]);
const Solution& sol=*boost::get<Solution>(&solutions[0]);
if(SK().has_on_3_object()(ca,sol.first,true))
*res++ = solutions[0];
} else {
const Solution& sol1=*object_cast<Solution>(&solutions[0]);
const Solution& sol2=*object_cast<Solution>(&solutions[1]);
const Solution& sol1=*boost::get<Solution>(&solutions[0]);
const Solution& sol2=*boost::get<Solution>(&solutions[1]);
if(SK().has_on_3_object()(ca,sol1.first,true))
*res++ = solutions[0];
if(SK().has_on_3_object()(ca,sol2.first,true))
@ -117,11 +117,15 @@ namespace CGAL {
OutputIterator res)
{
typedef typename SK::Circular_arc_point_3 Circular_arc_point_3;
typedef std::vector<CGAL::Object> solutions_container;
typedef typename IT<SK, typename SK::Circle_3, typename SK::Circular_arc_3>::result_type
result_type;
typedef std::vector<typename IT<SK, typename SK::Circle_3, typename SK::Circle_3>::result_type>
solutions_container;
typedef std::pair<Circular_arc_point_3, unsigned> Solution;
if(non_oriented_equal<SK>(c, ca.supporting_circle())) {
*res++ = make_object(ca);
*res++ = result_type(ca);
}
solutions_container solutions;
@ -130,12 +134,12 @@ namespace CGAL {
std::back_inserter(solutions) );
if(solutions.size() == 0) return res;
if(solutions.size() == 1) {
const Solution& sol=*object_cast<Solution>(&solutions[0]);
const Solution& sol=*boost::get<Solution>(&solutions[0]);
if(SK().has_on_3_object()(ca,sol.first,true))
*res++ = solutions[0];
} else {
const Solution& sol1=*object_cast<Solution>(&solutions[0]);
const Solution& sol2=*object_cast<Solution>(&solutions[1]);
const Solution& sol1=*boost::get<Solution>(&solutions[0]);
const Solution& sol2=*boost::get<Solution>(&solutions[1]);
if(SK().has_on_3_object()(ca,sol1.first,true))
*res++ = solutions[0];
if(SK().has_on_3_object()(ca,sol2.first,true))
@ -150,12 +154,17 @@ namespace CGAL {
const typename SK::Circular_arc_3 & c,
OutputIterator res)
{
typedef typename IT<SK, typename SK::Sphere_3, typename SK::Circular_arc_3>::result_type
result_type;
typedef typename SK::Circular_arc_point_3 Circular_arc_point_3;
typedef std::vector<CGAL::Object> solutions_container;
typedef std::vector<typename IT<SK, typename SK::Circle_3,
typename SK::Sphere_3>::result_type>
solutions_container;
typedef std::pair<Circular_arc_point_3, unsigned> Solution;
if(SK().has_on_3_object()(s, c.supporting_circle())) {
*res++ = make_object(c);
*res++ = result_type(c);
}
solutions_container solutions;
@ -164,12 +173,12 @@ namespace CGAL {
std::back_inserter(solutions) );
if(solutions.size() == 0) return res;
if(solutions.size() == 1) {
const Solution& sol=*object_cast<Solution>(&solutions[0]);
const Solution& sol=*boost::get<Solution>(&solutions[0]);
if(SK().has_on_3_object()(c,sol.first,true))
*res++ = solutions[0];
} else {
const Solution& sol1=*object_cast<Solution>(&solutions[0]);
const Solution& sol2=*object_cast<Solution>(&solutions[1]);
const Solution& sol1=*boost::get<Solution>(&solutions[0]);
const Solution& sol2=*boost::get<Solution>(&solutions[1]);
if(SK().has_on_3_object()(c,sol1.first,true))
*res++ = solutions[0];
if(SK().has_on_3_object()(c,sol2.first,true))
@ -184,12 +193,14 @@ namespace CGAL {
const typename SK::Circular_arc_3 & ca,
OutputIterator res)
{
typedef typename IT<SK, typename SK::Plane_3, typename SK::Circular_arc_3>::result_type result_type;
typedef typename SK::Point_3 Point_3;
typedef typename SK::Circular_arc_point_3 Circular_arc_point_3;
typedef std::vector<CGAL::Object> solutions_container;
typedef std::vector<typename IT<SK, typename SK::Circle_3,
typename SK::Plane_3>::result_type> solutions_container;
typedef std::pair<Circular_arc_point_3, unsigned> Solution;
if(SK().has_on_3_object()(p,ca.supporting_circle())) {
*res++ = make_object(ca);
*res++ = result_type(ca);
}
solutions_container solutions;
@ -197,16 +208,16 @@ namespace CGAL {
std::back_inserter(solutions) );
if(solutions.size() == 0) return res;
if(solutions.size() == 1) {
const Solution& sol=*object_cast<Solution>(&solutions[0]);
const Solution& sol=*boost::get<Solution>(&solutions[0]);
if(SK().has_on_3_object()(ca,sol.first,true))
*res++ = solutions[0];
*res++ = result_type(sol);
} else {
const Solution& sol1=*object_cast<Solution>(&solutions[0]);
const Solution& sol2=*object_cast<Solution>(&solutions[1]);
const Solution& sol1=*boost::get<Solution>(&solutions[0]);
const Solution& sol2=*boost::get<Solution>(&solutions[1]);
if(SK().has_on_3_object()(ca,sol1.first,true))
*res++ = solutions[0];
*res++ = result_type(sol1);
if(SK().has_on_3_object()(ca,sol2.first,true))
*res++ = solutions[1];
*res++ = result_type(sol2);
}
return res;
}
@ -218,7 +229,9 @@ namespace CGAL {
OutputIterator res)
{
typedef typename SK::Circular_arc_point_3 Circular_arc_point_3;
typedef std::vector<CGAL::Object> solutions_container;
typedef std::vector<
typename IT<SK, typename SK::Line_3, typename SK::Line_3>::result_type>
solutions_container;
typedef std::pair<Circular_arc_point_3, unsigned> Solution;
solutions_container solutions;
@ -227,13 +240,13 @@ namespace CGAL {
std::back_inserter(solutions) );
if(solutions.size() == 0) return res;
if(solutions.size() == 1) {
const Solution& sol=*object_cast<Solution>(&solutions[0]);
const Solution& sol=*boost::get<Solution>(&solutions[0]);
if(SK().has_on_3_object()(ca,sol.first,true) &&
SK().has_on_3_object()(la,sol.first,true))
*res++ = solutions[0];
} else {
const Solution& sol1=*object_cast<Solution>(&solutions[0]);
const Solution& sol2=*object_cast<Solution>(&solutions[1]);
const Solution& sol1=*boost::get<Solution>(&solutions[0]);
const Solution& sol2=*boost::get<Solution>(&solutions[1]);
if(SK().has_on_3_object()(ca,sol1.first,true) &&
SK().has_on_3_object()(la,sol1.first,true))
*res++ = solutions[0];
@ -250,18 +263,21 @@ namespace CGAL {
const typename SK::Circular_arc_3 & a2,
OutputIterator res)
{
typedef typename IT<SK, typename SK::Circular_arc_3,
typename SK::Circular_arc_3>::result_type result_type;
typedef typename SK::Circular_arc_point_3 Circular_arc_point_3;
typedef typename SK::Circular_arc_3 Circular_arc_3;
typedef std::vector<CGAL::Object> solutions_container;
typedef std::vector<typename IT<SK, typename SK::Circle_3,
typename SK::Circle_3 >::result_type> solutions_container;
typedef std::pair<Circular_arc_point_3, unsigned> Solution;
if(non_oriented_equal<SK>(a1.supporting_circle(), a2.supporting_circle())) {
if(a1.rep().is_full()) {
*res++ = make_object(a2);
*res++ = result_type(a2);
//return res;
}
else if(a2.rep().is_full()) {
*res++ = make_object(a1);
*res++ = result_type(a1);
//return res;
} else {
bool t2_in_a1 = SK().has_on_3_object()(a1,a2.target(),true);
@ -274,58 +290,58 @@ namespace CGAL {
SK().compare_xyz_3_object()(a1.source(), a2.source());
if(comp < 0) {
if(a1.source() == a2.target()) {
*res++ = make_object(std::make_pair(a1.source(),1u));
*res++ = result_type(std::make_pair(a1.source(),1u));
} else {
const Circular_arc_3 & arc =
Circular_arc_3(a1.supporting_circle(),a1.source(),a2.target());
*res++ = make_object(arc);
*res++ = result_type(arc);
}
if(a2.source() == a1.target()) {
*res++ = make_object(std::make_pair(a2.source(),1u));
*res++ = result_type(std::make_pair(a2.source(),1u));
} else {
const Circular_arc_3 & arc =
Circular_arc_3(a1.supporting_circle(),a2.source(),a1.target());
*res++ = make_object(arc);
*res++ = result_type(arc);
}
} else if(comp > 0) {
if(a2.source() == a1.target()) {
*res++ = make_object(std::make_pair(a2.source(),1u));
*res++ = result_type(std::make_pair(a2.source(),1u));
} else {
const Circular_arc_3 & arc =
Circular_arc_3(a1.supporting_circle(),a2.source(),a1.target());
*res++ = make_object(arc);
*res++ = result_type(arc);
}
if(a1.source() == a2.target()) {
*res++ = make_object(std::make_pair(a1.source(),1u));
*res++ = result_type(std::make_pair(a1.source(),1u));
} else {
const Circular_arc_3 & arc =
Circular_arc_3(a1.supporting_circle(),a1.source(),a2.target());
*res++ = make_object(arc);
*res++ = result_type(arc);
}
} else {
*res++ = make_object(a1);
*res++ = result_type(a1);
}
} else {
*res++ = make_object(a2);
*res++ = result_type(a2);
}
} else if(t2_in_a1) {
if(a1.source() == a2.target())
*res++ = make_object(std::make_pair(a1.source(),1u));
*res++ = result_type(std::make_pair(a1.source(),1u));
else {
const Circular_arc_3 & arc =
Circular_arc_3(a1.supporting_circle(),a1.source(),a2.target());
*res++ = make_object(arc);
*res++ = result_type(arc);
} //return res;
} else if(s2_in_a1) {
if(a2.source() == a1.target()) {
*res++ = make_object(std::make_pair(a2.source(),1u));
*res++ = result_type(std::make_pair(a2.source(),1u));
} else {
const Circular_arc_3 & arc =
Circular_arc_3(a1.supporting_circle(),a2.source(),a1.target());
*res++ = make_object(arc);
*res++ = result_type(arc);
}
} else if(SK().has_on_3_object()(a2,a1.source(),true)) {
*res++ = make_object(a1);
*res++ = result_type(a1);
}
}
} else {
@ -335,13 +351,13 @@ namespace CGAL {
std::back_inserter(solutions) );
if(solutions.size() == 0) return res;
if(solutions.size() == 1) {
const Solution& sol=*object_cast<Solution>(&solutions[0]);
const Solution& sol=*boost::get<Solution>(&solutions[0]);
if(SK().has_on_3_object()(a1,sol.first,true) &&
SK().has_on_3_object()(a2,sol.first,true))
*res++ = solutions[0];
} else {
const Solution& sol1=*object_cast<Solution>(&solutions[0]);
const Solution& sol2=*object_cast<Solution>(&solutions[1]);
const Solution& sol1=*boost::get<Solution>(&solutions[0]);
const Solution& sol2=*boost::get<Solution>(&solutions[1]);
if(SK().has_on_3_object()(a1,sol1.first,true) &&
SK().has_on_3_object()(a2,sol1.first,true))
*res++ = solutions[0];
@ -381,7 +397,9 @@ namespace CGAL {
typename SK::FT z_coord=extremal_points_z_coordinate<SK>(arc.supporting_circle(),sphere);
typename SK::Plane_3 plane(0,0,1,-z_coord);
std::vector<CGAL::Object> inters;
std::vector<typename IT<SK, typename SK::Plane_3,
typename SK::Circular_arc_3>::result_type>
inters;
intersect_3<SK>(plane,arc,std::back_inserter(inters));
@ -433,7 +451,7 @@ namespace CGAL {
case NORMAL:{
typename SK::FT z_coord=extremal_points_z_coordinate<SK>(arc.supporting_circle(),sphere);
typename SK::Plane_3 plane(0,0,1,-z_coord);
std::vector<CGAL::Object> inters;
std::vector<typename IT<SK, typename SK::Plane_3, typename SK::Circular_arc_3 >::result_type> inters;
intersect_3<SK>(plane,arc,std::back_inserter(inters));
@ -455,8 +473,8 @@ namespace CGAL {
//one endpoint is extremal: just split the arc
if (nb_extrem==1){
const std::pair<typename SK::Circular_arc_point_3,unsigned>* pt[2]={NULL,NULL};
pt[0]=object_cast<std::pair<typename SK::Circular_arc_point_3,unsigned> >(&inters[0]);
pt[1]=object_cast<std::pair<typename SK::Circular_arc_point_3,unsigned> >(&inters[1]);
pt[0]=boost::get<std::pair<typename SK::Circular_arc_point_3,unsigned> >(&inters[0]);
pt[1]=boost::get<std::pair<typename SK::Circular_arc_point_3,unsigned> >(&inters[1]);
CGAL_kernel_precondition(pt[0]!=NULL);
CGAL_kernel_precondition(pt[1]!=NULL);
const typename SK::Circular_arc_point_3& midpt=(arc.source()==pt[0]->first || arc.target()==pt[0]->first)?pt[1]->first:pt[0]->first;
@ -470,7 +488,7 @@ namespace CGAL {
//only one intersection points
if (inters.size()==1){
const std::pair<typename SK::Circular_arc_point_3,unsigned>* midpt=NULL;
midpt=object_cast<std::pair<typename SK::Circular_arc_point_3,unsigned> >(&inters[0]);
midpt=boost::get<std::pair<typename SK::Circular_arc_point_3,unsigned> >(&inters[0]);
CGAL_kernel_precondition(midpt!=NULL);
*out_it++=typename SK::Circular_arc_3(arc.supporting_circle(),arc.source(),midpt->first);
*out_it++=typename SK::Circular_arc_3(arc.supporting_circle(),midpt->first,arc.target());
@ -479,8 +497,8 @@ namespace CGAL {
//three arcs are defined by two intersection points
const std::pair<typename SK::Circular_arc_point_3,unsigned>* pt[2]={NULL,NULL};
pt[0]=object_cast<std::pair<typename SK::Circular_arc_point_3,unsigned> >(&inters[0]);
pt[1]=object_cast<std::pair<typename SK::Circular_arc_point_3,unsigned> >(&inters[1]);
pt[0]=boost::get<std::pair<typename SK::Circular_arc_point_3,unsigned> >(&inters[0]);
pt[1]=boost::get<std::pair<typename SK::Circular_arc_point_3,unsigned> >(&inters[1]);
CGAL_kernel_precondition(pt[0]!=NULL);
CGAL_kernel_precondition(pt[1]!=NULL);
@ -557,19 +575,20 @@ namespace CGAL {
const typename SK::Sphere_3& sphere)
{
typename SK::Plane_3 plane(sphere.center(),sphere.center()+m,sphere.center()+typename SK::Vector_3(0,0,1));
std::vector<CGAL::Object> inters;
std::vector<typename IT<SK, typename SK::Plane_3, typename SK::Circular_arc_3>::result_type> inters;
intersect_3<SK>(plane,arc,std::back_inserter(inters));
CGAL_kernel_precondition(!inters.empty());
if (inters.size()==1){
const typename SK::Circular_arc_point_3& pt=
object_cast<std::pair<typename SK::Circular_arc_point_3,unsigned> >(&inters[0])->first;
boost::get<std::pair<typename SK::Circular_arc_point_3,unsigned> >(&inters[0])->first;
return pt;
}
CGAL_kernel_precondition(classify_circle_3<SK>(arc.supporting_circle(),sphere)!=NORMAL);
const typename SK::Circular_arc_point_3& pts1=object_cast<std::pair<typename SK::Circular_arc_point_3,unsigned> >(&inters[0])->first;
const typename SK::Circular_arc_point_3& pts2=object_cast<std::pair<typename SK::Circular_arc_point_3,unsigned> >(&inters[1])->first;
const typename SK::Circular_arc_point_3& pts1=boost::get<std::pair<typename SK::Circular_arc_point_3,unsigned> >(&inters[0])->first;
const typename SK::Circular_arc_point_3& pts2=boost::get<std::pair<typename SK::Circular_arc_point_3,unsigned> >(&inters[1])->first;
//either a polar (1 pole + 1 pt) or a threaded circle (2 pts with theta-coord = +/- pi)

View File

@ -85,20 +85,21 @@ namespace CGAL {
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;
typedef typename IT<SK, Line_arc_3, Line_arc_3>::result_type result_type;
Point_3 inters_p;
Line_3 inters_l;
Object o = SK().intersect_3_object()(l1.supporting_line(),
typename IT<SK, Line_3, Line_3>::result_type o =
SK().intersect_3_object()(l1.supporting_line(),
l2.supporting_line());
if(assign(inters_p, o)) {
Circular_arc_point_3 p = inters_p;
if(!o)
return res;
if(const Point_3* inters_p = boost::get<Point_3>(&(*o))) {
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));
} else if(assign(inters_l, o)) {
*res++ = result_type(std::make_pair(p,1u));
} else if(const Line_3* inters_l = boost::get<Line_3>(&(*o))) {
if(SK().compare_xyz_3_object()(l1.lower_xyz_extremity(),
l2.lower_xyz_extremity()) < 0) {
int comparison =
@ -107,34 +108,34 @@ namespace CGAL {
if(comparison < 0) {
if(SK().compare_xyz_3_object()(l1.higher_xyz_extremity(),
l2.higher_xyz_extremity()) <= 0) {
*res++ = make_object
*res++ = result_type
(Line_arc_3(l1.supporting_line(),
l2.lower_xyz_extremity(),
l1.higher_xyz_extremity()));
} else {
*res++ = make_object(l2);
*res++ = result_type(l2);
}
} else if (comparison == 0) {
*res++ = make_object(std::make_pair(l2.lower_xyz_extremity(),1u));
}
*res++ = result_type(std::make_pair(l2.lower_xyz_extremity(),1u));
}
else {
int comparison =
SK().compare_xyz_3_object()(l1.lower_xyz_extremity(),
l2.higher_xyz_extremity());
if(comparison < 0){
if(comparison < 0) {
if(SK().compare_xyz_3_object()(l1.higher_xyz_extremity(),
l2.higher_xyz_extremity()) <= 0) {
*res++ = make_object(l1);
*res++ = result_type(l1);
} else {
*res++ = make_object
*res++ = result_type
(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));
*res++ = result_type(std::make_pair(l1.lower_xyz_extremity(),1u));
}
}
}
}
@ -151,19 +152,22 @@ namespace CGAL {
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;
typedef typename IT<SK, Line_3, Line_arc_3>::result_type result_type;
Point_3 inters_p;
Line_3 inters_l;
typename IT<SK,Line_3, Line_3>::result_type o =
SK().intersect_3_object()(l, la.supporting_line());
Object o = SK().intersect_3_object()(l, la.supporting_line());
if(!o)
return res;
if(assign(inters_l, o)) {
*res++ = make_object(la);
} else if(assign(inters_p, o)) {
Circular_arc_point_3 p = inters_p;
if(const Line_3* inters_l = boost::get<Line_3>(&*o)) {
*res++ = result_type(la);
} else if(const Point_3* inters_p = boost::get<Point_3>(&*o)) {
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));
*res++ = result_type(std::make_pair(p,1u));
}
return res;
}
@ -174,24 +178,26 @@ namespace CGAL {
OutputIterator res)
{
typedef typename SK::Circular_arc_point_3 Circular_arc_point_3;
typedef std::vector<CGAL::Object> solutions_container;
typedef std::vector<typename IT<SK, typename SK::Line_3, typename SK::Circle_3>::result_type>
solutions_container;
typedef std::pair<Circular_arc_point_3, unsigned> Solution;
typedef typename IT<SK, typename SK::Circle_3, typename SK::Line_arc_3>::result_type result_type;
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))
const Solution* sol = boost::get<Solution>(&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))
const Solution* sol1 = boost::get<Solution>(&solutions[0]);
const Solution* sol2 = boost::get<Solution>(&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))
if(SK().has_on_3_object()(l,(*sol2).first,true))
*res++ = solutions[1];
}
return res;
@ -204,24 +210,23 @@ namespace CGAL {
OutputIterator res)
{
typedef typename SK::Circular_arc_point_3 Circular_arc_point_3;
typedef std::vector<CGAL::Object> solutions_container;
typedef std::vector<typename IT<SK, typename SK::Line_3,
typename SK::Sphere_3>::result_type > solutions_container;
typedef std::pair<Circular_arc_point_3, unsigned> 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))
const Solution* sol = boost::get<Solution>(&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))
const Solution* sol1 = boost::get<Solution>(&solutions[0]);
const Solution* sol2 = boost::get<Solution>(&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))
if(SK().has_on_3_object()(l,(*sol2).first,true))
*res++ = solutions[1];
}
return res;
@ -236,14 +241,19 @@ namespace CGAL {
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);
*res++ = result_type(l);
}
Point_3 sol;
if(!assign(sol,SK().intersect_3_object()(p,l.supporting_line())))
const Point_3* sol;
typename IT<SK, typename SK::Plane_3, typename SK::Line_3>
::result_type o = SK().intersect_3_object()(p,l.supporting_line());
if(!o)
return res;
if(!SK().has_on_3_object()(l,sol)) return res;
if(sol = boost::get<Point_3>(&*o)) {
if(!SK().has_on_3_object()(l,*sol)) return res;
Circular_arc_point_3 point = sol;
*res++ = make_object(std::make_pair(point,1u));
*res++ = result_type(std::make_pair(point,1u));
}
return res;
}

View File

@ -199,12 +199,43 @@ namespace CGAL {
(c1.target() == c2.target());
}
namespace internal {
// we need to pass the result_type, to hack around the fact that
// object doesn't support operator=(const T&) and so we keep backwards compatibility
template<typename SK, typename RT>
RT pair_transform(const std::pair< typename SK::Root_for_spheres_2_3, unsigned >& p) {
return RT(std::make_pair(typename SK::Circular_arc_point_3(p.first), p.second));
}
// obscure trick: calculate the regular intersection between two
// objects, throw it away if empty, else check if the result was a
// point_3, if so turn in into a (circular_arc_point, unsigned)
// pair, otherwise just dump the value with conversion to RT
// (again: converting to RT before assigning to the Iterator is
// just to keep object working)
template<typename SK, typename RT, typename OutputIterator>
struct Point_conversion_visitor : public boost::static_visitor<OutputIterator> {
Point_conversion_visitor(const OutputIterator& it) : it(it) {}
template<typename T>
OutputIterator operator()(const T& t) { *it++ = RT(t); return it; }
OutputIterator operator()(const typename SK::Point_3& p) {
// 2 multiplicities
*it++ = RT(std::make_pair(typename SK::Circular_arc_point_3(p), 2u));
return it;
}
OutputIterator it;
};
} // namespace internal
template < class SK, class OutputIterator >
OutputIterator
intersect_3(const typename SK::Sphere_3 & s,
const typename SK::Line_3 & l,
OutputIterator res)
{
typedef typename IT<SK, typename SK::Sphere_3, typename SK::Line_3>
::result_type result_type;
typedef typename SK::Algebraic_kernel Algebraic_kernel;
typedef typename SK::Polynomial_for_spheres_2_3 Equation_sphere;
typedef typename SK::Polynomials_for_line_3 Equation_line;
@ -218,71 +249,11 @@ namespace CGAL {
solutions_container;
solutions_container solutions;
Algebraic_kernel().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;
}
namespace internal {
// It just converts when the solution is a Point_3 to Circular_arc_point_3
template < class SK, class OutputIterator >
OutputIterator
intersect_special(const typename SK::Sphere_3 & s1,
const typename SK::Sphere_3 & s2,
OutputIterator res)
{
Object obj = SK().intersect_3_object()(s1, s2);
if(obj.is_empty()) return res;
typename SK::Point_3 p;
if(assign(p, obj)) {
typename SK::Circular_arc_point_3 cp = p;
*res++ = make_object(std::make_pair(cp,2u));
} else {
*res++ = obj;
} return res;
}
template < class SK, class OutputIterator >
OutputIterator
intersect_special(const typename SK::Plane_3 & plane,
const typename SK::Sphere_3 & sphere,
OutputIterator res)
{
Object obj = SK().intersect_3_object()(plane, sphere);
if(obj.is_empty()) return res;
typename SK::Point_3 p;
if(assign(p, obj)) {
typename SK::Circular_arc_point_3 cp = p;
*res++ = make_object(std::make_pair(cp,2u));
} else {
*res++ = obj;
} return res;
}
template < class SK, class OutputIterator >
OutputIterator
intersect_special(const typename SK::Sphere_3 & sphere,
const typename SK::Plane_3 & plane,
OutputIterator res)
{
Object obj = SK().intersect_3_object()(plane, sphere);
if(obj.is_empty()) return res;
typename SK::Point_3 p;
if(assign(p, obj)) {
typename SK::Circular_arc_point_3 cp = p;
*res++ = make_object(std::make_pair(cp,2u));
} else {
*res++ = obj;
} return res;
}
return std::transform(solutions.begin(), solutions.end(), res, internal::pair_transform<SK, result_type>);
}
// The special 3 object functions
template < class SK, class OutputIterator >
OutputIterator
intersect_3(const typename SK::Sphere_3 & s1,
@ -290,43 +261,57 @@ namespace CGAL {
const typename SK::Sphere_3 & s3,
OutputIterator res)
{
// circle_3, sphere_3, (circular_arc_point_3, uint)
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::Point_3 Point_3;
typedef typename SK::Sphere_3 Sphere_3;
typedef typename SK::Plane_3 Plane_3;
typedef typename SK::Algebraic_kernel Algebraic_kernel;
typedef std::vector< Object > solutions_container;
typedef typename ITs<SK>::result_type result_type;
CGAL_kernel_precondition(!s1.is_degenerate());
CGAL_kernel_precondition(!s2.is_degenerate());
CGAL_kernel_precondition(!s3.is_degenerate());
if(non_oriented_equal<SK>(s1,s2) && non_oriented_equal<SK>(s2,s3)) {
*res++ = make_object(s1);
*res++ = result_type(s1);
return res;
}
if(non_oriented_equal<SK>(s1,s2)) {
return internal::intersect_special<SK>(s1, s3, res);
if(typename IT<SK, Sphere_3, Sphere_3>::result_type v =
SK().intersect_3_object()(s1, s3)) {
internal::Point_conversion_visitor<SK, result_type, OutputIterator> visitor(res);
return boost::apply_visitor(visitor,
*v);
}
if((non_oriented_equal<SK>(s1,s3)) ||
(non_oriented_equal<SK>(s2,s3))) {
return internal::intersect_special<SK>(s1, s2, res);
return res;
}
if(non_oriented_equal<SK>(s1,s3) || non_oriented_equal<SK>(s2,s3)) {
if(typename IT<SK, Sphere_3, Sphere_3>::result_type v =
SK().intersect_3_object()(s1, s2)) {
internal::Point_conversion_visitor<SK, result_type, OutputIterator> visitor(res);
return boost::apply_visitor(
visitor,
*v);
}
return res;
}
if(SK().collinear_3_object()(s1.center(),s2.center(),s3.center())) {
Object obj = SK().intersect_3_object()(s1, s2);
if(obj.is_empty()) return res;
Point_3 p;
if(assign(p, obj)) {
if(SK().has_on_3_object()(s3, p)) {
Circular_arc_point_3 cp = p;
*res++ = make_object(std::make_pair(cp,2u));
return res;
} else return res;
typename IT<SK, Sphere_3, Sphere_3>::result_type v =
SK().intersect_3_object()(s1, s2);
if(!v) return res;
if(const Point_3* p = boost::get<Point_3>(&*v)) {
if(SK().has_on_3_object()(s3, *p)) {
*res++ = result_type(std::make_pair(Circular_arc_point_3(*p),2u));
}
return res;
}
if(const Circle_3* c = boost::get<Circle_3>(&*v)) {
if(SK().has_on_3_object()(s3, *c)) {
*res++ = result_type(*c);
}
// must be a circle
Circle_3 c;
assign(c, obj);
if(SK().has_on_3_object()(s3,c)) {
*res++ = obj;
return res;
}
return res;
@ -338,12 +323,8 @@ namespace CGAL {
algebraic_solutions_container;
algebraic_solutions_container solutions;
Algebraic_kernel().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;
return std::transform(solutions.begin(), solutions.end(), res, internal::pair_transform<SK, result_type>);
}
template < class SK, class OutputIterator >
@ -353,21 +334,38 @@ namespace CGAL {
const typename SK::Sphere_3 & s2,
OutputIterator res)
{
typedef typename boost::variant< std::pair< typename SK::Circular_arc_point_3, unsigned int>,
typename SK::Circle_3 > result_type;
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::Sphere_3 Sphere_3;
typedef typename SK::Algebraic_kernel Algebraic_kernel;
CGAL_kernel_precondition(!p.is_degenerate());
CGAL_kernel_precondition(!s1.is_degenerate());
CGAL_kernel_precondition(!s2.is_degenerate());
if(non_oriented_equal<SK>(s1,s2)) {
return internal::intersect_special<SK>(p,s1,res);
if(typename IT<SK, Plane_3, Sphere_3>::result_type v =
SK().intersect_3_object()(p, s1)) {
internal::Point_conversion_visitor<SK, result_type, OutputIterator> visitor(res);
return boost::apply_visitor(
visitor,
*v);
}
return res;
}
Plane_3 radical_p = SK().construct_radical_plane_3_object()(s1,s2);
if(non_oriented_equal<SK>(p,radical_p)) {
return internal::intersect_special<SK>(p,s1,res);
if(typename IT<SK, Plane_3, Sphere_3>::result_type v =
SK().intersect_3_object()(p, s1)) {
internal::Point_conversion_visitor<SK, result_type, OutputIterator> visitor(res);
return boost::apply_visitor(
visitor,
*v);
}
return res;
}
Equation_sphere e1 = get_equation<SK>(s1);
Equation_sphere e2 = get_equation<SK>(s2);
@ -376,12 +374,7 @@ namespace CGAL {
algebraic_solutions_container;
algebraic_solutions_container solutions;
Algebraic_kernel().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;
return std::transform(solutions.begin(), solutions.end(), res, internal::pair_transform<SK, result_type>);
}
template < class SK, class OutputIterator >
@ -391,16 +384,27 @@ namespace CGAL {
const typename SK::Sphere_3 & s,
OutputIterator res)
{
typedef typename boost::variant< std::pair< typename SK::Circular_arc_point_3, unsigned int>,
typename SK::Circle_3 > result_type;
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::Algebraic_kernel Algebraic_kernel;
typedef typename SK::Plane_3 Plane_3;
typedef typename SK::Sphere_3 Sphere_3;
CGAL_kernel_precondition(!p1.is_degenerate());
CGAL_kernel_precondition(!p2.is_degenerate());
CGAL_kernel_precondition(!s.is_degenerate());
if(non_oriented_equal<SK>(p1,p2)) {
return internal::intersect_special<SK>(p1,s,res);
if(typename IT<SK, Plane_3, Sphere_3>::result_type v =
SK().intersect_3_object()(p1, s)) {
internal::Point_conversion_visitor<SK, result_type, OutputIterator> visitor(res);
return boost::apply_visitor(
visitor,
*v);
}
return res;
}
Equation_plane e1 = get_equation<SK>(p1);
Equation_plane e2 = get_equation<SK>(p2);
@ -409,12 +413,7 @@ namespace CGAL {
algebraic_solutions_container;
algebraic_solutions_container solutions;
Algebraic_kernel().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;
return std::transform(solutions.begin(), solutions.end(), res, internal::pair_transform<SK, result_type>);
}
template < class SK, class OutputIterator >
@ -446,8 +445,11 @@ namespace CGAL {
typedef typename SK::Polynomials_for_circle_3 Equation_circle;
typedef typename SK::Circle_3 Circle_3;
typedef typename SK::Algebraic_kernel Algebraic_kernel;
typedef typename IT<SK, Circle_3, Circle_3>
::result_type result_type;
if(non_oriented_equal<SK>(c1,c2)) {
*res++ = make_object(c1);
*res++ = result_type(c1);
return res;
}
Equation_circle e1 = get_equation<SK>(c1);
@ -456,12 +458,7 @@ namespace CGAL {
algebraic_solutions_container;
algebraic_solutions_container solutions;
Algebraic_kernel().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;
return std::transform(solutions.begin(), solutions.end(), res, internal::pair_transform<SK, result_type>);
}
template < class SK, class OutputIterator >
@ -475,6 +472,7 @@ namespace CGAL {
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 IT<SK, Circle_3, typename SK::Line_3>::result_type result_type;
typedef typename SK::Algebraic_kernel Algebraic_kernel;
CGAL_kernel_precondition(!l.is_degenerate());
Equation_circle e1 = get_equation<SK>(c);
@ -483,12 +481,7 @@ namespace CGAL {
algebraic_solutions_container;
algebraic_solutions_container solutions;
Algebraic_kernel().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;
return std::transform(solutions.begin(), solutions.end(), res, internal::pair_transform<SK, result_type>);
}
// At the moment we dont need those functions

View File

@ -30,7 +30,6 @@
#include <CGAL/Line_3.h>
#include <CGAL/Line_arc_3.h>
#include <CGAL/Circular_arc_point_3.h>
#include <CGAL/Object.h>
namespace CGAL {
@ -78,6 +77,7 @@ CGAL_SPHERICAL_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_2_(Sphere_3, Circle_3)
CGAL_SPHERICAL_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_2_(Circle_3, Circle_3)
CGAL_SPHERICAL_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_2_(Circle_3, Line_3)
CGAL_SPHERICAL_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_2_(Line_3, Circle_3)
CGAL_SPHERICAL_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_2_(Line_arc_3, Line_arc_3)
CGAL_SPHERICAL_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_2_(Line_3, Line_arc_3)
CGAL_SPHERICAL_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_2_(Line_arc_3, Line_3)
@ -101,4 +101,5 @@ CGAL_SPHERICAL_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_2_(Line_arc_3, Circular
} //namespace CGAL
#undef CGAL_SPHERICAL_KERNEL_MACRO_GLOBAL_FUNCTION_INTERSECTION_2_
#endif // CGAL_SPHERICAL_KERNEL_INTERNAL_FUNCTIONS_ON_INTERSECTION_3_H

View File

@ -51,6 +51,17 @@ struct Intersection_traits {};
template<typename K, typename A, typename B>
struct IT : public Intersection_traits<K, A, B> {};
// The version to cover ternary intersections of the Spherical_kernel
template<typename K>
struct Intersection_traits_spherical {
typedef boost::variant<
typename K::Circle_3, typename K::Plane_3, typename K::Sphere_3, std::pair< typename K::Circular_arc_point_3, unsigned > >
result_type;
};
template<typename K>
struct ITs : public Intersection_traits_spherical<K> {};
namespace internal {
// tags for dispatch

View File

@ -191,6 +191,39 @@ template<typename K>
struct Intersection_traits<K, typename K::Line_3, typename K::Circle_3>
: public Intersection_traits<K, typename K::Circle_3, typename K::Line_3> {};
// Circular_arc_3 Circular_arc_3
template<typename K>
struct Intersection_traits<K, typename K::Circular_arc_3, typename K::Circular_arc_3> {
typedef typename boost::variant<
typename K::Circle_3,
std::pair <typename K::Circular_arc_point_3, unsigned int >,
typename K::Circular_arc_3 > result_type;
typedef internal::Intersection_dim_three Dim_tag;
};
// Circular_arc_3 Plane_3
template<typename K>
struct Intersection_traits<K, typename K::Circular_arc_3, typename K::Plane_3> {
typedef typename boost::variant<
std::pair <typename K::Circular_arc_point_3, unsigned int >,
typename K::Circular_arc_3 > result_type;
typedef internal::Intersection_dim_three Dim_tag;
};
template<typename K>
struct Intersection_traits<K, typename K::Plane_3, typename K::Circular_arc_3>
: public Intersection_traits<K, typename K::Circular_arc_3, typename K::Plane_3> {};
template<typename K>
struct Intersection_traits<K, typename K::Line_arc_3, typename K::Line_arc_3> {
typedef typename boost::variant<
std::pair <typename K::Circular_arc_point_3, unsigned int >,
typename K::Line_arc_3 > result_type;
typedef internal::Intersection_dim_three Dim_tag;
};
} // namespace
#endif /* CGAL_INTERSECTION_TRAITS_3_H */