diff --git a/Polygon_mesh_processing/include/CGAL/Polyhedral_envelope.h b/Polygon_mesh_processing/include/CGAL/Polyhedral_envelope.h index b7efe75ddca..cf721e1fa33 100644 --- a/Polygon_mesh_processing/include/CGAL/Polyhedral_envelope.h +++ b/Polygon_mesh_processing/include/CGAL/Polyhedral_envelope.h @@ -85,7 +85,10 @@ #include #include - +#ifdef DOXYGEN_RUNNING +#define CGAL_PMP_NP_TEMPLATE_PARAMETERS NamedParameters +#define CGAL_PMP_NP_CLASS NamedParameters +#endif namespace CGAL { @@ -2062,15 +2065,21 @@ public: * must be available in `TriangleMesh`.} * \cgalParamNEnd * \cgalNamedParamsEnd + * \todo Add ConcurrencyTag as template parameter + use TBB parallel for + * \todo Find a way to test the containment of the vertices first and then + * the triangles. It requires to have a map vertex->prism id so that + * we can test if the 3 vertices of a face are in the same face + have + * the initial list of prisms. + * \todo apply that to the soup versions */ - template + template bool - operator()(const TriangleMesh& tmesh, const NamedParameters& np) const + operator()(const TriangleMesh& tmesh, const CGAL_PMP_NP_CLASS& np) const { using parameters::choose_parameter; using parameters::get_parameter; - typename GetVertexPointMap::const_type + typename GetVertexPointMap::const_type vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), get_const_property_map(CGAL::vertex_point, tmesh)); @@ -2097,6 +2106,70 @@ public: { return this->operator()(tmesh, parameters::all_default()); } +#endif + + /** + * returns `true`, iff all the triangles in `triangles` are inside the polyhedral envelope. + * + * @tparam PointRange a model of the concept `ConstRange` with `PointRange::const_iterator` + * being a model of `InputIterator` with a point as value type + * @tparam TriangleRange a model of the concept `ConstRange` with `TriangleRange::const_iterator` + * being a model of `InputIterator` whose value type is model of + * the concept `RandomAccessContainer` whose value_type is convertible to `std::size_t`. + * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" + * + * @param points points of the soup of triangles + * @param triangles each element in the range describes a triangle as a triple of indices of the points in `points` + * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below + * + * \cgalNamedParamsBegin + * \cgalParamNBegin{point_map} + * \cgalParamDescription{a property map associating points to the elements of the range `points`} + * \cgalParamType{a model of `ReadablePropertyMap` whose value type is `Point_3` and whose key + * is the value type of `PointRange::const_iterator`} + * \cgalParamDefault{`CGAL::Identity_property_map`} + * \cgalParamNEnd + * \cgalNamedParamsEnd + * + */ + template + bool operator()(const PointRange& points, + const TriangleRange& triangles, + const NamedParameters& np) const + { + using parameters::choose_parameter; + using parameters::get_parameter; + + typedef typename std::iterator_traits::value_type Triangle; + + typedef typename CGAL::GetPointMap::const_type Point_map; + Point_map pm = choose_parameter(get_parameter(np, internal_np::point_map)); + + std::array pts; + + for (const Triangle& f : triangles) + { + typename Triangle::const_iterator t_it = f.begin(); + + if (! this->operator()(get(pm, points[*t_it]), + get(pm, points[*++t_it]), + get(pm, points[*++t_it])) ) + { + return false; + } + } + + return true; + } + +#ifndef DOXYGEN_RUNNING + template + bool operator()(const PointRange& points, + const TriangleRange& triangles) const + { + return this->operator()(points, triangles, parameters::all_default()); + } + #endif /** @@ -2107,14 +2180,14 @@ public: * with `Point_3` as value type. * * @param triangle_range a range of triangles - * \cgalNamedParamsEnd */ template bool - operator()(const TriangleRange& triangle_range, + operator()(const TriangleRange& triangle_range #ifndef DOXYGEN_RUNNING - typename boost::enable_if>::type* = 0) const + , typename boost::enable_if>::type* = 0 #endif + ) const { std::vector triangle; triangle.reserve(3);