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
This commit is contained in:
hoskillua 2022-07-18 16:17:03 +02:00
parent b1e191212c
commit a5f99699e2
3 changed files with 88 additions and 61 deletions

View File

@ -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 <CGAL/config.h>
#include <CGAL/license.h>
#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

View File

@ -23,6 +23,7 @@ typedef CGAL::Polyhedron_3<Epic> Polyhedron;
typedef CGAL::Surface_mesh<Epic::Point_3> Mesh; typedef CGAL::Surface_mesh<Epic::Point_3> Mesh;
typedef boost::graph_traits<Mesh>::face_descriptor face_descriptor; typedef boost::graph_traits<Mesh>::face_descriptor face_descriptor;
typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor; typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
typedef std::unordered_map<face_descriptor, Epic::FT> FaceMeasureMap_tag;
int main(int argc, char* argv[]) int main(int argc, char* argv[])
@ -35,41 +36,20 @@ int main(int argc, char* argv[])
std::cerr << "Invalid input file." << std::endl; std::cerr << "Invalid input file." << std::endl;
return EXIT_FAILURE; return EXIT_FAILURE;
} }
std::unordered_map<vertex_descriptor, Epic::Vector_3> vnm_vec; std::unordered_map<vertex_descriptor, Epic::Vector_3> vnm_init;
boost::associative_property_map< std::unordered_map<vertex_descriptor, Epic::Vector_3>> vnm(vnm_vec); boost::associative_property_map< std::unordered_map<vertex_descriptor, Epic::Vector_3>> vnm(vnm_init);
PMP::compute_vertex_normals(g1, vnm); PMP::compute_vertex_normals(g1, vnm);
FaceMeasureMap_tag mu0_init, mu1_init, mu2_init;
boost::associative_property_map<FaceMeasureMap_tag> mu0_map(mu0_init), mu1_map(mu1_init), mu2_map(mu2_init);
std::vector<Epic::FT> 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)); for (face_descriptor f: g1.faces())
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++)
{ {
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;
} }

View File

@ -3,6 +3,7 @@
#endif #endif
#include <numeric> #include <numeric>
#include <CGAL/license/Polygon_mesh_processing/interpolated_corrected_curvature_measures.h>
#include <CGAL/assertions.h> #include <CGAL/assertions.h>
#include <CGAL/Named_function_parameters.h> #include <CGAL/Named_function_parameters.h>
@ -17,10 +18,10 @@ namespace Polygon_mesh_processing {
/*! /*!
* \ingroup PMP_corrected_curvatures_grp * \ingroup PMP_corrected_curvatures_grp
* Enumeration type used to specify which measure is computed for the * Enumeration type used to specify which measure is computed for the
* interpolated corrected curvature functions. * interpolated corrected curvature functions
*/ */
// enum // enum
enum Measure_index { enum Measure_index {
MU0_AREA_MEASURE, ///< corrected area density of the given face MU0_AREA_MEASURE, ///< corrected area density of the given face
MU1_MEAN_CURVATURE_MEASURE, ///< corrected mean curvature 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 * \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. * @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 * \ingroup PMP_corrected_curvatures_grp
* *
* computes the interpolated corrected measure of a specific quad. \n * computes the interpolated corrected measure of specific quad
* Note that the vertices 0 to 3 are ordered like this: \n * Note that the vertices 0 to 3 are ordered like this \n
* v0 _ v1 \n * v0 _ v1 \n
* v2 |_| v3 * v2 |_| v3
* *
* @tparam GT is the geometric traits class. * @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 * \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. * @tparam GT is the geometric traits class.
* *
@ -208,12 +209,12 @@ typename GT::FT interpolated_corrected_measure_face(const std::vector<typename G
/** /**
* \ingroup PMP_corrected_curvatures_grp * \ingroup PMP_corrected_curvatures_grp
* *
* computes the interpolated corrected curvature measure on each face of the mesh. * computes the interpolated corrected curvature measure on each face of the mesh
* *
* @tparam PolygonMesh a model of `FaceGraph` * @tparam PolygonMesh a model of `FaceGraph`
* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters"
* *
* @param pmesh the polygon mesh * @param pmesh the polygon mesh
* @param mu_i an enum for choosing between computing the area measure, the mean curvature measure or the gaussian curvature measure * @param mu_i an enum for choosing between computing the area measure, the mean curvature measure or the gaussian curvature measure
* @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below
* *
@ -226,7 +227,7 @@ typename GT::FT interpolated_corrected_measure_face(const std::vector<typename G
* \cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t` * \cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t`
* must be available in `PolygonMesh`.} * must be available in `PolygonMesh`.}
* \cgalParamNEnd * \cgalParamNEnd
* *
* \cgalParamNBegin{vertex_normal_map} * \cgalParamNBegin{vertex_normal_map}
* \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} * \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`}
* \cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits<PolygonMesh>::%vertex_descriptor` * \cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits<PolygonMesh>::%vertex_descriptor`
@ -234,29 +235,27 @@ typename GT::FT interpolated_corrected_measure_face(const std::vector<typename G
* \cgalParamDefault{`TODO`} * \cgalParamDefault{`TODO`}
* \cgalParamExtra{If this parameter is omitted, vertex normals should be computed inside the function body.} * \cgalParamExtra{If this parameter is omitted, vertex normals should be computed inside the function body.}
* \cgalParamNEnd * \cgalParamNEnd
* *
* \cgalNamedParamsEnd * \cgalNamedParamsEnd
* *
* @return a vector of the computed measure on all faces. The return type is a std::vector<GT::FT>. * @return a vector of the computed measure on all faces. The return type is a std::vector<GT::FT>.
* GT is the type of the Geometric Triats deduced from the PolygonMesh and the NamedParameters arguments * 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<face_descriptor, GT::FT>. * This is to be changed later to a property_map<face_descriptor, GT::FT>.
* *
* @see `interpolated_corrected_measure_face()` * @see `interpolated_corrected_measure_face()`
*/ */
template<typename PolygonMesh, template<typename PolygonMesh, typename FaceMeasureMap,
typename NamedParameters = parameters::Default_named_parameters> typename NamedParameters = parameters::Default_named_parameters>
#ifdef DOXYGEN_RUNNING void
std::vector<FT>
#else
std::vector<typename GetGeomTraits<PolygonMesh, NamedParameters>::type::FT>
#endif
interpolated_corrected_measure_mesh( interpolated_corrected_measure_mesh(
const PolygonMesh& pmesh, const PolygonMesh& pmesh,
FaceMeasureMap fmm,
const Measure_index mu_i, const Measure_index mu_i,
NamedParameters& np = parameters::default_values()) NamedParameters& np = parameters::default_values())
{ {
typedef GetGeomTraits<PolygonMesh, NamedParameters>::type GT; typedef GetGeomTraits<PolygonMesh, NamedParameters>::type GT;
typedef dynamic_vertex_property_t<GT::Vector_3> Vector_map_tag; typedef dynamic_vertex_property_t<typename GT::Vector_3> Vector_map_tag;
typedef typename boost::property_map<PolygonMesh, Vector_map_tag>::type Default_vector_map; typedef typename boost::property_map<PolygonMesh, Vector_map_tag>::type Default_vector_map;
typedef typename internal_np::Lookup_named_param_def<internal_np::vertex_normal_map_t, typedef typename internal_np::Lookup_named_param_def<internal_np::vertex_normal_map_t,
NamedParameters, NamedParameters,
@ -266,7 +265,6 @@ template<typename PolygonMesh,
using parameters::get_parameter; using parameters::get_parameter;
using parameters::is_default_parameter; using parameters::is_default_parameter;
typedef boost::graph_traits<PolygonMesh>::face_descriptor face_descriptor; typedef boost::graph_traits<PolygonMesh>::face_descriptor face_descriptor;
typedef boost::graph_traits<PolygonMesh>::vertex_descriptor vertex_descriptor; typedef boost::graph_traits<PolygonMesh>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<PolygonMesh>::halfedge_descriptor halfedge_descriptor; typedef boost::graph_traits<PolygonMesh>::halfedge_descriptor halfedge_descriptor;
@ -274,16 +272,13 @@ template<typename PolygonMesh,
typename GetVertexPointMap<PolygonMesh, NamedParameters>::const_type typename GetVertexPointMap<PolygonMesh, NamedParameters>::const_type
vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), vpm = choose_parameter(get_parameter(np, CGAL::vertex_point),
get_const_property_map(CGAL::vertex_point, pmesh)); get_const_property_map(CGAL::vertex_point, pmesh));
VNM vnm = choose_parameter<Default_vector_map>( // TODO - handle if vnm is not provided
get_parameter(np, internal_np::vertex_normal_map), Vector_map_tag(), pmesh); VNM vnm = choose_parameter(get_parameter(np, internal_np::vertex_normal_map), get(Vector_map_tag(), pmesh));
if (is_default_parameter<NamedParameters, internal_np::vertex_normal_map_t>::value) if (is_default_parameter<NamedParameters, internal_np::vertex_normal_map_t>::value)
compute_vertex_normals(pmesh, vnm, np); compute_vertex_normals(pmesh, vnm, np);
std::vector<GT::FT> mu_i_map;
for (face_descriptor f : faces(pmesh)) for (face_descriptor f : faces(pmesh))
{ {
halfedge_descriptor h_start = pmesh.halfedge(f); halfedge_descriptor h_start = pmesh.halfedge(f);
@ -301,10 +296,8 @@ template<typename PolygonMesh,
h_iter = next(h_iter, pmesh); h_iter = next(h_iter, pmesh);
} while (h_iter != h_start); } while (h_iter != h_start);
put(fmm, f, interpolated_corrected_measure_face<GT>(x, u, mu_i));
mu_i_map.push_back(interpolated_corrected_measure_face<GT>(x, u, mu_i));
} }
return mu_i_map;
} }
} }
} }