From 3463501b4d96b2beccc94f3b2c9ecb07746ed747 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 2 Dec 2020 18:21:11 +0100 Subject: [PATCH] add more operator() --- .../include/CGAL/Polyhedral_envelope.h | 103 +++++++++++++++++- 1 file changed, 98 insertions(+), 5 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polyhedral_envelope.h b/Polygon_mesh_processing/include/CGAL/Polyhedral_envelope.h index 2803287ebc9..0d619eafed5 100644 --- a/Polygon_mesh_processing/include/CGAL/Polyhedral_envelope.h +++ b/Polygon_mesh_processing/include/CGAL/Polyhedral_envelope.h @@ -1945,6 +1945,9 @@ private: public: + /// \name Query Operators + /// @{ + /*! * returns `true`, iff the query point is inside the polyhedral envelope. */ @@ -2011,17 +2014,107 @@ public: // only needed when we want to compare runs with FastEnvelope // std::sort(prismindex.begin(), prismindex.end()); -#ifdef CGAL_ENVELOPE_DEBUG - for(unsigned int i = 0; i < prismindex.size(); i++){ - prism_to_off(prismindex[i], "prism"); - } -#endif if(triangle_out_of_envelope(t0, t1, t2, prismindex)){ return false; } return true; } + /** + * returns `true`, iff all the triangles of `tmesh` are inside the polyhedral envelope. + * @tparam TriangleMesh a model of `FaceListGraph` + * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" + * + * @param tmesh a triangle mesh + * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below + * + * \cgalNamedParamsBegin + * \cgalParamNBegin{vertex_point_map} + * \cgalParamDescription{a property map associating points to the vertices of `tmesh`} + * \cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits::%vertex_descriptor` + * as key type and `%Point_3` as value type} + * \cgalParamDefault{`boost::get(CGAL::vertex_point, tmesh)`} + * \cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t` + * must be available in `TriangleMesh`.} + * \cgalParamNEnd + * \cgalNamedParamsEnd + */ + template + bool + operator()(const TriangleMesh& tmesh, const NamedParameters& np) const + { + using parameters::choose_parameter; + using parameters::get_parameter; + + typename GetVertexPointMap::const_type + vpm = choose_parameter(get_parameter(np, internal_np::vertex_point), + get_const_property_map(CGAL::vertex_point, tmesh)); + + for (typename boost::graph_traits::face_descriptor f : faces(tmesh)) + { + typename boost::graph_traits::halfedge_descriptor h = + halfedge(f, tmesh); + if (! this->operator()(get(vpm, source(h, tmesh)), + get(vpm, target(h, tmesh)), + get(vpm, target(next(h, tmesh), tmesh))) ) + { + return false; + } + } + + return true; + } + +#ifndef DOXYGEN_RUNNING + template + bool + operator()(const TriangleMesh& tmesh, + typename boost::disable_if>::type* = 0) const + { + return this->operator()(tmesh, parameters::all_default()); + } +#endif + + /** + * returns `true`, iff all the triangles in `triangle_range` are inside the polyhedral envelope. + * @tparam TriangleRange a model of `ConstRange` with `ConstRange::const_iterator` + * being a model of `InputIterator` with a value type being itself a model of + * `ConstRange` with `ConstRange::const_iterator` being a model of `InputIterator` + * with `Point_3` as value type. + * + * @param triangle_range a range of triangles + * \cgalNamedParamsEnd + */ + template + bool + operator()(const TriangleRange& triangle_range, +#ifndef DOXYGEN_RUNNING + typename boost::enable_if>::type* = 0) const +#endif + { + std::vector triangle; + triangle.reserve(3); + for (const auto& t : triangle_range) + { + triangle.clear(); + triangle.assign(t.begin(), t.end()); + CGAL_assertion(triangle.size()==3); + if (! this->operator()(t[0], t[1], t[2]) ) + { + return false; + } + } + + return true; + } + + /// @} + + /// returns `true` if the polyhedral envelope is empty and `false` otherwise. + bool empty() const + { + return env_faces.empty(); + } }; // class Polyhedral_envelope