diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index ce58ca93cc4..e5b2c6f9de5 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -3341,8 +3341,17 @@ namespace CartesianKernelFunctors { typedef typename K::Segment_3 Segment_3; typedef typename K::Ray_3 Ray_3; typedef typename K::FT FT; + public: - typedef Point_3 result_type; + template + struct result { + typedef const Point_3 type; + }; + + template + struct result { + typedef const Point_3& type; + }; Point_3 operator()( const Line_3& l, const Point_3& p ) const @@ -3369,15 +3378,19 @@ namespace CartesianKernelFunctors { Point_3 operator()( const Triangle_3& t, const Point_3& p ) const - { return CommonKernelFunctors::Construct_projected_point_3()(p,t,K()); } + { return CommonKernelFunctors::Construct_projected_point_3()(t,p,K()); } Point_3 operator()( const Segment_3& s, const Point_3& p ) const - { return CommonKernelFunctors::Construct_projected_point_3()(p,s,K()); } + { return CommonKernelFunctors::Construct_projected_point_3()(s,p,K()); } Point_3 operator()( const Ray_3& r, const Point_3& p ) const - { return CommonKernelFunctors::Construct_projected_point_3()(p,r,K()); } + { return CommonKernelFunctors::Construct_projected_point_3()(r,p,K()); } + + const Point_3& + operator()( const Point_3& p, const Point_3& q) const + { return CommonKernelFunctors::Construct_projected_point_3()(p,q,K()); } }; template diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h b/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h index 8091a640d18..6f807504fff 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h @@ -3398,8 +3398,17 @@ namespace HomogeneousKernelFunctors { typedef typename K::Triangle_3 Triangle_3; typedef typename K::Segment_3 Segment_3; typedef typename K::Ray_3 Ray_3; + public: - typedef Point_3 result_type; + template + struct result { + typedef const Point_3 type; + }; + + template + struct result { + typedef const Point_3& type; + }; Point_3 operator()( const Line_3& l, const Point_3& p ) const @@ -3429,15 +3438,19 @@ namespace HomogeneousKernelFunctors { Point_3 operator()( const Triangle_3& t, const Point_3& p ) const - { return CommonKernelFunctors::Construct_projected_point_3()(p,t,K()); } + { return CommonKernelFunctors::Construct_projected_point_3()(t,p,K()); } Point_3 operator()( const Segment_3& s, const Point_3& p ) const - { return CommonKernelFunctors::Construct_projected_point_3()(p,s,K()); } + { return CommonKernelFunctors::Construct_projected_point_3()(s,p,K()); } Point_3 operator()( const Ray_3& r, const Point_3& p ) const - { return CommonKernelFunctors::Construct_projected_point_3()(p,r,K()); } + { return CommonKernelFunctors::Construct_projected_point_3()(r,p,K()); } + + const Point_3& + operator()( const Point_3& p, const Point_3& q) const + { return CommonKernelFunctors::Construct_projected_point_3()(p,q,K()); } }; template diff --git a/Kernel_23/include/CGAL/Kernel/function_objects.h b/Kernel_23/include/CGAL/Kernel/function_objects.h index 06758a7d7a3..c3a7337aefb 100644 --- a/Kernel_23/include/CGAL/Kernel/function_objects.h +++ b/Kernel_23/include/CGAL/Kernel/function_objects.h @@ -2850,8 +2850,8 @@ namespace CommonKernelFunctors { public: typename K::Point_3 - operator()(const typename K::Point_3& origin, - const typename K::Triangle_3& triangle, + operator()(const typename K::Triangle_3& triangle, + const typename K::Point_3& origin, const K& k) { typedef typename K::Point_3 Point_3; @@ -2890,18 +2890,18 @@ namespace CommonKernelFunctors { if(linf_ab > linf_ac) { if(linf_ab > linf_bc) { // ab is the maximal segment - return this->operator()(origin, seg(a, b), k); + return this->operator()(seg(a, b), origin, k); } else { // ab > ac, bc >= ab, use bc - return this->operator()(origin, seg(b, c), k); + return this->operator()(seg(b, c), origin, k); } } else { // ab <= ac if(linf_ac > linf_bc) { // ac is the maximal segment - return this->operator()(origin, seg(a, c), k); + return this->operator()(seg(a, c), origin, k); } else { // ab <= ac, ac <= bc, use bc - return this->operator()(origin, seg(b, c), k); + return this->operator()(seg(b, c), origin, k); } } } // degenerate plane @@ -2923,8 +2923,8 @@ namespace CommonKernelFunctors { } typename K::Point_3 - operator()(const typename K::Point_3& query, - const typename K::Segment_3& segment, + operator()(const typename K::Segment_3& segment, + const typename K::Point_3& query, const K& k) { @@ -2945,8 +2945,8 @@ namespace CommonKernelFunctors { } typename K::Point_3 - operator()(const typename K::Point_3& query, - const typename K::Ray_3& ray, + operator()(const typename K::Ray_3& ray, + const typename K::Point_3& query, const K& k) { if ( ray.to_vector() * (query-ray.source()) <= 0) @@ -2957,6 +2957,14 @@ namespace CommonKernelFunctors { } } + const typename K::Point_3& + operator()(const typename K::Point_3& point, + const typename K::Point_3&, + const K&) + { + return point; + } + // code for operator for plane and point is defined in // CGAL/Cartesian/function_objects.h and CGAL/Homogeneous/function_objects.h }; @@ -3005,7 +3013,6 @@ namespace CommonKernelFunctors { public: typedef typename K::Boolean result_type; - // There are 36 combinaisons, so I use a template. template result_type operator()(const T1& t1, const T2& t2) const @@ -3018,7 +3025,6 @@ namespace CommonKernelFunctors { public: typedef typename K::Boolean result_type; - // There are x combinaisons, so I use a template. template result_type operator()(const T1& t1, const T2& t2) const diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_constructions_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_constructions_3.h index e45abb683e9..1931c2ae7e2 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_constructions_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_constructions_3.h @@ -131,6 +131,8 @@ _test_fct_constructions_3(const R& r) assert( r.construct_projected_point_3_object()(ray, Point(-1,0,0)) == Point(0,0,0)); assert( r.construct_projected_point_3_object()(s, Point(-1,0,0)) == Point(0,0,0)); assert( r.construct_projected_point_3_object()(s, Point(2,0,0)) == Point(1,1,0)); + assert( r.construct_projected_point_3_object()(Point(0,0,0), Point(2,0,0)) == Point(0,0,0)); + return true; }