Backport from trunk:

| ------------------------------------------------------------------------
  | r57752 | lrineau | 2010-08-03 16:22:25 +0200 (Tue, 03 Aug 2010) | 6 lines
  | Changed paths:
  |    M /trunk/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h
  |    M /trunk/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h
  |    M /trunk/Kernel_23/doc_tex/Kernel_23_ref/Kernel_CompareDistance_2.tex
  |    M /trunk/Kernel_23/doc_tex/Kernel_23_ref/Kernel_CompareDistance_3.tex
  |    M /trunk/Kernel_23/doc_tex/Kernel_23_ref/Kernel_CompareSquaredDistance_2.tex
  |    M /trunk/Kernel_23/doc_tex/Kernel_23_ref/Kernel_CompareSquaredDistance_3.tex
  |    M /trunk/Kernel_23/doc_tex/Kernel_23_ref/Kernel_ComputeSquaredDistance_2.tex
  |    M /trunk/Kernel_23/doc_tex/Kernel_23_ref/Kernel_ComputeSquaredDistance_3.tex
  |    A /trunk/Kernel_23/doc_tex/Kernel_23_ref/compare_distance.tex
  |    M /trunk/Kernel_23/doc_tex/Kernel_23_ref/compare_squared_distance.tex
  |    M /trunk/Kernel_23/include/CGAL/Kernel/global_functions.h
  |    M /trunk/Kernel_23/include/CGAL/Kernel/global_functions_internal_2.h
  |    M /trunk/Kernel_23/include/CGAL/Kernel/global_functions_internal_3.h
  |    M /trunk/Kernel_23/test/Kernel_23/include/CGAL/_test_new_2.h
  |    M /trunk/Kernel_23/test/Kernel_23/include/CGAL/_test_new_3.h
  | 
  | - Deprecate operator()(T1, T2, T3, T4) of Kernel::CompareSquaredDistance_[23]
  | and move it to Kernel::CompareDistance_[23].
  | - Add CGAL::compare_distance(T1, T2, T3, T4).
  | 
  | (Test suite OK.)
  | 
  | ------------------------------------------------------------------------
This commit is contained in:
Laurent Rineau 2010-08-03 14:24:59 +00:00
parent 4926946f29
commit 09d97fc9d7
15 changed files with 222 additions and 56 deletions

View File

@ -409,6 +409,13 @@ namespace CartesianKernelFunctors {
{ {
return cmp_dist_to_pointC2(p.x(), p.y(), q.x(), q.y(), r.x(), r.y()); return cmp_dist_to_pointC2(p.x(), p.y(), q.x(), q.y(), r.x(), r.y());
} }
template <class T1, class T2, class T3, class T4>
result_type
operator()(const T1& p, const T2& q, const T3& r, const T4& s) const
{
return CGAL_NTS compare(squared_distance(p, q), squared_distance(r, s));
}
}; };
template <typename K> template <typename K>
@ -425,6 +432,13 @@ namespace CartesianKernelFunctors {
q.x(), q.y(), q.z(), q.x(), q.y(), q.z(),
r.x(), r.y(), r.z()); r.x(), r.y(), r.z());
} }
template <class T1, class T2, class T3, class T4>
result_type
operator()(const T1& p, const T2& q, const T3& r, const T4& s) const
{
return CGAL_NTS compare(squared_distance(p, q), squared_distance(r, s));
}
}; };
template <typename K> template <typename K>

View File

@ -647,6 +647,13 @@ namespace HomogeneousKernelFunctors {
return CGAL_NTS sign(dosd); return CGAL_NTS sign(dosd);
} }
template <class T1, class T2, class T3, class T4>
result_type
operator()(const T1& p, const T2& q, const T3& r, const T4& s) const
{
return CGAL_NTS compare(squared_distance(p, q), squared_distance(r, s));
}
}; };
template <typename K> template <typename K>
@ -685,6 +692,13 @@ namespace HomogeneousKernelFunctors {
return CGAL_NTS sign(dosd); return CGAL_NTS sign(dosd);
} }
template <class T1, class T2, class T3, class T4>
result_type
operator()(const T1& p, const T2& q, const T3& r, const T4& s) const
{
return CGAL_NTS compare(squared_distance(p, q), squared_distance(r, s));
}
}; };
template <typename K> template <typename K>

View File

@ -8,6 +8,22 @@ A model for this must provide:
const Kernel::Point_2&r);} const Kernel::Point_2&r);}
{compares the distances of points \ccc{q} and \ccc{r} to point \ccc{p}} {compares the distances of points \ccc{q} and \ccc{r} to point \ccc{p}}
\ccMemberFunction{Comparison_result operator()(const Type1& obj1,
const Type2& obj2,
const Type3& obj3,
const Type4& obj4);}
{compares the squared distance between \ccc{obj1} and \ccc{obj2} to
the squared distance between \ccc{obj3} and \ccc{obj4}}
for all tuples of types \ccStyle{Type1}, \ccStyle{Type2}, \ccStyle{Type3}
and \ccStyle{Type4} in the following set of types:
\begin{itemize}\ccTexHtml{\itemsep0pt\topsep0pt\partopsep0pt\parskip0pt\parsep0pt}{}
\item \ccStyle{Kernel::Point_2}
\item \ccStyle{Kernel::Line_2}
\item \ccStyle{Kernel::Ray_2}
\item \ccStyle{Kernel::Segment_2}
\item \ccStyle{Kernel::Triangle_2}
\end{itemize}
\ccRefines \ccRefines
\ccc{AdaptableFunctor} (with three arguments) \ccc{AdaptableFunctor} (with three arguments)

View File

@ -8,6 +8,22 @@ A model for this must provide:
const Kernel::Point_3&r);} const Kernel::Point_3&r);}
{compares the distances of points \ccc{q} and \ccc{r} to point \ccc{p}} {compares the distances of points \ccc{q} and \ccc{r} to point \ccc{p}}
\ccMemberFunction{Comparison_result operator()(const Type1& obj1,
const Type2& obj2,
const Type3& obj3,
const Type4& obj4);}
{compares the squared distance between \ccc{obj1} and \ccc{obj2} to
the squared distance between \ccc{obj3} and \ccc{obj4}}
for all tuples of types \ccStyle{Type1}, \ccStyle{Type2}, \ccStyle{Type3}
and \ccStyle{Type4} in the following set of types:
\begin{itemize}\ccTexHtml{\itemsep0pt\topsep0pt\partopsep0pt\parskip0pt\parsep0pt}{}
\item \ccStyle{Kernel::Point_3}
\item \ccStyle{Kernel::Line_3}
\item \ccStyle{Kernel::Ray_3}
\item \ccStyle{Kernel::Segment_3}
\item \ccStyle{Kernel::Plane_3}
\end{itemize}
\ccRefines \ccRefines
\ccc{AdaptableFunctor} (with three arguments) \ccc{AdaptableFunctor} (with three arguments)

View File

@ -19,21 +19,22 @@ following:
\item \ccStyle{Kernel::Triangle_2} \item \ccStyle{Kernel::Triangle_2}
\end{itemize} \end{itemize}
\ccMemberFunction{Comparison_result operator()(const Type1& obj1, % Deprecated: use Kernel::CompareDistance_2 instead
const Type2& obj2, % \ccMemberFunction{Comparison_result operator()(const Type1& obj1,
const Type3& obj3, % const Type2& obj2,
const Type4& obj4);} % const Type3& obj3,
{compares the squared distance between \ccc{obj1} and \ccc{obj2} to % const Type4& obj4);}
the squared distance between \ccc{obj3} and \ccc{obj4}} % {compares the squared distance between \ccc{obj1} and \ccc{obj2} to
for all tuples of types \ccStyle{Type1}, \ccStyle{Type2}, \ccStyle{Type3} % the squared distance between \ccc{obj3} and \ccc{obj4}}
and \ccStyle{Type4} in the following set of types: % for all tuples of types \ccStyle{Type1}, \ccStyle{Type2}, \ccStyle{Type3}
\begin{itemize}\ccTexHtml{\itemsep0pt\topsep0pt\partopsep0pt\parskip0pt\parsep0pt}{} % and \ccStyle{Type4} in the following set of types:
\item \ccStyle{Kernel::Point_2} % \begin{itemize}\ccTexHtml{\itemsep0pt\topsep0pt\partopsep0pt\parskip0pt\parsep0pt}{}
\item \ccStyle{Kernel::Line_2} % \item \ccStyle{Kernel::Point_2}
\item \ccStyle{Kernel::Ray_2} % \item \ccStyle{Kernel::Line_2}
\item \ccStyle{Kernel::Segment_2} % \item \ccStyle{Kernel::Ray_2}
\item \ccStyle{Kernel::Triangle_2} % \item \ccStyle{Kernel::Segment_2}
\end{itemize} % \item \ccStyle{Kernel::Triangle_2}
% \end{itemize}
\ccRefines \ccRefines
\ccc{AdaptableFunctor} (with three arguments) \ccc{AdaptableFunctor} (with three arguments)

View File

@ -19,21 +19,22 @@ following:
\item \ccStyle{Kernel::Plane_3} \item \ccStyle{Kernel::Plane_3}
\end{itemize} \end{itemize}
\ccMemberFunction{Comparison_result operator()(const Type1& obj1, % Deprecated: use Kernel::CompareDistance_3 instead
const Type2& obj2, % \ccMemberFunction{Comparison_result operator()(const Type1& obj1,
const Type3& obj3, % const Type2& obj2,
const Type4& obj4);} % const Type3& obj3,
{compares the squared distance between \ccc{obj1} and \ccc{obj2} to % const Type4& obj4);}
the squared distance between \ccc{obj3} and \ccc{obj4}} % {compares the squared distance between \ccc{obj1} and \ccc{obj2} to
for all tuples of types \ccStyle{Type1}, \ccStyle{Type2}, \ccStyle{Type3} % the squared distance between \ccc{obj3} and \ccc{obj4}}
and \ccStyle{Type4} in the following set of types: % for all tuples of types \ccStyle{Type1}, \ccStyle{Type2}, \ccStyle{Type3}
\begin{itemize}\ccTexHtml{\itemsep0pt\topsep0pt\partopsep0pt\parskip0pt\parsep0pt}{} % and \ccStyle{Type4} in the following set of types:
\item \ccStyle{Kernel::Point_3} % \begin{itemize}\ccTexHtml{\itemsep0pt\topsep0pt\partopsep0pt\parskip0pt\parsep0pt}{}
\item \ccStyle{Kernel::Line_3} % \item \ccStyle{Kernel::Point_3}
\item \ccStyle{Kernel::Ray_3} % \item \ccStyle{Kernel::Line_3}
\item \ccStyle{Kernel::Segment_3} % \item \ccStyle{Kernel::Ray_3}
\item \ccStyle{Kernel::Plane_3} % \item \ccStyle{Kernel::Segment_3}
\end{itemize} % \item \ccStyle{Kernel::Plane_3}
% \end{itemize}
\ccRefines \ccRefines
\ccc{AdaptableFunctor} (with three arguments) \ccc{AdaptableFunctor} (with three arguments)

View File

@ -16,7 +16,8 @@ following:
\item \ccStyle{Kernel::Ray_2} \item \ccStyle{Kernel::Ray_2}
\item \ccStyle{Kernel::Segment_2} \item \ccStyle{Kernel::Segment_2}
\item \ccStyle{Kernel::Triangle_2} \item \ccStyle{Kernel::Triangle_2}
% If this list is changed, please change also in Kernel_CompareSquaredDistance_2.tex % If this list is changed, please change also in
% Kernel_CompareDistance_2.tex and compare_distance.tex
\end{itemize} \end{itemize}
\ccRefines \ccRefines

View File

@ -17,7 +17,7 @@ following:
\item \ccStyle{Kernel::Segment_3} \item \ccStyle{Kernel::Segment_3}
\item \ccStyle{Kernel::Plane_3} \item \ccStyle{Kernel::Plane_3}
% If this list is changed, please change also in % If this list is changed, please change also in
% Kernel_CompareSquaredDistance_3.tex % Kernel_CompareDistance_3.tex and compare_distance.tex
\end{itemize} \end{itemize}
\ccRefines \ccRefines

View File

@ -0,0 +1,39 @@
\begin{ccRefFunction}{compare_distance}
\ccFunction{Comparison_result
compare_distance(const Type1& obj1, const Type2& obj2,
const Type3& obj3, const Type4& obj4);}
{compares the distance between \ccc{obj1} and \ccc{obj2} to
the distance between \ccc{obj3} and \ccc{obj4}}
for all tuples of types \ccStyle{Type1}, \ccStyle{Type2}, \ccStyle{Type3}
and \ccStyle{Type4} in the following set of 2D types:
\begin{itemize}\ccTexHtml{\itemsep0pt\topsep0pt\partopsep0pt\parskip0pt\parsep0pt}{}
\item \ccStyle{Kernel::Point_2}
\item \ccStyle{Kernel::Line_2}
\item \ccStyle{Kernel::Ray_2}
\item \ccStyle{Kernel::Segment_2}
\item \ccStyle{Kernel::Triangle_2}
\end{itemize}
or in the following set of 3D types:
\begin{itemize}\ccTexHtml{\itemsep0pt\topsep0pt\partopsep0pt\parskip0pt\parsep0pt}{}
\item \ccStyle{Kernel::Point_3}
\item \ccStyle{Kernel::Line_3}
\item \ccStyle{Kernel::Ray_3}
\item \ccStyle{Kernel::Segment_3}
\item \ccStyle{Kernel::Plane_3}
\end{itemize}
\ccSeeAlso
\ccRefIdfierPage{CGAL::compare_squared_distance} \\
\ccRefIdfierPage{CGAL::compare_distance_to_point}\\
\ccRefIdfierPage{CGAL::compare_signed_distance_to_line} \\
\ccRefIdfierPage{CGAL::compare_signed_distance_to_plane} \\
\ccRefIdfierPage{CGAL::has_larger_distance_to_point} \\
\ccRefIdfierPage{CGAL::has_larger_signed_distance_to_line} \\
\ccRefIdfierPage{CGAL::has_larger_signed_distance_to_plane} \\
\ccRefIdfierPage{CGAL::has_smaller_distance_to_point} \\
\ccRefIdfierPage{CGAL::has_smaller_signed_distance_to_line} \\
\ccRefIdfierPage{CGAL::has_smaller_signed_distance_to_plane} \\
\end{ccRefFunction}

View File

@ -14,14 +14,15 @@ compare_squared_distance(const Point_3<Kernel>& p,
{compares the squared distance of points \ccStyle{p} and {compares the squared distance of points \ccStyle{p} and
\ccStyle{q} to \ccStyle{d2}.} \ccStyle{q} to \ccStyle{d2}.}
\ccFunction{Comparison_result % Deprecated: use compare_distance(..) instead
compare_squared_distance(const Point_3<Kernel>& p, % \ccFunction{Comparison_result
const Point_3<Kernel>& q, % compare_squared_distance(const Point_3<Kernel>& p,
const Point_3<Kernel>& r, % const Point_3<Kernel>& q,
const Point_3<Kernel>& s);} % const Point_3<Kernel>& r,
{compares the squared distance of points \ccStyle{p} and % const Point_3<Kernel>& s);}
\ccStyle{q} to the squared distance of points \ccStyle{r} and % {compares the squared distance of points \ccStyle{p} and
\ccStyle{s}.} % \ccStyle{q} to the squared distance of points \ccStyle{r} and
% \ccStyle{s}.}
\ccSeeAlso \ccSeeAlso
\ccRefIdfierPage{CGAL::compare_distance_to_point} \\ \ccRefIdfierPage{CGAL::compare_distance_to_point} \\

View File

@ -32,6 +32,18 @@
namespace CGAL { namespace CGAL {
template <class T1, class T2, class T3, class T4>
inline
Comparison_result
compare_distance(const T1 &o1,
const T2 &o2,
const T3 &o3,
const T4 &o4)
{
typedef typename Kernel_traits<T1>::Kernel K;
return internal::compare_distance(o1, o2, o3, o4, K());
}
template <typename O> template <typename O>
inline inline
bool bool

View File

@ -3,6 +3,7 @@
// INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg // INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg
// (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria), // (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria),
// and Tel-Aviv University (Israel). All rights reserved. // and Tel-Aviv University (Israel). All rights reserved.
// Copyright (c) 2010 GeometryFactory Sarl (France)
// //
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or // This file is part of CGAL (www.cgal.org); you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as // modify it under the terms of the GNU Lesser General Public License as
@ -30,6 +31,10 @@
// These functions are not documented for now, but could be as some point. // These functions are not documented for now, but could be as some point.
#include <CGAL/basic.h> #include <CGAL/basic.h>
#include <boost/utility/enable_if.hpp>
#include "boost/mpl/equal_to.hpp"
#include <boost/mpl/int.hpp>
#include <boost/mpl/integral_c.hpp>
namespace CGAL { namespace CGAL {
@ -253,6 +258,22 @@ compare_angle_with_x_axis(const typename K::Direction_2& d1,
return k.compare_angle_with_x_axis_2_object()(d1, d2); return k.compare_angle_with_x_axis_2_object()(d1, d2);
} }
template <class K, class T1, class T2, class T3, class T4>
inline
typename boost::enable_if<
boost::mpl::equal_to<boost::mpl::integral_c<int,
Ambient_dimension<T1>::type::value>,
boost::mpl::integral_c<int, 2> >,
typename K::Comparison_result>
::type
compare_distance(const T1 &o1,
const T2 &o2,
const T3 &o3,
const T4 &o4, const K& k)
{
return k.compare_distance_2_object()(o1, o2, o3, o4);
}
template <class K > template <class K >
inline inline
typename K::Comparison_result typename K::Comparison_result

View File

@ -3,6 +3,7 @@
// INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg // INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg
// (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria), // (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria),
// and Tel-Aviv University (Israel). All rights reserved. // and Tel-Aviv University (Israel). All rights reserved.
// Copyright (c) 2010 GeometryFactory Sarl (France)
// //
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or // This file is part of CGAL (www.cgal.org); you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as // modify it under the terms of the GNU Lesser General Public License as
@ -27,6 +28,11 @@
// Generic functions calling the kernel functor. // Generic functions calling the kernel functor.
// See comments in CGAL/Kernel/global_functions_internal_3.h. // See comments in CGAL/Kernel/global_functions_internal_3.h.
#include <CGAL/basic.h>
#include <boost/utility/enable_if.hpp>
#include "boost/mpl/equal_to.hpp"
#include <boost/mpl/integral_c.hpp>
namespace CGAL { namespace CGAL {
namespace internal { namespace internal {
@ -314,6 +320,25 @@ compare_dihedral_angle(const typename K::Vector_3& ab1,
return k.compare_dihedral_angle_3_object()(ab1, ac1, ad1, cosine); return k.compare_dihedral_angle_3_object()(ab1, ac1, ad1, cosine);
} }
template <class K, class T1, class T2, class T3, class T4>
inline
typename boost::enable_if<
boost::mpl::equal_to<boost::mpl::integral_c<int,
Ambient_dimension<T1>::type::value>,
boost::mpl::integral_c<int, 3> >,
typename K::Comparison_result>
::type
// boost::mpl::equal_to<typename Ambient_dimension<T1>::type,
// boost::mpl::int_<3> >,
// typename K::Comparison_result>::type
compare_distance(const T1 &o1,
const T2 &o2,
const T3 &o3,
const T4 &o4, const K& k)
{
return k.compare_distance_3_object()(o1, o2, o3, o4);
}
template < class K > template < class K >
inline inline
typename K::Comparison_result typename K::Comparison_result

View File

@ -456,15 +456,17 @@ test_new_2(const R& rep)
typename R::Compare_squared_distance_2 compare_sq_dist typename R::Compare_squared_distance_2 compare_sq_dist
= rep.compare_squared_distance_2_object(); = rep.compare_squared_distance_2_object();
tmp34ab = compare_sq_dist(p1,p2,FT(1)); tmp34ab = compare_sq_dist(p1,p2,FT(1));
tmp34ab = compare_sq_dist(p1, l2, FT(1)); tmp34ab = compare_sq_dist(p1, l2, FT(1));
tmp34ab = compare_sq_dist(p2, p1, FT(1)); tmp34ab = compare_sq_dist(p2, p1, FT(1));
tmp34ab = compare_sq_dist(l1, l2, FT(1)); tmp34ab = compare_sq_dist(l1, l2, FT(1));
tmp34ab = compare_sq_dist(p1, s1, FT(1)); tmp34ab = compare_sq_dist(p1, s1, FT(1));
tmp34ab = compare_sq_dist(p1, t2, FT(1)); tmp34ab = compare_sq_dist(p1, t2, FT(1));
tmp34ab = compare_sq_dist(t2, s1, FT(1)); tmp34ab = compare_sq_dist(t2, s1, FT(1));
tmp34ab = compare_sq_dist(t2, l1, FT(1)); tmp34ab = compare_sq_dist(t2, l1, FT(1));
tmp34ab = compare_sq_dist(t2, l1, s1, p1);
tmp34ab = CGAL::compare_distance(t2, l1, s1, p1);
tmp34ab = CGAL::compare_distance(t2, l1, s1, p1);
typename R::Compare_angle_with_x_axis_2 compare_angle typename R::Compare_angle_with_x_axis_2 compare_angle
= rep.compare_angle_with_x_axis_2_object(); = rep.compare_angle_with_x_axis_2_object();

View File

@ -572,13 +572,16 @@ test_new_3(const R& rep)
typename R::Compare_squared_distance_3 compare_sq_dist typename R::Compare_squared_distance_3 compare_sq_dist
= rep.compare_squared_distance_3_object(); = rep.compare_squared_distance_3_object();
tmp34ab = compare_sq_dist(p2,p3,FT(1)); tmp34ab = compare_sq_dist(p2,p3,FT(1));
tmp34ab = compare_sq_dist(p2,p3,p2,p3); tmp34ab = compare_sq_dist(p2,p3,p2,p3);
tmp34ab = compare_sq_dist(p1, l2, FT(1)); tmp34ab = compare_sq_dist(p1, l2, FT(1));
tmp34ab = compare_sq_dist(p2, p1, FT(1)); tmp34ab = compare_sq_dist(p2, p1, FT(1));
tmp34ab = compare_sq_dist(l2, l3, FT(1)); tmp34ab = compare_sq_dist(l2, l3, FT(1));
tmp34ab = compare_sq_dist(p1, s2, FT(1)); tmp34ab = compare_sq_dist(p1, s2, FT(1));
tmp34ab = compare_sq_dist(p1, p2, p3, p4); tmp34ab = compare_sq_dist(p1, p2, p3, p4);
tmp34ab = CGAL::compare_distance(p2,p3,p2,p3);
tmp34ab = CGAL::compare_distance(p1, p2, p3, p4);
typename R::Compare_squared_radius_3 compare_sq_radius typename R::Compare_squared_radius_3 compare_sq_radius
= rep.compare_squared_radius_3_object(); = rep.compare_squared_radius_3_object();