Replace Intersection_traits with result_of

This commit is contained in:
Philipp Möller 2012-12-07 18:00:30 +01:00
parent 542b0df6cf
commit 9d4d5e6e7d
7 changed files with 83 additions and 60 deletions

View File

@ -164,7 +164,7 @@ namespace CGAL {
const Sphere_3 &s1, bool less_xyz_s1,
const Sphere_3 &s2, bool less_xyz_s2)
{
typedef typename Intersection_traits<SK, Circle_3, Sphere_3>::result_type result_type;
typedef typename boost::result_of<typename SK::Intersect_3(Circle_3, Sphere_3)>::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));
@ -191,7 +191,7 @@ namespace CGAL {
const Plane_3 &p1, bool less_xyz_p1,
const Plane_3 &p2, bool less_xyz_p2)
{
typedef typename Intersection_traits<SK, Circle_3, Plane_3>::result_type result_type;
typedef typename boost::result_of<typename SK::Intersect_3(Circle_3, Plane_3)>::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));

View File

@ -142,7 +142,7 @@ public:
Circular_arc_point_3(const Line_3 &l,
const Sphere_3 &s,
const bool less_xyz = true) {
std::vector<typename Intersection_traits<SK, Line_3, Sphere_3>::result_type> sols;
std::vector<typename boost::result_of<typename SK::Intersect_3(Line_3, Sphere_3)>::type> sols;
SK().intersect_3_object()(l, s, std::back_inserter(sols));
// s1,s2,s3 must intersect
CGAL_kernel_precondition(sols.size() != 0);
@ -164,7 +164,7 @@ public:
Circular_arc_point_3(const Circle_3 &c,
const Plane_3 &p,
const bool less_xyz = true) {
std::vector<typename Intersection_traits<SK, Circle_3, Plane_3>::result_type> sols;
std::vector<typename boost::result_of<typename SK::Intersect_3(Circle_3, Plane_3)>::type> sols;
SK().intersect_3_object()(c, p, std::back_inserter(sols));
// s1,s2,s3 must intersect
CGAL_kernel_precondition(sols.size() != 0);
@ -186,7 +186,7 @@ public:
Circular_arc_point_3(const Circle_3 &c,
const Sphere_3 &s,
const bool less_xyz = true) {
std::vector<typename Intersection_traits<SK, Circle_3, Sphere_3>::result_type> sols;
std::vector<typename boost::result_of<typename SK::Intersect_3(Circle_3, Sphere_3)>::type> sols;
SK().intersect_3_object()(c, s, std::back_inserter(sols));
// s1,s2,s3 must intersect
CGAL_kernel_precondition(sols.size() != 0);

View File

@ -93,7 +93,7 @@ namespace CGAL {
const Sphere_3 &s,
bool less_xyz_first = true)
{
std::vector<typename Intersection_traits<SK, Line_3, Sphere_3>::result_type> sols;
std::vector<typename boost::result_of<typename SK::Intersect_3(Line_3, Sphere_3)>::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);
@ -112,7 +112,7 @@ namespace CGAL {
const Sphere_3 &s1, bool less_xyz_s1,
const Sphere_3 &s2, bool less_xyz_s2)
{
std::vector<typename Intersection_traits<SK, Line_3, Sphere_3>::result_type> sols1, sols2;
std::vector<typename boost::result_of<typename SK::Intersect_3(Line_3, Sphere_3)>::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
@ -135,7 +135,7 @@ 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
typedef typename Intersection_traits<SK, Line_3, Plane_3>::result_type Intersection;
typedef typename boost::result_of<typename SK::Intersect_3(Line_3, Plane_3)>::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 );

View File

@ -1105,19 +1105,19 @@ template < class SK > \
using SK::Linear_kernel::Do_intersect_3::operator();
#define CGAL_SPHERICAL_KERNEL_MACRO_DO_INTERSECTION_3_2(A,B) \
result_type \
operator()(const A & c1, const B & c2) const \
{ std::vector< typename Intersection_traits<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_2(A,B) \
result_type \
operator()(const A & c1, const B & c2) const \
{ std::vector< typename boost::result_of<typename SK::Intersect_3(A, B)>::type > res; \
typename SK::Intersect_3()(c1,c2,std::back_inserter(res)); \
return !res.empty(); }
#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< typename ITs<SK>::result_type > res; \
typename SK::Intersect_3()(c1,c2,c3,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< typename ITs<SK>::result_type > res; \
typename SK::Intersect_3()(c1,c2,c3,std::back_inserter(res)); \
return !res.empty(); }
CGAL_SPHERICAL_KERNEL_MACRO_DO_INTERSECTION_3_2(Sphere_3, Line_3)
CGAL_SPHERICAL_KERNEL_MACRO_DO_INTERSECTION_3_2(Line_3, Sphere_3)
@ -1159,7 +1159,6 @@ template < class SK > \
template < class SK >
class 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;
@ -1176,7 +1175,7 @@ template < class SK > \
private:
// helper to minimize result implementation
template <typename A, typename B,
typename C, bool is_iterator = CGAL::is_iterator<C>::value>
typename C, bool is_iterator = CGAL::is_iterator<typename boost::decay<C>::type>::value>
struct result_impl
{ typedef typename boost::result_of<typename SK::Linear_kernel::Intersect_3(A, B, C)>::type
type; };
@ -1192,7 +1191,7 @@ template < class SK > \
// the binary overload always goes to Linear::Intersect_3
template <typename F, typename A, typename B>
struct result<F(A, B)>
{ typedef typename boost::result_of<F(A, B)>::type type; };
{ typedef typename boost::result_of<typename SK::Linear_kernel::Intersect_3(A, B)>::type type; };
// we match the ternary case if the last argument is an iterator,
// otherwise Linear::Intersect_3 wins
@ -1209,12 +1208,15 @@ template < class SK > \
template <typename A, typename B>
typename boost::result_of<typename SK::Intersect_3(A, B)>::type
operator()(const A& a, const B& b)
{ return SK().intersect_3_object()(a, b); }
{ return typename SK::Linear_kernel().intersect_3_object()(a, b); }
template <typename A, typename B, typename C>
typename boost::result_of<typename SK::Intersect_3(A, B, C)>::type
operator()(const A& a, const B& b, const C& c)
{ return SK().intersect_3_object()(a, b, c); }
operator()(const A& a, const B& b, const C& c,
typename boost::enable_if_c<!(CGAL::is_iterator<typename boost::decay<C>::type>::value)>::type* = 0)
{
return typename SK::Linear_kernel().intersect_3_object()(a, b, c);
}
template < class OutputIterator >
OutputIterator

View File

@ -120,7 +120,8 @@ 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<typename Intersection_traits<SK, typename SK::Circle_3, typename SK::Plane_3>::result_type > inters;
std::vector<typename boost::result_of<
typename SK::Intersect_3(typename SK::Circle_3, typename SK::Plane_3)>::type > inters;
intersect_3<SK>(circle,plane,std::back_inserter(inters));
CGAL_kernel_precondition(inters.size()==2);

View File

@ -88,7 +88,9 @@ namespace CGAL {
OutputIterator res)
{
typedef typename SK::Circular_arc_point_3 Circular_arc_point_3;
typedef std::vector<typename Intersection_traits<SK, typename SK::Line_3, typename SK::Circle_3 >::result_type > solutions_container;
typedef std::vector<
typename boost::result_of<typename SK::Intersect_3(typename SK::Line_3, typename SK::Circle_3 )>::type
> solutions_container;
typedef std::pair<Circular_arc_point_3, unsigned> Solution;
solutions_container solutions;
@ -118,11 +120,13 @@ namespace CGAL {
OutputIterator res)
{
typedef typename SK::Circular_arc_point_3 Circular_arc_point_3;
typedef typename Intersection_traits<SK, typename SK::Circle_3, typename SK::Circular_arc_3>::result_type
result_type;
typedef typename boost::result_of<
typename SK::Intersect_3(typename SK::Circle_3, typename SK::Circular_arc_3)
>::type result_type;
typedef std::vector<typename Intersection_traits<SK, typename SK::Circle_3, typename SK::Circle_3>::result_type>
solutions_container;
typedef std::vector<typename boost::result_of<
typename SK::Intersect_3(typename SK::Circle_3, typename SK::Circle_3)
>::type > solutions_container;
typedef std::pair<Circular_arc_point_3, unsigned> Solution;
if(non_oriented_equal<SK>(c, ca.supporting_circle())) {
@ -155,13 +159,14 @@ namespace CGAL {
const typename SK::Circular_arc_3 & c,
OutputIterator res)
{
typedef typename Intersection_traits<SK, typename SK::Sphere_3, typename SK::Circular_arc_3>::result_type
result_type;
typedef typename boost::result_of<
typename SK::Intersect_3(typename SK::Sphere_3, typename SK::Circular_arc_3)
>::type result_type;
typedef typename SK::Circular_arc_point_3 Circular_arc_point_3;
typedef std::vector<typename Intersection_traits<SK, typename SK::Circle_3,
typename SK::Sphere_3>::result_type>
solutions_container;
typedef std::vector<typename boost::result_of<
typename SK::Intersect_3(typename SK::Circle_3, typename SK::Sphere_3)>::type
> solutions_container;
typedef std::pair<Circular_arc_point_3, unsigned> Solution;
if(SK().has_on_3_object()(s, c.supporting_circle())) {
@ -194,11 +199,15 @@ namespace CGAL {
const typename SK::Circular_arc_3 & ca,
OutputIterator res)
{
typedef typename Intersection_traits<SK, typename SK::Plane_3, typename SK::Circular_arc_3>::result_type result_type;
typedef typename boost::result_of<
typename SK::Intersect_3(typename SK::Plane_3, typename SK::Circular_arc_3)
>::type result_type;
typedef typename SK::Point_3 Point_3;
typedef typename SK::Circular_arc_point_3 Circular_arc_point_3;
typedef std::vector<typename Intersection_traits<SK, typename SK::Circle_3,
typename SK::Plane_3>::result_type> solutions_container;
typedef std::vector<
typename boost::result_of<typename SK::Intersect_3(typename SK::Circle_3, typename SK::Plane_3)>::type
> solutions_container;
typedef std::pair<Circular_arc_point_3, unsigned> Solution;
if(SK().has_on_3_object()(p,ca.supporting_circle())) {
*res++ = CGAL::internal::intersection_return<SK, typename SK::Plane_3, typename SK::Circular_arc_3>(ca);
@ -231,7 +240,7 @@ namespace CGAL {
{
typedef typename SK::Circular_arc_point_3 Circular_arc_point_3;
typedef std::vector<
typename Intersection_traits<SK, typename SK::Line_3, typename SK::Line_3>::result_type>
typename boost::result_of<typename SK::Intersect_3(typename SK::Line_3, typename SK::Line_3)>::type>
solutions_container;
typedef std::pair<Circular_arc_point_3, unsigned> Solution;
@ -264,12 +273,15 @@ namespace CGAL {
const typename SK::Circular_arc_3 & a2,
OutputIterator res)
{
typedef typename Intersection_traits<SK, typename SK::Circular_arc_3,
typename SK::Circular_arc_3>::result_type result_type;
typedef typename boost::result_of<
typename SK::Intersect_3(typename SK::Circular_arc_3, typename SK::Circular_arc_3)
>::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<typename Intersection_traits<SK, typename SK::Circle_3,
typename SK::Circle_3 >::result_type> solutions_container;
typedef std::vector< typename boost::result_of<
typename SK::Intersect_3(typename SK::Circle_3, typename SK::Circle_3 )
>::type> solutions_container;
typedef std::pair<Circular_arc_point_3, unsigned> Solution;
if(non_oriented_equal<SK>(a1.supporting_circle(), a2.supporting_circle())) {
@ -415,8 +427,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<typename Intersection_traits<SK, typename SK::Plane_3,
typename SK::Circular_arc_3>::result_type>
std::vector<typename boost::result_of<
typename SK::Intersect_3(typename SK::Plane_3,
typename SK::Circular_arc_3)>::type>
inters;
intersect_3<SK>(plane,arc,std::back_inserter(inters));
@ -469,7 +482,9 @@ 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<typename Intersection_traits<SK, typename SK::Plane_3, typename SK::Circular_arc_3 >::result_type> inters;
std::vector<typename boost::result_of<
typename SK::Intersect_3(typename SK::Plane_3, typename SK::Circular_arc_3 )>::type
> inters;
intersect_3<SK>(plane,arc,std::back_inserter(inters));
@ -594,7 +609,9 @@ namespace CGAL {
{
typename SK::Plane_3 plane(sphere.center(),sphere.center()+m,sphere.center()+typename SK::Vector_3(0,0,1));
std::vector<typename Intersection_traits<SK, typename SK::Plane_3, typename SK::Circular_arc_3>::result_type> inters;
std::vector<typename boost::result_of<
typename SK::Intersect_3(typename SK::Plane_3, typename SK::Circular_arc_3)
>::type> inters;
intersect_3<SK>(plane,arc,std::back_inserter(inters));
CGAL_kernel_precondition(!inters.empty());
if (inters.size()==1){

View File

@ -86,9 +86,9 @@ 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 Intersection_traits<SK, Line_arc_3, Line_arc_3>::result_type result_type;
typedef typename boost::result_of<typename SK::Intersect_3(Line_arc_3, Line_arc_3)>::type result_type;
typename Intersection_traits<SK, Line_3, Line_3>::result_type o =
typename boost::result_of<typename SK::Intersect_3(Line_3, Line_3)>::type o =
SK().intersect_3_object()(l1.supporting_line(),
l2.supporting_line());
@ -153,9 +153,9 @@ 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 Intersection_traits<SK, Line_3, Line_arc_3>::result_type result_type;
typedef typename boost::result_of<typename SK::Intersect_3(Line_3, Line_arc_3)>::type result_type;
typename Intersection_traits<SK,Line_3, Line_3>::result_type o =
typename boost::result_of<typename SK::Intersect_3(Line_3, Line_3)>::type o =
SK().intersect_3_object()(l, la.supporting_line());
if(!o)
@ -179,10 +179,12 @@ namespace CGAL {
OutputIterator res)
{
typedef typename SK::Circular_arc_point_3 Circular_arc_point_3;
typedef std::vector<typename Intersection_traits<SK, typename SK::Line_3, typename SK::Circle_3>::result_type>
solutions_container;
typedef std::vector<
typename boost::result_of<typename SK::Intersect_3(typename SK::Line_3, typename SK::Circle_3)
>::type> solutions_container;
typedef std::pair<Circular_arc_point_3, unsigned> Solution;
typedef typename Intersection_traits<SK, typename SK::Circle_3, typename SK::Line_arc_3>::result_type result_type;
typedef typename boost::result_of<
typename SK::Intersect_3(typename SK::Circle_3, typename SK::Line_arc_3)>::type result_type;
solutions_container solutions;
SK().intersect_3_object()(l.supporting_line(), c,
@ -211,8 +213,9 @@ namespace CGAL {
OutputIterator res)
{
typedef typename SK::Circular_arc_point_3 Circular_arc_point_3;
typedef std::vector<typename Intersection_traits<SK, typename SK::Line_3,
typename SK::Sphere_3>::result_type > solutions_container;
typedef std::vector<typename boost::result_of<
typename SK::Intersect_3(typename SK::Line_3,
typename SK::Sphere_3)>::type > solutions_container;
typedef std::pair<Circular_arc_point_3, unsigned> Solution;
solutions_container solutions;
SK().intersect_3_object()(l.supporting_line(), s,
@ -245,8 +248,8 @@ namespace CGAL {
*res++ = result_type(l);
}
const Point_3* sol;
typename Intersection_traits<SK, typename SK::Plane_3, typename SK::Line_3>
::result_type o = SK().intersect_3_object()(p,l.supporting_line());
typename boost::result_of<typename SK::Intersect_3(typename SK::Plane_3, typename SK::Line_3)>
::type o = SK().intersect_3_object()(p,l.supporting_line());
if(!o)
return res;