Update and clean up the doc

This commit is contained in:
Maxime Gimeno 2018-07-03 10:46:15 +02:00
parent ea11369caf
commit 276871d708
10 changed files with 89 additions and 59 deletions

View File

@ -7,14 +7,18 @@ namespace CGAL {
* `extreme_points_3()`. It permits the use of this function for accessing vertices, indices,
* or anything that can be used as `key_type` for `PointPropertyMap`.
*
* \tparam Base_traits a model of `ConvexHullTraits_3` and `IsStronglyConvexTraits_3`
* \tparam PointPropertyMap a model of `ReadablePropertyMap` with `CGAL::Point_3`
* as value_type.
* \tparam Base_traits a model of `ConvexHullTraits_3` and `IsStronglyConvexTraits_3`.
* If the kernel `R` of the points from `PointPropertyMap`
* is a kernel with exact predicates but inexact constructions
* (in practice we check `R::Has_filtered_predicates_tag` is `Tag_true` and `R::FT` is a floating point type),
* then the default traits class used is `Convex_hull_traits_3<R>`, and `R` otherwise.
*
* \cgalModels `ConvexHullTraits_3`
* \cgalModels `IsStronglyConvexTraits_3`
*/
template<class Base_traits,class PointPropertyMap>
template<class PointPropertyMap, class Base_traits>
class Extreme_points_traits_adapter_3
{
public:
@ -39,4 +43,12 @@ public:
get_point(const typename boost::property_traits<PointPropertyMap>::key_type& k) const;
};
/*!
* \ingroup PkgConvexHull3Functions
* Returns `Extreme_points_traits_adapter_3<PointPropertyMap, Base_traits>(pmap, traits)`.
*/
template<class PointPropertyMap,class Base_traits>
Extreme_points_traits_adapter_3<PointPropertyMap, Base_traits>
make_extreme_points_traits_adapter(const PointPropertyMap& pmap, Base_traits traits);
}//end CGAL

View File

@ -83,7 +83,7 @@ then the default traits class used is `Convex_hull_traits_3<R>`, and `R` otherwi
@param out an output iterator where the extreme points will be put.
@param traits an instance of `Traits`.
\sa CGAL::Extreme_points_traits_adapter_3
\sa `CGAL::Extreme_points_traits_adapter_3`
*/
template <class InputRange, class OutputIterator, class Traits>
OutputIterator
@ -91,38 +91,6 @@ extreme_points_3(InputRange range,
OutputIterator out,
const Traits& traits);
/*!
\ingroup PkgConvexHull3Functions
\brief copies in `out` the `vertices` on the convex hull of the vertices in `range`.
The type of `vertex` is the PointPropertyMap's key_type.
\tparam InputRange a range of `vertex`, model of `ConstRange`.
Its iterator type is `InputIterator`.
\tparam PointPropertyMap a model of `ReadablePropertyMap` with `vertex` as key_type and
`Traits::Point_3` as value_type.
\tparam OutputIterator must be an output iterator where vertices can be put.
\tparam Traits must be model of the concept `ConvexHullTraits_3`.
If the kernel `R` of the points from `PointPropertyMap`
is a kernel with exact predicates but inexact constructions
(in practice we check `R::Has_filtered_predicates_tag` is `Tag_true` and `R::FT` is a floating point type),
then the default traits class used is `Convex_hull_traits_3<R>`, and `R` otherwise.
@param range the range of input vertices.
@param map the map containing the Vertices and their associated points.
@param out an output iterator where the extreme vertices will be put.
@param traits an instance of `Traits`.
*/
template <class InputRange,
class OutputIterator,
class PointPropertyMap,
class Traits>
OutputIterator
extreme_vertices(const InputRange& range,
PointPropertyMap map,
OutputIterator out,
const Traits& traits);
} /* namespace CGAL */

View File

@ -76,6 +76,7 @@ defining `CGAL_CH_CHECK_EXPENSIVE`.
- `CGAL::convex_hull_3`
- `CGAL::extreme_points_3`
- `CGAL::make_extreme_points_traits_adapter`
## Convexity Checking Function ##

View File

@ -5,4 +5,5 @@
\example Convex_hull_3/quickhull_OM_3.cpp
\example Convex_hull_3/halfspace_intersection_3.cpp
\example Convex_hull_3/quickhull_any_dim_3.cpp
\example Convex_hull_3/extreme_points_3_sm.cpp
*/

View File

@ -64,6 +64,8 @@ create_single_source_cgal_program( "quickhull_3.cpp" )
create_single_source_cgal_program( "quickhull_any_dim_3.cpp" )
create_single_source_cgal_program( "extreme_points_3_sm.cpp" )
if(OpenMesh_FOUND)
create_single_source_cgal_program( "quickhull_OM_3.cpp" )

View File

@ -0,0 +1,40 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Extreme_points_traits_adapter_3.h>
#include <CGAL/convex_hull_3.h>
#include <vector>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_3 Point_3;
typedef CGAL::Surface_mesh<Point_3> SM;
typedef boost::property_map<SM, CGAL::vertex_point_t>::type PMAP;
typedef CGAL::Convex_hull_traits_3<K, SM> Base_traits;
typedef CGAL::Extreme_points_traits_adapter_3<PMAP, Base_traits> Adapter_traits;
int main(int argc, char* argv[])
{
std::ifstream in( (argc>1)? argv[1] : "data/cross.off");
SM sm;
if(! in || !(in >> sm) || !sm.is_valid()){
std::cerr<<"Not a valid off file."<<std::endl;
}
//Define the base ConvexHullTraits
Base_traits b_traits;
//get the vertex property map of the Surface_mesh
PMAP pmap = get(CGAL::vertex_point, sm);
//This will contain the extreme vertices
std::vector<boost::graph_traits<SM>::vertex_descriptor> verts;
//make the adapter traits. You can also directly pass the helper function to extreme_points_3.
Adapter_traits traits = CGAL::make_extreme_points_traits_adapter(pmap, b_traits);
//call the function with the traits adapter for vertices
CGAL::extreme_points_3(vertices(sm), std::back_inserter(verts) ,
traits);
//print the number of extreme vertices
std::cout << "There are " << verts.size() << " extreme vertices in this mesh." << std::endl;
return 0;
}

View File

@ -77,7 +77,11 @@ struct Forward_functor
}
};
}//end Convex_hull_impl
template<class Base_traits,class PointPropertyMap>
template<
class PointPropertyMap,
class Base_traits=internal::Convex_hull_3::Default_traits_for_Chull_3<
typename boost::property_traits<PointPropertyMap>::type>
>
class Extreme_points_traits_adapter_3
:public Base_traits
{
@ -235,6 +239,13 @@ public:
}
};
template<class PointPropertyMap,class Base_traits>
Extreme_points_traits_adapter_3<PointPropertyMap, Base_traits>
make_extreme_points_traits_adapter(const PointPropertyMap& pmap, Base_traits traits)
{
return Extreme_points_traits_adapter_3<PointPropertyMap, Base_traits>(pmap, traits);
}
//helper function
}//end CGAL

View File

@ -68,7 +68,7 @@
namespace CGAL {
// Forward declaration
template<class Base_traits,class VertexPointMap> class Extreme_points_traits_adapter_3;
template<class VertexPointMap,class Base_traits> class Extreme_points_traits_adapter_3;
namespace internal{ namespace Convex_hull_3{
@ -206,10 +206,10 @@ public:
};
template <class Base_traits, class VPM, class Is_CK>
class Is_on_positive_side_of_plane_3< Extreme_points_traits_adapter_3<Base_traits, VPM>, Is_CK>
class Is_on_positive_side_of_plane_3< Extreme_points_traits_adapter_3<VPM,Base_traits>, Is_CK>
: public Is_on_positive_side_of_plane_3< Base_traits >
{
typedef Extreme_points_traits_adapter_3<Base_traits, VPM> Traits;
typedef Extreme_points_traits_adapter_3<VPM, Base_traits> Traits;
typedef Is_on_positive_side_of_plane_3< Base_traits > Base;
typedef typename Traits::Point_3 Point_3;
const Traits& m_traits;
@ -1022,22 +1022,6 @@ void convex_hull_3(InputIterator first, InputIterator beyond,
}
template <class InputRange,
class PointPropertyMap,
class OutputIterator,
class Traits>
OutputIterator
extreme_vertices(const InputRange& range,
PointPropertyMap map,
OutputIterator out,
const Traits& traits)
{
Extreme_points_traits_adapter_3<Traits, PointPropertyMap> traits_adapter(map, traits);
extreme_points_3(range, out,traits_adapter);
return out;
}
template <class InputIterator, class Polyhedron_3>
void convex_hull_3(InputIterator first, InputIterator beyond,
Polyhedron_3& polyhedron)

View File

@ -212,12 +212,19 @@ void test_extreme_vertices(const char* fname)
std::cerr << fname << " is not a valid off file.\n";
exit(1);
}
CGAL::Extreme_points_traits_adapter_3<CGAL::Convex_hull_traits_3<K, Polyhedron_3, CGAL::Tag_true>
,boost::property_map<Polyhedron_3, CGAL::vertex_point_t>::type >
traits(get(CGAL::vertex_point, P));
/*CGAL::Extreme_points_traits_adapter_3<
boost::property_map<Polyhedron_3, CGAL::vertex_point_t>::type
,
CGAL::Convex_hull_traits_3<K, Polyhedron_3, CGAL::Tag_true>
>
traits(get(CGAL::vertex_point, P));*/
CGAL::Convex_hull_traits_3<K, Polyhedron_3, CGAL::Tag_true> traits;
boost::property_map<Polyhedron_3, CGAL::vertex_point_t>::type pmap =
get(CGAL::vertex_point, P);
std::vector<boost::graph_traits<Polyhedron_3>::vertex_descriptor> verts;
CGAL::extreme_points_3(vertices(P), std::back_inserter(verts) ,
traits);
CGAL::make_extreme_points_traits_adapter(pmap, traits));
}
int main()

View File

@ -53,6 +53,10 @@ Release date: September 2018
- Added the function `extreme_points_3()` computing the
points on the convex hull without underlying connectivity.
- Added a traits adapter for `extreme_points_3()` called
`Extreme_points_traits_adapter_3` that permits the use of
the function with something else than just points, if
providing the right property map.
### Point Set Processing