Add Construct_projected_point_3(P3, P3) + correct parameter order

Not a kernel requirement
This commit is contained in:
Mael Rouxel-Labbé 2021-09-28 15:34:51 +02:00
parent 2dda84c9b3
commit e424356ffa
4 changed files with 54 additions and 20 deletions

View File

@ -3341,8 +3341,17 @@ namespace CartesianKernelFunctors {
typedef typename K::Segment_3 Segment_3; typedef typename K::Segment_3 Segment_3;
typedef typename K::Ray_3 Ray_3; typedef typename K::Ray_3 Ray_3;
typedef typename K::FT FT; typedef typename K::FT FT;
public: public:
typedef Point_3 result_type; template<typename>
struct result {
typedef const Point_3 type;
};
template<typename F>
struct result<F(Point_3, Point_3)> {
typedef const Point_3& type;
};
Point_3 Point_3
operator()( const Line_3& l, const Point_3& p ) const operator()( const Line_3& l, const Point_3& p ) const
@ -3369,15 +3378,19 @@ namespace CartesianKernelFunctors {
Point_3 Point_3
operator()( const Triangle_3& t, const Point_3& p ) const operator()( const Triangle_3& t, const Point_3& p ) const
{ return CommonKernelFunctors::Construct_projected_point_3<K>()(p,t,K()); } { return CommonKernelFunctors::Construct_projected_point_3<K>()(t,p,K()); }
Point_3 Point_3
operator()( const Segment_3& s, const Point_3& p ) const operator()( const Segment_3& s, const Point_3& p ) const
{ return CommonKernelFunctors::Construct_projected_point_3<K>()(p,s,K()); } { return CommonKernelFunctors::Construct_projected_point_3<K>()(s,p,K()); }
Point_3 Point_3
operator()( const Ray_3& r, const Point_3& p ) const operator()( const Ray_3& r, const Point_3& p ) const
{ return CommonKernelFunctors::Construct_projected_point_3<K>()(p,r,K()); } { return CommonKernelFunctors::Construct_projected_point_3<K>()(r,p,K()); }
const Point_3&
operator()( const Point_3& p, const Point_3& q) const
{ return CommonKernelFunctors::Construct_projected_point_3<K>()(p,q,K()); }
}; };
template <class K> template <class K>

View File

@ -3398,8 +3398,17 @@ namespace HomogeneousKernelFunctors {
typedef typename K::Triangle_3 Triangle_3; typedef typename K::Triangle_3 Triangle_3;
typedef typename K::Segment_3 Segment_3; typedef typename K::Segment_3 Segment_3;
typedef typename K::Ray_3 Ray_3; typedef typename K::Ray_3 Ray_3;
public: public:
typedef Point_3 result_type; template<typename>
struct result {
typedef const Point_3 type;
};
template<typename F>
struct result<F(Point_3, Point_3)> {
typedef const Point_3& type;
};
Point_3 Point_3
operator()( const Line_3& l, const Point_3& p ) const operator()( const Line_3& l, const Point_3& p ) const
@ -3429,15 +3438,19 @@ namespace HomogeneousKernelFunctors {
Point_3 Point_3
operator()( const Triangle_3& t, const Point_3& p ) const operator()( const Triangle_3& t, const Point_3& p ) const
{ return CommonKernelFunctors::Construct_projected_point_3<K>()(p,t,K()); } { return CommonKernelFunctors::Construct_projected_point_3<K>()(t,p,K()); }
Point_3 Point_3
operator()( const Segment_3& s, const Point_3& p ) const operator()( const Segment_3& s, const Point_3& p ) const
{ return CommonKernelFunctors::Construct_projected_point_3<K>()(p,s,K()); } { return CommonKernelFunctors::Construct_projected_point_3<K>()(s,p,K()); }
Point_3 Point_3
operator()( const Ray_3& r, const Point_3& p ) const operator()( const Ray_3& r, const Point_3& p ) const
{ return CommonKernelFunctors::Construct_projected_point_3<K>()(p,r,K()); } { return CommonKernelFunctors::Construct_projected_point_3<K>()(r,p,K()); }
const Point_3&
operator()( const Point_3& p, const Point_3& q) const
{ return CommonKernelFunctors::Construct_projected_point_3<K>()(p,q,K()); }
}; };
template <class K> template <class K>

View File

@ -2850,8 +2850,8 @@ namespace CommonKernelFunctors {
public: public:
typename K::Point_3 typename K::Point_3
operator()(const typename K::Point_3& origin, operator()(const typename K::Triangle_3& triangle,
const typename K::Triangle_3& triangle, const typename K::Point_3& origin,
const K& k) const K& k)
{ {
typedef typename K::Point_3 Point_3; typedef typename K::Point_3 Point_3;
@ -2890,18 +2890,18 @@ namespace CommonKernelFunctors {
if(linf_ab > linf_ac) { if(linf_ab > linf_ac) {
if(linf_ab > linf_bc) { if(linf_ab > linf_bc) {
// ab is the maximal segment // ab is the maximal segment
return this->operator()(origin, seg(a, b), k); return this->operator()(seg(a, b), origin, k);
} else { } else {
// ab > ac, bc >= ab, use bc // 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 } else { // ab <= ac
if(linf_ac > linf_bc) { if(linf_ac > linf_bc) {
// ac is the maximal segment // ac is the maximal segment
return this->operator()(origin, seg(a, c), k); return this->operator()(seg(a, c), origin, k);
} else { } else {
// ab <= ac, ac <= bc, use bc // ab <= ac, ac <= bc, use bc
return this->operator()(origin, seg(b, c), k); return this->operator()(seg(b, c), origin, k);
} }
} }
} // degenerate plane } // degenerate plane
@ -2923,8 +2923,8 @@ namespace CommonKernelFunctors {
} }
typename K::Point_3 typename K::Point_3
operator()(const typename K::Point_3& query, operator()(const typename K::Segment_3& segment,
const typename K::Segment_3& segment, const typename K::Point_3& query,
const K& k) const K& k)
{ {
@ -2945,8 +2945,8 @@ namespace CommonKernelFunctors {
} }
typename K::Point_3 typename K::Point_3
operator()(const typename K::Point_3& query, operator()(const typename K::Ray_3& ray,
const typename K::Ray_3& ray, const typename K::Point_3& query,
const K& k) const K& k)
{ {
if ( ray.to_vector() * (query-ray.source()) <= 0) 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 // code for operator for plane and point is defined in
// CGAL/Cartesian/function_objects.h and CGAL/Homogeneous/function_objects.h // CGAL/Cartesian/function_objects.h and CGAL/Homogeneous/function_objects.h
}; };
@ -3005,7 +3013,6 @@ namespace CommonKernelFunctors {
public: public:
typedef typename K::Boolean result_type; typedef typename K::Boolean result_type;
// There are 36 combinaisons, so I use a template.
template <class T1, class T2> template <class T1, class T2>
result_type result_type
operator()(const T1& t1, const T2& t2) const operator()(const T1& t1, const T2& t2) const
@ -3018,7 +3025,6 @@ namespace CommonKernelFunctors {
public: public:
typedef typename K::Boolean result_type; typedef typename K::Boolean result_type;
// There are x combinaisons, so I use a template.
template <class T1, class T2> template <class T1, class T2>
result_type result_type
operator()(const T1& t1, const T2& t2) const operator()(const T1& t1, const T2& t2) const

View File

@ -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()(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(-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()(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; return true;
} }