mirror of https://github.com/CGAL/cgal
Removed mentioning of the Intersect metafunction. Switched everything
to the yet unimplemented boost::result_of.
This commit is contained in:
parent
17797b7271
commit
b6a4607ece
|
|
@ -62,18 +62,21 @@ There are number types on which no \ccStyle{sqrt} operation is defined,
|
|||
especially integer types and rationals.
|
||||
\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
|
||||
in a type safe way {\cgal} uses return values of type
|
||||
\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
|
||||
\ccStyle{Result<A, B>} in either \ccc{Kernel::Intersect_2} or
|
||||
\ccc{Kernel::Intersect_3}.
|
||||
\ccc{boost::result_of<Kernel::Intersect_2(Type1, Type2)>} or
|
||||
\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
|
||||
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%
|
||||
\begin{cprog}
|
||||
|
|
@ -86,8 +89,12 @@ In the following example, the metafunction is used to provide the return value f
|
|||
|
||||
std::cin >> segment_1 >> segment_2;
|
||||
|
||||
K::Intersect_2::template Result<Segment_2, Segment_2>::Type
|
||||
v = intersection(s1, s2);
|
||||
/* C++11 */
|
||||
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) {
|
||||
/* not empty */
|
||||
if (const Point_2 *p = boost::get<Point_2>(&*v) ) {
|
||||
|
|
|
|||
|
|
@ -3,15 +3,11 @@ A model for this must provide
|
|||
|
||||
\ccCreationVariable{fo}
|
||||
|
||||
\ccMemberFunction{Kernel::Intersect_2::Result<Type1, Type2>::Type operator()(Type1 obj1, Type2 obj2);}
|
||||
\ccMemberFunction{typename
|
||||
boost::result_of<Kernel::Intersect_2(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{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)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,14 +3,9 @@ A model for this must provide
|
|||
|
||||
\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}}
|
||||
|
||||
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
|
||||
\ccc{AdaptableFunctor} (with two or three arguments)
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ the macro \ccc{CGAL_INTERSECTION_VERSION} must be defined to
|
|||
|
||||
\ccUnchecked{
|
||||
\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
|
||||
\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
|
||||
|
|
@ -629,9 +629,6 @@ intersection point,
|
|||
and \ccc{obj3} are equal.
|
||||
\end{itemize}
|
||||
|
||||
A typedef for the result type is available through the special traits class
|
||||
\ccStyle{template<K> Intersection_traits_spherical}.
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
\ccExample
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,8 @@ int main()
|
|||
|
||||
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::Cartesian_const_iterator_2 cit = construct_it(a);
|
||||
|
|
|
|||
|
|
@ -3,20 +3,22 @@
|
|||
#include <CGAL/iterator.h>
|
||||
#include <CGAL/point_generators_2.h>
|
||||
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
using namespace CGAL;
|
||||
|
||||
typedef CGAL::Simple_cartesian<double> K;
|
||||
typedef K::Point_2 Point;
|
||||
typedef CGAL::Creator_uniform_2<double,Point> Pt_creator;
|
||||
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_circle_2<Point,Pt_creator> P2;
|
||||
typedef Creator_uniform_2< Point, Segment> Seg_creator;
|
||||
typedef Join_input_iterator_2< P1, P2, Seg_creator> Seg_iterator;
|
||||
|
||||
using boost::result_of;
|
||||
|
||||
int main()
|
||||
{
|
||||
std::vector<Segment> input;
|
||||
|
|
@ -37,7 +39,8 @@ int main()
|
|||
auto v = intersection(input.back(), input.front());
|
||||
#else
|
||||
// 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
|
||||
|
||||
// splitting results with Dispatch_output_iterator
|
||||
|
|
@ -60,11 +63,9 @@ int main()
|
|||
[&s1] (const Segment& s) { return intersection(s1, s); });
|
||||
#else
|
||||
// without
|
||||
K::Intersect_2 intersector = K().intersect_2_object();
|
||||
std::transform(input.begin(), input.end(), disp,
|
||||
boost::bind(static_cast<
|
||||
K::Intersect_2::Result<Segment, Segment>::Type(*)(const Segment&, const Segment&)
|
||||
>(&intersection),
|
||||
input.front(), _1));
|
||||
boost::bind(intersector, input.front(), _1));
|
||||
#endif
|
||||
|
||||
std::cout << "Point intersections: " << points.size() << std::endl;
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
The exact result type of an intersection can be determined by using
|
||||
the metafunction \ccStyle{Result<A, B>} in either
|
||||
\ccc{Kernel::Intersect_d}.
|
||||
\ccStyle{boost::result_of<Kernel::Intersect_d(Type1, Type2)>::type}
|
||||
where \ccStyle{Type1} and \ccStyle{Type2} are the types of the objects
|
||||
used in the intersection query.
|
||||
|
||||
\ccExample
|
||||
\ccHtmlLinksOff%
|
||||
|
|
@ -79,7 +80,8 @@ the metafunction \ccStyle{Result<A, B>} in either
|
|||
typedef Segment_d< K > Segment;
|
||||
Segment 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);
|
||||
if(v) {
|
||||
/* not empty */
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ A model for this must provide:
|
|||
\ccCreationVariable{fo}
|
||||
|
||||
\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);}
|
||||
{returns the result of the intersection of $p$ and $q$ in form of a
|
||||
polymorphic object. \ccc{Kernel_object} may be any of
|
||||
|
|
|
|||
Loading…
Reference in New Issue