Introduced Intersection_results as a Kernel concept for use in public APIs in favor over Intersection_traits.

This commit is contained in:
Philipp Möller 2011-11-15 13:41:14 +00:00
parent 51100ae07c
commit 9051768cea
16 changed files with 56 additions and 33 deletions

View File

@ -51,6 +51,9 @@ struct Cartesian_base_ref_count
#define CGAL_Kernel_cons(Y,Z) CGAL_Kernel_pred(Y,Z)
#include <CGAL/Kernel/interface_macros.h>
template<typename A, typename B>
struct Intersection_result : CGAL::Intersection_traits<K, A, B> {};
};
template < typename FT_ >

View File

@ -50,6 +50,9 @@ struct Cartesian_base_no_ref_count
#define CGAL_Kernel_cons(Y,Z) CGAL_Kernel_pred(Y,Z)
#include <CGAL/Kernel/interface_macros.h>
template<typename A, typename B>
struct Intersection_result : CGAL::Intersection_traits<K, A, B> {};
};
template < typename FT_ >

View File

@ -80,9 +80,11 @@ struct Circular_kernel_base_ref_count: public LinearKernelBase
#include <CGAL/Circular_kernel_2/interface_macros.h>
typedef LinearFunctors::Construct_line_2<CircularKernel> Construct_line_2;
typedef LinearFunctors::Construct_line_2<CircularKernel> Construct_line_2;
Construct_line_2 construct_line_2_object() const { return Construct_line_2(); }
template<typename A, typename B>
struct Intersection_result : CGAL::Intersection_traits<K, A, B> {};
};
} // namespace internal

View File

@ -65,6 +65,8 @@ struct Filtered_bbox_circular_kernel_base_ref_count : public CircularKernel
#include <CGAL/Filtered_bbox_circular_kernel_2/interface_macros.h>
template<typename A, typename B>
struct Intersection_result : CGAL::Intersection_traits<K, A, B> {};
};
} // namespace internal

View File

@ -74,6 +74,9 @@ struct Circular_kernel_base_ref_count: public LinearKernelBase
#define CGAL_Circular_Kernel_cons(Y,Z) CGAL_Circular_Kernel_pred(Y,Z)
#include <CGAL/Circular_kernel_2/interface_macros.h>
template<typename A, typename B>
struct Intersection_result : CGAL::Intersection_traits<K, A, B> {};
};
} // namespace internal

View File

@ -68,6 +68,9 @@ namespace CGAL {
#include <CGAL/Circular_kernel_3/interface_macros.h>
template<typename A, typename B>
struct Intersection_result : CGAL::Intersection_traits<SphericalKernel, A, B> {};
};
} // namespace internal

View File

@ -66,6 +66,9 @@ namespace CGAL {
Y Z(const CGAL::Sphere_3<SphericalKernel>& S) const { return Y(S); }
#include <CGAL/Circular_kernel_3/interface_macros.h>
template<typename A, typename B>
struct Intersection_result : CGAL::Intersection_traits<SphericalKernel, A, B> {};
};
} // namespace internal

View File

@ -93,7 +93,8 @@ struct Cartesian_base_ref_count_I
intersect_with_iterators_2_object)
#include <CGAL/Kernel/interface_macros.h>
template<typename A, typename B>
struct Intersection_result : CGAL::Intersection_traits<K, A, B> {};
};
template < typename FT_ >

View File

@ -156,6 +156,8 @@ struct Homogeneous_base
#include <CGAL/Kernel/interface_macros.h>
template<typename A, typename B>
struct Intersection_result : CGAL::Intersection_traits<Kernel, A, B> {};
};
} //namespace CGAL

View File

@ -66,12 +66,12 @@ especially integer types and rationals.
Some functions can return different types of objects. To achieve this
in a type safe way {\cgal} uses return values of
\ccStyle{boost::optional< boost::variant< T \ldots\ >} were
T\textellipsis\ is a list of all possible resulting geometric objects.
T... is a list of all possible resulting geometric objects.
The exact result type of an intersection can be determined by using the
\ccStyle{Intersection_traits} class.
metafunction \ccc{Kernel::Intersection_result<A, B>}.
\ccExample
In the following example, the traits class is used to provide the return value for the
In the following example, the metafunction is used to provide the return value for the
\ccHtmlNoLinksFrom{intersection} computation:
\ccHtmlLinksOff%
@ -85,8 +85,7 @@ In the following example, the traits class is used to provide the return value f
std::cin >> segment_1 >> segment_2;
/* IT is an alias for Intersection_traits */
IT< K, Segment_2, Segment_2>::result_type
K::Intersection_result<Segment_2, Segment_2>::result_type
v = intersection(s1, s2);
if(v) {
/* not empty */

View File

@ -53,6 +53,6 @@ It uses the fast but inexact predicate based on interval arithmetic for
filtering and the slow but exact predicate based on multi-precision floats
when the filtering predicate fails.
\ccIncludeExampleCode{Filtered_kernel/Filtered_predicate.cpp}
%% \ccIncludeExampleCode{Filtered_kernel/Filtered_predicate.cpp}
\end{ccRefClass}

View File

@ -52,6 +52,8 @@ number type is used such as within the filtering kernels, in which case it is
\ccNestedType{Bounded_side}{\ccc{CGAL::Bounded_side} or \ccc{Uncertain<CGAL::Bounded_side>}}
\ccGlue
\ccNestedType{Angle}{\ccc{CGAL::Angle} or \ccc{Uncertain<CGAL::Angle>}}
\ccGlue
\ccNestedType{Intersection_result}{a model of \ccc{Kernel::Intersection_result}}
\ccConstants

View File

@ -3,18 +3,18 @@ A model for this must provide
\ccCreationVariable{fo}
\ccMemberFunction{Intersection_traits<K, Type1<K>, Type2<K>>::result_type operator()(Type1 obj1, Type2 obj2);}
\ccMemberFunction{Kernel::Intersection_result<Type1, Type2>::result_type operator()(Type1 obj1, Type2 obj2);}
{computes the \ccHtmlNoLinksFrom{intersection} region of two geometrical objects of type
\ccStyle{Type1} and \ccStyle{Type2}}
The function is only defined for \ccStyle{Type} and \ccStyle{Type2}
when \ccStyle{Intersection_traits<Kernel, Kernel::Type1,
Kernel::Type2>::result_type} is also defined.
The function is only defined for \ccStyle{Type1} and \ccStyle{Type2}
when \ccStyle{Kernel::Intersection_result<Type1, Type2>::result_type} is also defined.
\ccRefines
\ccc{AdaptableFunctor} (with two arguments)
\ccSeeAlso
\ccRefIdfierPage{CGAL::intersection}\\
\ccRefIdfierPage{CGAL::Kernel::Intersection_result<A, B>}\\
\end{ccRefFunctionObjectConcept}

View File

@ -3,19 +3,18 @@ A model for this must provide
\ccCreationVariable{fo}
\ccMemberFunction{Intersection_traits<K, Type1<K>, Type2<K>>::result_type operator()(Type1 obj1, Type2 obj2);}
{computes the \ccHtmlNoLinksFrom{intersection} region of two geometrical
objects of type \ccStyle{Type1} and \ccStyle{Type2}}
\ccMemberFunction{Kernel::Intersection_result<Type1, Type2>::result_type operator()(Type1 obj1, Type2 obj2);}
{computes the \ccHtmlNoLinksFrom{intersection} region of two geometrical objects of type
\ccStyle{Type1} and \ccStyle{Type2}}
The function is only defined for \ccStyle{Type} and \ccStyle{Type2}
when \ccStyle{Intersection_traits<Kernel, Kernel::Type1,
Kernel::Type2>::result_type} is also defined.
The function is only defined for \ccStyle{Type1} and \ccStyle{Type2}
when \ccStyle{Kernel::Intersection_result<Type1, Type2>::result_type} is also defined.
\ccRefines
\ccc{AdaptableFunctor} (with two or three arguments)
\ccSeeAlso
\ccRefIdfierPage{CGAL::intersection}\\
\ccRefIdfierPage{CGAL::Intersection_traits<K, A<K>, B<K>>}\\
\ccRefIdfierPage{CGAL::Kernel::Intersection_result<A, B>}\\
\end{ccRefFunctionObjectConcept}

View File

@ -8,13 +8,13 @@ described below.
The \ccStyle{intersection} function used to return
\ccStyle{CGAL::Object} but starting with {\cgal} VERSION HERE the
return type is determined by a dedicated traits class. To preserve
backwards compatibility \ccStyle{CGAL::Object} can be constructed from
the new return types implicitly, but switching to the new style is
advocated. To enable the old style without any overhead, the macro
\ccc{CGAL_INTERSECTION_VERSION} can be defined to \ccStyle{1} before
any {\cgal} header is included or through your particular build
system.
return type is determined by a metafunction defined by the kernel. To
preserve backwards compatibility \ccStyle{CGAL::Object} can be
constructed from the new return types implicitly, but switching to the
new style is advocated. To enable the old style without any overhead,
the macro \ccc{CGAL_INTERSECTION_VERSION} can be defined to
\ccStyle{1} before any {\cgal} header is included or through your
particular build system.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\paragraph{With the basic 2D and 3D Kernel} (see Chapter~\ref{chapter-kernel-23})
@ -23,7 +23,7 @@ system.
\ccUnchecked{
\ccRefLabel{Kernel::intersection}
\ccFunction{IT<Type1, Type2 >::result_type intersection(Type1 obj1, Type2 obj2);}
\ccFunction{Kernel::Intersection_result<Type1, Type2 >::result_type intersection(Type1 obj1, Type2 obj2);}
{Two objects \ccStyle{obj1} and \ccStyle{obj2} intersect if there is a point
\ccStyle{p} that is part of both \ccStyle{obj1} and \ccStyle{obj2}.
The \ccHtmlNoLinksFrom{intersection} region of those two objects is defined as the set of all
@ -39,7 +39,7 @@ The same functionality is also available through the functors \ccc{Kernel::Inter
The possible values for types \ccStyle{Type1} and \ccStyle{Type2} and
the value for T\ldots in \ccStyle{boost::optional< boost::variant<
T\ldots >} are the following and can be obtained through
\ccc{Intersection_traits<Kernel, A<Kernel>, B<Kernel>>}:
\ccc{Kernel::Intersection_result<A, B>}:
\begin{ccTexOnly}
\begin{longtable}[c]{|l|l|l|}
@ -512,7 +512,7 @@ with \ccc{CGAL::Dispatch_output_iterator<V,O>}.
Since both the number of intersections, if any, and their type,
depend on the arguments, the function expects an output
iterator on \ccc{Intersection_Traits<Kernel, Type1<Kernel>, Type2<Kernel>>}, as presented below.
iterator on \ccc{K::Intersection_result<Type1, Type2>}, as presented below.
\ccFunction{template < class OutputIterator >
OutputIterator
@ -559,7 +559,7 @@ with \ccc{CGAL::Dispatch_output_iterator<V,O>}.
Since both the number of intersections, if any, and their type,
depend on the arguments, the functions expects an output
iterator on \ccStyle{Intersection_Traits<Kernel, Type1<Kernel>, Type2<Kernel>}, as presented below.
iterator on \ccStyle{Kernel::Intersection_result<Type1, Type2>}, as presented below.
The \textbf{first function} is:
@ -651,7 +651,7 @@ struct Intersection_visitor {
template <class R>
void foo(Segment_2<R> seg, Line_2<R> lin)
{
ITd< R, Segment_2<R>, Line_2<R> >::result_type result = intersection(seg, lin);
R::template Intersection_result<Segment_2<R>, Line_2<R> >::result_type result = intersection(seg, lin);
if(result) { boost::apply_visitor(Intersection_visitor(), *result); }
else { /* no intersection */ }
}
@ -665,6 +665,7 @@ and~\ref{chapter-spherical-kernel}.
\ccSeeAlso
\ccRefIdfierPage{CGAL::do_intersect}, \\
\ccRefIdfierPage{CGAL::Kernel::Intersection_result<A, B>}, \\
\ccRefIdfierPage{CGAL::Intersection_traits<Kernel, A<Kernel>, B<Kernel>>}, \\
\ccRefIdfierPage{CGAL_INTERSECTION_VERSION}, \\
\ccAnchor{www.boost.org/doc/libs/release/libs/optional/index.html}{boost::optional}, \\

View File

@ -2524,7 +2524,7 @@ namespace CommonKernelFunctors {
#if CGAL_INTERSECTION_VERSION < 2
result_type
#else
typename Intersection_traits< K, T1, T2>::result_type
typename K::template Intersection_result< T1, T2 >::result_type
#endif
operator()(const T1& t1, const T2& t2) const
{ return internal::intersection(t1, t2, K()); }
@ -2544,7 +2544,7 @@ namespace CommonKernelFunctors {
#if CGAL_INTERSECTION_VERSION < 2
result_type
#else
typename Intersection_traits< K, T1, T2>::result_type
typename K::template Intersection_result< T1, T2 >::result_type
#endif
operator()(const T1& t1, const T2& t2) const
{ return internal::intersection(t1, t2, K() ); }