mirror of https://github.com/CGAL/cgal
fixed docs + a few code improvements
This commit is contained in:
parent
69ed0152cc
commit
209513dc56
|
|
@ -45,11 +45,9 @@ typedef unspecified_type Do_intersect_3;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
A functor object to construct the intersection between two geometric objects.
|
A functor object to construct the intersection between two geometric objects.
|
||||||
This functor must support the result_of protocol, that is the return
|
|
||||||
type of the `operator()(A, B)` is `CGAL::cpp11::result<Intersect_3(A,B)>`.
|
|
||||||
|
|
||||||
Provides the operators:
|
Provides the operators:
|
||||||
`CGAL::cpp11::result<Intersect_3(A,B)> operator()(const A& a, const B& b);`
|
`decltype(auto) operator()(const A& a, const B& b);`
|
||||||
where `A` and `B` are any relevant types among `Ray_3`, `Segment_3`, `Line_3`,
|
where `A` and `B` are any relevant types among `Ray_3`, `Segment_3`, `Line_3`,
|
||||||
`Triangle_3`, `Plane_3` and `Bbox_3`.
|
`Triangle_3`, `Plane_3` and `Bbox_3`.
|
||||||
Relevant herein means that a line primitive (ray, segment, line) is tested
|
Relevant herein means that a line primitive (ray, segment, line) is tested
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
#include <CGAL/disable_warnings.h>
|
#include <CGAL/disable_warnings.h>
|
||||||
|
|
||||||
#include <CGAL/AABB_primitive.h>
|
#include <CGAL/AABB_primitive.h>
|
||||||
#include <CGAL/result_of.h>
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
@ -31,9 +30,9 @@ namespace internal {
|
||||||
//classical typedefs
|
//classical typedefs
|
||||||
typedef Iterator key_type;
|
typedef Iterator key_type;
|
||||||
typedef typename GeomTraits::Point_3 value_type;
|
typedef typename GeomTraits::Point_3 value_type;
|
||||||
typedef typename cpp11::result_of<
|
typedef decltype(
|
||||||
typename GeomTraits::Construct_source_3(typename GeomTraits::Segment_3)
|
std::declval<typename GeomTraits::Construct_source_3>()(
|
||||||
>::type reference;
|
std::declval<typename GeomTraits::Segment_3>())) reference;
|
||||||
typedef boost::readable_property_map_tag category;
|
typedef boost::readable_property_map_tag category;
|
||||||
|
|
||||||
inline friend
|
inline friend
|
||||||
|
|
@ -57,7 +56,6 @@ namespace internal {
|
||||||
* \tparam GeomTraits is a traits class providing the nested type `Point_3` and `Segment_3`.
|
* \tparam GeomTraits is a traits class providing the nested type `Point_3` and `Segment_3`.
|
||||||
* It also provides the functor `Construct_source_3` that has an operator taking a `Segment_3`
|
* It also provides the functor `Construct_source_3` that has an operator taking a `Segment_3`
|
||||||
* and returning its source as a type convertible to `Point_3`.
|
* and returning its source as a type convertible to `Point_3`.
|
||||||
* In addition `Construct_source_3` must support the result_of protocol.
|
|
||||||
* \tparam Iterator is a model of `ForwardIterator` with its value type convertible to `GeomTraits::Segment_3`
|
* \tparam Iterator is a model of `ForwardIterator` with its value type convertible to `GeomTraits::Segment_3`
|
||||||
* \tparam CacheDatum is either `CGAL::Tag_true` or `CGAL::Tag_false`. In the former case,
|
* \tparam CacheDatum is either `CGAL::Tag_true` or `CGAL::Tag_false`. In the former case,
|
||||||
* the datum is stored in the primitive, while in the latter it is
|
* the datum is stored in the primitive, while in the latter it is
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@
|
||||||
#include <CGAL/internal/AABB_tree/Has_nested_type_Shared_data.h>
|
#include <CGAL/internal/AABB_tree/Has_nested_type_Shared_data.h>
|
||||||
#include <CGAL/internal/AABB_tree/Is_ray_intersection_geomtraits.h>
|
#include <CGAL/internal/AABB_tree/Is_ray_intersection_geomtraits.h>
|
||||||
#include <CGAL/internal/AABB_tree/Primitive_helper.h>
|
#include <CGAL/internal/AABB_tree/Primitive_helper.h>
|
||||||
#include <CGAL/result_of.h>
|
|
||||||
|
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
|
@ -190,14 +189,14 @@ public:
|
||||||
typedef typename std::pair<typename GeomTraits::Point_3, typename Primitive::Id> Point_and_primitive_id;
|
typedef typename std::pair<typename GeomTraits::Point_3, typename Primitive::Id> Point_and_primitive_id;
|
||||||
|
|
||||||
/// `Intersection_and_primitive_id<Query>::%Type::first_type` is found according to
|
/// `Intersection_and_primitive_id<Query>::%Type::first_type` is found according to
|
||||||
/// the result type of `GeomTraits::Intersect_3::operator()`,
|
/// the result type of `GeomTraits::Intersect_3::operator()`. If it is
|
||||||
/// (that is cpp11::result_of<GeomTraits::Intersect_3(Query, Primitive::Datum)>::type). If it is
|
|
||||||
/// `boost::optional<T>` then it is `T`, and the result type otherwise.
|
/// `boost::optional<T>` then it is `T`, and the result type otherwise.
|
||||||
template<typename Query>
|
template<typename Query>
|
||||||
struct Intersection_and_primitive_id {
|
struct Intersection_and_primitive_id {
|
||||||
typedef typename cpp11::result_of<
|
typedef decltype(
|
||||||
typename GeomTraits::Intersect_3(Query, typename Primitive::Datum)
|
std::declval<typename GeomTraits::Intersect_3>()(
|
||||||
>::type Intersection_type;
|
std::declval<Query>(),
|
||||||
|
std::declval<typename Primitive::Datum>())) Intersection_type;
|
||||||
|
|
||||||
typedef std::pair<
|
typedef std::pair<
|
||||||
typename internal::AABB_tree::Remove_optional<Intersection_type>::type,
|
typename internal::AABB_tree::Remove_optional<Intersection_type>::type,
|
||||||
|
|
@ -364,8 +363,7 @@ public:
|
||||||
template<typename Query>
|
template<typename Query>
|
||||||
boost::optional< typename Intersection_and_primitive_id<Query>::Type >
|
boost::optional< typename Intersection_and_primitive_id<Query>::Type >
|
||||||
operator()(const Query& query, const typename AT::Primitive& primitive) const {
|
operator()(const Query& query, const typename AT::Primitive& primitive) const {
|
||||||
typename cpp11::result_of<typename GeomTraits::Intersect_3(Query, typename Primitive::Datum) >::type
|
auto inter_res = GeomTraits().intersect_3_object()(internal::Primitive_helper<AT>::get_datum(primitive,m_traits),query);
|
||||||
inter_res = GeomTraits().intersect_3_object()(internal::Primitive_helper<AT>::get_datum(primitive,m_traits),query);
|
|
||||||
if (!inter_res)
|
if (!inter_res)
|
||||||
return boost::none;
|
return boost::none;
|
||||||
return boost::make_optional( std::make_pair(*inter_res, primitive.id()) );
|
return boost::make_optional( std::make_pair(*inter_res, primitive.id()) );
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
#include <CGAL/disable_warnings.h>
|
#include <CGAL/disable_warnings.h>
|
||||||
|
|
||||||
#include <CGAL/AABB_primitive.h>
|
#include <CGAL/AABB_primitive.h>
|
||||||
#include <CGAL/result_of.h>
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
@ -31,9 +30,10 @@ namespace internal {
|
||||||
//classical typedefs
|
//classical typedefs
|
||||||
typedef Iterator key_type;
|
typedef Iterator key_type;
|
||||||
typedef typename GeomTraits::Point_3 value_type;
|
typedef typename GeomTraits::Point_3 value_type;
|
||||||
typedef typename cpp11::result_of<
|
typedef decltype(
|
||||||
typename GeomTraits::Construct_vertex_3(typename GeomTraits::Triangle_3,int)
|
std::declval<typename GeomTraits::Construct_vertex_3>()(
|
||||||
>::type reference;
|
std::declval<typename GeomTraits::Triangle_3>(),
|
||||||
|
std::declval<int>())) reference;
|
||||||
typedef boost::readable_property_map_tag category;
|
typedef boost::readable_property_map_tag category;
|
||||||
|
|
||||||
inline friend
|
inline friend
|
||||||
|
|
@ -57,7 +57,6 @@ namespace internal {
|
||||||
* \tparam GeomTraits is a traits class providing the nested type `Point_3` and `Triangle_3`.
|
* \tparam GeomTraits is a traits class providing the nested type `Point_3` and `Triangle_3`.
|
||||||
* It also provides the functor `Construct_vertex_3` that has an operator taking a `Triangle_3`
|
* It also provides the functor `Construct_vertex_3` that has an operator taking a `Triangle_3`
|
||||||
* and an integer as parameters and returning a triangle point as a type convertible to `Point_3`.
|
* and an integer as parameters and returning a triangle point as a type convertible to `Point_3`.
|
||||||
* In addition `Construct_vertex_3` must support the result_of protocol.
|
|
||||||
* \tparam Iterator is a model of `ForwardIterator` with its value type convertible to `GeomTraits::Triangle_3`
|
* \tparam Iterator is a model of `ForwardIterator` with its value type convertible to `GeomTraits::Triangle_3`
|
||||||
* \tparam CacheDatum is either `CGAL::Tag_true` or `CGAL::Tag_false`. In the former case,
|
* \tparam CacheDatum is either `CGAL::Tag_true` or `CGAL::Tag_false`. In the former case,
|
||||||
* the datum is stored in the primitive, while in the latter it is
|
* the datum is stored in the primitive, while in the latter it is
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
|
|
||||||
#include <CGAL/AABB_primitive.h>
|
#include <CGAL/AABB_primitive.h>
|
||||||
#include <CGAL/result_of.h>
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
namespace CGAL
|
namespace CGAL
|
||||||
|
|
@ -31,9 +30,10 @@ namespace CGAL
|
||||||
//classical typedefs
|
//classical typedefs
|
||||||
typedef Iterator key_type;
|
typedef Iterator key_type;
|
||||||
typedef typename GeomTraits::Point_3 value_type;
|
typedef typename GeomTraits::Point_3 value_type;
|
||||||
typedef typename cpp11::result_of<
|
typedef decltype(
|
||||||
typename GeomTraits::Construct_vertex_3(typename GeomTraits::Tetrahedron_3, int)
|
std::declval<typename GeomTraits::Construct_vertex_3>()(
|
||||||
>::type reference;
|
std::declval<typename GeomTraits::Tetrahedron_3>(),
|
||||||
|
std::declval<int>())) reference;
|
||||||
typedef boost::readable_property_map_tag category;
|
typedef boost::readable_property_map_tag category;
|
||||||
|
|
||||||
inline friend
|
inline friend
|
||||||
|
|
|
||||||
|
|
@ -123,10 +123,10 @@ namespace internal {
|
||||||
// Overloads for empty returns are also provided.
|
// Overloads for empty returns are also provided.
|
||||||
template<typename F, typename A, typename B, typename T>
|
template<typename F, typename A, typename B, typename T>
|
||||||
decltype(auto)
|
decltype(auto)
|
||||||
intersection_return(T&& t) { return decltype(std::declval<F>()(A(), B()))(std::forward<T>(t)); }
|
intersection_return(T&& t) { return decltype(std::declval<F>()(std::declval<A>(), std::declval<B>()))(std::forward<T>(t)); }
|
||||||
template<typename F, typename A, typename B>
|
template<typename F, typename A, typename B>
|
||||||
decltype(auto)
|
decltype(auto)
|
||||||
intersection_return() { return decltype(std::declval<F>()(A(), B()))(); }
|
intersection_return() { return decltype(std::declval<F>()(std::declval<A>(), std::declval<B>()))(); }
|
||||||
|
|
||||||
// Something similar to wrap around boost::get and object_cast to
|
// Something similar to wrap around boost::get and object_cast to
|
||||||
// prevent ifdefing too much. Another way could be to introduce an
|
// prevent ifdefing too much. Another way could be to introduce an
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ with `Dispatch_output_iterator`.
|
||||||
|
|
||||||
Since both the number of intersections, if any, and their types, depend
|
Since both the number of intersections, if any, and their types, depend
|
||||||
on the arguments, the function expects an output iterator on
|
on the arguments, the function expects an output iterator on
|
||||||
`cpp11::result_of<K::Intersect_2(Type1, Type2)>::%type`, as
|
`decltype(std::declval<K::Intersect_2>()(std::declval<Type1>(), std::declval<Type2>()))`, as
|
||||||
presented below.
|
presented below.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,18 +59,15 @@ with `Dispatch_output_iterator`.
|
||||||
|
|
||||||
Since both the number of intersections, if any, and their types, depend
|
Since both the number of intersections, if any, and their types, depend
|
||||||
on the arguments, the function expects an output iterator on
|
on the arguments, the function expects an output iterator on
|
||||||
`cpp11::result_of<Kernel::Intersect_3(Type1, Type2)>::%type`,
|
`decltype(std::declval<Kernel::Intersect_3>()(std::declval<Type1>(), std::declval<Type2>()))`,
|
||||||
as presented below.
|
as presented below.
|
||||||
*/
|
*/
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Copies in the output iterator the intersection elements between the
|
Constructs the intersection elements between the two input
|
||||||
two objects. `intersections` iterates on
|
objects and stores them in the OutputIterator in lexicographic order,
|
||||||
elements of type `result_of< Intersect_3(SphericalType1, SphericalType2) >`, in lexicographic order,
|
where both, `SphericalType1` and `SphericalType2`, can be either
|
||||||
when this ordering is defined on the computed objects,
|
|
||||||
|
|
||||||
where `SphericalType1` and `SphericalType2` can both be one of:
|
|
||||||
|
|
||||||
- `Sphere_3<SphericalKernel>`,
|
- `Sphere_3<SphericalKernel>`,
|
||||||
- `Plane_3<SphericalKernel>`,
|
- `Plane_3<SphericalKernel>`,
|
||||||
|
|
@ -90,7 +87,7 @@ type can be
|
||||||
and if the two objets `obj1` and `obj2` are equal,
|
and if the two objets `obj1` and `obj2` are equal,
|
||||||
- `Line_3<SphericalKernel>` or
|
- `Line_3<SphericalKernel>` or
|
||||||
`Circle_3<SphericalKernel>` when `SphericalType1` and `SphericalType2`
|
`Circle_3<SphericalKernel>` when `SphericalType1` and `SphericalType2`
|
||||||
are two-dimensional objets intersecting along a curve (2 planes, or 2
|
are two-dimensional objects intersecting along a curve (2 planes, or 2
|
||||||
spheres, or one plane and one sphere),
|
spheres, or one plane and one sphere),
|
||||||
- `Circular_arc_3<SphericalKernel>` in case of an overlap of
|
- `Circular_arc_3<SphericalKernel>` in case of an overlap of
|
||||||
two circular arcs or
|
two circular arcs or
|
||||||
|
|
|
||||||
|
|
@ -95,12 +95,15 @@ The following tables give the possible values for `Type1` and `Type2`.
|
||||||
|
|
||||||
\cgalHeading{2D Intersections}
|
\cgalHeading{2D Intersections}
|
||||||
|
|
||||||
The return type can be obtained through `cpp11::result_of<Kernel::Intersect_2(A, B)>::%type`.
|
The return type of intersecting two objects of the types `Type1` and `Type2` can be
|
||||||
It is equivalent to `boost::optional< boost::variant< T... > >`, the last column in the table providing the template parameter pack.
|
specified through the placeholder type specifier `auto`. It is equivalent to
|
||||||
|
`boost::optional< boost::variant< T... > >`, the last column in the table providing
|
||||||
|
the template parameter pack.
|
||||||
|
|
||||||
<DIV ALIGN="CENTER">
|
<DIV ALIGN="CENTER">
|
||||||
<TABLE CELLPADDING=3 BORDER="1">
|
<TABLE CELLPADDING=3 BORDER="1">
|
||||||
<TR> <TH> Type1 </TH>
|
<TR>
|
||||||
|
<TH> Type1 </TH>
|
||||||
<TH> Type2 </TH>
|
<TH> Type2 </TH>
|
||||||
<TH> Return Type: `T...` </TH>
|
<TH> Return Type: `T...` </TH>
|
||||||
</TR>
|
</TR>
|
||||||
|
|
@ -191,12 +194,15 @@ intersections existing with the type `Iso_rectangle_2`. Note that the return typ
|
||||||
|
|
||||||
\cgalHeading{3D Intersections}
|
\cgalHeading{3D Intersections}
|
||||||
|
|
||||||
The return type can be obtained through `cpp11::result_of<Kernel::Intersect_3(A, B)>::%type`.
|
The return type of intersecting two objects of the types `Type1` and `Type2` can be
|
||||||
It is equivalent to `boost::optional< boost::variant< T... > >`, the last column in the table providing the template parameter pack.
|
specified through the placeholder type specifier `auto`. It is equivalent to
|
||||||
|
`boost::optional< boost::variant< T... > >`, the last column in the table providing
|
||||||
|
the template parameter pack.
|
||||||
|
|
||||||
<DIV ALIGN="CENTER">
|
<DIV ALIGN="CENTER">
|
||||||
<TABLE CELLPADDING=3 BORDER="1">
|
<TABLE CELLPADDING=3 BORDER="1">
|
||||||
<TR> <TH> Type1 </TH>
|
<TR>
|
||||||
|
<TH> Type1 </TH>
|
||||||
<TH> Type2 </TH>
|
<TH> Type2 </TH>
|
||||||
<TH> Return Type: `T...` </TH>
|
<TH> Return Type: `T...` </TH>
|
||||||
</TR>
|
</TR>
|
||||||
|
|
@ -350,9 +356,9 @@ The following examples demonstrate the most common use of
|
||||||
`intersection()` functions with the 2D and 3D Linear %Kernel.
|
`intersection()` functions with the 2D and 3D Linear %Kernel.
|
||||||
|
|
||||||
In the first two examples we intersect a segment and a line.
|
In the first two examples we intersect a segment and a line.
|
||||||
The result type can be obtained with `cpp11::result_of`. It looks simpler
|
The result type can be specified through the placeholder type specifier `auto`,
|
||||||
if you use a C++ compiler which supports `auto`,
|
but you must anyway know that the result type is a `boost::optional<boost::variant<..> >`,
|
||||||
but you must anyways know that the result type is a `boost::optional<boost::variant<..> >`, in order to unpack the point or segment.
|
in order to unpack the point or segment.
|
||||||
|
|
||||||
<A HREF="https://www.boost.org/libs/optional/">`boost::optional`</A> comes in
|
<A HREF="https://www.boost.org/libs/optional/">`boost::optional`</A> comes in
|
||||||
as there might be no intersection. <A HREF="https://www.boost.org/libs/variant/">`boost::variant`</A> comes in
|
as there might be no intersection. <A HREF="https://www.boost.org/libs/variant/">`boost::variant`</A> comes in
|
||||||
|
|
@ -374,7 +380,7 @@ a standard library algorithm.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
template <typename Kernel>
|
template <typename Kernel>
|
||||||
cpp11::result_of<Kernel::Intersect_23(Type1, Type2)>::type
|
decltype(auto)
|
||||||
intersection(Type1<Kernel> obj1, Type2<Kernel> obj2);
|
intersection(Type1<Kernel> obj1, Type2<Kernel> obj2);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -382,7 +388,7 @@ returns the intersection of 3 planes, which can be a
|
||||||
point, a line, a plane, or empty.
|
point, a line, a plane, or empty.
|
||||||
*/
|
*/
|
||||||
template <typename Kernel>
|
template <typename Kernel>
|
||||||
boost::optional< boost::variant< Point_3, Line_3, Plane_3 > >
|
decltype(auto)
|
||||||
intersection(const Plane_3<Kernel>& pl1,
|
intersection(const Plane_3<Kernel>& pl1,
|
||||||
const Plane_3<Kernel>& pl2,
|
const Plane_3<Kernel>& pl2,
|
||||||
const Plane_3<Kernel>& pl3);
|
const Plane_3<Kernel>& pl3);
|
||||||
|
|
|
||||||
|
|
@ -8413,8 +8413,6 @@ public:
|
||||||
\cgalRefines `AdaptableFunctor` (with two arguments)
|
\cgalRefines `AdaptableFunctor` (with two arguments)
|
||||||
|
|
||||||
\sa \link intersection_grp `CGAL::intersection()` \endlink
|
\sa \link intersection_grp `CGAL::intersection()` \endlink
|
||||||
\sa `CGAL::cpp11::result_of`
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
class Intersect_2 {
|
class Intersect_2 {
|
||||||
public:
|
public:
|
||||||
|
|
@ -8428,7 +8426,7 @@ public:
|
||||||
`Type1` and `Type2`, for all pairs `Type1` and `Type2`.
|
`Type1` and `Type2`, for all pairs `Type1` and `Type2`.
|
||||||
For details see the reference manual page for \link intersection_grp `CGAL::intersection()` \endlink.
|
For details see the reference manual page for \link intersection_grp `CGAL::intersection()` \endlink.
|
||||||
*/
|
*/
|
||||||
CGAL::cpp11::result_of<Kernel::Intersect_2(Type1, Type2)>::type
|
decltype(auto)
|
||||||
operator()(Type1 obj1, Type2 obj2);
|
operator()(Type1 obj1, Type2 obj2);
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
@ -8442,8 +8440,6 @@ public:
|
||||||
\cgalRefines `AdaptableFunctor` (with two or three arguments)
|
\cgalRefines `AdaptableFunctor` (with two or three arguments)
|
||||||
|
|
||||||
\sa intersection_linear_grp
|
\sa intersection_linear_grp
|
||||||
\sa `CGAL::cpp11::result_of`
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
class Intersect_3 {
|
class Intersect_3 {
|
||||||
public:
|
public:
|
||||||
|
|
@ -8457,8 +8453,8 @@ public:
|
||||||
objects of type `Type1` and `Type2`.
|
objects of type `Type1` and `Type2`.
|
||||||
For details see the reference manual page for \ref intersection_linear_grp.
|
For details see the reference manual page for \ref intersection_linear_grp.
|
||||||
*/
|
*/
|
||||||
CGAL::cpp11::result_of<Kernel::Intersect_3(Type1, Type2)>::type
|
decltype(auto)
|
||||||
operator()(Type1 obj1, Type2 obj2);
|
operator()(Type1 obj1, Type2 obj2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -493,23 +493,19 @@ especially integer types and rationals.
|
||||||
|
|
||||||
\subsection Kernel_23VariantReturnValues Intersections and Variant Return Types
|
\subsection Kernel_23VariantReturnValues Intersections and Variant Return Types
|
||||||
|
|
||||||
Some functions, for example \link intersection_linear_grp `intersection()`\endlink, can return different types of objects. To achieve this
|
Some functions, for example \link intersection_linear_grp `intersection()`\endlink,
|
||||||
in a type-safe way \cgal uses return values of type
|
can return different types of objects. To achieve this in a type-safe way \cgal uses
|
||||||
`boost::optional< boost::variant< T... > >` were `T...` is a
|
return values of type `boost::optional< boost::variant< T... > >` where `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
|
||||||
type of an intersection can be determined through the metafunction
|
can be specified through the placeholder type specifier `auto`.
|
||||||
`CGAL::cpp11::result_of<Kernel::Intersect_2(Type1, Type2)>` or
|
|
||||||
`CGAL::cpp11::result_of<Kernel::Intersect_3(Type1, Type2)>`, where
|
|
||||||
`Type1` and `Type2` are the types of the objects used in the
|
|
||||||
intersection computation.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Example
|
Example
|
||||||
-------
|
-------
|
||||||
|
|
||||||
In the following example, `result_of` is used to query the type of the
|
In the following example, `auto` is used to specify the type of the return value
|
||||||
return value for the intersection computation:
|
for the intersection computation:
|
||||||
|
|
||||||
\code{.cpp}
|
\code{.cpp}
|
||||||
typedef Cartesian<double> K;
|
typedef Cartesian<double> K;
|
||||||
|
|
@ -521,13 +517,9 @@ Segment_2 segment_1, segment_2;
|
||||||
std::cin >> segment_1 >> segment_2;
|
std::cin >> segment_1 >> segment_2;
|
||||||
|
|
||||||
|
|
||||||
/* C++11 */
|
/* use auto */
|
||||||
// auto v = intersection(segment_1, segment_2);
|
auto v = intersection(segment_1, segment_2);
|
||||||
|
if (v) {
|
||||||
/* C++03 */
|
|
||||||
CGAL::cpp11::result_of<K::Intersect_2(Segment_2, Segment_2)>::type
|
|
||||||
v = intersection(segment_1, segment_2);
|
|
||||||
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 */
|
||||||
|
|
|
||||||
|
|
@ -34,14 +34,16 @@ The same functionality is also available through the functor `Kernel::Intersect_
|
||||||
|
|
||||||
The following table gives the possible values for `Type1` and `Type2`.
|
The following table gives the possible values for `Type1` and `Type2`.
|
||||||
|
|
||||||
The return type can be obtained through `cpp11::result_of<Kernel::Intersect_d(A, B)>::%type`.
|
The return type of intersecting two objects of the types `Type1` and `Type2` can be
|
||||||
It is equivalent to `boost::optional< boost::variant< T... > >`, the last column in the table providing the template parameter pack.
|
specified through the placeholder type specifier `auto`. It is equivalent to
|
||||||
|
`boost::optional< boost::variant< T... > >`, the last column in the table providing
|
||||||
|
the template parameter pack.
|
||||||
|
|
||||||
|
|
||||||
<DIV ALIGN="CENTER">
|
<DIV ALIGN="CENTER">
|
||||||
<TABLE CELLPADDING=3 BORDER="1">
|
<TABLE CELLPADDING=3 BORDER="1">
|
||||||
<TR> <TH> Type1 </TH>
|
<TR>
|
||||||
|
<TH> Type1 </TH>
|
||||||
<TH> Type2 </TH>
|
<TH> Type2 </TH>
|
||||||
<TH> `T...` </TH>
|
<TH> `T...` </TH>
|
||||||
</TR>
|
</TR>
|
||||||
|
|
@ -143,13 +145,8 @@ struct Intersection_visitor {
|
||||||
template <class R>
|
template <class R>
|
||||||
void foo(Segment_d<R> seg, Line_d<R> lin)
|
void foo(Segment_d<R> seg, Line_d<R> lin)
|
||||||
{
|
{
|
||||||
// with C++11 support
|
// use auto
|
||||||
// auto result = intersection(seg, lin);
|
auto result = intersection(seg, lin);
|
||||||
|
|
||||||
// without C++11 support
|
|
||||||
typename CGAL::cpp11::result_of<R::Intersect_d(Segment_d<R>, Line_d<R>)>::type
|
|
||||||
result = intersection(seg, lin);
|
|
||||||
|
|
||||||
if(result) { boost::apply_visitor(Intersection_visitor<R>(), *result); }
|
if(result) { boost::apply_visitor(Intersection_visitor<R>(), *result); }
|
||||||
else { // no intersection
|
else { // no intersection
|
||||||
}
|
}
|
||||||
|
|
@ -160,10 +157,10 @@ void foo(Segment_d<R> seg, Line_d<R> lin)
|
||||||
\sa `Kernel_d::Intersect_d`
|
\sa `Kernel_d::Intersect_d`
|
||||||
\sa <a HREF="https://www.boost.org/doc/libs/release/libs/optional/index.html">`boost::optional`</a>
|
\sa <a HREF="https://www.boost.org/doc/libs/release/libs/optional/index.html">`boost::optional`</a>
|
||||||
\sa <a HREF="https://www.boost.org/doc/html/variant.html">`boost::variant`</a>
|
\sa <a HREF="https://www.boost.org/doc/html/variant.html">`boost::variant`</a>
|
||||||
\sa `cpp11::result_of`
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
cpp11::result_of<R::Intersect_d(Type1<R>, Type2<R>)>::type intersection(Type1<R> f1, Type2<R> f2);
|
decltype(auto)
|
||||||
|
intersection(Type1<R> f1, Type2<R> f2);
|
||||||
|
|
||||||
} /* namespace CGAL */
|
} /* namespace CGAL */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ For a list of the possible return types, see `CGAL::intersection()`.
|
||||||
\pre `p` and `q` have the same dimension.
|
\pre `p` and `q` have the same dimension.
|
||||||
*/
|
*/
|
||||||
template <class Type1, class Type2>
|
template <class Type1, class Type2>
|
||||||
CGAL::cpp11::result_of<Kernel::Intersect_d(Type1, Type2)>::type
|
decltype(auto)
|
||||||
operator()(const Type1& p, const Type2& q);
|
operator()(const Type1& p, const Type2& q);
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
|
||||||
|
|
@ -480,17 +480,14 @@ that are part of flats (`R::Segment_d`, `R::Ray_d`,
|
||||||
returns a `boost::optional< boost::variant< T... > >`
|
returns a `boost::optional< boost::variant< T... > >`
|
||||||
where `T...` is a list of all possible resulting geometric objects.
|
where `T...` is a list of all possible resulting geometric objects.
|
||||||
|
|
||||||
The exact result type of an intersection can be determined by using
|
The return type of intersecting two objects of the types `Type1` and `Type2` can be
|
||||||
`CGAL::cpp11::result_of<Kernel::Intersect_d(Type1, Type2)>::%type`
|
specified through the placeholder type specifier `auto`.
|
||||||
where `Type1` and `Type2` are the types of the objects
|
|
||||||
used in the intersection computation.
|
|
||||||
|
|
||||||
|
|
||||||
\subsubsection Kernel_dExample Example
|
\subsubsection Kernel_dExample Example
|
||||||
|
|
||||||
In the following example, the object type is used as a return value for
|
In the following example, the `auto` is used for the intersection computation,
|
||||||
the intersection computation, as there are
|
as there are possibly different return values.
|
||||||
possibly different return values.
|
|
||||||
|
|
||||||
\code{.cpp}
|
\code{.cpp}
|
||||||
typedef Cartesian_d<double> K;
|
typedef Cartesian_d<double> K;
|
||||||
|
|
@ -500,9 +497,9 @@ typedef Segment_d<K> Segment;
|
||||||
Segment s1, s2;
|
Segment s1, s2;
|
||||||
std::cin >> s1 >> s2;
|
std::cin >> s1 >> s2;
|
||||||
|
|
||||||
CGAL::cpp11::result_of<K::Intersect_d(Segment, Segment)>::type
|
/* use auto */
|
||||||
v = intersection(s1, s2);
|
auto v = intersection(s1, s2);
|
||||||
if(v) {
|
if (v) {
|
||||||
// not empty
|
// not empty
|
||||||
if (const Point *p = boost::get<Point>(&*v) ) {
|
if (const Point *p = boost::get<Point>(&*v) ) {
|
||||||
// do something with *p
|
// do something with *p
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ template <class Base_,class R_> struct Orientation_of_points_2 : private Store_k
|
||||||
struct Point_2 {
|
struct Point_2 {
|
||||||
R_ const&r; CC const&c; Point const& p;
|
R_ const&r; CC const&c; Point const& p;
|
||||||
Point_2(R_ const&r_, CC const&c_, Point const&p_):r(r_),c(c_),p(p_){}
|
Point_2(R_ const&r_, CC const&c_, Point const&p_):r(r_),c(c_),p(p_){}
|
||||||
// use result_of instead?
|
|
||||||
typename CC::result_type x()const{return c(p,0);}
|
typename CC::result_type x()const{return c(p,0);}
|
||||||
typename CC::result_type y()const{return c(p,1);}
|
typename CC::result_type y()const{return c(p,1);}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,6 @@ public:
|
||||||
typedef C2E To_exact_converter;
|
typedef C2E To_exact_converter;
|
||||||
typedef C2A To_approximate_converter;
|
typedef C2A To_approximate_converter;
|
||||||
|
|
||||||
// FIXME: should use result_of, see emails by Nico
|
|
||||||
typedef typename EP::result_type result_type;
|
typedef typename EP::result_type result_type;
|
||||||
// AP::result_type must be convertible to EP::result_type.
|
// AP::result_type must be convertible to EP::result_type.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ typename typeset_intersection<typename K1::Object_list, typename K2::Object_list
|
||||||
KernelD_converter(){}
|
KernelD_converter(){}
|
||||||
KernelD_converter(K1 const&a,K2 const&b):Store_kernel<K1>(a),Store_kernel2<K2>(b){}
|
KernelD_converter(K1 const&a,K2 const&b):Store_kernel<K1>(a),Store_kernel2<K2>(b){}
|
||||||
|
|
||||||
// For boost::result_of, used in transforming_iterator
|
// For the (not anymore used in CGAL) boost result of, used in transforming_iterator
|
||||||
template<class T,int i=is_iterator<T>::value?42:0> struct result:Base::template result<T>{};
|
template<class T,int i=is_iterator<T>::value?42:0> struct result:Base::template result<T>{};
|
||||||
template<class T> struct result<Final_(T),42> {
|
template<class T> struct result<Final_(T),42> {
|
||||||
typedef transforming_iterator<Final_,T> type;
|
typedef transforming_iterator<Final_,T> type;
|
||||||
|
|
|
||||||
|
|
@ -127,15 +127,15 @@ template <class Base_> struct Kernel_d_interface : public Base_ {
|
||||||
typedef typename Get_functor<Base, Construct_ttag<Point_cartesian_const_iterator_tag> >::type CPI;
|
typedef typename Get_functor<Base, Construct_ttag<Point_cartesian_const_iterator_tag> >::type CPI;
|
||||||
typedef typename Get_functor<Base, Construct_ttag<Vector_cartesian_const_iterator_tag> >::type CVI;
|
typedef typename Get_functor<Base, Construct_ttag<Vector_cartesian_const_iterator_tag> >::type CVI;
|
||||||
// FIXME: The following sometimes breaks compilation. The typedef below forces instantiation of this, which forces Point_d, which itself (in the wrapper) needs the derived kernel to tell it what the base kernel is, and that's a cycle. The exact circumstances are not clear, g++ and clang++ are ok in both C++03 and C++11, it is only clang in C++11 without CGAL_CXX11 that breaks. Relying on CPI::result_type is great for Epick_d but not Epeck_d.
|
// FIXME: The following sometimes breaks compilation. The typedef below forces instantiation of this, which forces Point_d, which itself (in the wrapper) needs the derived kernel to tell it what the base kernel is, and that's a cycle. The exact circumstances are not clear, g++ and clang++ are ok in both C++03 and C++11, it is only clang in C++11 without CGAL_CXX11 that breaks. Relying on CPI::result_type is great for Epick_d but not Epeck_d.
|
||||||
//typedef typename CGAL::decay<typename boost::result_of<CPI(Point_d,CGAL::Begin_tag)>::type>::type result_type;
|
// typedef typename CGAL::decay<decltype(std::declval<CPI>()(std::declval<Point_d>(), std::declval<CGAL::Begin_tag>()))>::type result_type;
|
||||||
//typedef typename CGAL::decay<typename CPI::result_type>::type result_type;
|
// typedef typename CGAL::decay<typename CPI::result_type>::type result_type;
|
||||||
//typedef decltype(std::declval<CPI>()(std::declval<Point_d>(),Begin_tag{})) result_type;
|
// typedef decltype(std::declval<CPI>()(std::declval<Point_d>(),Begin_tag{})) result_type;
|
||||||
// HACK
|
// HACK
|
||||||
typedef typename Base::Point_cartesian_const_iterator result_type;
|
typedef typename Base::Point_cartesian_const_iterator result_type;
|
||||||
// Kernel_d requires a common iterator type for points and vectors
|
// Kernel_d requires a common iterator type for points and vectors
|
||||||
// TODO: provide this mixed functor in preKernel?
|
// TODO: provide this mixed functor in preKernel?
|
||||||
//CGAL_static_assertion((boost::is_same<typename CGAL::decay<typename boost::result_of<CVI(Vector_d,CGAL::Begin_tag)>::type>::type, result_type>::value));
|
// CGAL_static_assertion((boost::is_same<typename CGAL::decay<decltype(std::declval<CVI>()(std::declval<Vector_d>(), std::declval<CGAL::Begin_tag>()))>::type, result_type>::value));
|
||||||
//CGAL_static_assertion((boost::is_same<typename CGAL::decay<typename CVI::result_type>::type, result_type>::value));
|
// CGAL_static_assertion((boost::is_same<typename CGAL::decay<typename CVI::result_type>::type, result_type>::value));
|
||||||
template <class Tag_>
|
template <class Tag_>
|
||||||
auto operator()(Point_d const&p, Tag_ t)const{
|
auto operator()(Point_d const&p, Tag_ t)const{
|
||||||
return CPI(this->kernel())(p,t);
|
return CPI(this->kernel())(p,t);
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ public:
|
||||||
typedef Dimension_tag<0> Feature_dimension;
|
typedef Dimension_tag<0> Feature_dimension;
|
||||||
|
|
||||||
typedef typename Get_type<Kbase, Point_tag>::type Rep;
|
typedef typename Get_type<Kbase, Point_tag>::type Rep;
|
||||||
//typedef typename CGAL::decay<typename boost::result_of<CPI(Rep,Begin_tag)>::type>::type Cartesian_const_iterator;
|
// typedef typename CGAL::decay<decltype(std::declval<CPI>()(std::declval<Rep>(), std::declval<Begin_tag>()))>::type Cartesian_const_iterator;
|
||||||
|
|
||||||
const Rep& rep() const noexcept
|
const Rep& rep() const noexcept
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@
|
||||||
#include <boost/type_traits.hpp>
|
#include <boost/type_traits.hpp>
|
||||||
#include <CGAL/Kernel/Return_base_tag.h>
|
#include <CGAL/Kernel/Return_base_tag.h>
|
||||||
#include <CGAL/Dimension.h>
|
#include <CGAL/Dimension.h>
|
||||||
#include <boost/utility/result_of.hpp>
|
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
namespace Wrap {
|
namespace Wrap {
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@
|
||||||
#include <CGAL/enum.h>
|
#include <CGAL/enum.h>
|
||||||
#include <CGAL/internal/Has_nested_type_Bare_point.h>
|
#include <CGAL/internal/Has_nested_type_Bare_point.h>
|
||||||
#include <CGAL/spatial_sort.h>
|
#include <CGAL/spatial_sort.h>
|
||||||
#include <CGAL/result_of.h>
|
|
||||||
#include <CGAL/utility.h>
|
#include <CGAL/utility.h>
|
||||||
|
|
||||||
#include <boost/mpl/if.hpp>
|
#include <boost/mpl/if.hpp>
|
||||||
|
|
@ -498,7 +497,7 @@ public:
|
||||||
|
|
||||||
// Spatial sorting can only be applied to bare points, so we need an adaptor
|
// Spatial sorting can only be applied to bare points, so we need an adaptor
|
||||||
typedef typename Geom_traits::Construct_point_3 Construct_point_3;
|
typedef typename Geom_traits::Construct_point_3 Construct_point_3;
|
||||||
typedef typename cpp11::result_of<const Construct_point_3(const Weighted_point&)>::type Ret;
|
typedef decltype(std::declval<const Construct_point_3>()(std::declval<const Weighted_point&>())) Ret;
|
||||||
typedef boost::function_property_map<Construct_point_3, Weighted_point, Ret> fpmap;
|
typedef boost::function_property_map<Construct_point_3, Weighted_point, Ret> fpmap;
|
||||||
typedef CGAL::Spatial_sort_traits_adapter_3<Geom_traits, fpmap> Search_traits_3;
|
typedef CGAL::Spatial_sort_traits_adapter_3<Geom_traits, fpmap> Search_traits_3;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,18 @@ namespace cpp11 {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\ingroup PkgSTLExtensionRef
|
\ingroup PkgSTLExtensionRef
|
||||||
Alias to the tr1 implementation from boost of the `result_of` mechanism.
|
Alias to the implementation of the `std::result_of` mechanism. When all compilers
|
||||||
When all compilers supported by %CGAL will have a Standard compliant implemention of the
|
supported by \cgal have a Standard compliant implemention of the `std::invoke_result`
|
||||||
the \cpp11 `decltype` feature, it will become an alias to <code>std::result_of</code>.
|
mechanism, it will become an alias to the <code>std::invoke_result</code>.
|
||||||
|
|
||||||
\sa <a href=https://www.boost.org/libs/utility/utility.htm#result_of><code>boost::result_of</code></a>
|
\sa <a href=https://en.cppreference.com/w/cpp/types/result_of><code>std::result_of</code></a>
|
||||||
*/
|
*/
|
||||||
template <typename F>
|
template <typename F>
|
||||||
struct result_of{
|
struct result_of {
|
||||||
/// starting from boost version 1.44, it is `boost::tr1_result_of<F>::%type`, and
|
|
||||||
/// `boost::result_of<F>::%type` otherwise.
|
/*!
|
||||||
|
It is a type `std::result_of<F>::%type`.
|
||||||
|
*/
|
||||||
typedef unspecified_type type;
|
typedef unspecified_type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@
|
||||||
#ifndef CGAL_TRANSFORMING_ITERATOR_H
|
#ifndef CGAL_TRANSFORMING_ITERATOR_H
|
||||||
#define CGAL_TRANSFORMING_ITERATOR_H
|
#define CGAL_TRANSFORMING_ITERATOR_H
|
||||||
#include <boost/iterator/iterator_adaptor.hpp>
|
#include <boost/iterator/iterator_adaptor.hpp>
|
||||||
#include <boost/utility/result_of.hpp>
|
|
||||||
#include <boost/type_traits/is_empty.hpp>
|
#include <boost/type_traits/is_empty.hpp>
|
||||||
#include <boost/type_traits/is_reference.hpp>
|
#include <boost/type_traits/is_reference.hpp>
|
||||||
#include <boost/type_traits/is_integral.hpp>
|
#include <boost/type_traits/is_integral.hpp>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue