Have squared_distance(Point_3, Point_3) call its functor.

This commit is contained in:
Sylvain Pion 2006-08-04 12:41:56 +00:00
parent c7f1f68b40
commit fcbacc1284
2 changed files with 13 additions and 7 deletions

View File

@ -188,12 +188,9 @@ inline
typename K::FT typename K::FT
squared_distance(const typename CGAL_WRAP(K)::Point_3 & pt1, squared_distance(const typename CGAL_WRAP(K)::Point_3 & pt1,
const typename CGAL_WRAP(K)::Point_3 & pt2, const typename CGAL_WRAP(K)::Point_3 & pt2,
const K&) const K& k)
{ {
typename K::Construct_vector_3 construct_vector; return k.compute_squared_distance_3_object()(pt1, pt2);
typedef typename K::Vector_3 Vector_3;
Vector_3 vec = construct_vector(pt2, pt1);
return vec*vec;
} }

View File

@ -212,7 +212,8 @@ namespace CommonKernelFunctors {
template <typename K> template <typename K>
class Compute_squared_distance_3 class Compute_squared_distance_3
{ {
typedef typename K::FT FT; typedef typename K::FT FT;
typedef typename K::Point_3 Point_3;
public: public:
typedef FT result_type; typedef FT result_type;
typedef Arity_tag< 2 > Arity; typedef Arity_tag< 2 > Arity;
@ -222,6 +223,14 @@ namespace CommonKernelFunctors {
FT FT
operator()( const T1& t1, const T2& t2) const operator()( const T1& t1, const T2& t2) const
{ return CGALi::squared_distance(t1, t2, K()); } { return CGALi::squared_distance(t1, t2, K()); }
FT
operator()( const Point_3& pt1, const Point_3& pt2) const
{
typedef typename K::Vector_3 Vector_3;
Vector_3 vec = pt2 - pt1;
return vec*vec;
}
}; };
template <typename K> template <typename K>