From 2160da4ceb5a29e736816202f526722b5fae334b Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 4 Sep 2015 17:37:36 +0200 Subject: [PATCH] add area function for the complete triangulated Surface use CGAL_PMP_NP_TEMPLATE_PARAMETERS and CGAL_PMP_NP_CLASS to avoid ambiguities --- .../CGAL/Polygon_mesh_processing/measure.h | 54 +++++++++++++++---- .../Polygon_mesh_processing/measures_test.cpp | 5 ++ 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/measure.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/measure.h index cb4c4fdc5a6..aaf7544afdb 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/measure.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/measure.h @@ -29,6 +29,11 @@ #include #include +#ifdef DOXYGEN_RUNNING +#define CGAL_PMP_NP_TEMPLATE_PARAMETERS NamedParameters +#define CGAL_PMP_NP_CLASS NamedParameters +#endif + namespace CGAL { namespace Polygon_mesh_processing { @@ -127,7 +132,8 @@ namespace Polygon_mesh_processing { /** * \ingroup measure_grp - * computes the area of a face of a given polygon mesh. + * computes the area of a face of a given + * triangulated surface mesh. * * @tparam TriangleMesh a model of `HalfedgeGraph` that has an internal property map * for `boost::vertex_point_t` @@ -142,15 +148,15 @@ namespace Polygon_mesh_processing { * \cgalNamedParamsEnd */ template + typename CGAL_PMP_NP_TEMPLATE_PARAMETERS> double area(typename boost::graph_traits::face_descriptor f , const TriangleMesh& tmesh - , const NamedParameters& np) + , const CGAL_PMP_NP_CLASS& np) { using boost::choose_const_pmap; using boost::get_param; - typename GetVertexPointMap::const_type + typename GetVertexPointMap::const_type vpm = choose_const_pmap(get_param(np, CGAL::vertex_point), tmesh, CGAL::vertex_point); @@ -166,15 +172,16 @@ namespace Polygon_mesh_processing { template double area(typename boost::graph_traits::face_descriptor f - , const TriangleMesh& pmesh) + , const TriangleMesh& tmesh) { - return area(f, pmesh, + return area(f, tmesh, CGAL::Polygon_mesh_processing::parameters::all_default()); } /** * \ingroup measure_grp - * computes the area of a range of faces of a given polygon mesh. + * computes the area of a range of faces of a given + * triangulated surface mesh. * * @tparam FaceRange range of `boost::graph_traits::%face_descriptor`, model of `Range`. @@ -193,10 +200,10 @@ namespace Polygon_mesh_processing { */ template + typename CGAL_PMP_NP_TEMPLATE_PARAMETERS> double area(FaceRange face_range , const TriangleMesh& tmesh - , const NamedParameters& np) + , const CGAL_PMP_NP_CLASS& np) { typedef typename boost::graph_traits::face_descriptor face_descriptor; double result = 0.; @@ -214,6 +221,35 @@ namespace Polygon_mesh_processing { CGAL::Polygon_mesh_processing::parameters::all_default()); } + /** + * \ingroup measure_grp + * computes the surface area of a triangulated surface mesh. + * + * @tparam TriangleMesh a model of `HalfedgeGraph` that has an internal property map + * for `boost::vertex_point_t` + * @tparam NamedParameters a sequence of \ref namedparameters + * + * @param tmesh the triangulated surface mesh to which the faces of `face_range` belong + * @param np optional sequence of \ref namedparameters among the ones listed below + * + * \cgalNamedParamsBegin + * \cgalParamBegin{vertex_point_map} the property map with the points associated to the vertices of `pmesh` \cgalParamEnd + * \cgalNamedParamsEnd + */ + template + double area(const TriangleMesh& tmesh + , const CGAL_PMP_NP_CLASS& np) + { + return area(faces(tmesh), tmesh, np); + } + + template + double area(const TriangleMesh& tmesh) + { + return area(faces(tmesh), tmesh); + } + } } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/measures_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/measures_test.cpp index d5c76d1e49d..ba611a8d905 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/measures_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/measures_test.cpp @@ -49,6 +49,9 @@ void test(const Mesh& pmesh) continue; else { + double face_area = PMP::area(face(h, pmesh), pmesh); + std::cout << "face area = " << face_area << std::endl; + patch.push_back(face(h, pmesh)); patch.push_back(face(opposite(h, pmesh), pmesh)); patch.push_back(face(opposite(next(h, pmesh), pmesh), pmesh)); @@ -59,6 +62,8 @@ void test(const Mesh& pmesh) double patch_area = PMP::area(patch, pmesh); std::cout << "patch area = " << patch_area << std::endl; + double mesh_area = PMP::area(pmesh); + std::cout << "mesh area = " << mesh_area << std::endl; } void test_polyhedron(const char* filename)