From 94affd589d0ca861318155bac2e4ffc9cd2a9f53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20M=C3=B6ller?= Date: Tue, 15 Nov 2011 15:40:22 +0000 Subject: [PATCH] Moved the Intersection_result concept into the functors and adapted code in the lazy kernel to that change. --- .gitattributes | 2 -- Cartesian_kernel/include/CGAL/Cartesian.h | 3 -- .../include/CGAL/Simple_cartesian.h | 3 -- .../include/CGAL/Circular_kernel_2.h | 3 -- .../CGAL/Filtered_bbox_circular_kernel_2.h | 3 -- .../include/CGAL/Simple_circular_kernel_2.h | 3 -- .../include/CGAL/Simple_spherical_kernel_3.h | 3 -- .../include/CGAL/Spherical_kernel_3.h | 3 -- Filtered_kernel/include/CGAL/Lazy.h | 8 ++++- .../test_lazy_vector_objects.cpp | 4 +-- .../Kernel_23/predicates_constructions.tex | 4 +-- .../Kernel_23_ref/Intersection_traits.tex | 24 ------------- .../Kernel_23_ref/Intersection_version.tex | 8 ++--- Kernel_23/doc_tex/Kernel_23_ref/Kernel.tex | 2 -- .../Kernel_23_ref/Kernel_Intersect_2.tex | 7 ++-- .../Kernel_23_ref/Kernel_Intersect_3.tex | 7 ++-- .../Kernel_Intersection_result.tex | 10 ------ .../doc_tex/Kernel_23_ref/intersection.tex | 11 +++--- Kernel_23/doc_tex/Kernel_23_ref/main.tex | 1 - .../include/CGAL/Kernel/function_objects.h | 34 ++++++++++++------- 20 files changed, 48 insertions(+), 95 deletions(-) delete mode 100644 Kernel_23/doc_tex/Kernel_23_ref/Intersection_traits.tex delete mode 100644 Kernel_23/doc_tex/Kernel_23_ref/Kernel_Intersection_result.tex diff --git a/.gitattributes b/.gitattributes index 96bae574417..cf388fd4e15 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/Cartesian_kernel/include/CGAL/Cartesian.h b/Cartesian_kernel/include/CGAL/Cartesian.h index 3f5de1d9dd7..41af5cf7b48 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian.h +++ b/Cartesian_kernel/include/CGAL/Cartesian.h @@ -51,9 +51,6 @@ struct Cartesian_base_ref_count #define CGAL_Kernel_cons(Y,Z) CGAL_Kernel_pred(Y,Z) #include - - template - struct Intersection_result : CGAL::Intersection_traits {}; }; template < typename FT_ > diff --git a/Cartesian_kernel/include/CGAL/Simple_cartesian.h b/Cartesian_kernel/include/CGAL/Simple_cartesian.h index c107e8b82a7..13a6160d241 100644 --- a/Cartesian_kernel/include/CGAL/Simple_cartesian.h +++ b/Cartesian_kernel/include/CGAL/Simple_cartesian.h @@ -50,9 +50,6 @@ struct Cartesian_base_no_ref_count #define CGAL_Kernel_cons(Y,Z) CGAL_Kernel_pred(Y,Z) #include - - template - struct Intersection_result : CGAL::Intersection_traits {}; }; template < typename FT_ > diff --git a/Circular_kernel_2/include/CGAL/Circular_kernel_2.h b/Circular_kernel_2/include/CGAL/Circular_kernel_2.h index fb7e0cf9a02..3a365b64a17 100644 --- a/Circular_kernel_2/include/CGAL/Circular_kernel_2.h +++ b/Circular_kernel_2/include/CGAL/Circular_kernel_2.h @@ -82,9 +82,6 @@ struct Circular_kernel_base_ref_count: public LinearKernelBase typedef LinearFunctors::Construct_line_2 Construct_line_2; Construct_line_2 construct_line_2_object() const { return Construct_line_2(); } - - template - struct Intersection_result : CGAL::Intersection_traits {}; }; } // namespace internal diff --git a/Circular_kernel_2/include/CGAL/Filtered_bbox_circular_kernel_2.h b/Circular_kernel_2/include/CGAL/Filtered_bbox_circular_kernel_2.h index 0f0d5a37122..370bd8130cb 100644 --- a/Circular_kernel_2/include/CGAL/Filtered_bbox_circular_kernel_2.h +++ b/Circular_kernel_2/include/CGAL/Filtered_bbox_circular_kernel_2.h @@ -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 - - template - struct Intersection_result : CGAL::Intersection_traits {}; }; } // namespace internal diff --git a/Circular_kernel_2/include/CGAL/Simple_circular_kernel_2.h b/Circular_kernel_2/include/CGAL/Simple_circular_kernel_2.h index 160ffc9925f..389a1dc5e61 100644 --- a/Circular_kernel_2/include/CGAL/Simple_circular_kernel_2.h +++ b/Circular_kernel_2/include/CGAL/Simple_circular_kernel_2.h @@ -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 - - template - struct Intersection_result : CGAL::Intersection_traits {}; }; } // namespace internal diff --git a/Circular_kernel_3/include/CGAL/Simple_spherical_kernel_3.h b/Circular_kernel_3/include/CGAL/Simple_spherical_kernel_3.h index 4d963dbf42a..17b505a8c30 100644 --- a/Circular_kernel_3/include/CGAL/Simple_spherical_kernel_3.h +++ b/Circular_kernel_3/include/CGAL/Simple_spherical_kernel_3.h @@ -68,9 +68,6 @@ namespace CGAL { #include - - template - struct Intersection_result : CGAL::Intersection_traits {}; }; } // namespace internal diff --git a/Circular_kernel_3/include/CGAL/Spherical_kernel_3.h b/Circular_kernel_3/include/CGAL/Spherical_kernel_3.h index 743acec9e96..9e40c310bca 100644 --- a/Circular_kernel_3/include/CGAL/Spherical_kernel_3.h +++ b/Circular_kernel_3/include/CGAL/Spherical_kernel_3.h @@ -66,9 +66,6 @@ namespace CGAL { Y Z(const CGAL::Sphere_3& S) const { return Y(S); } #include - - template - struct Intersection_result : CGAL::Intersection_traits {}; }; } // namespace internal diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index d8ac23add16..07ecd45b608 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -1934,9 +1934,15 @@ struct Lazy_construction_variant { typedef typename EK::FT EFT; typedef typename LK::E2A E2A; + // Forward the result meta function + template + struct Result { + typedef typename Intersection_traits< LK, A, B >::result_type Type; + typedef Type type; + }; template - typename Intersection_traits< LK, L1, L2 >::result_type + typename Result::Type operator()(const L1& l1, const L2& l2) const { typedef typename Intersection_traits::result_type result_type; diff --git a/Filtered_kernel/test/Filtered_kernel/test_lazy_vector_objects.cpp b/Filtered_kernel/test/Filtered_kernel/test_lazy_vector_objects.cpp index 57b125d2348..37bbf569333 100644 --- a/Filtered_kernel/test/Filtered_kernel/test_lazy_vector_objects.cpp +++ b/Filtered_kernel/test/Filtered_kernel/test_lazy_vector_objects.cpp @@ -35,7 +35,7 @@ int main() obj = CGAL::intersection(s1,s2); // check the variant return type - CGAL::IT::result_type o_variant = CGAL::intersection(t1,t2); + K::Intersect_2::Result::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::result_type o_variant = CGAL::intersection(t1,t2); + K::Intersect_3::Result::Type o_variant = CGAL::intersection(t1,t2); if(!o_variant) { std::cerr << "ERROR, empty" << std::endl; return EXIT_FAILURE; diff --git a/Kernel_23/doc_tex/Kernel_23/predicates_constructions.tex b/Kernel_23/doc_tex/Kernel_23/predicates_constructions.tex index fec99377315..996f6a4dccb 100644 --- a/Kernel_23/doc_tex/Kernel_23/predicates_constructions.tex +++ b/Kernel_23/doc_tex/Kernel_23/predicates_constructions.tex @@ -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}. +metafunction \ccStyle{Result} 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::result_type + K::Intersect_2::template Result::Type v = intersection(s1, s2); if(v) { /* not empty */ diff --git a/Kernel_23/doc_tex/Kernel_23_ref/Intersection_traits.tex b/Kernel_23/doc_tex/Kernel_23_ref/Intersection_traits.tex deleted file mode 100644 index 366cc262d42..00000000000 --- a/Kernel_23/doc_tex/Kernel_23_ref/Intersection_traits.tex +++ /dev/null @@ -1,24 +0,0 @@ -\begin{ccRefClass}{Intersection_traits, B>} - -\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} 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} diff --git a/Kernel_23/doc_tex/Kernel_23_ref/Intersection_version.tex b/Kernel_23/doc_tex/Kernel_23_ref/Intersection_version.tex index 02f31d5dce2..a5fb7557b7a 100644 --- a/Kernel_23/doc_tex/Kernel_23_ref/Intersection_version.tex +++ b/Kernel_23/doc_tex/Kernel_23_ref/Intersection_version.tex @@ -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, B>} \end{ccRefMacro} diff --git a/Kernel_23/doc_tex/Kernel_23_ref/Kernel.tex b/Kernel_23/doc_tex/Kernel_23_ref/Kernel.tex index e2a7d662ecc..0ce9097582a 100644 --- a/Kernel_23/doc_tex/Kernel_23_ref/Kernel.tex +++ b/Kernel_23/doc_tex/Kernel_23_ref/Kernel.tex @@ -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}} \ccGlue \ccNestedType{Angle}{\ccc{CGAL::Angle} or \ccc{Uncertain}} -\ccGlue -\ccNestedType{Intersection_result}{a model of \ccc{Kernel::Intersection_result}} \ccConstants diff --git a/Kernel_23/doc_tex/Kernel_23_ref/Kernel_Intersect_2.tex b/Kernel_23/doc_tex/Kernel_23_ref/Kernel_Intersect_2.tex index 1db607afeff..610ed7d4be5 100644 --- a/Kernel_23/doc_tex/Kernel_23_ref/Kernel_Intersect_2.tex +++ b/Kernel_23/doc_tex/Kernel_23_ref/Kernel_Intersect_2.tex @@ -3,18 +3,19 @@ A model for this must provide \ccCreationVariable{fo} -\ccMemberFunction{Kernel::Intersection_result::result_type operator()(Type1 obj1, Type2 obj2);} +\ccMemberFunction{Kernel::Intersect_2::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{Type1} and \ccStyle{Type2} -when \ccStyle{Kernel::Intersection_result::result_type} is also defined. +when \ccStyle{Result::Type} is also defined. + +\ccNestedType{Result}{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}\\ \end{ccRefFunctionObjectConcept} diff --git a/Kernel_23/doc_tex/Kernel_23_ref/Kernel_Intersect_3.tex b/Kernel_23/doc_tex/Kernel_23_ref/Kernel_Intersect_3.tex index ce6a91378b3..8a7b0b6e9b3 100644 --- a/Kernel_23/doc_tex/Kernel_23_ref/Kernel_Intersect_3.tex +++ b/Kernel_23/doc_tex/Kernel_23_ref/Kernel_Intersect_3.tex @@ -3,18 +3,19 @@ A model for this must provide \ccCreationVariable{fo} -\ccMemberFunction{Kernel::Intersection_result::result_type operator()(Type1 obj1, Type2 obj2);} +\ccMemberFunction{Kernel::Intersect_3::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{Type1} and \ccStyle{Type2} -when \ccStyle{Kernel::Intersection_result::result_type} is also defined. +when \ccStyle{Result::Type} is also defined. + +\ccNestedType{Result}{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}\\ \end{ccRefFunctionObjectConcept} diff --git a/Kernel_23/doc_tex/Kernel_23_ref/Kernel_Intersection_result.tex b/Kernel_23/doc_tex/Kernel_23_ref/Kernel_Intersection_result.tex deleted file mode 100644 index 866b1d3622e..00000000000 --- a/Kernel_23/doc_tex/Kernel_23_ref/Kernel_Intersection_result.tex +++ /dev/null @@ -1,10 +0,0 @@ -\begin{ccRefConcept}{Kernel::Intersection_result} - -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, B>}\\ - -\end{ccRefConcept} diff --git a/Kernel_23/doc_tex/Kernel_23_ref/intersection.tex b/Kernel_23/doc_tex/Kernel_23_ref/intersection.tex index 604ac53f031..fbe14a0fd64 100644 --- a/Kernel_23/doc_tex/Kernel_23_ref/intersection.tex +++ b/Kernel_23/doc_tex/Kernel_23_ref/intersection.tex @@ -23,7 +23,7 @@ particular build system. \ccUnchecked{ \ccRefLabel{Kernel::intersection} -\ccFunction{Kernel::Intersection_result::result_type intersection(Type1 obj1, Type2 obj2);} +\ccFunction{Kernel::Intersect_23::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,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}: +\ccStyle{Intersect_2::Result::Type} or +\ccStyle{Intersect_3::Result::Type}. \begin{ccTexOnly} \begin{longtable}[c]{|l|l|l|} @@ -512,7 +513,7 @@ with \ccc{CGAL::Dispatch_output_iterator}. 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}, as presented below. +iterator on \ccStyle{K::Intersect_2::Result::type}, as presented below. \ccFunction{template < class OutputIterator > OutputIterator @@ -559,7 +560,7 @@ with \ccc{CGAL::Dispatch_output_iterator}. 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}, as presented below. +iterator on \ccStyle{Kernel::Intersect_3::Result::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}, \\ -\ccRefIdfierPage{CGAL::Intersection_traits, B>}, \\ \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} diff --git a/Kernel_23/doc_tex/Kernel_23_ref/main.tex b/Kernel_23/doc_tex/Kernel_23_ref/main.tex index 77093a195e7..7b556eb6f27 100644 --- a/Kernel_23/doc_tex/Kernel_23_ref/main.tex +++ b/Kernel_23/doc_tex/Kernel_23_ref/main.tex @@ -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} diff --git a/Kernel_23/include/CGAL/Kernel/function_objects.h b/Kernel_23/include/CGAL/Kernel/function_objects.h index 24da04a8e42..773098b2973 100644 --- a/Kernel_23/include/CGAL/Kernel/function_objects.h +++ b/Kernel_23/include/CGAL/Kernel/function_objects.h @@ -2515,17 +2515,21 @@ namespace CommonKernelFunctors { class Intersect_2 { public: + template + struct Result { + typedef typename Intersection_traits::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 - #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 + struct Result { + typedef typename Intersection_traits::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 - #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