Moved the Intersection_result concept into the functors and adapted code in the lazy kernel to that change.

This commit is contained in:
Philipp Möller 2011-11-15 15:40:22 +00:00
parent c935a9dbc1
commit 94affd589d
20 changed files with 48 additions and 95 deletions

2
.gitattributes vendored
View File

@ -1827,10 +1827,8 @@ Jet_fitting_3/doc_tex/Jet_fitting_3_ref/template_dependence.jpg -text svneol=uns
Jet_fitting_3/doc_tex/Jet_fitting_3_ref/template_dependence.pdf -text svneol=unset#application/pdf
Jet_fitting_3/examples/Jet_fitting_3/data/ellipe0.003.off -text svneol=unset#application/octet-stream
Kernel_23/doc_tex/Kernel_23/fig/pointSegmentTriangle.png -text
Kernel_23/doc_tex/Kernel_23_ref/Intersection_traits.tex -text
Kernel_23/doc_tex/Kernel_23_ref/Intersection_version.tex -text
Kernel_23/doc_tex/Kernel_23_ref/Kernel_ConstructRadicalLine_2.tex -text
Kernel_23/doc_tex/Kernel_23_ref/Kernel_Intersection_result.tex -text
Kernel_23/doc_tex/Kernel_23_ref/compare_lexicographically.tex -text
Kernel_23/doc_tex/Kernel_23_ref/fig/IsoCuboid.gif -text svneol=unset#image/gif
Kernel_23/doc_tex/Kernel_23_ref/fig/IsoCuboid.pdf -text svneol=unset#application/pdf

View File

@ -51,9 +51,6 @@ 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,9 +50,6 @@ 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

@ -82,9 +82,6 @@ struct Circular_kernel_base_ref_count: public LinearKernelBase
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

@ -64,9 +64,6 @@ struct Filtered_bbox_circular_kernel_base_ref_count : public CircularKernel
#define CGAL_Filtered_Bbox_Circular_Kernel_cons(Y,Z) CGAL_Filtered_Bbox_Circular_Kernel_pred(Y,Z)
#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,9 +74,6 @@ 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,9 +68,6 @@ 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,9 +66,6 @@ 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

@ -1934,9 +1934,15 @@ struct Lazy_construction_variant {
typedef typename EK::FT EFT;
typedef typename LK::E2A E2A;
// Forward the result meta function
template<typename A, typename B>
struct Result {
typedef typename Intersection_traits< LK, A, B >::result_type Type;
typedef Type type;
};
template <typename L1, typename L2>
typename Intersection_traits< LK, L1, L2 >::result_type
typename Result<L1, L2>::Type
operator()(const L1& l1, const L2& l2) const {
typedef typename Intersection_traits<LK, L1, L2 >::result_type result_type;

View File

@ -35,7 +35,7 @@ int main()
obj = CGAL::intersection(s1,s2);
// check the variant return type
CGAL::IT<K, Triangle_2, Triangle_2>::result_type o_variant = CGAL::intersection(t1,t2);
K::Intersect_2::Result<Triangle_2, Triangle_2>::Type o_variant = CGAL::intersection(t1,t2);
if(!o_variant) {
std::cerr << "ERROR, empty" << std::endl;
return EXIT_FAILURE;
@ -75,7 +75,7 @@ int main()
}
// check the variant return type
CGAL::IT<K, Triangle_3, Triangle_3>::result_type o_variant = CGAL::intersection(t1,t2);
K::Intersect_3::Result<Triangle_3, Triangle_3>::Type o_variant = CGAL::intersection(t1,t2);
if(!o_variant) {
std::cerr << "ERROR, empty" << std::endl;
return EXIT_FAILURE;

View File

@ -68,7 +68,7 @@ in a type safe way {\cgal} uses return values of
\ccStyle{boost::optional< boost::variant< T \ldots\ >} were
T... is a list of all possible resulting geometric objects.
The exact result type of an intersection can be determined by using the
metafunction \ccc{Kernel::Intersection_result<A, B>}.
metafunction \ccStyle{Result<A, B>} in either \ccc{Kernel::Intersect_2} or \ccc{Kernel::Intersect_3}.
\ccExample
In the following example, the metafunction is used to provide the return value for the
@ -85,7 +85,7 @@ In the following example, the metafunction is used to provide the return value f
std::cin >> segment_1 >> segment_2;
K::Intersection_result<Segment_2, Segment_2>::result_type
K::Intersect_2::template Result<Segment_2, Segment_2>::Type
v = intersection(s1, s2);
if(v) {
/* not empty */

View File

@ -1,24 +0,0 @@
\begin{ccRefClass}{Intersection_traits<Kernel, A<Kernel>, B<Kernel>>}
\ccInclude{CGAL/Intersection_traits.h}
\ccDefinition
The traits class \ccClassTemplateName provides a typedef for the
return type of the \ccc{intersection} function objects belonging to a
model of \ccc{Kernel}. The value of \ccStyle{result_type} can be found
in the \ccc{intersection} documentation of the corresponding kernel.
A list of all available specializations can be found in \ccc{intersection}.
The traits class \ccStyle{IT<A, B>} provides an alias for
\ccClassTemplateName that ommits specifying the Kernel type.
\ccTypes
\ccStyle{result_type} The type of the resulting intersection between \ccStyle{A} and \ccStyle{B}.
\ccSeeAlso
\ccRefIdfierPage{CGAL::intersection}
\end{ccRefClass}

View File

@ -1,18 +1,16 @@
\begin{ccRefMacro}{CGAL_INTERSECTION_VERSION}
\ccInclude{CGAL/Intersection_traits.h}
\ccDefinition
The macro \ccc{CGAL_INTERSECTION_VERSION} can be used to configure
which version of the \ccc{intersection} function should be
used and enables the corresponding APIs in other {\cgal} packages.
which version of the \ccc{intersection} function should be used and
enables the corresponding APIs in other {\cgal} packages. It should be
defined before any {\cgal} header is included.
\ccc{CGAL_INTERSECTION_VERSION == 1} \ccc{intersection} uses \ccc{CGAL::Object} \\
\ccc{CGAL_INTERSECTION_VERSION == 2} \ccc{intersection} uses \ccc{boost::optional< boost::variant< T... > >}
\ccSeeAlso
\ccRefIdfierPage{CGAL::intersection} \\
\ccRefIdfierPage{CGAL::Intersection_traits<Kernel, A<Kernel>, B<Kernel>>}
\end{ccRefMacro}

View File

@ -52,8 +52,6 @@ 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,19 @@ A model for this must provide
\ccCreationVariable{fo}
\ccMemberFunction{Kernel::Intersection_result<Type1, Type2>::result_type operator()(Type1 obj1, Type2 obj2);}
\ccMemberFunction{Kernel::Intersect_2::Result<Type1, Type2>::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{Type1} and \ccStyle{Type2}
when \ccStyle{Kernel::Intersection_result<Type1, Type2>::result_type} is also defined.
when \ccStyle{Result<Type1, Type2>::Type} is also defined.
\ccNestedType{Result<A, B>}{A binary metafunction to determine the return type of \ccStyle{operator()}, when called with types \ccStyle{A} and \ccStyle{B}. Provides the typedef \ccStyle{Type}.}
\ccRefines
\ccc{AdaptableFunctor} (with two arguments)
\ccSeeAlso
\ccRefIdfierPage{CGAL::intersection}\\
\ccRefIdfierPage{CGAL::Kernel::Intersection_result<A, B>}\\
\end{ccRefFunctionObjectConcept}

View File

@ -3,18 +3,19 @@ A model for this must provide
\ccCreationVariable{fo}
\ccMemberFunction{Kernel::Intersection_result<Type1, Type2>::result_type operator()(Type1 obj1, Type2 obj2);}
\ccMemberFunction{Kernel::Intersect_3::Result<Type1, Type2>::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{Type1} and \ccStyle{Type2}
when \ccStyle{Kernel::Intersection_result<Type1, Type2>::result_type} is also defined.
when \ccStyle{Result<Type1, Type2>::Type} is also defined.
\ccNestedType{Result<A, B>}{A binary metafunction to determine the return type of \ccStyle{operator()}, when called with types \ccStyle{A} and \ccStyle{B}. Provides the typedef \ccStyle{Type}.}
\ccRefines
\ccc{AdaptableFunctor} (with two or three arguments)
\ccSeeAlso
\ccRefIdfierPage{CGAL::intersection}\\
\ccRefIdfierPage{CGAL::Kernel::Intersection_result<A, B>}\\
\end{ccRefFunctionObjectConcept}

View File

@ -1,10 +0,0 @@
\begin{ccRefConcept}{Kernel::Intersection_result<A, B>}
A binary metafunction over two Kernel objects. A model for this must provide:
\ccNestedType{result_type}{The result type of \ccc{intersection}, \ccc{Kernel::Intersect_2}, and \ccc{Kernel::Intersect_3} with geometric objects from this kernel.}
\ccSeeAlso
\ccRefIdfierPage{CGAL::Intersection_traits<Kernel, A<Kernel>, B<Kernel>>}\\
\end{ccRefConcept}

View File

@ -23,7 +23,7 @@ particular build system.
\ccUnchecked{
\ccRefLabel{Kernel::intersection}
\ccFunction{Kernel::Intersection_result<Type1, Type2 >::result_type intersection(Type1 obj1, Type2 obj2);}
\ccFunction{Kernel::Intersect_23::Result::<Type1, Type2 >::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,8 @@ 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{Kernel::Intersection_result<A, B>}:
\ccStyle{Intersect_2::Result<A, B>::Type} or
\ccStyle{Intersect_3::Result<A, B>::Type}.
\begin{ccTexOnly}
\begin{longtable}[c]{|l|l|l|}
@ -512,7 +513,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{K::Intersection_result<Type1, Type2>}, as presented below.
iterator on \ccStyle{K::Intersect_2::Result<Type1, Type2>::type}, as presented below.
\ccFunction{template < class OutputIterator >
OutputIterator
@ -559,7 +560,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{Kernel::Intersection_result<Type1, Type2>}, as presented below.
iterator on \ccStyle{Kernel::Intersect_3::Result<Type1, Type2>::Type}, as presented below.
The \textbf{first function} is:
@ -665,8 +666,6 @@ 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}, \\
\ccAnchor{www.boost.org/doc/html/variant.html}{boost::variant}

View File

@ -189,7 +189,6 @@ in the kernel.
\input{Kernel_23_ref/has_smaller_signed_distance_to_line.tex}
\input{Kernel_23_ref/has_smaller_signed_distance_to_plane.tex}
\input{Kernel_23_ref/intersection.tex}
\input{Kernel_23_ref/Intersection_traits.tex}
\input{Kernel_23_ref/Intersection_version.tex}
\input{Kernel_23_ref/left_turn.tex}
\input{Kernel_23_ref/lexicographically_xyz_smaller.tex}

View File

@ -2515,17 +2515,21 @@ namespace CommonKernelFunctors {
class Intersect_2
{
public:
template<typename A, typename B>
struct Result {
typedef typename Intersection_traits<K, A, B>::result_type Type;
// Boost MPL compatibility
typedef Type type;
};
// Solely to make the lazy kernel work
#if CGAL_INTERSECTION_VERSION < 2
typedef typename K::Object_3 result_type;
typedef CGAL::Object result_type;
#endif
// 25 possibilities, so I keep the template.
template <class T1, class T2>
#if CGAL_INTERSECTION_VERSION < 2
result_type
#else
typename K::template Intersection_result< T1, T2 >::result_type
#endif
typename Result< T1, T2 >::Type
operator()(const T1& t1, const T2& t2) const
{ return internal::intersection(t1, t2, K()); }
};
@ -2535,22 +2539,26 @@ namespace CommonKernelFunctors {
{
typedef typename K::Plane_3 Plane_3;
public:
template<typename A, typename B>
struct Result {
typedef typename Intersection_traits<K, A, B>::result_type Type;
// Boost MPL compatibility
typedef Type type;
};
// Solely to make the lazy kernel work
#if CGAL_INTERSECTION_VERSION < 2
typedef typename K::Object_3 result_type;
typedef CGAL::Object result_type;
#endif
// n possibilities, so I keep the template.
template <class T1, class T2>
#if CGAL_INTERSECTION_VERSION < 2
result_type
#else
typename K::template Intersection_result< T1, T2 >::result_type
#endif
typename Result< T1, T2 >::Type
operator()(const T1& t1, const T2& t2) const
{ return internal::intersection(t1, t2, K() ); }
#if CGAL_INTERSECTION_VERSION < 2
result_type
CGAL::Object
#else
typename boost::optional< boost::variant< typename K::Point_3, typename K::Line_3, typename K::Plane_3 > >
#endif