From a5f99699e2d43b4373fe14f32e6c8676fdf81f5e Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 18 Jul 2022 16:17:03 +0200 Subject: [PATCH] used a face property map for computing measures, added license will update docs to match void interpolated_corrected_measure_mesh( const PolygonMesh& pmesh, FaceMeasureMap fmm, const Measure_index mu_i, NamedParameters& np = parameters::default_values()) { later if it works --- ...nterpolated_corrected_curvature_measures.h | 54 ++++++++++++++++++ .../interpolated_corrected_curvatures.cpp | 40 ++++---------- ...nterpolated_corrected_curvature_measures.h | 55 ++++++++----------- 3 files changed, 88 insertions(+), 61 deletions(-) create mode 100644 Installation/include/CGAL/license/Polygon_mesh_processing/interpolated_corrected_curvature_measures.h diff --git a/Installation/include/CGAL/license/Polygon_mesh_processing/interpolated_corrected_curvature_measures.h b/Installation/include/CGAL/license/Polygon_mesh_processing/interpolated_corrected_curvature_measures.h new file mode 100644 index 00000000000..15e2a79af8a --- /dev/null +++ b/Installation/include/CGAL/license/Polygon_mesh_processing/interpolated_corrected_curvature_measures.h @@ -0,0 +1,54 @@ +// Copyright (c) 2016 GeometryFactory SARL (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org) +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// +// Author(s) : Andreas Fabri +// +// Warning: this file is generated, see include/CGAL/licence/README.md + +#ifndef CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURE_MEASURES_H +#define CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURE_MEASURES_H + +#include +#include + +#ifdef CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURE_MEASURES_COMMERCIAL_LICENSE + +# if CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURE_MEASURES_COMMERCIAL_LICENSE < CGAL_RELEASE_DATE + +# if defined(CGAL_LICENSE_WARNING) + + CGAL_pragma_warning("Your commercial license for CGAL does not cover " + "this release of the Polygon Mesh Processing - Interpolated Corrected Curvatures package.") +# endif + +# ifdef CGAL_LICENSE_ERROR +# error "Your commercial license for CGAL does not cover this release \ + of the Polygon Mesh Processing - Interpolated Corrected Curvatures package. \ + You get this error, as you defined CGAL_LICENSE_ERROR." +# endif // CGAL_LICENSE_ERROR + +# endif // CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURE_MEASURES_COMMERCIAL_LICENSE < CGAL_RELEASE_DATE + +#else // no CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURE_MEASURES_COMMERCIAL_LICENSE + +# if defined(CGAL_LICENSE_WARNING) + CGAL_pragma_warning("\nThe macro CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURE_MEASURES_COMMERCIAL_LICENSE is not defined." + "\nYou use the CGAL Polygon Mesh Processing - Interpolated Corrected Curvatures package under " + "the terms of the GPLv3+.") +# endif // CGAL_LICENSE_WARNING + +# ifdef CGAL_LICENSE_ERROR +# error "The macro CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURE_MEASURES_COMMERCIAL_LICENSE is not defined.\ + You use the CGAL Polygon Mesh Processing - Interpolated Corrected Curvatures package under the terms of \ + the GPLv3+. You get this error, as you defined CGAL_LICENSE_ERROR." +# endif // CGAL_LICENSE_ERROR + +#endif // no CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURE_MEASURES_COMMERCIAL_LICENSE + +#endif // CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURE_MEASURES_H diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures.cpp index c117e3f817f..8dcf387d0ed 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures.cpp @@ -23,6 +23,7 @@ typedef CGAL::Polyhedron_3 Polyhedron; typedef CGAL::Surface_mesh Mesh; typedef boost::graph_traits::face_descriptor face_descriptor; typedef boost::graph_traits::vertex_descriptor vertex_descriptor; +typedef std::unordered_map FaceMeasureMap_tag; int main(int argc, char* argv[]) @@ -35,41 +36,20 @@ int main(int argc, char* argv[]) std::cerr << "Invalid input file." << std::endl; return EXIT_FAILURE; } - std::unordered_map vnm_vec; - boost::associative_property_map< std::unordered_map> vnm(vnm_vec); + std::unordered_map vnm_init; + boost::associative_property_map< std::unordered_map> vnm(vnm_init); PMP::compute_vertex_normals(g1, vnm); + FaceMeasureMap_tag mu0_init, mu1_init, mu2_init; + boost::associative_property_map mu0_map(mu0_init), mu1_map(mu1_init), mu2_map(mu2_init); - std::vector mu0_map, mu1_map, mu2_map; + PMP::interpolated_corrected_measure_mesh(g1, mu0_map, PMP::MU0_AREA_MEASURE, CGAL::parameters::vertex_normal_map(vnm)); + PMP::interpolated_corrected_measure_mesh(g1, mu1_map, PMP::MU1_MEAN_CURVATURE_MEASURE, CGAL::parameters::vertex_normal_map(vnm)); + PMP::interpolated_corrected_measure_mesh(g1, mu2_map, PMP::MU2_GAUSSIAN_CURVATURE_MEASURE, CGAL::parameters::vertex_normal_map(vnm)); - mu0_map = PMP::interpolated_corrected_measure_mesh(g1, PMP::MU0_AREA_MEASURE, CGAL::parameters::vertex_normal_map(vnm)); - mu1_map = PMP::interpolated_corrected_measure_mesh(g1, PMP::MU1_MEAN_CURVATURE_MEASURE, CGAL::parameters::vertex_normal_map(vnm)); - mu2_map = PMP::interpolated_corrected_measure_mesh(g1, PMP::MU2_GAUSSIAN_CURVATURE_MEASURE, CGAL::parameters::vertex_normal_map(vnm)); - - int n = g1.faces().size(); - - for (int i = 0; i < n; i++) + for (face_descriptor f: g1.faces()) { - std::cout << mu0_map[i] << "\n"; + std::cout << f.idx() << ": " << get(mu0_map, f) << ", " << get(mu1_map, f) << ", " << get(mu2_map, f) << ", " << "\n"; } - - std::cout << "\n"; - - for (int i = 0; i < n; i++) - { - std::cout << mu1_map[i] << "\n"; - } - - std::cout << "\n"; - - for (int i = 0; i < n; i++) - { - std::cout << mu2_map[i] << "\n"; - } - - - CGAL::draw(g1); - - return EXIT_SUCCESS; } diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Curvatures/interpolated_corrected_curvature_measures.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Curvatures/interpolated_corrected_curvature_measures.h index 38fa4bb05bd..6a5c675d4e6 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Curvatures/interpolated_corrected_curvature_measures.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Curvatures/interpolated_corrected_curvature_measures.h @@ -3,6 +3,7 @@ #endif #include +#include #include #include @@ -17,10 +18,10 @@ namespace Polygon_mesh_processing { /*! * \ingroup PMP_corrected_curvatures_grp - * Enumeration type used to specify which measure is computed for the - * interpolated corrected curvature functions. + * Enumeration type used to specify which measure is computed for the + * interpolated corrected curvature functions */ -// enum +// enum enum Measure_index { MU0_AREA_MEASURE, ///< corrected area density of the given face MU1_MEAN_CURVATURE_MEASURE, ///< corrected mean curvature density of the given face @@ -30,7 +31,7 @@ enum Measure_index { /** * \ingroup PMP_corrected_curvatures_grp * -* computes the interpolated corrected measure of a specific triangle. +* computes the interpolated corrected measure of specific triangle. * * @tparam GT is the geometric traits class. * @@ -79,9 +80,9 @@ typename GT::FT interpolated_corrected_measure_triangle(const typename GT::Vecto /** * \ingroup PMP_corrected_curvatures_grp * -* computes the interpolated corrected measure of a specific quad. \n -* Note that the vertices 0 to 3 are ordered like this: \n -* v0 _ v1 \n +* computes the interpolated corrected measure of specific quad +* Note that the vertices 0 to 3 are ordered like this \n +* v0 _ v1 \n * v2 |_| v3 * * @tparam GT is the geometric traits class. @@ -148,7 +149,7 @@ typename GT::FT interpolated_corrected_measure_quad(const typename GT::Vector_3 /** * \ingroup PMP_corrected_curvatures_grp * -* computes the interpolated corrected measure of a specific face. +* computes the interpolated corrected measure of specific face. * * @tparam GT is the geometric traits class. * @@ -208,12 +209,12 @@ typename GT::FT interpolated_corrected_measure_face(const std::vector::%vertex_descriptor` @@ -234,29 +235,27 @@ typename GT::FT interpolated_corrected_measure_face(const std::vector. +* @return a vector of the computed measure on all faces. The return type is a std::vector. * GT is the type of the Geometric Triats deduced from the PolygonMesh and the NamedParameters arguments * This is to be changed later to a property_map. * * @see `interpolated_corrected_measure_face()` */ -template -#ifdef DOXYGEN_RUNNING - std::vector -#else - std::vector::type::FT> -#endif + void interpolated_corrected_measure_mesh( const PolygonMesh& pmesh, + FaceMeasureMap fmm, const Measure_index mu_i, NamedParameters& np = parameters::default_values()) { + typedef GetGeomTraits::type GT; - typedef dynamic_vertex_property_t Vector_map_tag; + typedef dynamic_vertex_property_t Vector_map_tag; typedef typename boost::property_map::type Default_vector_map; typedef typename internal_np::Lookup_named_param_def::face_descriptor face_descriptor; typedef boost::graph_traits::vertex_descriptor vertex_descriptor; typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; @@ -274,16 +272,13 @@ template::const_type vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), get_const_property_map(CGAL::vertex_point, pmesh)); - - VNM vnm = choose_parameter( - get_parameter(np, internal_np::vertex_normal_map), Vector_map_tag(), pmesh); + + // TODO - handle if vnm is not provided + VNM vnm = choose_parameter(get_parameter(np, internal_np::vertex_normal_map), get(Vector_map_tag(), pmesh)); if (is_default_parameter::value) compute_vertex_normals(pmesh, vnm, np); - std::vector mu_i_map; - - for (face_descriptor f : faces(pmesh)) { halfedge_descriptor h_start = pmesh.halfedge(f); @@ -301,10 +296,8 @@ template(x, u, mu_i)); + put(fmm, f, interpolated_corrected_measure_face(x, u, mu_i)); } - return mu_i_map; } } -} \ No newline at end of file +}