mirror of https://github.com/CGAL/cgal
Add example to the User Manual
This commit is contained in:
parent
757918be95
commit
4450996725
|
|
@ -0,0 +1,62 @@
|
|||
namespace CGAL {
|
||||
|
||||
/*!
|
||||
\ingroup PkgConvexHull2Traits
|
||||
|
||||
The class `Convex_hull_traits_adapter_2` serves as a traits class for all the two-dimensional
|
||||
convex hull and extreme point calculation function. This class corresponds
|
||||
to the default traits class for these functions.
|
||||
|
||||
Given a property map associating a key to a point, the class `Convex_hull_traits_adapter_2` enables
|
||||
to compute the sequence of keys for which the associted points are the convex hull points ,
|
||||
the predicates being computed on the associated points.
|
||||
In other words, the traits provides to a convex hull algorithm a point type which is a key,
|
||||
while the actual point type is `Base_traits::Point_2`.
|
||||
|
||||
\cgalModels `ConvexHullTraits_2`
|
||||
|
||||
\sa `CGAL::Convex_hull_constructive_traits_2<R>`
|
||||
\sa `CGAL::Projection_traits_xy_3<K>`
|
||||
\sa `CGAL::Projection_traits_yz_3<K>`
|
||||
\sa `CGAL::Projection_traits_xz_3<K>`
|
||||
|
||||
*/
|
||||
template< typename Base_traits, typename PointPropertyMap >
|
||||
class Convex_hull_traits_adapter_2 {
|
||||
public:
|
||||
|
||||
/// \name Types
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
|
||||
*/
|
||||
typedef boost::property_traits<PointPropertyMap>::key_type Point_2;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Creation
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
*/
|
||||
Convex_hull_traits_2(Base_traits base=Base_traits());
|
||||
|
||||
/*!
|
||||
*/
|
||||
Convex_hull_traits_2(const PointPropertyMap& ppmap, Base_traits base=Base_traits());
|
||||
/// @}
|
||||
|
||||
/// \name Operations
|
||||
/// @{
|
||||
|
||||
/*!
|
||||
Returns a const reference to the point property map.
|
||||
*/
|
||||
const PointPropertyMap& point_property_map() const;
|
||||
|
||||
|
||||
/// @}
|
||||
|
||||
}; /* end Convex_hull_traits_2 */
|
||||
} /* end namespace CGAL */
|
||||
|
|
@ -9,7 +9,8 @@ to the default traits class for these functions.
|
|||
|
||||
\cgalModels `ConvexHullTraits_2`
|
||||
|
||||
\sa `CGAL::Convex_hull_constructive_traits_2<R>`
|
||||
\sa `CGAL::Convex_hull_constructive_traits_2<R>`
|
||||
\sa `CGAL::Convex_hull_traits_adapter_2<R,P>`
|
||||
\sa `CGAL::Projection_traits_xy_3<K>`
|
||||
\sa `CGAL::Projection_traits_yz_3<K>`
|
||||
\sa `CGAL::Projection_traits_xz_3<K>`
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ is specified with each function.
|
|||
|
||||
\cgalHasModel `CGAL::Convex_hull_constructive_traits_2<R>`
|
||||
\cgalHasModel `CGAL::Convex_hull_traits_2<R>`
|
||||
\cgalHasModel `CGAL::Convex_hull_traits_adapter_2<R>`
|
||||
\cgalHasModel `CGAL::Projection_traits_xy_3<K>`
|
||||
\cgalHasModel `CGAL::Projection_traits_yz_3 <K>`
|
||||
\cgalHasModel `CGAL::Projection_traits_xz_3<K>`
|
||||
|
|
|
|||
|
|
@ -79,6 +79,21 @@ functions such as `ch_bykat()`.
|
|||
|
||||
\cgalExample{Convex_hull_2/ch_from_cin_to_cout.cpp}
|
||||
|
||||
|
||||
\section Convex_hull_2ExampleIndex Example using a Property Map
|
||||
|
||||
In the following example we have as input a vector of points,
|
||||
and we retrieve the indices of of the points which are on the convex hull.
|
||||
The convex hull function takes as fourth argument a traits class
|
||||
that must be model of the concept `ConvexHullTraits_2`. It provides
|
||||
predicates such as orientation tests.
|
||||
The class `Convex_hull_traits_adapter_2` in combination with a
|
||||
`Pointer_property_map`, is a model. The indices `i` are then "points",
|
||||
and the adapter performs the predicates on `points[i]`.
|
||||
|
||||
\cgalExample{Convex_hull_2/convex_hull_indices_2.cpp}
|
||||
|
||||
|
||||
\section Convex_hull_2Extreme Extreme Points and Hull Subsequences
|
||||
|
||||
In addition to the functions for producing convex hulls, there are a
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ defining `CGAL_CH_CHECK_EXPENSIVE`.
|
|||
|
||||
- `CGAL::Convex_hull_constructive_traits_2<R>`
|
||||
- `CGAL::Convex_hull_traits_2<R>`
|
||||
- `CGAL::Convex_hull_traits_adapter_2<R,P>`
|
||||
|
||||
\cgalCRPSection{Convex Hull Functions}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
/*!
|
||||
\example Convex_hull_2/array_convex_hull_2.cpp
|
||||
\example Convex_hull_2/convex_hull_indices_2.cpp
|
||||
\example Convex_hull_2/ch_from_cin_to_cout.cpp
|
||||
\example Convex_hull_2/ch_graham_anderson.cpp
|
||||
\example Convex_hull_2/ch_timing.cpp
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <CGAL/Convex_hull_traits_adapter_2.h>
|
||||
#include <CGAL/property_map.h>
|
||||
#include <vector>
|
||||
#include <numeric>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||
typedef K::Point_2 Point_2;
|
||||
|
|
@ -11,22 +12,17 @@ typedef CGAL::Convex_hull_traits_adapter_2<K,
|
|||
|
||||
int main()
|
||||
{
|
||||
std::vector<Point_2> points;
|
||||
|
||||
points.push_back(Point_2(10,0));
|
||||
points.push_back(Point_2(0,10));
|
||||
points.push_back(Point_2(1,1));
|
||||
points.push_back(Point_2(3,4));
|
||||
points.push_back(Point_2(0,0));
|
||||
points.push_back(Point_2(10,10));
|
||||
points.push_back(Point_2(2,6));
|
||||
std::vector<Point_2> points = { Point_2(10,0),
|
||||
Point_2(10,0),
|
||||
Point_2(0,10),
|
||||
Point_2(1,1),
|
||||
Point_2(3,4),
|
||||
Point_2(0,0),
|
||||
Point_2(10,10),
|
||||
Point_2(2,6) };
|
||||
|
||||
std::vector<std::size_t> indices(points.size()), out;
|
||||
|
||||
for(int i=0; i < indices.size();i++){
|
||||
indices[i] = i;
|
||||
}
|
||||
|
||||
std::iota(indices.begin(), indices.end(),0);
|
||||
|
||||
CGAL::convex_hull_2(indices.begin(), indices.end(), std::back_inserter(out),
|
||||
Convex_hull_traits_2(CGAL::make_property_map(points)));
|
||||
|
|
|
|||
Loading…
Reference in New Issue