Removed mentioning of the Intersect metafunction. Switched everything

to the yet unimplemented boost::result_of.
This commit is contained in:
Philipp Möller 2012-04-24 16:17:26 +00:00
parent 17797b7271
commit b6a4607ece
8 changed files with 48 additions and 48 deletions

View File

@ -62,18 +62,21 @@ There are number types on which no \ccStyle{sqrt} operation is defined,
especially integer types and rationals. especially integer types and rationals.
\end{itemize} \end{itemize}
\subsection{Intersections and variant return values} \subsection{Intersections and variant return types}
Some functions can return different types of objects. To achieve this Some functions can return different types of objects. To achieve this
in a type safe way {\cgal} uses return values of type in a type safe way {\cgal} uses return values of type
\ccStyle{boost::optional< boost::variant< T \ldots\ >} were T... is a \ccStyle{boost::optional< boost::variant< T \ldots\ >} were T... is a
list of all possible resulting geometric objects. The exact result list of all possible resulting geometric objects. The exact result
type of an intersection can be determined by using the metafunction type of an intersection can be determined by using the metafunction
\ccStyle{Result<A, B>} in either \ccc{Kernel::Intersect_2} or \ccc{boost::result_of<Kernel::Intersect_2(Type1, Type2)>} or
\ccc{Kernel::Intersect_3}. \ccc{boost::result_of<Kernel::Intersect_3(Type1, Type2)>}, where
\ccc{Type1} and \ccc{Type2} are the types of the objects used in the
intersection computation.
\ccExample \ccExample
In the following example, the metafunction is used to provide the return value for the
\ccHtmlNoLinksFrom{intersection} computation: In the following example, \ccc{result_of} is used to query the return
value for the \ccHtmlNoLinksFrom{intersection} computation:
\ccHtmlLinksOff% \ccHtmlLinksOff%
\begin{cprog} \begin{cprog}
@ -86,15 +89,19 @@ In the following example, the metafunction is used to provide the return value f
std::cin >> segment_1 >> segment_2; std::cin >> segment_1 >> segment_2;
K::Intersect_2::template Result<Segment_2, Segment_2>::Type /* C++11 */
v = intersection(s1, s2); auto v = intersection(segment_1, segment_2);
/* C++03 */
/*boost::result_of<K::Intersect_2(Segment_2, Segment_2)>::type */
/* v = intersection(segment_1, segment_2); */
if(v) { if(v) {
/* not empty */ /* not empty */
if (const Point_2 *p = boost::get<Point_2>(&*v) ) { if (const Point_2 *p = boost::get<Point_2>(&*v) ) {
/* do something with *p */ /* do something with *p */
} else if (const Segment_2 *s = boost::get<Segment_2>(&*v) ) { } else if (const Segment_2 *s = boost::get<Segment_2>(&*v) ) {
/* do something with *s */ /* do something with *s */
} }
} else { } else {
/* empty intersection */ /* empty intersection */
} }

View File

@ -3,14 +3,10 @@ A model for this must provide
\ccCreationVariable{fo} \ccCreationVariable{fo}
\ccMemberFunction{Kernel::Intersect_2::Result<Type1, Type2>::Type operator()(Type1 obj1, Type2 obj2);} \ccMemberFunction{typename
{computes the \ccHtmlNoLinksFrom{intersection} region of two geometrical objects of type boost::result_of<Kernel::Intersect_2(Type1, Type2)>::type operator()(Type1 obj1, Type2 obj2);}
\ccStyle{Type1} and \ccStyle{Type2}} {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{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 \ccRefines
\ccc{AdaptableFunctor} (with two arguments) \ccc{AdaptableFunctor} (with two arguments)

View File

@ -3,14 +3,9 @@ A model for this must provide
\ccCreationVariable{fo} \ccCreationVariable{fo}
\ccMemberFunction{Kernel::Intersect_3::Result<Type1, Type2>::Type operator()(Type1 obj1, Type2 obj2);} \ccMemberFunction{boost::result_of<Kernel::Intersect_2(Type1, Type2)>::type operator()(Type1 obj1, Type2 obj2);}
{computes the \ccHtmlNoLinksFrom{intersection} region of \ccStyle{obj1} and \ccStyle{obj2}} {computes the \ccHtmlNoLinksFrom{intersection} region of \ccStyle{obj1} and \ccStyle{obj2}}
The function is only defined for \ccStyle{Type1} and \ccStyle{Type2}
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 \ccRefines
\ccc{AdaptableFunctor} (with two or three arguments) \ccc{AdaptableFunctor} (with two or three arguments)

View File

@ -22,7 +22,7 @@ the macro \ccc{CGAL_INTERSECTION_VERSION} must be defined to
\ccUnchecked{ \ccUnchecked{
\ccRefLabel{Kernel::intersection} \ccRefLabel{Kernel::intersection}
\ccFunction{Kernel::Intersect_23::Result::<Type1, Type2 >::Type intersection(Type1 obj1, Type2 obj2);} \ccFunction{boost::result_of<Intersect(Type1, Type2)>::type intersection(Type1 obj1, Type2 obj2);}
{Two objects \ccStyle{obj1} and \ccStyle{obj2} intersect if there is a point {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}. \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 The \ccHtmlNoLinksFrom{intersection} region of those two objects is defined as the set of all
@ -629,9 +629,6 @@ intersection point,
and \ccc{obj3} are equal. and \ccc{obj3} are equal.
\end{itemize} \end{itemize}
A typedef for the result type is available through the special traits class
\ccStyle{template<K> Intersection_traits_spherical}.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ccExample \ccExample

View File

@ -55,7 +55,8 @@ int main()
K::Intersect_2 intersection; K::Intersect_2 intersection;
CGAL::Object o = intersection(s1, s2); boost::result_of<K::Intersect_2(Segment, Segment)>::type
intersect = intersection(s1, s2);
K::Construct_cartesian_const_iterator_2 construct_it; K::Construct_cartesian_const_iterator_2 construct_it;
K::Cartesian_const_iterator_2 cit = construct_it(a); K::Cartesian_const_iterator_2 cit = construct_it(a);

View File

@ -3,19 +3,21 @@
#include <CGAL/iterator.h> #include <CGAL/iterator.h>
#include <CGAL/point_generators_2.h> #include <CGAL/point_generators_2.h>
#include <boost/bind.hpp> #include <boost/bind.hpp>
using namespace CGAL; using namespace CGAL;
typedef CGAL::Simple_cartesian<double> K; typedef CGAL::Simple_cartesian<double> K;
typedef K::Point_2 Point; typedef K::Point_2 Point;
typedef CGAL::Creator_uniform_2<double,Point> Pt_creator; typedef K::Segment_2 Segment;
typedef K::Segment_2 Segment;
typedef CGAL::Creator_uniform_2<double,Point> Pt_creator;
typedef Random_points_on_segment_2<Point,Pt_creator> P1; typedef Random_points_on_segment_2<Point,Pt_creator> P1;
typedef Random_points_on_circle_2<Point,Pt_creator> P2; typedef Random_points_on_circle_2<Point,Pt_creator> P2;
typedef Creator_uniform_2< Point, Segment> Seg_creator; typedef Creator_uniform_2< Point, Segment> Seg_creator;
typedef Join_input_iterator_2< P1, P2, Seg_creator> Seg_iterator; typedef Join_input_iterator_2< P1, P2, Seg_creator> Seg_iterator;
using boost::result_of;
int main() int main()
{ {
@ -37,7 +39,8 @@ int main()
auto v = intersection(input.back(), input.front()); auto v = intersection(input.back(), input.front());
#else #else
// without C++11 // without C++11
K::Intersect_2::Result<Segment, Segment>::Type v = intersection(input.back(), input.front()); result_of<K::Intersect_2(Segment, Segment)>::type v
= intersection(input.back(), input.front());
#endif #endif
// splitting results with Dispatch_output_iterator // splitting results with Dispatch_output_iterator
@ -60,11 +63,9 @@ int main()
[&s1] (const Segment& s) { return intersection(s1, s); }); [&s1] (const Segment& s) { return intersection(s1, s); });
#else #else
// without // without
K::Intersect_2 intersector = K().intersect_2_object();
std::transform(input.begin(), input.end(), disp, std::transform(input.begin(), input.end(), disp,
boost::bind(static_cast< boost::bind(intersector, input.front(), _1));
K::Intersect_2::Result<Segment, Segment>::Type(*)(const Segment&, const Segment&)
>(&intersection),
input.front(), _1));
#endif #endif
std::cout << "Point intersections: " << points.size() << std::endl; std::cout << "Point intersections: " << points.size() << std::endl;

View File

@ -68,8 +68,9 @@ returns a \ccStyle{boost::optional< boost::variant< T \ldots\ > >}
were T\textellipsis\ is a list of all possible resulting geometric objects. were T\textellipsis\ is a list of all possible resulting geometric objects.
The exact result type of an intersection can be determined by using The exact result type of an intersection can be determined by using
the metafunction \ccStyle{Result<A, B>} in either \ccStyle{boost::result_of<Kernel::Intersect_d(Type1, Type2)>::type}
\ccc{Kernel::Intersect_d}. where \ccStyle{Type1} and \ccStyle{Type2} are the types of the objects
used in the intersection query.
\ccExample \ccExample
\ccHtmlLinksOff% \ccHtmlLinksOff%
@ -79,7 +80,8 @@ the metafunction \ccStyle{Result<A, B>} in either
typedef Segment_d< K > Segment; typedef Segment_d< K > Segment;
Segment s1, s2; Segment s1, s2;
std::cin >> s1 >> s2; std::cin >> s1 >> s2;
K::Intersect_d::Result<Segment, Segment>::Type
boost::result_of<K::Intersect_2(Segment, Segment)>::type
v = intersection(s1, s2); v = intersection(s1, s2);
if(v) { if(v) {
/* not empty */ /* not empty */

View File

@ -4,7 +4,8 @@ A model for this must provide:
\ccCreationVariable{fo} \ccCreationVariable{fo}
\ccMemberFunction{ \ccMemberFunction{
Kernel::Intersect_d::Result<Type1<K>, Type2<K> >::Type typename
boost::result_of<Kernel::Intersect_d(Type1<K>, Type2<K>)>::type
operator()(const Type1<K>& p, const Type2<K>& q);} operator()(const Type1<K>& p, const Type2<K>& q);}
{returns the result of the intersection of $p$ and $q$ in form of a {returns the result of the intersection of $p$ and $q$ in form of a
polymorphic object. \ccc{Kernel_object} may be any of polymorphic object. \ccc{Kernel_object} may be any of