From 048d38d18723eadace96d369fbb36f3c09225207 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sun, 10 Jul 2022 03:10:01 +0200 Subject: [PATCH 001/142] interpolated mu i measures (yet to check ) I will replace ExactPredInexactConstructs with a geometry traits template next ISA --- .../interpolated_curvature_measures.h | 88 +++++++++++++++++++ .../Triangulation_2/triangulation_prog1.cpp | 63 ++++++++----- 2 files changed, 131 insertions(+), 20 deletions(-) create mode 100644 Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Curvatures/interpolated_curvature_measures.h diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Curvatures/interpolated_curvature_measures.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Curvatures/interpolated_curvature_measures.h new file mode 100644 index 000000000000..e4f67d03e17a --- /dev/null +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Curvatures/interpolated_curvature_measures.h @@ -0,0 +1,88 @@ +#ifndef CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CURVATURE_MEASURES_H +#define CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CURVATURE_MEASURES_H +#endif + +#include +#include +#include +#include + +namespace CGAL { + +namespace Polygon_mesh_processing { + +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; + +// enum to specify which measure is computed +enum MEASURE_INDEX { + MU0_AREA_MEASURE, + MU1_MEAN_CURVATURE_MEASURE, + MU2_GAUSSIAN_CURVATURE_MEASURE +}; + +Epic::FT interpolated_mu_i_triangle(const Epic::Vector_3 x0, const Epic::Vector_3 x1, const Epic::Vector_3 x2, + const Epic::Vector_3 u0, const Epic::Vector_3 u1, const Epic::Vector_3 u2, MEASURE_INDEX mu_i) +{ + Epic::Vector_3 um; + switch (mu_i) + { + case MU0_AREA_MEASURE: + + um = (u0 + u1 + u2) / 3.0; + + return 0.5 * um * CGAL::cross_product(x1 - x0, x2 - x0); + + case MU1_MEAN_CURVATURE_MEASURE: + + um = (u0 + u1 + u2) / 3.0; + + return 0.5 * um * (CGAL::cross_product(u2 - u1, x0) + + CGAL::cross_product(u0 - u2, x1) + + CGAL::cross_product(u1 - u0, x2)); + + case MU2_GAUSSIAN_CURVATURE_MEASURE: + + return 0.5 * u0 * CGAL::cross_product(u1, u2); + + default: return 0; + } +} + +Epic::FT interpolated_mu_i_face(std::vector& x, std::vector& u, MEASURE_INDEX mu_i) +{ + std::size_t n = x.size(); + CGAL_precondition(u.size() == n); + CGAL_precondition(n >= 3); + + if (n == 3) + return interpolated_mu_i_triangle(x[0], x[1], x[2], + u[0], u[1], u[2], mu_i); + + /// If Quad measure formulas (Bilinear Interpolation) proved to be better, + /// they will be implemented and called here + //else if(n == 4) + // return interpolated_mu0_quad(x[0], x[1], x[2], x[3] + // u[0], u[1], u[2], u[3]); + else { + Epic::FT mu0 = 0; + + // getting barycenter of points + Epic::Vector_3 xm = std::accumulate(x.begin(), x.end(), Epic::Vector_3(0, 0, 0)); + xm /= n; + + // getting unit average normal of points + Epic::Vector_3 um = std::accumulate(u.begin(), u.end(), Epic::Vector_3(0,0,0)); + um /= sqrt(um * um); + + // summing each triangle's measure after triangulation by barycenter split. + for (std::size_t i = 0; i < n; i++) + { + mu0 += interpolated_mu_i_triangle(x[i], x[(i + 1) % n], xm, + u[i], u[(i + 1) % n], um, mu_i); + } + return mu0; + } +} + +} +} diff --git a/Triangulation_2/examples/Triangulation_2/triangulation_prog1.cpp b/Triangulation_2/examples/Triangulation_2/triangulation_prog1.cpp index e68f7973163d..e52400cd5d0c 100644 --- a/Triangulation_2/examples/Triangulation_2/triangulation_prog1.cpp +++ b/Triangulation_2/examples/Triangulation_2/triangulation_prog1.cpp @@ -1,27 +1,50 @@ -#include - #include -#include -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +#include +#include +#include +#include + + +#include +#include +#include +#include +#include + +#define N 4 +namespace PMP = CGAL::Polygon_mesh_processing; -typedef CGAL::Triangulation_2 Triangulation; -typedef Triangulation::Vertex_circulator Vertex_circulator; -typedef Triangulation::Point Point; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; -int main() { - std::ifstream in("data/triangulation_prog1.cin"); - std::istream_iterator begin(in); - std::istream_iterator end; +int main(int argc, char* argv[]) +{ + srand(time(NULL)); - Triangulation t; - t.insert(begin, end); + std::vector X(N); + std::vector U(N); + + for (int i = 0; i < N; i++) { + X[i] = { rand() , rand() , rand() }; + U[i] = { rand() , rand() , rand() }; + U[i] = U[i] / sqrt(U[i] * U[i]); + } + std::cout << PMP::interpolated_mu_i_face(X, U, PMP::MU0_AREA_MEASURE) << std::endl; + std::cout << PMP::interpolated_mu_i_face(X, U, PMP::MU1_MEAN_CURVATURE_MEASURE) << std::endl; + std::cout << PMP::interpolated_mu_i_face(X, U, PMP::MU2_GAUSSIAN_CURVATURE_MEASURE) << std::endl; + + /*srand(time(NULL)); + Epic::Vector_3 x, y; + Epic::FT d = 0; + + Epic::Vector_3 z; + std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now(); + for (int i = 0; i < N; i++) + { + x * y; + } + std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); + std::cout << std::chrono::duration_cast(end - begin).count() << std::endl;*/ - Vertex_circulator vc = t.incident_vertices(t.infinite_vertex()), - done(vc); - if (vc != nullptr) { - do { std::cout << vc->point() << std::endl; - }while(++vc != done); - } - return 0; } + From e63de4f48ae1772992c4c64f158c8c353984e4b1 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Wed, 13 Jul 2022 07:59:21 +0200 Subject: [PATCH 002/142] implemented computing mu_i over all faces it works fine, still need to handle if vnm is not given --- ...nterpolated_corrected_curvature_measures.h | 201 ++++++++++++++++++ .../interpolated_curvature_measures.h | 88 -------- .../Triangulation_2/triangulation_prog1.cpp | 76 ++++++- 3 files changed, 267 insertions(+), 98 deletions(-) create mode 100644 Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Curvatures/interpolated_corrected_curvature_measures.h delete mode 100644 Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Curvatures/interpolated_curvature_measures.h 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 new file mode 100644 index 000000000000..1ebf5fe4dfef --- /dev/null +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Curvatures/interpolated_corrected_curvature_measures.h @@ -0,0 +1,201 @@ +#ifndef CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURE_MEASURES_H +#define CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURE_MEASURES_H +#endif + +#include +#include + +#include +#include +#include +#include +#include + + +namespace CGAL { + + namespace Polygon_mesh_processing { + + typedef Exact_predicates_inexact_constructions_kernel Epic; + + // enum to specify which measure is computed + enum Measure_index { + MU0_AREA_MEASURE, + MU1_MEAN_CURVATURE_MEASURE, + MU2_GAUSSIAN_CURVATURE_MEASURE + }; + + Epic::FT interpolated_mu_i_triangle(const Epic::Vector_3 x0, const Epic::Vector_3 x1, const Epic::Vector_3 x2, + const Epic::Vector_3 u0, const Epic::Vector_3 u1, const Epic::Vector_3 u2, const Measure_index mu_i) + { + Epic::Vector_3 um; + switch (mu_i) + { + case MU0_AREA_MEASURE: + + um = (u0 + u1 + u2) / 3.0; + + return 0.5 * um * CGAL::cross_product(x1 - x0, x2 - x0); + + case MU1_MEAN_CURVATURE_MEASURE: + + um = (u0 + u1 + u2) / 3.0; + + return 0.5 * um * (CGAL::cross_product(u2 - u1, x0) + + CGAL::cross_product(u0 - u2, x1) + + CGAL::cross_product(u1 - u0, x2)); + + case MU2_GAUSSIAN_CURVATURE_MEASURE: + + return 0.5 * u0 * CGAL::cross_product(u1, u2); + + default: return 0; + } + } + + Epic::FT interpolated_mu_i_quad(const Epic::Vector_3 x0, const Epic::Vector_3 x1, const Epic::Vector_3 x2, const Epic::Vector_3 x3, + const Epic::Vector_3 u0, const Epic::Vector_3 u1, const Epic::Vector_3 u2, const Epic::Vector_3 u3, const Measure_index mu_i) + { + /// x0 _ x1 + /// x2 |_| x3 + + switch (mu_i) + { + case MU0_AREA_MEASURE: + + return (1 / 36.0) * ((4 * u0 + 2 * u1 + 2 * u2 + u3) * CGAL::cross_product(x1 - x0, x2 - x0) + + (2 * u0 + 4 * u1 + u2 + 2 * u3) * CGAL::cross_product(x1 - x0, x3 - x1) + + (2 * u0 + u1 + 4 * u2 + 2 * u3) * CGAL::cross_product(x3 - x2, x2 - x0) + + (u0 + 2 * u1 + 2 * u2 + 4 * u3) * CGAL::cross_product(x3 - x2, x3 - x1)); + + case MU1_MEAN_CURVATURE_MEASURE: + { + const Epic::Vector_3 u03 = u3 - u0; + const Epic::Vector_3 u12 = u2 - u1; + const Epic::Vector_3 x0_cross = CGAL::cross_product(u12, x0); + const Epic::Vector_3 x1_cross = -CGAL::cross_product(u03, x1); + const Epic::Vector_3 x2_cross = CGAL::cross_product(u03, x2); + const Epic::Vector_3 x3_cross = -CGAL::cross_product(u12, x3); + + + return (1 / 12.0) * (u0 * (2 * x0_cross - CGAL::cross_product((u2 + u3), x1) + CGAL::cross_product((u1 + u3), x2) + x3_cross) + + u1 * (CGAL::cross_product((u2 + u3), x0) + 2 * x1_cross + x2_cross - CGAL::cross_product((u0 + u2), x3)) + + u2 * (CGAL::cross_product(-(u1 + u3), x0) + x1_cross + 2 * x2_cross + CGAL::cross_product((u0 + u1), x3)) + + u3 * (x0_cross + CGAL::cross_product((u0 + u2), x1) - CGAL::cross_product((u0 + u1), x2) + 2 * x3_cross)); + } + case MU2_GAUSSIAN_CURVATURE_MEASURE: + + return (1 / 36.0) * ((4 * u0 + 2 * u1 + 2 * u2 + u3) * CGAL::cross_product(u1 - u0, u2 - u0) + + (2 * u0 + 4 * u1 + u2 + 2 * u3) * CGAL::cross_product(u1 - u0, u3 - u1) + + (2 * u0 + u1 + 4 * u2 + 2 * u3) * CGAL::cross_product(u3 - u2, u2 - u0) + + (u0 + 2 * u1 + 2 * u2 + 4 * u3) * CGAL::cross_product(u3 - u2, u3 - u1)); + + default: return 0; + } + } + + Epic::FT interpolated_mu_i_face(const std::vector& x, const std::vector& u, const Measure_index mu_i) + { + std::size_t n = x.size(); + CGAL_precondition(u.size() == n); + CGAL_precondition(n >= 3); + + // Triangle: use triangle formulas + if (n == 3) + return interpolated_mu_i_triangle(x[0], x[1], x[2], + u[0], u[1], u[2], mu_i); + + // Quad: use bilinear interpolation formulas + else if (n == 4) + /// x[0] _ x[1] ---> x0 _ x1 (reason for changing order) + /// x[3] |_| x[2] ---> x2 |_| x3 + return interpolated_mu_i_quad(x[0], x[1], x[3], x[2], + u[0], u[1], u[3], u[2], mu_i); + + // N-gon: split into n triangles by barycenter and use triangle formulas for each + else { + Epic::FT mu0 = 0; + + // getting barycenter of points + Epic::Vector_3 xm = std::accumulate(x.begin(), x.end(), Epic::Vector_3(0, 0, 0)); + xm /= n; + + // getting unit average normal of points + Epic::Vector_3 um = std::accumulate(u.begin(), u.end(), Epic::Vector_3(0, 0, 0)); + um /= sqrt(um * um); + + // summing each triangle's measure after triangulation by barycenter split. + for (std::size_t i = 0; i < n; i++) + { + mu0 += interpolated_mu_i_triangle(x[i], x[(i + 1) % n], xm, + u[i], u[(i + 1) % n], um, mu_i); + } + return mu0; + } + } + + + /// TODO: + /// 1- Handle if VNM is not given + /// 2- use GT instead of Epic + + template + std::vector + interpolated_corrected_measure_i( + const PolygonMesh& pmesh, + const Measure_index mu_i, + VertexNormalMap vnm, + const NamedParameters& np = parameters::default_values()) + { + using parameters::choose_parameter; + using parameters::get_parameter; + + typedef boost::graph_traits::face_descriptor face_descriptor; + typedef boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; + + typename GetVertexPointMap::const_type + vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), + get_const_property_map(CGAL::vertex_point, pmesh)); + + //std::unordered_map vnm_init; + + //boost::associative_property_map + // ::vertex_descriptor, Epic::Vector_3>> vnm(vnm_init); + + ////if (!vnm) + // { + // compute_vertex_normals(pmesh, vnm, np); + //} + + std::vector mu_i_map; + + + for (face_descriptor f : faces(pmesh)) + { + halfedge_descriptor h_start = pmesh.halfedge(f); + halfedge_descriptor h_iter = h_start; + + std::vector x; + std::vector u; + + // looping over vertices in face + do { + vertex_descriptor v = source(h_iter, pmesh); + Epic::Point_3 p = get(vpm, v); + x.push_back(Epic::Vector_3(p.x(),p.y(),p.z())); + u.push_back(get(vnm, v)); + h_iter = next(h_iter, pmesh); + } while (h_iter != h_start); + + + mu_i_map.push_back(interpolated_mu_i_face(x, u, mu_i)); + } + return mu_i_map; + } + + } +} + diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Curvatures/interpolated_curvature_measures.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Curvatures/interpolated_curvature_measures.h deleted file mode 100644 index e4f67d03e17a..000000000000 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Curvatures/interpolated_curvature_measures.h +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CURVATURE_MEASURES_H -#define CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CURVATURE_MEASURES_H -#endif - -#include -#include -#include -#include - -namespace CGAL { - -namespace Polygon_mesh_processing { - -typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; - -// enum to specify which measure is computed -enum MEASURE_INDEX { - MU0_AREA_MEASURE, - MU1_MEAN_CURVATURE_MEASURE, - MU2_GAUSSIAN_CURVATURE_MEASURE -}; - -Epic::FT interpolated_mu_i_triangle(const Epic::Vector_3 x0, const Epic::Vector_3 x1, const Epic::Vector_3 x2, - const Epic::Vector_3 u0, const Epic::Vector_3 u1, const Epic::Vector_3 u2, MEASURE_INDEX mu_i) -{ - Epic::Vector_3 um; - switch (mu_i) - { - case MU0_AREA_MEASURE: - - um = (u0 + u1 + u2) / 3.0; - - return 0.5 * um * CGAL::cross_product(x1 - x0, x2 - x0); - - case MU1_MEAN_CURVATURE_MEASURE: - - um = (u0 + u1 + u2) / 3.0; - - return 0.5 * um * (CGAL::cross_product(u2 - u1, x0) - + CGAL::cross_product(u0 - u2, x1) - + CGAL::cross_product(u1 - u0, x2)); - - case MU2_GAUSSIAN_CURVATURE_MEASURE: - - return 0.5 * u0 * CGAL::cross_product(u1, u2); - - default: return 0; - } -} - -Epic::FT interpolated_mu_i_face(std::vector& x, std::vector& u, MEASURE_INDEX mu_i) -{ - std::size_t n = x.size(); - CGAL_precondition(u.size() == n); - CGAL_precondition(n >= 3); - - if (n == 3) - return interpolated_mu_i_triangle(x[0], x[1], x[2], - u[0], u[1], u[2], mu_i); - - /// If Quad measure formulas (Bilinear Interpolation) proved to be better, - /// they will be implemented and called here - //else if(n == 4) - // return interpolated_mu0_quad(x[0], x[1], x[2], x[3] - // u[0], u[1], u[2], u[3]); - else { - Epic::FT mu0 = 0; - - // getting barycenter of points - Epic::Vector_3 xm = std::accumulate(x.begin(), x.end(), Epic::Vector_3(0, 0, 0)); - xm /= n; - - // getting unit average normal of points - Epic::Vector_3 um = std::accumulate(u.begin(), u.end(), Epic::Vector_3(0,0,0)); - um /= sqrt(um * um); - - // summing each triangle's measure after triangulation by barycenter split. - for (std::size_t i = 0; i < n; i++) - { - mu0 += interpolated_mu_i_triangle(x[i], x[(i + 1) % n], xm, - u[i], u[(i + 1) % n], um, mu_i); - } - return mu0; - } -} - -} -} diff --git a/Triangulation_2/examples/Triangulation_2/triangulation_prog1.cpp b/Triangulation_2/examples/Triangulation_2/triangulation_prog1.cpp index e52400cd5d0c..2e625d722cc1 100644 --- a/Triangulation_2/examples/Triangulation_2/triangulation_prog1.cpp +++ b/Triangulation_2/examples/Triangulation_2/triangulation_prog1.cpp @@ -1,25 +1,79 @@ #include +#include +#include +#include +#include -#include -#include -#include -#include +#include - -#include -#include +#include +#include #include #include #include +#include -#define N 4 namespace PMP = CGAL::Polygon_mesh_processing; typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; +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; + + int main(int argc, char* argv[]) { - srand(time(NULL)); + Mesh g1; + if (!PMP::IO::read_polygon_mesh("small_bunny.obj", g1) || !CGAL::is_triangle_mesh(g1)) + { + std::cerr << "Invalid input." << std::endl; + return 1; + } + + //int n1 = g1.size_of_facets(); + + std::unordered_map vnm_vec; + boost::associative_property_map< std::unordered_map> vnm(vnm_vec); + + PMP::compute_vertex_normals(g1, vnm); + + + + std::vector mu0_map, mu1_map, mu2_map; + + mu0_map = PMP::interpolated_corrected_measure_i(g1, PMP::MU0_AREA_MEASURE, vnm); + mu1_map = PMP::interpolated_corrected_measure_i(g1, PMP::MU1_MEAN_CURVATURE_MEASURE, vnm); + mu2_map = PMP::interpolated_corrected_measure_i(g1, PMP::MU2_GAUSSIAN_CURVATURE_MEASURE, vnm); + + int n = g1.faces().size(); + + for (int i = 0; i < n; i++) + { + std::cout << mu0_map[i] << "\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"; + } + + + + + /*srand(time(NULL)); + + CGAL::GetGeomTraits GT; std::vector X(N); std::vector U(N); @@ -29,9 +83,11 @@ int main(int argc, char* argv[]) U[i] = { rand() , rand() , rand() }; U[i] = U[i] / sqrt(U[i] * U[i]); } + + std::cout << PMP::interpolated_mu_i_face(X, U, PMP::MU0_AREA_MEASURE) << std::endl; std::cout << PMP::interpolated_mu_i_face(X, U, PMP::MU1_MEAN_CURVATURE_MEASURE) << std::endl; - std::cout << PMP::interpolated_mu_i_face(X, U, PMP::MU2_GAUSSIAN_CURVATURE_MEASURE) << std::endl; + std::cout << PMP::interpolated_mu_i_face(X, U, PMP::MU2_GAUSSIAN_CURVATURE_MEASURE) << std::endl;*/ /*srand(time(NULL)); Epic::Vector_3 x, y; From 2eeb88ac96cb49755b487cb01a1bfc3fc8f0f1fb Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Fri, 15 Jul 2022 13:18:56 +0200 Subject: [PATCH 003/142] moved my main program to a new example file in PMP --- .../Polygon_mesh_processing/CMakeLists.txt | 12 +- .../interpolated_corrected_curvatures.cpp | 75 +++++++++++ .../Triangulation_2/triangulation_prog1.cpp | 120 +++--------------- 3 files changed, 106 insertions(+), 101 deletions(-) create mode 100644 Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures.cpp diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt index baa4d41677ac..d6f4e273516f 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt @@ -5,11 +5,13 @@ cmake_minimum_required(VERSION 3.1...3.23) project(Polygon_mesh_processing_Examples) # CGAL and its components -find_package(CGAL REQUIRED) +find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) # Boost and its components find_package(Boost REQUIRED) + + if(NOT Boost_FOUND) message( @@ -100,6 +102,14 @@ create_single_source_cgal_program("orientation_pipeline_example.cpp") #create_single_source_cgal_program( "snapping_example.cpp") create_single_source_cgal_program("match_faces.cpp") create_single_source_cgal_program("cc_compatible_orientations.cpp") +create_single_source_cgal_program("interpolated_corrected_curvatures.cpp") + +if(CGAL_Qt5_FOUND) + + #link it with the required CGAL libraries + target_link_libraries(interpolated_corrected_curvatures PUBLIC CGAL::CGAL_Basic_viewer) + +endif() if(OpenMesh_FOUND) 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 new file mode 100644 index 000000000000..f45bec68a03b --- /dev/null +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures.cpp @@ -0,0 +1,75 @@ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace PMP = CGAL::Polygon_mesh_processing; + +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; +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; + + +int main(int argc, char* argv[]) +{ + const std::string filename = (argc>1) ? argv[1] : CGAL::data_file_path("small_bunny.obj"); + + Mesh g1; + if(!CGAL::IO::read_polygon_mesh(filename, g1)) + { + 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); + + PMP::compute_vertex_normals(g1, vnm); + + + std::vector mu0_map, mu1_map, mu2_map; + + mu0_map = PMP::interpolated_corrected_measure_i(g1, PMP::MU0_AREA_MEASURE, CGAL::parameters::vertex_normal_map(vnm)); + mu1_map = PMP::interpolated_corrected_measure_i(g1, PMP::MU1_MEAN_CURVATURE_MEASURE, CGAL::parameters::vertex_normal_map(vnm)); + mu2_map = PMP::interpolated_corrected_measure_i(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 << "\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/Triangulation_2/examples/Triangulation_2/triangulation_prog1.cpp b/Triangulation_2/examples/Triangulation_2/triangulation_prog1.cpp index 2e625d722cc1..86b2c23cb481 100644 --- a/Triangulation_2/examples/Triangulation_2/triangulation_prog1.cpp +++ b/Triangulation_2/examples/Triangulation_2/triangulation_prog1.cpp @@ -1,106 +1,26 @@ -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -namespace PMP = CGAL::Polygon_mesh_processing; - -typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; -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; - - - -int main(int argc, char* argv[]) -{ - Mesh g1; - if (!PMP::IO::read_polygon_mesh("small_bunny.obj", g1) || !CGAL::is_triangle_mesh(g1)) - { - std::cerr << "Invalid input." << std::endl; - return 1; - } - - //int n1 = g1.size_of_facets(); - - std::unordered_map vnm_vec; - boost::associative_property_map< std::unordered_map> vnm(vnm_vec); - - PMP::compute_vertex_normals(g1, vnm); - - - - std::vector mu0_map, mu1_map, mu2_map; - - mu0_map = PMP::interpolated_corrected_measure_i(g1, PMP::MU0_AREA_MEASURE, vnm); - mu1_map = PMP::interpolated_corrected_measure_i(g1, PMP::MU1_MEAN_CURVATURE_MEASURE, vnm); - mu2_map = PMP::interpolated_corrected_measure_i(g1, PMP::MU2_GAUSSIAN_CURVATURE_MEASURE, vnm); +#include - int n = g1.faces().size(); - - for (int i = 0; i < n; i++) - { - std::cout << mu0_map[i] << "\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"; - } - - - - - /*srand(time(NULL)); - - CGAL::GetGeomTraits GT; - - std::vector X(N); - std::vector U(N); - - for (int i = 0; i < N; i++) { - X[i] = { rand() , rand() , rand() }; - U[i] = { rand() , rand() , rand() }; - U[i] = U[i] / sqrt(U[i] * U[i]); - } - +#include +#include - std::cout << PMP::interpolated_mu_i_face(X, U, PMP::MU0_AREA_MEASURE) << std::endl; - std::cout << PMP::interpolated_mu_i_face(X, U, PMP::MU1_MEAN_CURVATURE_MEASURE) << std::endl; - std::cout << PMP::interpolated_mu_i_face(X, U, PMP::MU2_GAUSSIAN_CURVATURE_MEASURE) << std::endl;*/ +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; - /*srand(time(NULL)); - Epic::Vector_3 x, y; - Epic::FT d = 0; +typedef CGAL::Triangulation_2 Triangulation; +typedef Triangulation::Vertex_circulator Vertex_circulator; +typedef Triangulation::Point Point; - Epic::Vector_3 z; - std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now(); - for (int i = 0; i < N; i++) - { - x * y; - } - std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now(); - std::cout << std::chrono::duration_cast(end - begin).count() << std::endl;*/ +int main() { + std::ifstream in("data/triangulation_prog1.cin"); + std::istream_iterator begin(in); + std::istream_iterator end; -} + Triangulation t; + t.insert(begin, end); + Vertex_circulator vc = t.incident_vertices(t.infinite_vertex()), + done(vc); + if (vc != nullptr) { + do { std::cout << vc->point() << std::endl; + }while(++vc != done); + } + return 0; \ No newline at end of file From 5af7795d9450ed2ff27e954b23cf65cfb3524cf5 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Fri, 15 Jul 2022 16:47:44 +0200 Subject: [PATCH 004/142] typo fix --- .../examples/Triangulation_2/triangulation_prog1.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Triangulation_2/examples/Triangulation_2/triangulation_prog1.cpp b/Triangulation_2/examples/Triangulation_2/triangulation_prog1.cpp index 86b2c23cb481..b212837b4ee2 100644 --- a/Triangulation_2/examples/Triangulation_2/triangulation_prog1.cpp +++ b/Triangulation_2/examples/Triangulation_2/triangulation_prog1.cpp @@ -23,4 +23,5 @@ int main() { do { std::cout << vc->point() << std::endl; }while(++vc != done); } - return 0; \ No newline at end of file + return 0; +} \ No newline at end of file From 8c943fd433b4d3ce1390aa4802847a6a851d584c Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Fri, 15 Jul 2022 17:23:13 +0200 Subject: [PATCH 005/142] typo fix --- .../examples/Triangulation_2/triangulation_prog1.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Triangulation_2/examples/Triangulation_2/triangulation_prog1.cpp b/Triangulation_2/examples/Triangulation_2/triangulation_prog1.cpp index b212837b4ee2..e68f7973163d 100644 --- a/Triangulation_2/examples/Triangulation_2/triangulation_prog1.cpp +++ b/Triangulation_2/examples/Triangulation_2/triangulation_prog1.cpp @@ -24,4 +24,4 @@ int main() { }while(++vc != done); } return 0; -} \ No newline at end of file +} From 4b0577a2cff9d47e99577701eae6c3e085cc14c4 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sun, 17 Jul 2022 18:46:04 +0200 Subject: [PATCH 006/142] added doc (yet to build), used generic GT instead of Epic, made VNM a named parameter (WIP) --- .../PackageDescription.txt | 4 + .../doc/Polygon_mesh_processing/examples.txt | 1 + .../interpolated_corrected_curvatures.cpp | 6 +- ...nterpolated_corrected_curvature_measures.h | 422 +++++++++++------- 4 files changed, 271 insertions(+), 162 deletions(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt index 34d2f83f08e2..9f6d7ffd4736 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt @@ -16,6 +16,10 @@ /// Functions to triangulate faces, and to refine and fair regions of a polygon mesh. /// \ingroup PkgPolygonMeshProcessingRef +/// \defgroup PMP_corrected_curvatures_grp Corrected Curvature Computation +/// Functions to compute the corrected curvatures of a polygon mesh. +/// \ingroup PkgPolygonMeshProcessingRef + /// \defgroup PMP_normal_grp Normal Computation /// Functions to compute unit normals for individual/all vertices or faces. /// \ingroup PkgPolygonMeshProcessingRef diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt index 3ce5384c81ce..0317812aa443 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt @@ -19,6 +19,7 @@ \example Polygon_mesh_processing/refine_fair_example.cpp \example Polygon_mesh_processing/mesh_slicer_example.cpp \example Polygon_mesh_processing/isotropic_remeshing_example.cpp +\example Polygon_mesh_processing/interpolated_corrected_curvatures.cpp \example Polygon_mesh_processing/delaunay_remeshing_example.cpp \example Polygon_mesh_processing/compute_normals_example_Polyhedron.cpp \example Polygon_mesh_processing/hausdorff_distance_remeshing_example.cpp 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 f45bec68a03b..c117e3f817fe 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 @@ -43,9 +43,9 @@ int main(int argc, char* argv[]) std::vector mu0_map, mu1_map, mu2_map; - mu0_map = PMP::interpolated_corrected_measure_i(g1, PMP::MU0_AREA_MEASURE, CGAL::parameters::vertex_normal_map(vnm)); - mu1_map = PMP::interpolated_corrected_measure_i(g1, PMP::MU1_MEAN_CURVATURE_MEASURE, CGAL::parameters::vertex_normal_map(vnm)); - mu2_map = PMP::interpolated_corrected_measure_i(g1, 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(); 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 1ebf5fe4dfef..df5197b2f005 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 @@ -2,7 +2,6 @@ #define CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURE_MEASURES_H #endif -#include #include #include @@ -14,188 +13,293 @@ namespace CGAL { - namespace Polygon_mesh_processing { - - typedef Exact_predicates_inexact_constructions_kernel Epic; - - // enum to specify which measure is computed - enum Measure_index { - MU0_AREA_MEASURE, - MU1_MEAN_CURVATURE_MEASURE, - MU2_GAUSSIAN_CURVATURE_MEASURE - }; - - Epic::FT interpolated_mu_i_triangle(const Epic::Vector_3 x0, const Epic::Vector_3 x1, const Epic::Vector_3 x2, - const Epic::Vector_3 u0, const Epic::Vector_3 u1, const Epic::Vector_3 u2, const Measure_index mu_i) - { - Epic::Vector_3 um; - switch (mu_i) - { - case MU0_AREA_MEASURE: - - um = (u0 + u1 + u2) / 3.0; +namespace Polygon_mesh_processing { + +// enum to specify which measure is computed +enum Measure_index { + MU0_AREA_MEASURE, + MU1_MEAN_CURVATURE_MEASURE, + MU2_GAUSSIAN_CURVATURE_MEASURE +}; + +/** +* \ingroup PMP_corrected_curvatures_grp +* +* computes the interpolated corrected measure of specific triangle. +* +* @tparam GT is the geometric traits class. +* +* @param x0 is the position of vertex #0. +* @param x1 is the position of vertex #1. +* @param x2 is the position of vertex #2. +* @param u0 is the normal vector of vertex #0. +* @param u1 is the normal vector of vertex #1. +* @param u2 is the normal vector of vertex #2. +* @param mu_i an enum for choosing between computing the area measure, +* the mean curvature measure, or the gaussian curvature measure. +* +* @return a scalar of type GT::FT. This is the value of the interpolated corrected measure of the given triangle. +* +* @see `interpolated_corrected_measure_face()` +* @see `interpolated_corrected_measure_quad()` +*/ +template +typename GT::FT interpolated_corrected_measure_triangle(const typename GT::Vector_3 x0, const typename GT::Vector_3 x1, const typename GT::Vector_3 x2, + const typename GT::Vector_3 u0, const typename GT::Vector_3 u1, const typename GT::Vector_3 u2, const Measure_index mu_i) +{ + switch (mu_i) + { + case MU0_AREA_MEASURE: + { + const typename GT::Vector_3 um = (u0 + u1 + u2) / 3.0; + + return 0.5 * um * CGAL::cross_product(x1 - x0, x2 - x0); + } + case MU1_MEAN_CURVATURE_MEASURE: + { + const typename GT::Vector_3 um = (u0 + u1 + u2) / 3.0; - return 0.5 * um * CGAL::cross_product(x1 - x0, x2 - x0); + return 0.5 * um * (CGAL::cross_product(u2 - u1, x0) + + CGAL::cross_product(u0 - u2, x1) + + CGAL::cross_product(u1 - u0, x2)); + } + case MU2_GAUSSIAN_CURVATURE_MEASURE: - case MU1_MEAN_CURVATURE_MEASURE: + return 0.5 * u0 * CGAL::cross_product(u1, u2); - um = (u0 + u1 + u2) / 3.0; + default: return 0; + } +} - return 0.5 * um * (CGAL::cross_product(u2 - u1, x0) - + CGAL::cross_product(u0 - u2, x1) - + CGAL::cross_product(u1 - u0, x2)); +/** +* \ingroup PMP_corrected_curvatures_grp +* +* 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. +* +* @param x0 is the position of vertex #0. +* @param x1 is the position of vertex #1. +* @param x2 is the position of vertex #2. +* @param x3 is the position of vertex #3. +* @param u0 is the normal vector of vertex #0. +* @param u1 is the normal vector of vertex #1. +* @param u2 is the normal vector of vertex #2. +* @param u3 is the normal vector of vertex #3. +* @param mu_i an enum for choosing between computing the area measure, +* the mean curvature measure, or the gaussian curvature measure. +* +* @return a scalar of type GT::FT. This is the value of the interpolated corrected measure of the given triangle. +* +* @see `interpolated_corrected_measure_face()` +* @see `interpolated_corrected_measure_quad()` +*/ +template +typename GT::FT interpolated_corrected_measure_quad(const typename GT::Vector_3 x0, const typename GT::Vector_3 x1, const typename GT::Vector_3 x2, const typename GT::Vector_3 x3, + const typename GT::Vector_3 u0, const typename GT::Vector_3 u1, const typename GT::Vector_3 u2, const typename GT::Vector_3 u3, const Measure_index mu_i) +{ + /// x0 _ x1 + /// x2 |_| x3 + + switch (mu_i) + { + case MU0_AREA_MEASURE: + + return (1 / 36.0) * ((4 * u0 + 2 * u1 + 2 * u2 + u3) * CGAL::cross_product(x1 - x0, x2 - x0) + + (2 * u0 + 4 * u1 + u2 + 2 * u3) * CGAL::cross_product(x1 - x0, x3 - x1) + + (2 * u0 + u1 + 4 * u2 + 2 * u3) * CGAL::cross_product(x3 - x2, x2 - x0) + + (u0 + 2 * u1 + 2 * u2 + 4 * u3) * CGAL::cross_product(x3 - x2, x3 - x1)); + + case MU1_MEAN_CURVATURE_MEASURE: + { + const typename GT::Vector_3 u03 = u3 - u0; + const typename GT::Vector_3 u12 = u2 - u1; + const typename GT::Vector_3 x0_cross = CGAL::cross_product(u12, x0); + const typename GT::Vector_3 x1_cross = -CGAL::cross_product(u03, x1); + const typename GT::Vector_3 x2_cross = CGAL::cross_product(u03, x2); + const typename GT::Vector_3 x3_cross = -CGAL::cross_product(u12, x3); + + + return (1 / 12.0) * (u0 * (2 * x0_cross - CGAL::cross_product((u2 + u3), x1) + CGAL::cross_product((u1 + u3), x2) + x3_cross) + + u1 * (CGAL::cross_product((u2 + u3), x0) + 2 * x1_cross + x2_cross - CGAL::cross_product((u0 + u2), x3)) + + u2 * (CGAL::cross_product(-(u1 + u3), x0) + x1_cross + 2 * x2_cross + CGAL::cross_product((u0 + u1), x3)) + + u3 * (x0_cross + CGAL::cross_product((u0 + u2), x1) - CGAL::cross_product((u0 + u1), x2) + 2 * x3_cross)); + } + case MU2_GAUSSIAN_CURVATURE_MEASURE: - case MU2_GAUSSIAN_CURVATURE_MEASURE: + return (1 / 36.0) * ((4 * u0 + 2 * u1 + 2 * u2 + u3) * CGAL::cross_product(u1 - u0, u2 - u0) + + (2 * u0 + 4 * u1 + u2 + 2 * u3) * CGAL::cross_product(u1 - u0, u3 - u1) + + (2 * u0 + u1 + 4 * u2 + 2 * u3) * CGAL::cross_product(u3 - u2, u2 - u0) + + (u0 + 2 * u1 + 2 * u2 + 4 * u3) * CGAL::cross_product(u3 - u2, u3 - u1)); - return 0.5 * u0 * CGAL::cross_product(u1, u2); + default: return 0; + } +} - default: return 0; - } - } - Epic::FT interpolated_mu_i_quad(const Epic::Vector_3 x0, const Epic::Vector_3 x1, const Epic::Vector_3 x2, const Epic::Vector_3 x3, - const Epic::Vector_3 u0, const Epic::Vector_3 u1, const Epic::Vector_3 u2, const Epic::Vector_3 u3, const Measure_index mu_i) +/** +* \ingroup PMP_corrected_curvatures_grp +* +* computes the interpolated corrected measure of specific face. +* +* @tparam GT is the geometric traits class. +* +* @param x is a vector of the vertex positions of the face. +* @param u is a vector of the vertex nomrals of the face. +* @param mu_i an enum for choosing between computing the area measure, +* the mean curvature measure, or the gaussian curvature measure. +* +* @return a scalar of type GT::FT. This is the value of the interpolated corrected measure of the given face. +* +* @see `interpolated_corrected_measure_triangle()` +* @see `interpolated_corrected_measure_quad()` +* @see `interpolated_corrected_measure_mesh()` +*/ +template +typename GT::FT interpolated_corrected_measure_face(const std::vector& x, const std::vector& u, const Measure_index mu_i) +{ + std::size_t n = x.size(); + CGAL_precondition(u.size() == n); + CGAL_precondition(n >= 3); + + // Triangle: use triangle formulas + if (n == 3) + return interpolated_corrected_measure_triangle(x[0], x[1], x[2], + u[0], u[1], u[2], mu_i); + + // Quad: use bilinear interpolation formulas + else if (n == 4) + /// x[0] _ x[1] ---> x0 _ x1 (reason for changing order) + /// x[3] |_| x[2] ---> x2 |_| x3 + return interpolated_corrected_measure_quad(x[0], x[1], x[3], x[2], + u[0], u[1], u[3], u[2], mu_i); + + // N-gon: split into n triangles by barycenter and use triangle formulas for each + else { + typename GT::FT mu0 = 0; + + // getting barycenter of points + typename GT::Vector_3 xm = std::accumulate(x.begin(), x.end(), GT::Vector_3(0, 0, 0)); + xm /= n; + + // getting unit average normal of points + typename GT::Vector_3 um = std::accumulate(u.begin(), u.end(), GT::Vector_3(0, 0, 0)); + um /= sqrt(um * um); + + // summing each triangle's measure after triangulation by barycenter split. + for (std::size_t i = 0; i < n; i++) { - /// x0 _ x1 - /// x2 |_| x3 - - switch (mu_i) - { - case MU0_AREA_MEASURE: - - return (1 / 36.0) * ((4 * u0 + 2 * u1 + 2 * u2 + u3) * CGAL::cross_product(x1 - x0, x2 - x0) - + (2 * u0 + 4 * u1 + u2 + 2 * u3) * CGAL::cross_product(x1 - x0, x3 - x1) - + (2 * u0 + u1 + 4 * u2 + 2 * u3) * CGAL::cross_product(x3 - x2, x2 - x0) - + (u0 + 2 * u1 + 2 * u2 + 4 * u3) * CGAL::cross_product(x3 - x2, x3 - x1)); - - case MU1_MEAN_CURVATURE_MEASURE: - { - const Epic::Vector_3 u03 = u3 - u0; - const Epic::Vector_3 u12 = u2 - u1; - const Epic::Vector_3 x0_cross = CGAL::cross_product(u12, x0); - const Epic::Vector_3 x1_cross = -CGAL::cross_product(u03, x1); - const Epic::Vector_3 x2_cross = CGAL::cross_product(u03, x2); - const Epic::Vector_3 x3_cross = -CGAL::cross_product(u12, x3); - - - return (1 / 12.0) * (u0 * (2 * x0_cross - CGAL::cross_product((u2 + u3), x1) + CGAL::cross_product((u1 + u3), x2) + x3_cross) - + u1 * (CGAL::cross_product((u2 + u3), x0) + 2 * x1_cross + x2_cross - CGAL::cross_product((u0 + u2), x3)) - + u2 * (CGAL::cross_product(-(u1 + u3), x0) + x1_cross + 2 * x2_cross + CGAL::cross_product((u0 + u1), x3)) - + u3 * (x0_cross + CGAL::cross_product((u0 + u2), x1) - CGAL::cross_product((u0 + u1), x2) + 2 * x3_cross)); - } - case MU2_GAUSSIAN_CURVATURE_MEASURE: - - return (1 / 36.0) * ((4 * u0 + 2 * u1 + 2 * u2 + u3) * CGAL::cross_product(u1 - u0, u2 - u0) - + (2 * u0 + 4 * u1 + u2 + 2 * u3) * CGAL::cross_product(u1 - u0, u3 - u1) - + (2 * u0 + u1 + 4 * u2 + 2 * u3) * CGAL::cross_product(u3 - u2, u2 - u0) - + (u0 + 2 * u1 + 2 * u2 + 4 * u3) * CGAL::cross_product(u3 - u2, u3 - u1)); - - default: return 0; - } + mu0 += interpolated_corrected_measure_triangle(x[i], x[(i + 1) % n], xm, + u[i], u[(i + 1) % n], um, mu_i); } + return mu0; + } +} - Epic::FT interpolated_mu_i_face(const std::vector& x, const std::vector& u, const Measure_index mu_i) - { - std::size_t n = x.size(); - CGAL_precondition(u.size() == n); - CGAL_precondition(n >= 3); - - // Triangle: use triangle formulas - if (n == 3) - return interpolated_mu_i_triangle(x[0], x[1], x[2], - u[0], u[1], u[2], mu_i); - - // Quad: use bilinear interpolation formulas - else if (n == 4) - /// x[0] _ x[1] ---> x0 _ x1 (reason for changing order) - /// x[3] |_| x[2] ---> x2 |_| x3 - return interpolated_mu_i_quad(x[0], x[1], x[3], x[2], - u[0], u[1], u[3], u[2], mu_i); - - // N-gon: split into n triangles by barycenter and use triangle formulas for each - else { - Epic::FT mu0 = 0; - - // getting barycenter of points - Epic::Vector_3 xm = std::accumulate(x.begin(), x.end(), Epic::Vector_3(0, 0, 0)); - xm /= n; - - // getting unit average normal of points - Epic::Vector_3 um = std::accumulate(u.begin(), u.end(), Epic::Vector_3(0, 0, 0)); - um /= sqrt(um * um); - - // summing each triangle's measure after triangulation by barycenter split. - for (std::size_t i = 0; i < n; i++) - { - mu0 += interpolated_mu_i_triangle(x[i], x[(i + 1) % n], xm, - u[i], u[(i + 1) % n], um, mu_i); - } - return mu0; - } - } - - /// TODO: - /// 1- Handle if VNM is not given - /// 2- use GT instead of Epic - - template - std::vector - interpolated_corrected_measure_i( - const PolygonMesh& pmesh, - const Measure_index mu_i, - VertexNormalMap vnm, - const NamedParameters& np = parameters::default_values()) - { - using parameters::choose_parameter; - using parameters::get_parameter; +/** +* \ingroup PMP_corrected_curvatures_grp +* +* computes the interpolated corrected curvature measure on each face of the mesh +* +* @tparam PolygonMesh a model of `FaceGraph` +* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" +* +* @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 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 `pmesh`} +* \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, pmesh)`} +* \cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t` +* must be available in `PolygonMesh`.} +* \cgalParamNEnd +* +* \cgalParamNBegin{vertex_normal_map} +* \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} +* \cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits::%vertex_descriptor` +* as key type and `%Vector_3` as value type} +* \cgalParamDefault{`TODO`} +* \cgalParamExtra{If this parameter is omitted, vertex normals should be computed inside the function body.} +* \cgalParamNEnd +* +* \cgalNamedParamsEnd +* +* @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 + interpolated_corrected_measure_mesh( + const PolygonMesh& pmesh, + const Measure_index mu_i, + NamedParameters& np = parameters::default_values()) +{ + typedef GetGeomTraits::type GT; + 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::type VNM; - typedef boost::graph_traits::face_descriptor face_descriptor; - typedef boost::graph_traits::vertex_descriptor vertex_descriptor; - typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; + using parameters::choose_parameter; + using parameters::get_parameter; + using parameters::is_default_parameter; - typename GetVertexPointMap::const_type - vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), - get_const_property_map(CGAL::vertex_point, pmesh)); - //std::unordered_map vnm_init; + typedef boost::graph_traits::face_descriptor face_descriptor; + typedef boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; - //boost::associative_property_map - // ::vertex_descriptor, Epic::Vector_3>> vnm(vnm_init); + typename GetVertexPointMap::const_type + vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), + get_const_property_map(CGAL::vertex_point, pmesh)); - ////if (!vnm) - // { - // compute_vertex_normals(pmesh, vnm, np); - //} + VNM vnm = choose_parameter( + get_parameter(np, internal_np::vertex_normal_map), Vector_map_tag(), pmesh); - std::vector mu_i_map; + 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); - halfedge_descriptor h_iter = h_start; - std::vector x; - std::vector u; + for (face_descriptor f : faces(pmesh)) + { + halfedge_descriptor h_start = pmesh.halfedge(f); + halfedge_descriptor h_iter = h_start; - // looping over vertices in face - do { - vertex_descriptor v = source(h_iter, pmesh); - Epic::Point_3 p = get(vpm, v); - x.push_back(Epic::Vector_3(p.x(),p.y(),p.z())); - u.push_back(get(vnm, v)); - h_iter = next(h_iter, pmesh); - } while (h_iter != h_start); + std::vector x; + std::vector u; + // looping over vertices in face + do { + vertex_descriptor v = source(h_iter, pmesh); + GT::Point_3 p = get(vpm, v); + x.push_back(GT::Vector_3(p.x(),p.y(),p.z())); + u.push_back(get(vnm, v)); + h_iter = next(h_iter, pmesh); + } while (h_iter != h_start); - mu_i_map.push_back(interpolated_mu_i_face(x, u, mu_i)); - } - return mu_i_map; - } + mu_i_map.push_back(interpolated_corrected_measure_face(x, u, mu_i)); } + return mu_i_map; } - +} +} \ No newline at end of file From c3d654b2c372ae23c135d0641faab1edd099c772 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 18 Jul 2022 02:44:14 +0200 Subject: [PATCH 007/142] add documentation for enum --- ...nterpolated_corrected_curvature_measures.h | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) 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 df5197b2f005..0b164f2d8509 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 @@ -15,11 +15,16 @@ namespace CGAL { namespace Polygon_mesh_processing { -// enum to specify which measure is computed +/*! + * \ingroup PMP_corrected_curvatures_grp + * Enumeration type used to specify which measure is computed for the + * interpolated corrected curvature functions + */ +// enum enum Measure_index { - MU0_AREA_MEASURE, - MU1_MEAN_CURVATURE_MEASURE, - MU2_GAUSSIAN_CURVATURE_MEASURE + MU0_AREA_MEASURE, ///< corrected area density of the given face + MU1_MEAN_CURVATURE_MEASURE, ///< corrected mean curvature density of the given face + MU2_GAUSSIAN_CURVATURE_MEASURE ///< corrected gaussian curvature density of the given face }; /** @@ -101,8 +106,8 @@ template typename GT::FT interpolated_corrected_measure_quad(const typename GT::Vector_3 x0, const typename GT::Vector_3 x1, const typename GT::Vector_3 x2, const typename GT::Vector_3 x3, const typename GT::Vector_3 u0, const typename GT::Vector_3 u1, const typename GT::Vector_3 u2, const typename GT::Vector_3 u3, const Measure_index mu_i) { - /// x0 _ x1 - /// x2 |_| x3 + // x0 _ x1 + // x2 |_| x3 switch (mu_i) { @@ -172,8 +177,8 @@ typename GT::FT interpolated_corrected_measure_face(const std::vector x0 _ x1 (reason for changing order) - /// x[3] |_| x[2] ---> x2 |_| x3 + // x[0] _ x[1] ---> x0 _ x1 (reason for changing order) + // x[3] |_| x[2] ---> x2 |_| x3 return interpolated_corrected_measure_quad(x[0], x[1], x[3], x[2], u[0], u[1], u[3], u[2], mu_i); From e1961c4340bef283b3b4c27afaceecdd89d3c01a Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 18 Jul 2022 02:48:52 +0200 Subject: [PATCH 008/142] minor doc fix --- .../Curvatures/interpolated_corrected_curvature_measures.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 0b164f2d8509..cf6ca10fc8ec 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 @@ -100,7 +100,7 @@ typename GT::FT interpolated_corrected_measure_triangle(const typename GT::Vecto * @return a scalar of type GT::FT. This is the value of the interpolated corrected measure of the given triangle. * * @see `interpolated_corrected_measure_face()` -* @see `interpolated_corrected_measure_quad()` +* @see `interpolated_corrected_measure_triangle()` */ template typename GT::FT interpolated_corrected_measure_quad(const typename GT::Vector_3 x0, const typename GT::Vector_3 x1, const typename GT::Vector_3 x2, const typename GT::Vector_3 x3, From 138f1ea831d9138f008bcb88e0d0db8f7dd26f5b Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 18 Jul 2022 03:31:49 +0200 Subject: [PATCH 009/142] added to reference manual page --- .../doc/Polygon_mesh_processing/PackageDescription.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt index 9f6d7ffd4736..c25cfb8490d3 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt @@ -200,6 +200,12 @@ The page \ref bgl_namedparameters "Named Parameters" describes their usage. - \link PMP_locate_grp Nearest Face Location Queries \endlink - \link PMP_locate_grp Random Location Generation \endlink +\cgalCRPSection{Corrected Curvature Functions} +- `CGAL::Polygon_mesh_processing::interpolated_corrected_measure_mesh()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_measure_face()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_measure_triangle()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_measure_quad()` + \cgalCRPSection{Normal Computation Functions} - `CGAL::Polygon_mesh_processing::compute_face_normal()` - `CGAL::Polygon_mesh_processing::compute_face_normals()` From b1e191212c8d727180e0614ceae545acc8527b9f Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 18 Jul 2022 04:35:21 +0200 Subject: [PATCH 010/142] doc typos --- .../interpolated_corrected_curvature_measures.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 cf6ca10fc8ec..38fa4bb05bd8 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 @@ -18,7 +18,7 @@ namespace Polygon_mesh_processing { /*! * \ingroup PMP_corrected_curvatures_grp * Enumeration type used to specify which measure is computed for the - * interpolated corrected curvature functions + * interpolated corrected curvature functions. */ // enum enum Measure_index { @@ -30,7 +30,7 @@ enum Measure_index { /** * \ingroup PMP_corrected_curvatures_grp * -* computes the interpolated corrected measure of specific triangle. +* computes the interpolated corrected measure of a specific triangle. * * @tparam GT is the geometric traits class. * @@ -79,8 +79,8 @@ typename GT::FT interpolated_corrected_measure_triangle(const typename GT::Vecto /** * \ingroup PMP_corrected_curvatures_grp * -* computes the interpolated corrected measure of specific quad -* Note that the vertices 0 to 3 are ordered like this \n +* 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 * v2 |_| v3 * @@ -148,7 +148,7 @@ typename GT::FT interpolated_corrected_measure_quad(const typename GT::Vector_3 /** * \ingroup PMP_corrected_curvatures_grp * -* computes the interpolated corrected measure of specific face. +* computes the interpolated corrected measure of a specific face. * * @tparam GT is the geometric traits class. * @@ -208,7 +208,7 @@ typename GT::FT interpolated_corrected_measure_face(const std::vector Date: Mon, 18 Jul 2022 16:17:03 +0200 Subject: [PATCH 011/142] 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 000000000000..15e2a79af8a9 --- /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 c117e3f817fe..8dcf387d0ed5 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 38fa4bb05bd8..6a5c675d4e69 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 +} From a54033c0c9211b9c9c42b8eeb6ec6f3f7fa86dfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 18 Jul 2022 16:32:33 +0200 Subject: [PATCH 012/142] add a couple of missing const and typename --- ...nterpolated_corrected_curvature_measures.h | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) 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 6a5c675d4e69..46b2f5c01fcc 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 @@ -188,11 +188,11 @@ typename GT::FT interpolated_corrected_measure_face(const std::vector::type GT; + typedef typename GetGeomTraits::type GT; typedef dynamic_vertex_property_t Vector_map_tag; - typedef typename boost::property_map::type Default_vector_map; + typedef typename boost::property_map::const_type Default_vector_map; typedef typename internal_np::Lookup_named_param_def::type VNM; @@ -265,9 +265,9 @@ template::face_descriptor face_descriptor; - typedef boost::graph_traits::vertex_descriptor vertex_descriptor; - typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; + typedef typename boost::graph_traits::face_descriptor face_descriptor; + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typename GetVertexPointMap::const_type vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), @@ -284,14 +284,14 @@ template x; - std::vector u; + std::vector x; + std::vector u; // looping over vertices in face do { vertex_descriptor v = source(h_iter, pmesh); - GT::Point_3 p = get(vpm, v); - x.push_back(GT::Vector_3(p.x(),p.y(),p.z())); + typename GT::Point_3 p = get(vpm, v); + x.push_back(typename GT::Vector_3(p.x(),p.y(),p.z())); u.push_back(get(vnm, v)); h_iter = next(h_iter, pmesh); } while (h_iter != h_start); From 5cc75c0bc4690df397c7dc14d03ca3049ad113f2 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 18 Jul 2022 21:57:42 +0200 Subject: [PATCH 013/142] Updated Demo Display property plugin, added to license list, --- .../include/CGAL/license/gpl_package_list.txt | 1 + .../interpolated_corrected_curvatures.cpp | 2 +- ...nterpolated_corrected_curvature_measures.h | 10 +- .../Display/Display_property_plugin.cpp | 191 +++++++++++++++++- 4 files changed, 188 insertions(+), 16 deletions(-) diff --git a/Installation/include/CGAL/license/gpl_package_list.txt b/Installation/include/CGAL/license/gpl_package_list.txt index f023d48f375f..485c4234b91d 100644 --- a/Installation/include/CGAL/license/gpl_package_list.txt +++ b/Installation/include/CGAL/license/gpl_package_list.txt @@ -51,6 +51,7 @@ Polygon_mesh_processing/connected_components Polygon Mesh Processing - Connected Polygon_mesh_processing/corefinement Polygon Mesh Processing - Corefinement Polygon_mesh_processing/core Polygon Mesh Processing - Core Polygon_mesh_processing/distance Polygon Mesh Processing - Distance +Polygon_mesh_processing/Curvatures/interpolated_corrected_curvature_measures Polygon Mesh Processing - Interpolated Corrected Curvatures Polygon_mesh_processing/measure Polygon Mesh Processing - Geometric Measure Polygon_mesh_processing/meshing_hole_filling Polygon Mesh Processing - Meshing and Hole Filling Polygon_mesh_processing/orientation Polygon Mesh Processing - Orientation 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 8dcf387d0ed5..d17e37726a8a 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 @@ -44,7 +44,7 @@ int main(int argc, char* argv[]) FaceMeasureMap_tag mu0_init, mu1_init, mu2_init; boost::associative_property_map mu0_map(mu0_init), mu1_map(mu1_init), mu2_map(mu2_init); - PMP::interpolated_corrected_measure_mesh(g1, mu0_map, PMP::MU0_AREA_MEASURE, CGAL::parameters::vertex_normal_map(vnm)); + PMP::interpolated_corrected_measure_mesh(g1, mu0_map, PMP::MU0_AREA_MEASURE); 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)); 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 46b2f5c01fcc..7f99fbd7cace 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 @@ -22,7 +22,7 @@ namespace Polygon_mesh_processing { * interpolated corrected curvature functions */ // enum -enum Measure_index { +enum Curvature_measure_index { MU0_AREA_MEASURE, ///< corrected area density of the given face MU1_MEAN_CURVATURE_MEASURE, ///< corrected mean curvature density of the given face MU2_GAUSSIAN_CURVATURE_MEASURE ///< corrected gaussian curvature density of the given face @@ -51,7 +51,7 @@ enum Measure_index { */ template typename GT::FT interpolated_corrected_measure_triangle(const typename GT::Vector_3 x0, const typename GT::Vector_3 x1, const typename GT::Vector_3 x2, - const typename GT::Vector_3 u0, const typename GT::Vector_3 u1, const typename GT::Vector_3 u2, const Measure_index mu_i) + const typename GT::Vector_3 u0, const typename GT::Vector_3 u1, const typename GT::Vector_3 u2, const Curvature_measure_index mu_i) { switch (mu_i) { @@ -105,7 +105,7 @@ typename GT::FT interpolated_corrected_measure_triangle(const typename GT::Vecto */ template typename GT::FT interpolated_corrected_measure_quad(const typename GT::Vector_3 x0, const typename GT::Vector_3 x1, const typename GT::Vector_3 x2, const typename GT::Vector_3 x3, - const typename GT::Vector_3 u0, const typename GT::Vector_3 u1, const typename GT::Vector_3 u2, const typename GT::Vector_3 u3, const Measure_index mu_i) + const typename GT::Vector_3 u0, const typename GT::Vector_3 u1, const typename GT::Vector_3 u2, const typename GT::Vector_3 u3, const Curvature_measure_index mu_i) { // x0 _ x1 // x2 |_| x3 @@ -165,7 +165,7 @@ typename GT::FT interpolated_corrected_measure_quad(const typename GT::Vector_3 * @see `interpolated_corrected_measure_mesh()` */ template -typename GT::FT interpolated_corrected_measure_face(const std::vector& x, const std::vector& u, const Measure_index mu_i) +typename GT::FT interpolated_corrected_measure_face(const std::vector& x, const std::vector& u, const Curvature_measure_index mu_i) { std::size_t n = x.size(); CGAL_precondition(u.size() == n); @@ -250,7 +250,7 @@ template #include #include +#include #include "Scene_points_with_normal_item.h" @@ -31,6 +32,7 @@ #include #include #include +#include #define ARBITRARY_DBL_MIN 1.0E-30 #define ARBITRARY_DBL_MAX 1.0E+30 @@ -41,6 +43,8 @@ typedef CGAL::Three::Triangle_container Tri; typedef CGAL::Three::Viewer_interface VI; +namespace PMP = CGAL::Polygon_mesh_processing; + class Scene_heat_item : public CGAL::Three::Scene_item_rendering_helper { @@ -529,6 +533,9 @@ private Q_SLOTS: dock_widget->propertyBox->addItem("Scaled Jacobian"); dock_widget->propertyBox->addItem("Heat Intensity"); dock_widget->propertyBox->addItem("Heat Intensity (Intrinsic Delaunay)"); + dock_widget->propertyBox->addItem("corrected area density"); + dock_widget->propertyBox->addItem("corrected mean curvature density"); + dock_widget->propertyBox->addItem("corrected gaussian curvature density"); detectSMScalarProperties(sm_item->face_graph()); } @@ -603,6 +610,18 @@ private Q_SLOTS: return; sm_item->setRenderingMode(Gouraud); break; + case 4: // corrected area density + displayInterpolatedCurvatureMeasure(sm_item, PMP::MU0_AREA_MEASURE); + sm_item->setRenderingMode(Flat); + break; + case 5: // corrected mean curvature density + displayInterpolatedCurvatureMeasure(sm_item, PMP::MU1_MEAN_CURVATURE_MEASURE); + sm_item->setRenderingMode(Flat); + break; + case 6: // corrected gaussian curvature density + displayInterpolatedCurvatureMeasure(sm_item, PMP::MU2_GAUSSIAN_CURVATURE_MEASURE); + sm_item->setRenderingMode(Flat); + break; default: if(dock_widget->propertyBox->currentText().contains("v:")) { @@ -637,6 +656,18 @@ private Q_SLOTS: sm_item->face_graph()->property_map("f:angle"); if(does_exist) sm_item->face_graph()->remove_property_map(pmap); + std::tie(pmap, does_exist) = + sm_item->face_graph()->property_map("f:corrected_area_density"); + if (does_exist) + sm_item->face_graph()->remove_property_map(pmap); + std::tie(pmap, does_exist) = + sm_item->face_graph()->property_map("f:corrected_mean_curvature_density"); + if (does_exist) + sm_item->face_graph()->remove_property_map(pmap); + std::tie(pmap, does_exist) = + sm_item->face_graph()->property_map("f:corrected_gaussian_curvature_density"); + if (does_exist) + sm_item->face_graph()->remove_property_map(pmap); }); QApplication::restoreOverrideCursor(); sm_item->invalidateOpenGLBuffers(); @@ -668,13 +699,25 @@ private Q_SLOTS: switch(dock_widget->propertyBox->currentIndex()) { case 0: - dock_widget->zoomToMinButton->setEnabled(angles_max.count(sm_item)>0 ); + dock_widget->zoomToMinButton->setEnabled(angles_min.count(sm_item)>0 ); dock_widget->zoomToMaxButton->setEnabled(angles_max.count(sm_item)>0 ); break; case 1: - dock_widget->zoomToMinButton->setEnabled(jacobian_max.count(sm_item)>0); + dock_widget->zoomToMinButton->setEnabled(jacobian_min.count(sm_item)>0); dock_widget->zoomToMaxButton->setEnabled(jacobian_max.count(sm_item)>0); break; + case 4: + dock_widget->zoomToMinButton->setEnabled(mu0_min.count(sm_item) > 0); + dock_widget->zoomToMaxButton->setEnabled(mu0_max.count(sm_item) > 0); + break; + case 5: + dock_widget->zoomToMinButton->setEnabled(mu1_min.count(sm_item) > 0); + dock_widget->zoomToMaxButton->setEnabled(mu1_max.count(sm_item) > 0); + break; + case 6: + dock_widget->zoomToMinButton->setEnabled(mu2_min.count(sm_item) > 0); + dock_widget->zoomToMaxButton->setEnabled(mu2_max.count(sm_item) > 0); + break; default: break; } @@ -701,11 +744,28 @@ private Q_SLOTS: { smesh.remove_property_map(angles); } + SMesh::Property_map mu0; + std::tie(mu0, found) = smesh.property_map("f:corrected_area_density"); + if (found) + { + smesh.remove_property_map(mu0); + } + SMesh::Property_map mu1; + std::tie(mu1, found) = smesh.property_map("f:corrected_mean_curvature_density"); + if (found) + { + smesh.remove_property_map(mu0); + } + SMesh::Property_map mu2; + std::tie(mu2, found) = smesh.property_map("f:corrected_gaussian_curvature_density"); + if (found) + { + smesh.remove_property_map(mu0); + } } void displayScaledJacobian(Scene_surface_mesh_item* item) { - SMesh& smesh = *item->face_graph(); //compute and store the jacobian per face bool non_init; @@ -742,16 +802,59 @@ private Q_SLOTS: treat_sm_property("f:jacobian", item->face_graph()); } - bool resetScaledJacobian(Scene_surface_mesh_item* item) + void displayInterpolatedCurvatureMeasure(Scene_surface_mesh_item* item, PMP::Curvature_measure_index mu_index) { + std::vector tied_map = { + "f:corrected_area_density", + "f:corrected_mean_curvature_density", + "f:corrected_gaussian_curvature_density" + }; SMesh& smesh = *item->face_graph(); - if(!smesh.property_map("f:jacobian").second) + //compute once and store the value per face + bool non_init; + SMesh::Property_map mu_i_map; + std::tie(mu_i_map, non_init) = + smesh.add_property_map(tied_map[mu_index], 0); + if (non_init) { - return false; + PMP::interpolated_corrected_measure_mesh(smesh, mu_i_map, mu_index); + + double res_min = ARBITRARY_DBL_MAX, + res_max = -ARBITRARY_DBL_MAX; + SMesh::Face_index min_index, max_index; + for (SMesh::Face_index f : faces(smesh)) + { + if (mu_i_map[f] > res_max) + { + res_max = mu_i_map[f]; + max_index = f; + } + if (mu_i_map[f] < res_min) + { + res_min = mu_i_map[f]; + min_index = f; + } + } + switch (mu_index) + { + case PMP::MU0_AREA_MEASURE: + mu0_max[item] = std::make_pair(res_max, max_index); + mu0_min[item] = std::make_pair(res_min, min_index); + break; + case PMP::MU1_MEAN_CURVATURE_MEASURE: + mu1_max[item] = std::make_pair(res_max, max_index); + mu1_min[item] = std::make_pair(res_min, min_index); + break; + case PMP::MU2_GAUSSIAN_CURVATURE_MEASURE: + mu2_max[item] = std::make_pair(res_max, max_index); + mu2_min[item] = std::make_pair(res_min, min_index); + break; + } + + connect(item, &Scene_surface_mesh_item::itemChanged, + this, &DisplayPropertyPlugin::resetProperty); } - dock_widget->minBox->setValue(jacobian_min[item].first-0.01); - dock_widget->maxBox->setValue(jacobian_max[item].first); - return true; + treat_sm_property(tied_map[mu_index], item->face_graph()); } @@ -1054,6 +1157,9 @@ private Q_SLOTS: break; } case 1: + case 4: + case 5: + case 6: dock_widget->groupBox-> setEnabled(true); dock_widget->groupBox_3->setEnabled(true); @@ -1113,6 +1219,34 @@ private Q_SLOTS: dummy_fd, dummy_p); } + break; + case 4: + { + ::zoomToId(*item->face_graph(), + QString("f%1").arg(mu0_min[item].second), + getActiveViewer(), + dummy_fd, + dummy_p); + } + break; + case 5: + { + ::zoomToId(*item->face_graph(), + QString("f%1").arg(mu1_min[item].second), + getActiveViewer(), + dummy_fd, + dummy_p); + } + break; + case 6: + { + ::zoomToId(*item->face_graph(), + QString("f%1").arg(mu2_min[item].second), + getActiveViewer(), + dummy_fd, + dummy_p); + } + break; break; default: break; @@ -1145,6 +1279,33 @@ private Q_SLOTS: getActiveViewer(), dummy_fd, dummy_p); + } + break; + case 4: + { + ::zoomToId(*item->face_graph(), + QString("f%1").arg(mu0_max[item].second), + getActiveViewer(), + dummy_fd, + dummy_p); + } + break; + case 5: + { + ::zoomToId(*item->face_graph(), + QString("f%1").arg(mu1_max[item].second), + getActiveViewer(), + dummy_fd, + dummy_p); + } + break; + case 6: + { + ::zoomToId(*item->face_graph(), + QString("f%1").arg(mu2_max[item].second), + getActiveViewer(), + dummy_fd, + dummy_p); } break; default: @@ -1436,6 +1597,16 @@ private Q_SLOTS: std::unordered_map > angles_min; std::unordered_map > angles_max; + + std::unordered_map > mu0_min; + std::unordered_map > mu0_max; + + std::unordered_map > mu1_min; + std::unordered_map > mu1_max; + + std::unordered_map > mu2_min; + std::unordered_map > mu2_max; + std::unordered_map is_source; @@ -1718,7 +1889,7 @@ private Q_SLOTS: } - EPICK::Vector_3 unit_center_normal = CGAL::Polygon_mesh_processing::compute_face_normal(f, mesh); + EPICK::Vector_3 unit_center_normal = PMP::compute_face_normal(f, mesh); unit_center_normal *= 1.0/CGAL::approximate_sqrt(unit_center_normal.squared_length()); for(std::size_t i = 0; i < corner_areas.size(); ++i) From 5af4a28b1674cb660d1c4575ccf69a5d4925ace5 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 18 Jul 2022 22:23:46 +0200 Subject: [PATCH 014/142] updated doc for interpolated_corrected_measure_mesh() --- ...nterpolated_corrected_curvature_measures.h | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) 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 7f99fbd7cace..93d41ac77db7 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 @@ -18,10 +18,10 @@ namespace Polygon_mesh_processing { /*! * \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 */ -// enum +// enum enum Curvature_measure_index { MU0_AREA_MEASURE, ///< corrected area density of the given face MU1_MEAN_CURVATURE_MEASURE, ///< corrected mean curvature density of the given face @@ -212,9 +212,12 @@ typename GT::FT interpolated_corrected_measure_face(const std::vector::%face_descriptor` as key type and GT::FT as value type. * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" * -* @param pmesh the polygon mesh +* @param pmesh the polygon mesh +* @param fmm (face measure map) the property map used for storing the computed interpolated corrected 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 * @@ -227,7 +230,7 @@ typename GT::FT interpolated_corrected_measure_face(const std::vector::%vertex_descriptor` @@ -235,12 +238,8 @@ typename GT::FT interpolated_corrected_measure_face(const 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. +* \cgalNamedParamsEnd * * @see `interpolated_corrected_measure_face()` */ @@ -272,7 +271,7 @@ template::const_type vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), get_const_property_map(CGAL::vertex_point, 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)); @@ -291,7 +290,7 @@ template Date: Mon, 18 Jul 2022 22:40:38 +0200 Subject: [PATCH 015/142] minor fix --- .../interpolated_corrected_curvatures.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d17e37726a8a..05c74f68cfc7 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 @@ -28,7 +28,7 @@ typedef std::unordered_map FaceMeasureMap_tag; int main(int argc, char* argv[]) { - const std::string filename = (argc>1) ? argv[1] : CGAL::data_file_path("small_bunny.obj"); + const std::string filename = (argc>1) ? argv[1] : CGAL::data_file_path("meshes/small_bunny.obj"); Mesh g1; if(!CGAL::IO::read_polygon_mesh(filename, g1)) From 063e058988567727b9ae5421a98212e18958841e Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Fri, 22 Jul 2022 15:29:19 +0200 Subject: [PATCH 016/142] minor changes regarding the pull review reordering includes, splitting too long lines, minor addition to doc regarding review on the pull req --- .../interpolated_corrected_curvatures.cpp | 66 +++++++----- ...nterpolated_corrected_curvature_measures.h | 102 +++++++++++------- 2 files changed, 104 insertions(+), 64 deletions(-) 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 05c74f68cfc7..505d43286451 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 @@ -1,55 +1,67 @@ -#include #include -#include -#include -#include +#include #include -#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include + namespace PMP = CGAL::Polygon_mesh_processing; -typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; -typedef CGAL::Polyhedron_3 Polyhedron; -typedef CGAL::Surface_mesh Mesh; +typedef CGAL::Exact_predicates_inexact_constructions_kernel EpicKernel; +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; +typedef std::unordered_map FaceMeasureMap_tag; +typedef std::unordered_map vertexVectorMap_tag; int main(int argc, char* argv[]) { - const std::string filename = (argc>1) ? argv[1] : CGAL::data_file_path("meshes/small_bunny.obj"); - Mesh g1; + const std::string filename = (argc>1) ? + argv[1] : + CGAL::data_file_path("meshes/small_bunny.obj"); + if(!CGAL::IO::read_polygon_mesh(filename, g1)) { std::cerr << "Invalid input file." << std::endl; return EXIT_FAILURE; } - std::unordered_map vnm_init; - boost::associative_property_map< std::unordered_map> vnm(vnm_init); + + vertexVectorMap_tag vnm_init; + boost::associative_property_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); + boost::associative_property_map + mu0_map(mu0_init), mu1_map(mu1_init), mu2_map(mu2_init); - PMP::interpolated_corrected_measure_mesh(g1, mu0_map, PMP::MU0_AREA_MEASURE); - 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)); + PMP::interpolated_corrected_measure_mesh( + g1, + mu0_map, + PMP::MU0_AREA_MEASURE); + + 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)); for (face_descriptor f: g1.faces()) - { - std::cout << f.idx() << ": " << get(mu0_map, f) << ", " << get(mu1_map, f) << ", " << get(mu2_map, f) << ", " << "\n"; - } + std::cout << f.idx() << ": " + << get(mu0_map, f) << ", " + << get(mu1_map, f) << ", " + << get(mu2_map, f) << ", " << "\n"; } 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 93d41ac77db7..aae957dc0159 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 @@ -2,15 +2,15 @@ #define CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURE_MEASURES_H #endif -#include #include #include -#include #include #include +#include #include +#include namespace CGAL { @@ -18,14 +18,14 @@ 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 of a given face + * is computed for the interpolated corrected curvature functions */ // enum enum Curvature_measure_index { - MU0_AREA_MEASURE, ///< corrected area density of the given face - MU1_MEAN_CURVATURE_MEASURE, ///< corrected mean curvature density of the given face - MU2_GAUSSIAN_CURVATURE_MEASURE ///< corrected gaussian curvature density of the given face + MU0_AREA_MEASURE, ///< corrected area density + MU1_MEAN_CURVATURE_MEASURE, ///< corrected mean curvature density + MU2_GAUSSIAN_CURVATURE_MEASURE ///< corrected gaussian curvature density }; /** @@ -44,14 +44,20 @@ enum Curvature_measure_index { * @param mu_i an enum for choosing between computing the area measure, * the mean curvature measure, or the gaussian curvature measure. * -* @return a scalar of type GT::FT. This is the value of the interpolated corrected measure of the given triangle. +* @return a scalar of type GT::FT. +* This is the value of the interpolated corrected measure of the given triangle. * * @see `interpolated_corrected_measure_face()` * @see `interpolated_corrected_measure_quad()` */ template -typename GT::FT interpolated_corrected_measure_triangle(const typename GT::Vector_3 x0, const typename GT::Vector_3 x1, const typename GT::Vector_3 x2, - const typename GT::Vector_3 u0, const typename GT::Vector_3 u1, const typename GT::Vector_3 u2, const Curvature_measure_index mu_i) +typename GT::FT interpolated_corrected_measure_triangle(const typename GT::Vector_3 x0, + const typename GT::Vector_3 x1, + const typename GT::Vector_3 x2, + const typename GT::Vector_3 u0, + const typename GT::Vector_3 u1, + const typename GT::Vector_3 u2, + const Curvature_measure_index mu_i) { switch (mu_i) { @@ -98,26 +104,36 @@ typename GT::FT interpolated_corrected_measure_triangle(const typename GT::Vecto * @param mu_i an enum for choosing between computing the area measure, * the mean curvature measure, or the gaussian curvature measure. * -* @return a scalar of type GT::FT. This is the value of the interpolated corrected measure of the given triangle. +* @return a scalar of type GT::FT. +* This is the value of the interpolated corrected measure of the given triangle. * * @see `interpolated_corrected_measure_face()` * @see `interpolated_corrected_measure_triangle()` */ template -typename GT::FT interpolated_corrected_measure_quad(const typename GT::Vector_3 x0, const typename GT::Vector_3 x1, const typename GT::Vector_3 x2, const typename GT::Vector_3 x3, - const typename GT::Vector_3 u0, const typename GT::Vector_3 u1, const typename GT::Vector_3 u2, const typename GT::Vector_3 u3, const Curvature_measure_index mu_i) +typename GT::FT interpolated_corrected_measure_quad(const typename GT::Vector_3 x0, + const typename GT::Vector_3 x1, + const typename GT::Vector_3 x2, + const typename GT::Vector_3 x3, + const typename GT::Vector_3 u0, + const typename GT::Vector_3 u1, + const typename GT::Vector_3 u2, + const typename GT::Vector_3 u3, + const Curvature_measure_index mu_i) { // x0 _ x1 // x2 |_| x3 - + switch (mu_i) { case MU0_AREA_MEASURE: - return (1 / 36.0) * ((4 * u0 + 2 * u1 + 2 * u2 + u3) * CGAL::cross_product(x1 - x0, x2 - x0) + return (1 / 36.0) * ( + (4 * u0 + 2 * u1 + 2 * u2 + u3) * CGAL::cross_product(x1 - x0, x2 - x0) + (2 * u0 + 4 * u1 + u2 + 2 * u3) * CGAL::cross_product(x1 - x0, x3 - x1) + (2 * u0 + u1 + 4 * u2 + 2 * u3) * CGAL::cross_product(x3 - x2, x2 - x0) - + (u0 + 2 * u1 + 2 * u2 + 4 * u3) * CGAL::cross_product(x3 - x2, x3 - x1)); + + (u0 + 2 * u1 + 2 * u2 + 4 * u3) * CGAL::cross_product(x3 - x2, x3 - x1) + ); case MU1_MEAN_CURVATURE_MEASURE: { @@ -129,17 +145,21 @@ typename GT::FT interpolated_corrected_measure_quad(const typename GT::Vector_3 const typename GT::Vector_3 x3_cross = -CGAL::cross_product(u12, x3); - return (1 / 12.0) * (u0 * (2 * x0_cross - CGAL::cross_product((u2 + u3), x1) + CGAL::cross_product((u1 + u3), x2) + x3_cross) + return (1 / 12.0) * ( + u0 * (2 * x0_cross - CGAL::cross_product((u2 + u3), x1) + CGAL::cross_product((u1 + u3), x2) + x3_cross) + u1 * (CGAL::cross_product((u2 + u3), x0) + 2 * x1_cross + x2_cross - CGAL::cross_product((u0 + u2), x3)) - + u2 * (CGAL::cross_product(-(u1 + u3), x0) + x1_cross + 2 * x2_cross + CGAL::cross_product((u0 + u1), x3)) - + u3 * (x0_cross + CGAL::cross_product((u0 + u2), x1) - CGAL::cross_product((u0 + u1), x2) + 2 * x3_cross)); + + u2 * (-CGAL::cross_product((u1 + u3), x0) + x1_cross + 2 * x2_cross + CGAL::cross_product((u0 + u1), x3)) + + u3 * (x0_cross + CGAL::cross_product((u0 + u2), x1) - CGAL::cross_product((u0 + u1), x2) + 2 * x3_cross) + ); } case MU2_GAUSSIAN_CURVATURE_MEASURE: - return (1 / 36.0) * ((4 * u0 + 2 * u1 + 2 * u2 + u3) * CGAL::cross_product(u1 - u0, u2 - u0) + return (1 / 36.0) * ( + (4 * u0 + 2 * u1 + 2 * u2 + u3) * CGAL::cross_product(u1 - u0, u2 - u0) + (2 * u0 + 4 * u1 + u2 + 2 * u3) * CGAL::cross_product(u1 - u0, u3 - u1) + (2 * u0 + u1 + 4 * u2 + 2 * u3) * CGAL::cross_product(u3 - u2, u2 - u0) - + (u0 + 2 * u1 + 2 * u2 + 4 * u3) * CGAL::cross_product(u3 - u2, u3 - u1)); + + (u0 + 2 * u1 + 2 * u2 + 4 * u3) * CGAL::cross_product(u3 - u2, u3 - u1) + ); default: return 0; } @@ -158,14 +178,17 @@ typename GT::FT interpolated_corrected_measure_quad(const typename GT::Vector_3 * @param mu_i an enum for choosing between computing the area measure, * the mean curvature measure, or the gaussian curvature measure. * -* @return a scalar of type GT::FT. This is the value of the interpolated corrected measure of the given face. +* @return a scalar of type GT::FT. +* This is the value of the interpolated corrected measure of the given face. * * @see `interpolated_corrected_measure_triangle()` * @see `interpolated_corrected_measure_quad()` * @see `interpolated_corrected_measure_mesh()` */ template -typename GT::FT interpolated_corrected_measure_face(const std::vector& x, const std::vector& u, const Curvature_measure_index mu_i) +typename GT::FT interpolated_corrected_measure_face(const std::vector& x, + const std::vector& u, + const Curvature_measure_index mu_i) { std::size_t n = x.size(); CGAL_precondition(u.size() == n); @@ -188,11 +211,13 @@ typename GT::FT interpolated_corrected_measure_face(const std::vector::%vertex_descriptor` +* \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, pmesh)`} -* \cgalParamExtra{If this parameter is omitted, an internal property map for `CGAL::vertex_point_t` -* must be available in `PolygonMesh`.} +* \cgalParamExtra{If this parameter is omitted, an internal property map for +* `CGAL::vertex_point_t` must be available in `PolygonMesh`.} * \cgalParamNEnd * * \cgalParamNBegin{vertex_normal_map} * \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} -* \cgalParamType{a class model of `ReadablePropertyMap` with `boost::graph_traits::%vertex_descriptor` +* \cgalParamType{a class model of `ReadablePropertyMap` with +* `boost::graph_traits::%vertex_descriptor` * as key type and `%Vector_3` as value type} -* \cgalParamDefault{`TODO`} -* \cgalParamExtra{If this parameter is omitted, vertex normals should be computed inside the function body.} +* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} +* \cgalParamExtra{If this parameter is omitted, vertex normals should be +* computed inside the function body.} * \cgalParamNEnd * * \cgalNamedParamsEnd @@ -246,11 +275,10 @@ typename GT::FT interpolated_corrected_measure_face(const std::vector void - interpolated_corrected_measure_mesh( - const PolygonMesh& pmesh, - FaceMeasureMap fmm, - const Curvature_measure_index mu_i, - const NamedParameters& np = parameters::default_values()) + interpolated_corrected_measure_mesh(const PolygonMesh& pmesh, + FaceMeasureMap fmm, + const Curvature_measure_index mu_i, + const NamedParameters& np = parameters::default_values()) { typedef typename GetGeomTraits::type GT; From 66a26246412d9922610d380c37da5623c432dc69 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 25 Jul 2022 13:31:07 +0200 Subject: [PATCH 017/142] minor doc fix making GT::FT back ticked --- .../interpolated_corrected_curvature_measures.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 aae957dc0159..2409eab42b74 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 @@ -44,7 +44,7 @@ enum Curvature_measure_index { * @param mu_i an enum for choosing between computing the area measure, * the mean curvature measure, or the gaussian curvature measure. * -* @return a scalar of type GT::FT. +* @return a scalar of type `GT::FT`. * This is the value of the interpolated corrected measure of the given triangle. * * @see `interpolated_corrected_measure_face()` @@ -104,7 +104,7 @@ typename GT::FT interpolated_corrected_measure_triangle(const typename GT::Vecto * @param mu_i an enum for choosing between computing the area measure, * the mean curvature measure, or the gaussian curvature measure. * -* @return a scalar of type GT::FT. +* @return a scalar of type `GT::FT`. * This is the value of the interpolated corrected measure of the given triangle. * * @see `interpolated_corrected_measure_face()` @@ -178,7 +178,7 @@ typename GT::FT interpolated_corrected_measure_quad(const typename GT::Vector_3 * @param mu_i an enum for choosing between computing the area measure, * the mean curvature measure, or the gaussian curvature measure. * -* @return a scalar of type GT::FT. +* @return a scalar of type `GT::FT`. * This is the value of the interpolated corrected measure of the given face. * * @see `interpolated_corrected_measure_triangle()` @@ -238,7 +238,7 @@ typename GT::FT interpolated_corrected_measure_face(const std::vector::%face_descriptor` as key type and GT::FT as value type. +* `boost::graph_traits::%face_descriptor` as key type and `GT::FT` as value type. * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" * * @param pmesh the polygon mesh From 41be3688ae6a0682ad03db7f22a2bb5a215b4a7b Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Tue, 26 Jul 2022 19:32:17 +0200 Subject: [PATCH 018/142] Mean and Gaussian Curvatures + Visualizer (Still wip) --- .../interpolated_corrected_curvatures.cpp | 35 +-- ...nterpolated_corrected_curvature_measures.h | 224 +++++++++++++++++- .../Display/Display_property_plugin.cpp | 116 +++------ .../internal/parameters_interface.h | 1 + 4 files changed, 259 insertions(+), 117 deletions(-) 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 505d43286451..4480366bc2b0 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 @@ -33,35 +33,20 @@ int main(int argc, char* argv[]) return EXIT_FAILURE; } - vertexVectorMap_tag vnm_init; - boost::associative_property_map vnm(vnm_init); - - PMP::compute_vertex_normals(g1, vnm); - - FaceMeasureMap_tag mu0_init, mu1_init, mu2_init; + FaceMeasureMap_tag mean_curvature_init, gaussian_curvature_init; boost::associative_property_map - mu0_map(mu0_init), mu1_map(mu1_init), mu2_map(mu2_init); + mean_curvature_map(mean_curvature_init), gaussian_curvature_map(gaussian_curvature_init); - PMP::interpolated_corrected_measure_mesh( + PMP::interpolated_corrected_mean_curvature( g1, - mu0_map, - PMP::MU0_AREA_MEASURE); - - PMP::interpolated_corrected_measure_mesh( - g1, - mu1_map, - PMP::MU1_MEAN_CURVATURE_MEASURE, - CGAL::parameters::vertex_normal_map(vnm)); - - PMP::interpolated_corrected_measure_mesh( + mean_curvature_map + ); + PMP::interpolated_corrected_gaussian_curvature( g1, - mu2_map, - PMP::MU2_GAUSSIAN_CURVATURE_MEASURE, - CGAL::parameters::vertex_normal_map(vnm)); + gaussian_curvature_map + ); for (face_descriptor f: g1.faces()) - std::cout << f.idx() << ": " - << get(mu0_map, f) << ", " - << get(mu1_map, f) << ", " - << get(mu2_map, f) << ", " << "\n"; + std::cout << f.idx() << ": HC = " << get(mean_curvature_map, f) + << ", GC = " << get(gaussian_curvature_map, f) << "\n"; } 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 2409eab42b74..737a2525ebd7 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 @@ -11,6 +11,8 @@ #include #include +#include +#include namespace CGAL { @@ -210,8 +212,8 @@ typename GT::FT interpolated_corrected_measure_face(const std::vector::value) compute_vertex_normals(pmesh, vnm, np); for (face_descriptor f : faces(pmesh)) { - halfedge_descriptor h_start = pmesh.halfedge(f); - halfedge_descriptor h_iter = h_start; - std::vector x; std::vector u; - // looping over vertices in face - do { - vertex_descriptor v = source(h_iter, pmesh); + for (vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) + { typename GT::Point_3 p = get(vpm, v); x.push_back(typename GT::Vector_3(p.x(), p.y(), p.z())); u.push_back(get(vnm, v)); - h_iter = next(h_iter, pmesh); - } while (h_iter != h_start); + } put(fmm, f, interpolated_corrected_measure_face(x, u, mu_i)); } } + +// +// +//template +//typename GT::FT triangle_in_ball_ratio_1(const typename GT::Vector_3 x1, +// const typename GT::Vector_3 x2, +// const typename GT::Vector_3 x3, +// const typename GT::FT r, +// const typename GT::Vector_3 c, +// const std::size_t res = 3) +//{ +// const typename GT::FT R = r * r; +// const typename GT::FT acc = 1.0 / res; +// std::size_t samples_in = 0; +// for (GT::FT alpha = acc / 3; alpha < 1; alpha += acc) +// for (GT::FT beta = acc / 3; beta < 1 - alpha; beta += acc) +// { +// if ((alpha * x1 + beta * x2 + (1 - alpha - beta) * x3 - c).squared_length() < R) +// samples_in++; +// } +// return samples_in / (typename GT::FT)(res * (res + 1) / 2); +//} + + +template +typename GT::FT face_in_ball_ratio_2(const std::vector& x, + const typename GT::FT r, + const typename GT::Vector_3 c) +{ + std::size_t n = x.size(); + + // getting center of points + typename GT::Vector_3 xm = + std::accumulate(x.begin(), x.end(), typename GT::Vector_3(0, 0, 0)); + xm /= n; + + typename GT::FT d_min = (xm - c).squared_length(); + typename GT::FT d_max = d_min; + + for (const typename GT::Vector_3 xi : x) + { + const typename GT::FT d_sq = (xi - c).squared_length(); + d_max = std::max(d_sq, d_max); + d_min = std::min(d_sq, d_min); + } + + if (d_max <= r * r) return 1.0; + else if (r * r <= d_min) return 0.0; + + d_max = sqrt(d_max); + d_min = sqrt(d_min); + + return (r - d_min) / (d_max - d_min); +} + +template + void expand_interpolated_corrected_measure_face(const PolygonMesh& pmesh, + FaceMeasureMap fmm, + const typename boost::graph_traits::face_descriptor f, + const NamedParameters& np = parameters::default_values()) +{ + using parameters::choose_parameter; + using parameters::get_parameter; + + typedef typename GetGeomTraits::type GT; + typedef typename boost::graph_traits::face_descriptor face_descriptor; + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + + const typename GetGeomTraits::type::FT + r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0.01); + + if (r < 0.000001) + return; + + typename GetVertexPointMap::const_type + vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), + get_const_property_map(CGAL::vertex_point, pmesh)); + + + std::queue bfs_q; + std::unordered_set bfs_v; + + //get face center c + typename GT::Vector_3 c; + for (vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) + { + typename GT::Point_3 p = get(vpm, v); + c += typename GT::Vector_3(p.x(), p.y(), p.z()); + } + c /= degree(f, pmesh); + + GT::FT corrected_mui = 0; + + bfs_q.push(f); + bfs_v.insert(f); + + while (!bfs_q.empty()) { + face_descriptor fi = bfs_q.front(); + bfs_q.pop(); + + // looping over vertices in face to get point coordinates + std::vector x; + for (vertex_descriptor v : vertices_around_face(halfedge(fi, pmesh), pmesh)) + { + typename GT::Point_3 p = get(vpm, v); + x.push_back(typename GT::Vector_3(p.x(), p.y(), p.z())); + } + + const typename GT::FT f_ratio = face_in_ball_ratio_2(x, r, c); + + if (f_ratio > 0.000001) + { + corrected_mui += f_ratio * get(fmm, fi); + for (face_descriptor fj : faces_around_face(halfedge(fi, pmesh), pmesh)) + { + if (bfs_v.find(fj) == bfs_v.end()) + { + bfs_q.push(fj); + bfs_v.insert(fj); + } + } + } + } + + put(fmm, f, corrected_mui); +} + +//template +// void expand_interpolated_corrected_measure_mesh(const PolygonMesh& pmesh, +// FaceMeasureMap fmm, +// const NamedParameters& np = parameters::default_values()) +//{ +// typedef typename boost::graph_traits::face_descriptor face_descriptor; +// for (face_descriptor f : faces(pmesh)) +// expand_interpolated_corrected_measure_face(pmesh, fmm, f, np); +//} + +template + void interpolated_corrected_mean_curvature(const PolygonMesh& pmesh, + FaceCurvatureMap fcm, + const NamedParameters& np = parameters::default_values()) +{ + typedef typename GetGeomTraits::type GT; + typedef typename boost::graph_traits::face_descriptor face_descriptor; + typedef std::unordered_map FaceMeasureMap_tag; + + FaceMeasureMap_tag mu0_init, mu1_init; + boost::associative_property_map + mu0_map(mu0_init), mu1_map(mu1_init); + + interpolated_corrected_measure_mesh(pmesh, mu0_map, MU0_AREA_MEASURE); + interpolated_corrected_measure_mesh(pmesh, mu1_map, MU1_MEAN_CURVATURE_MEASURE); + + for (face_descriptor f : faces(pmesh)) + { + expand_interpolated_corrected_measure_face(pmesh, mu0_map, f, np); + expand_interpolated_corrected_measure_face(pmesh, mu1_map, f, np); + + GT::FT f_mu0 = get(mu0_map, f); + if (f_mu0 > 0.000001) + put(fcm, f, 0.5 * get(mu1_map, f) / get(mu0_map, f)); + else + put(fcm, f, 0); + } + +} + +template + void interpolated_corrected_gaussian_curvature(const PolygonMesh& pmesh, + FaceCurvatureMap fcm, + const NamedParameters& np = parameters::default_values()) +{ + typedef typename GetGeomTraits::type GT; + typedef typename boost::graph_traits::face_descriptor face_descriptor; + typedef std::unordered_map FaceMeasureMap_tag; + + FaceMeasureMap_tag mu0_init, mu2_init; + boost::associative_property_map + mu0_map(mu0_init), mu2_map(mu2_init); + + interpolated_corrected_measure_mesh(pmesh, mu0_map, MU0_AREA_MEASURE); + interpolated_corrected_measure_mesh(pmesh, mu2_map, MU2_GAUSSIAN_CURVATURE_MEASURE); + + for (face_descriptor f : faces(pmesh)) + { + expand_interpolated_corrected_measure_face(pmesh, mu0_map, f, np); + expand_interpolated_corrected_measure_face(pmesh, mu2_map, f, np); + + GT::FT f_mu0 = get(mu0_map, f); + if(f_mu0 > 0.000001) + put(fcm, f, get(mu2_map, f) / f_mu0); + else + put(fcm, f, 0); + } + +} + + + } } diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index 1ea1394649c2..88d86966f1d7 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -533,9 +533,8 @@ private Q_SLOTS: dock_widget->propertyBox->addItem("Scaled Jacobian"); dock_widget->propertyBox->addItem("Heat Intensity"); dock_widget->propertyBox->addItem("Heat Intensity (Intrinsic Delaunay)"); - dock_widget->propertyBox->addItem("corrected area density"); - dock_widget->propertyBox->addItem("corrected mean curvature density"); - dock_widget->propertyBox->addItem("corrected gaussian curvature density"); + dock_widget->propertyBox->addItem("Interpolated Corrected Mean Curvature"); + dock_widget->propertyBox->addItem("Interpolated Corrected Gaussian Curvature"); detectSMScalarProperties(sm_item->face_graph()); } @@ -610,15 +609,11 @@ private Q_SLOTS: return; sm_item->setRenderingMode(Gouraud); break; - case 4: // corrected area density - displayInterpolatedCurvatureMeasure(sm_item, PMP::MU0_AREA_MEASURE); - sm_item->setRenderingMode(Flat); - break; - case 5: // corrected mean curvature density + case 4: // Interpolated Corrected Mean Curvature displayInterpolatedCurvatureMeasure(sm_item, PMP::MU1_MEAN_CURVATURE_MEASURE); sm_item->setRenderingMode(Flat); break; - case 6: // corrected gaussian curvature density + case 5: // Interpolated Corrected Gaussian Curvature displayInterpolatedCurvatureMeasure(sm_item, PMP::MU2_GAUSSIAN_CURVATURE_MEASURE); sm_item->setRenderingMode(Flat); break; @@ -657,15 +652,11 @@ private Q_SLOTS: if(does_exist) sm_item->face_graph()->remove_property_map(pmap); std::tie(pmap, does_exist) = - sm_item->face_graph()->property_map("f:corrected_area_density"); - if (does_exist) - sm_item->face_graph()->remove_property_map(pmap); - std::tie(pmap, does_exist) = - sm_item->face_graph()->property_map("f:corrected_mean_curvature_density"); + sm_item->face_graph()->property_map("f:interpolated_corrected_mean_curvature"); if (does_exist) sm_item->face_graph()->remove_property_map(pmap); std::tie(pmap, does_exist) = - sm_item->face_graph()->property_map("f:corrected_gaussian_curvature_density"); + sm_item->face_graph()->property_map("f:interpolated_corrected_gaussian_curvature"); if (does_exist) sm_item->face_graph()->remove_property_map(pmap); }); @@ -707,16 +698,12 @@ private Q_SLOTS: dock_widget->zoomToMaxButton->setEnabled(jacobian_max.count(sm_item)>0); break; case 4: - dock_widget->zoomToMinButton->setEnabled(mu0_min.count(sm_item) > 0); - dock_widget->zoomToMaxButton->setEnabled(mu0_max.count(sm_item) > 0); + dock_widget->zoomToMinButton->setEnabled(mean_curvature_min.count(sm_item) > 0); + dock_widget->zoomToMaxButton->setEnabled(mean_curvature_max.count(sm_item) > 0); break; case 5: - dock_widget->zoomToMinButton->setEnabled(mu1_min.count(sm_item) > 0); - dock_widget->zoomToMaxButton->setEnabled(mu1_max.count(sm_item) > 0); - break; - case 6: - dock_widget->zoomToMinButton->setEnabled(mu2_min.count(sm_item) > 0); - dock_widget->zoomToMaxButton->setEnabled(mu2_max.count(sm_item) > 0); + dock_widget->zoomToMinButton->setEnabled(gaussian_curvature_min.count(sm_item) > 0); + dock_widget->zoomToMaxButton->setEnabled(gaussian_curvature_max.count(sm_item) > 0); break; default: break; @@ -744,23 +731,17 @@ private Q_SLOTS: { smesh.remove_property_map(angles); } - SMesh::Property_map mu0; - std::tie(mu0, found) = smesh.property_map("f:corrected_area_density"); + SMesh::Property_map mean_curvature; + std::tie(mean_curvature, found) = smesh.property_map("f:interpolated_corrected_mean_curvature"); if (found) { - smesh.remove_property_map(mu0); + smesh.remove_property_map(mean_curvature); } - SMesh::Property_map mu1; - std::tie(mu1, found) = smesh.property_map("f:corrected_mean_curvature_density"); + SMesh::Property_map gaussian_curvature; + std::tie(gaussian_curvature, found) = smesh.property_map("f:interpolated_corrected_gaussian_curvature"); if (found) { - smesh.remove_property_map(mu0); - } - SMesh::Property_map mu2; - std::tie(mu2, found) = smesh.property_map("f:corrected_gaussian_curvature_density"); - if (found) - { - smesh.remove_property_map(mu0); + smesh.remove_property_map(gaussian_curvature); } } @@ -804,20 +785,20 @@ private Q_SLOTS: void displayInterpolatedCurvatureMeasure(Scene_surface_mesh_item* item, PMP::Curvature_measure_index mu_index) { - std::vector tied_map = { - "f:corrected_area_density", - "f:corrected_mean_curvature_density", - "f:corrected_gaussian_curvature_density" - }; + std::string tied_string = (mu_index == PMP::MU1_MEAN_CURVATURE_MEASURE)? + "f:interpolated_corrected_mean_curvature": "f:interpolated_corrected_gaussian_curvature"; SMesh& smesh = *item->face_graph(); //compute once and store the value per face bool non_init; SMesh::Property_map mu_i_map; std::tie(mu_i_map, non_init) = - smesh.add_property_map(tied_map[mu_index], 0); + smesh.add_property_map(tied_string, 0); if (non_init) { - PMP::interpolated_corrected_measure_mesh(smesh, mu_i_map, mu_index); + if (mu_index == PMP::MU1_MEAN_CURVATURE_MEASURE) + PMP::interpolated_corrected_mean_curvature(smesh, mu_i_map); + else + PMP::interpolated_corrected_gaussian_curvature(smesh, mu_i_map); double res_min = ARBITRARY_DBL_MAX, res_max = -ARBITRARY_DBL_MAX; @@ -837,24 +818,20 @@ private Q_SLOTS: } switch (mu_index) { - case PMP::MU0_AREA_MEASURE: - mu0_max[item] = std::make_pair(res_max, max_index); - mu0_min[item] = std::make_pair(res_min, min_index); - break; case PMP::MU1_MEAN_CURVATURE_MEASURE: - mu1_max[item] = std::make_pair(res_max, max_index); - mu1_min[item] = std::make_pair(res_min, min_index); + mean_curvature_max[item] = std::make_pair(res_max, max_index); + mean_curvature_min[item] = std::make_pair(res_min, min_index); break; case PMP::MU2_GAUSSIAN_CURVATURE_MEASURE: - mu2_max[item] = std::make_pair(res_max, max_index); - mu2_min[item] = std::make_pair(res_min, min_index); + gaussian_curvature_max[item] = std::make_pair(res_max, max_index); + gaussian_curvature_min[item] = std::make_pair(res_min, min_index); break; } connect(item, &Scene_surface_mesh_item::itemChanged, this, &DisplayPropertyPlugin::resetProperty); } - treat_sm_property(tied_map[mu_index], item->face_graph()); + treat_sm_property(tied_string, item->face_graph()); } @@ -1159,7 +1136,6 @@ private Q_SLOTS: case 1: case 4: case 5: - case 6: dock_widget->groupBox-> setEnabled(true); dock_widget->groupBox_3->setEnabled(true); @@ -1223,7 +1199,7 @@ private Q_SLOTS: case 4: { ::zoomToId(*item->face_graph(), - QString("f%1").arg(mu0_min[item].second), + QString("f%1").arg(mean_curvature_min[item].second), getActiveViewer(), dummy_fd, dummy_p); @@ -1232,20 +1208,12 @@ private Q_SLOTS: case 5: { ::zoomToId(*item->face_graph(), - QString("f%1").arg(mu1_min[item].second), + QString("f%1").arg(gaussian_curvature_min[item].second), getActiveViewer(), dummy_fd, dummy_p); } break; - case 6: - { - ::zoomToId(*item->face_graph(), - QString("f%1").arg(mu2_min[item].second), - getActiveViewer(), - dummy_fd, - dummy_p); - } break; break; default: @@ -1284,7 +1252,7 @@ private Q_SLOTS: case 4: { ::zoomToId(*item->face_graph(), - QString("f%1").arg(mu0_max[item].second), + QString("f%1").arg(mean_curvature_max[item].second), getActiveViewer(), dummy_fd, dummy_p); @@ -1293,21 +1261,12 @@ private Q_SLOTS: case 5: { ::zoomToId(*item->face_graph(), - QString("f%1").arg(mu1_max[item].second), + QString("f%1").arg(gaussian_curvature_max[item].second), getActiveViewer(), dummy_fd, dummy_p); } break; - case 6: - { - ::zoomToId(*item->face_graph(), - QString("f%1").arg(mu2_max[item].second), - getActiveViewer(), - dummy_fd, - dummy_p); - } - break; default: break; } @@ -1598,14 +1557,11 @@ private Q_SLOTS: std::unordered_map > angles_min; std::unordered_map > angles_max; - std::unordered_map > mu0_min; - std::unordered_map > mu0_max; + std::unordered_map > mean_curvature_min; + std::unordered_map > mean_curvature_max; - std::unordered_map > mu1_min; - std::unordered_map > mu1_max; - - std::unordered_map > mu2_min; - std::unordered_map > mu2_max; + std::unordered_map > gaussian_curvature_min; + std::unordered_map > gaussian_curvature_max; std::unordered_map is_source; diff --git a/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h index c224b4982513..dd4785ab7e8a 100644 --- a/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h +++ b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h @@ -87,6 +87,7 @@ CGAL_add_named_parameter(number_of_points_per_edge_t, number_of_points_per_edge, CGAL_add_named_parameter(number_of_points_on_edges_t, number_of_points_on_edges, number_of_points_on_edges) CGAL_add_named_parameter(nb_points_per_area_unit_t, nb_points_per_area_unit, number_of_points_per_area_unit) CGAL_add_named_parameter(nb_points_per_distance_unit_t, nb_points_per_distance_unit, number_of_points_per_distance_unit) +CGAL_add_named_parameter(ball_radius_t, ball_radius, ball_radius) CGAL_add_named_parameter(outward_orientation_t, outward_orientation, outward_orientation) CGAL_add_named_parameter(overlap_test_t, overlap_test, do_overlap_test_of_bounded_sides) CGAL_add_named_parameter(preserve_genus_t, preserve_genus, preserve_genus) From 48ff36dcc94d621d27a1fde09811159e3963eb3a Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Wed, 27 Jul 2022 12:42:38 +0200 Subject: [PATCH 019/142] fixed some missing typenames --- .../interpolated_corrected_curvature_measures.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) 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 737a2525ebd7..9f9a6c0fc14f 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 @@ -415,7 +415,7 @@ template::type GT; typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef std::unordered_map FaceMeasureMap_tag; + typedef std::unordered_map FaceMeasureMap_tag; FaceMeasureMap_tag mu0_init, mu1_init; boost::associative_property_map @@ -484,13 +484,12 @@ template 0.000001) put(fcm, f, 0.5 * get(mu1_map, f) / get(mu0_map, f)); else put(fcm, f, 0); } - } template::type GT; typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef std::unordered_map FaceMeasureMap_tag; + typedef std::unordered_map FaceMeasureMap_tag; FaceMeasureMap_tag mu0_init, mu2_init; boost::associative_property_map @@ -515,13 +514,12 @@ template 0.000001) put(fcm, f, get(mu2_map, f) / f_mu0); else put(fcm, f, 0); } - } From 6b985bfeb86efd80958f42409fdd9fae5f2b5539 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Wed, 27 Jul 2022 13:25:35 +0200 Subject: [PATCH 020/142] for boundary faces --- .../Curvatures/interpolated_corrected_curvature_measures.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 9f9a6c0fc14f..3528ffed8a43 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 @@ -439,7 +439,7 @@ template::null_face()) { bfs_q.push(fj); bfs_v.insert(fj); From 8d2a5bcf82a026a0c7aa8399dc024c96cf40b0d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 27 Jul 2022 13:40:25 +0200 Subject: [PATCH 021/142] add license header --- .../interpolated_corrected_curvature_measures.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 9f9a6c0fc14f..a3c3d9f16e2c 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 @@ -1,3 +1,16 @@ +// Copyright (c) 2022 GeometryFactory (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Hossam Saeed +// + #ifndef CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURE_MEASURES_H #define CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURE_MEASURES_H #endif From c99008dde1ad696b2e9eea65081908f325e5ac8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 27 Jul 2022 13:40:33 +0200 Subject: [PATCH 022/142] trailing whitespaces --- .../PackageDescription.txt | 2 +- .../interpolated_corrected_curvatures.cpp | 2 +- ...nterpolated_corrected_curvature_measures.h | 28 +++++++++---------- .../Display/Display_property_plugin.cpp | 4 +-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt index c25cfb8490d3..d0cab92d6a89 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt @@ -16,7 +16,7 @@ /// Functions to triangulate faces, and to refine and fair regions of a polygon mesh. /// \ingroup PkgPolygonMeshProcessingRef -/// \defgroup PMP_corrected_curvatures_grp Corrected Curvature Computation +/// \defgroup PMP_corrected_curvatures_grp Corrected Curvature Computation /// Functions to compute the corrected curvatures of a polygon mesh. /// \ingroup PkgPolygonMeshProcessingRef 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 4480366bc2b0..acf4591fe392 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 @@ -47,6 +47,6 @@ int main(int argc, char* argv[]) ); for (face_descriptor f: g1.faces()) - std::cout << f.idx() << ": HC = " << get(mean_curvature_map, f) + std::cout << f.idx() << ": HC = " << get(mean_curvature_map, f) << ", GC = " << get(gaussian_curvature_map, f) << "\n"; } 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 a3c3d9f16e2c..f618533d2bc9 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 @@ -59,7 +59,7 @@ enum Curvature_measure_index { * @param mu_i an enum for choosing between computing the area measure, * the mean curvature measure, or the gaussian curvature measure. * -* @return a scalar of type `GT::FT`. +* @return a scalar of type `GT::FT`. * This is the value of the interpolated corrected measure of the given triangle. * * @see `interpolated_corrected_measure_face()` @@ -69,9 +69,9 @@ template typename GT::FT interpolated_corrected_measure_triangle(const typename GT::Vector_3 x0, const typename GT::Vector_3 x1, const typename GT::Vector_3 x2, - const typename GT::Vector_3 u0, - const typename GT::Vector_3 u1, - const typename GT::Vector_3 u2, + const typename GT::Vector_3 u0, + const typename GT::Vector_3 u1, + const typename GT::Vector_3 u2, const Curvature_measure_index mu_i) { switch (mu_i) @@ -102,8 +102,8 @@ typename GT::FT interpolated_corrected_measure_triangle(const typename GT::Vecto * \ingroup PMP_corrected_curvatures_grp * * computes the interpolated corrected measure of specific quad -* Note that the vertices 0 to 3 are ordered like this \n -* v0 _ v1 \n +* Note that the vertices 0 to 3 are ordered like this \n +* v0 _ v1 \n * v2 |_| v3 * * @tparam GT is the geometric traits class. @@ -119,7 +119,7 @@ typename GT::FT interpolated_corrected_measure_triangle(const typename GT::Vecto * @param mu_i an enum for choosing between computing the area measure, * the mean curvature measure, or the gaussian curvature measure. * -* @return a scalar of type `GT::FT`. +* @return a scalar of type `GT::FT`. * This is the value of the interpolated corrected measure of the given triangle. * * @see `interpolated_corrected_measure_face()` @@ -138,7 +138,7 @@ typename GT::FT interpolated_corrected_measure_quad(const typename GT::Vector_3 { // x0 _ x1 // x2 |_| x3 - + switch (mu_i) { case MU0_AREA_MEASURE: @@ -193,7 +193,7 @@ typename GT::FT interpolated_corrected_measure_quad(const typename GT::Vector_3 * @param mu_i an enum for choosing between computing the area measure, * the mean curvature measure, or the gaussian curvature measure. * -* @return a scalar of type `GT::FT`. +* @return a scalar of type `GT::FT`. * This is the value of the interpolated corrected measure of the given face. * * @see `interpolated_corrected_measure_triangle()` @@ -231,7 +231,7 @@ typename GT::FT interpolated_corrected_measure_face(const std::vector::%vertex_descriptor` * as key type and `%Point_3` as value type} * \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`} @@ -275,7 +275,7 @@ typename GT::FT interpolated_corrected_measure_face(const std::vector::%vertex_descriptor` * as key type and `%Vector_3` as value type} * \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} @@ -405,7 +405,7 @@ template::face_descriptor face_descriptor; typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; - const typename GetGeomTraits::type::FT + const typename GetGeomTraits::type::FT r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0.01); if (r < 0.000001) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index 88d86966f1d7..13f704774e38 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -785,13 +785,13 @@ private Q_SLOTS: void displayInterpolatedCurvatureMeasure(Scene_surface_mesh_item* item, PMP::Curvature_measure_index mu_index) { - std::string tied_string = (mu_index == PMP::MU1_MEAN_CURVATURE_MEASURE)? + std::string tied_string = (mu_index == PMP::MU1_MEAN_CURVATURE_MEASURE)? "f:interpolated_corrected_mean_curvature": "f:interpolated_corrected_gaussian_curvature"; SMesh& smesh = *item->face_graph(); //compute once and store the value per face bool non_init; SMesh::Property_map mu_i_map; - std::tie(mu_i_map, non_init) = + std::tie(mu_i_map, non_init) = smesh.add_property_map(tied_string, 0); if (non_init) { From 1c42a61fa11dc97e0c4629a4c73600e1356a518c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 27 Jul 2022 14:26:28 +0200 Subject: [PATCH 023/142] use traits functor --- ...nterpolated_corrected_curvature_measures.h | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) 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 f618533d2bc9..415737e4991a 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 @@ -74,25 +74,26 @@ typename GT::FT interpolated_corrected_measure_triangle(const typename GT::Vecto const typename GT::Vector_3 u2, const Curvature_measure_index mu_i) { + GT::Construct_cross_product_3 cross_product; switch (mu_i) { case MU0_AREA_MEASURE: { const typename GT::Vector_3 um = (u0 + u1 + u2) / 3.0; - return 0.5 * um * CGAL::cross_product(x1 - x0, x2 - x0); + return 0.5 * um * cross_product(x1 - x0, x2 - x0); } case MU1_MEAN_CURVATURE_MEASURE: { const typename GT::Vector_3 um = (u0 + u1 + u2) / 3.0; - return 0.5 * um * (CGAL::cross_product(u2 - u1, x0) - + CGAL::cross_product(u0 - u2, x1) - + CGAL::cross_product(u1 - u0, x2)); + return 0.5 * um * (cross_product(u2 - u1, x0) + + cross_product(u0 - u2, x1) + + cross_product(u1 - u0, x2)); } case MU2_GAUSSIAN_CURVATURE_MEASURE: - return 0.5 * u0 * CGAL::cross_product(u1, u2); + return 0.5 * u0 * cross_product(u1, u2); default: return 0; } @@ -138,42 +139,42 @@ typename GT::FT interpolated_corrected_measure_quad(const typename GT::Vector_3 { // x0 _ x1 // x2 |_| x3 - + GT::Construct_cross_product_3 cross_product; switch (mu_i) { case MU0_AREA_MEASURE: return (1 / 36.0) * ( - (4 * u0 + 2 * u1 + 2 * u2 + u3) * CGAL::cross_product(x1 - x0, x2 - x0) - + (2 * u0 + 4 * u1 + u2 + 2 * u3) * CGAL::cross_product(x1 - x0, x3 - x1) - + (2 * u0 + u1 + 4 * u2 + 2 * u3) * CGAL::cross_product(x3 - x2, x2 - x0) - + (u0 + 2 * u1 + 2 * u2 + 4 * u3) * CGAL::cross_product(x3 - x2, x3 - x1) + (4 * u0 + 2 * u1 + 2 * u2 + u3) * cross_product(x1 - x0, x2 - x0) + + (2 * u0 + 4 * u1 + u2 + 2 * u3) * cross_product(x1 - x0, x3 - x1) + + (2 * u0 + u1 + 4 * u2 + 2 * u3) * cross_product(x3 - x2, x2 - x0) + + (u0 + 2 * u1 + 2 * u2 + 4 * u3) * cross_product(x3 - x2, x3 - x1) ); case MU1_MEAN_CURVATURE_MEASURE: { const typename GT::Vector_3 u03 = u3 - u0; const typename GT::Vector_3 u12 = u2 - u1; - const typename GT::Vector_3 x0_cross = CGAL::cross_product(u12, x0); - const typename GT::Vector_3 x1_cross = -CGAL::cross_product(u03, x1); - const typename GT::Vector_3 x2_cross = CGAL::cross_product(u03, x2); - const typename GT::Vector_3 x3_cross = -CGAL::cross_product(u12, x3); + const typename GT::Vector_3 x0_cross = cross_product(u12, x0); + const typename GT::Vector_3 x1_cross = -cross_product(u03, x1); + const typename GT::Vector_3 x2_cross = cross_product(u03, x2); + const typename GT::Vector_3 x3_cross = -cross_product(u12, x3); return (1 / 12.0) * ( - u0 * (2 * x0_cross - CGAL::cross_product((u2 + u3), x1) + CGAL::cross_product((u1 + u3), x2) + x3_cross) - + u1 * (CGAL::cross_product((u2 + u3), x0) + 2 * x1_cross + x2_cross - CGAL::cross_product((u0 + u2), x3)) - + u2 * (-CGAL::cross_product((u1 + u3), x0) + x1_cross + 2 * x2_cross + CGAL::cross_product((u0 + u1), x3)) - + u3 * (x0_cross + CGAL::cross_product((u0 + u2), x1) - CGAL::cross_product((u0 + u1), x2) + 2 * x3_cross) + u0 * (2 * x0_cross - cross_product((u2 + u3), x1) + cross_product((u1 + u3), x2) + x3_cross) + + u1 * (cross_product((u2 + u3), x0) + 2 * x1_cross + x2_cross - cross_product((u0 + u2), x3)) + + u2 * (-cross_product((u1 + u3), x0) + x1_cross + 2 * x2_cross + cross_product((u0 + u1), x3)) + + u3 * (x0_cross + cross_product((u0 + u2), x1) - cross_product((u0 + u1), x2) + 2 * x3_cross) ); } case MU2_GAUSSIAN_CURVATURE_MEASURE: return (1 / 36.0) * ( - (4 * u0 + 2 * u1 + 2 * u2 + u3) * CGAL::cross_product(u1 - u0, u2 - u0) - + (2 * u0 + 4 * u1 + u2 + 2 * u3) * CGAL::cross_product(u1 - u0, u3 - u1) - + (2 * u0 + u1 + 4 * u2 + 2 * u3) * CGAL::cross_product(u3 - u2, u2 - u0) - + (u0 + 2 * u1 + 2 * u2 + 4 * u3) * CGAL::cross_product(u3 - u2, u3 - u1) + (4 * u0 + 2 * u1 + 2 * u2 + u3) * cross_product(u1 - u0, u2 - u0) + + (2 * u0 + 4 * u1 + u2 + 2 * u3) * cross_product(u1 - u0, u3 - u1) + + (2 * u0 + u1 + 4 * u2 + 2 * u3) * cross_product(u3 - u2, u2 - u0) + + (u0 + 2 * u1 + 2 * u2 + 4 * u3) * cross_product(u3 - u2, u3 - u1) ); default: return 0; From 12a627e23f2d26e98a6b53228fa4c050cef07d2c Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Wed, 27 Jul 2022 15:40:06 +0200 Subject: [PATCH 024/142] expanding from and evaluating on vertices instead of faces --- .../interpolated_corrected_curvatures.cpp | 15 ++-- ...nterpolated_corrected_curvature_measures.h | 87 +++++++++++-------- .../Display/Display_property_plugin.cpp | 56 ++++++------ 3 files changed, 85 insertions(+), 73 deletions(-) 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 4480366bc2b0..63c0b8df528c 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 @@ -17,7 +17,7 @@ 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; -typedef std::unordered_map vertexVectorMap_tag; +typedef std::unordered_map vertexVectorMap_tag; int main(int argc, char* argv[]) @@ -25,7 +25,7 @@ int main(int argc, char* argv[]) Mesh g1; const std::string filename = (argc>1) ? argv[1] : - CGAL::data_file_path("meshes/small_bunny.obj"); + CGAL::data_file_path("meshes/cylinder.off"); if(!CGAL::IO::read_polygon_mesh(filename, g1)) { @@ -33,8 +33,9 @@ int main(int argc, char* argv[]) return EXIT_FAILURE; } - FaceMeasureMap_tag mean_curvature_init, gaussian_curvature_init; - boost::associative_property_map + + vertexVectorMap_tag mean_curvature_init, gaussian_curvature_init; + boost::associative_property_map mean_curvature_map(mean_curvature_init), gaussian_curvature_map(gaussian_curvature_init); PMP::interpolated_corrected_mean_curvature( @@ -46,7 +47,7 @@ int main(int argc, char* argv[]) gaussian_curvature_map ); - for (face_descriptor f: g1.faces()) - std::cout << f.idx() << ": HC = " << get(mean_curvature_map, f) - << ", GC = " << get(gaussian_curvature_map, f) << "\n"; + for (vertex_descriptor v : vertices(g1)) + std::cout << v.idx() << ": HC = " << get(mean_curvature_map, v) + << ", GC = " << get(gaussian_curvature_map, v) << "\n"; } 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 3528ffed8a43..3b499a8fe94d 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 @@ -378,11 +378,12 @@ typename GT::FT face_in_ball_ratio_2(const std::vector& x return (r - d_min) / (d_max - d_min); } -template - void expand_interpolated_corrected_measure_face(const PolygonMesh& pmesh, + void expand_interpolated_corrected_measure_vertex(const PolygonMesh& pmesh, FaceMeasureMap fmm, - const typename boost::graph_traits::face_descriptor f, + VertexCurvatureMap vcm, + const typename boost::graph_traits::vertex_descriptor v, const NamedParameters& np = parameters::default_values()) { using parameters::choose_parameter; @@ -406,30 +407,28 @@ template bfs_q; std::unordered_set bfs_v; - //get face center c - typename GT::Vector_3 c; - for (vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) - { - typename GT::Point_3 p = get(vpm, v); - c += typename GT::Vector_3(p.x(), p.y(), p.z()); - } - c /= degree(f, pmesh); + typename GT::Point_3 vp = get(vpm, v); + typename GT::Vector_3 c = typename GT::Vector_3(vp.x(), vp.y(), vp.z()); typename GT::FT corrected_mui = 0; - bfs_q.push(f); - bfs_v.insert(f); - + for (face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { + if (f != boost::graph_traits::null_face()) + { + bfs_q.push(f); + bfs_v.insert(f); + } + } while (!bfs_q.empty()) { face_descriptor fi = bfs_q.front(); bfs_q.pop(); // looping over vertices in face to get point coordinates std::vector x; - for (vertex_descriptor v : vertices_around_face(halfedge(fi, pmesh), pmesh)) + for (vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh)) { - typename GT::Point_3 p = get(vpm, v); - x.push_back(typename GT::Vector_3(p.x(), p.y(), p.z())); + typename GT::Point_3 pi = get(vpm, vi); + x.push_back(typename GT::Vector_3(pi.x(), pi.y(), pi.z())); } const typename GT::FT f_ratio = face_in_ball_ratio_2(x, r, c); @@ -448,7 +447,7 @@ template void interpolated_corrected_mean_curvature(const PolygonMesh& pmesh, - FaceCurvatureMap fcm, + VertexCurvatureMap vcm, const NamedParameters& np = parameters::default_values()) { typedef typename GetGeomTraits::type GT; typedef typename boost::graph_traits::face_descriptor face_descriptor; typedef std::unordered_map FaceMeasureMap_tag; + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef std::unordered_map VertexMeasureMap_tag; FaceMeasureMap_tag mu0_init, mu1_init; boost::associative_property_map mu0_map(mu0_init), mu1_map(mu1_init); + VertexMeasureMap_tag mu0_expand_init, mu1_expand_init; + boost::associative_property_map + mu0_expand_map(mu0_expand_init), mu1_expand_map(mu1_expand_init); + interpolated_corrected_measure_mesh(pmesh, mu0_map, MU0_AREA_MEASURE); interpolated_corrected_measure_mesh(pmesh, mu1_map, MU1_MEAN_CURVATURE_MEASURE); - for (face_descriptor f : faces(pmesh)) + for (vertex_descriptor v : vertices(pmesh)) { - expand_interpolated_corrected_measure_face(pmesh, mu0_map, f, np); - expand_interpolated_corrected_measure_face(pmesh, mu1_map, f, np); - - const typename GT::FT f_mu0 = get(mu0_map, f); - if (f_mu0 > 0.000001) - put(fcm, f, 0.5 * get(mu1_map, f) / get(mu0_map, f)); - else - put(fcm, f, 0); + expand_interpolated_corrected_measure_vertex(pmesh, mu0_map, mu0_expand_map, v, np); + expand_interpolated_corrected_measure_vertex(pmesh, mu1_map, mu1_expand_map, v, np); + + typename GT::FT v_mu0 = get(mu0_expand_map, v); + if (v_mu0 > 0.000001) + put(vcm, v, 0.5 * get(mu1_expand_map, v) / v_mu0); + else + put(vcm, v, 0); } } -template void interpolated_corrected_gaussian_curvature(const PolygonMesh& pmesh, - FaceCurvatureMap fcm, + VertexCurvatureMap vcm, const NamedParameters& np = parameters::default_values()) { typedef typename GetGeomTraits::type GT; typedef typename boost::graph_traits::face_descriptor face_descriptor; typedef std::unordered_map FaceMeasureMap_tag; + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef std::unordered_map VertexMeasureMap_tag; FaceMeasureMap_tag mu0_init, mu2_init; boost::associative_property_map mu0_map(mu0_init), mu2_map(mu2_init); + VertexMeasureMap_tag mu0_expand_init, mu2_expand_init; + boost::associative_property_map + mu0_expand_map(mu0_expand_init), mu2_expand_map(mu2_expand_init); + interpolated_corrected_measure_mesh(pmesh, mu0_map, MU0_AREA_MEASURE); interpolated_corrected_measure_mesh(pmesh, mu2_map, MU2_GAUSSIAN_CURVATURE_MEASURE); - for (face_descriptor f : faces(pmesh)) + for (vertex_descriptor v : vertices(pmesh)) { - expand_interpolated_corrected_measure_face(pmesh, mu0_map, f, np); - expand_interpolated_corrected_measure_face(pmesh, mu2_map, f, np); + expand_interpolated_corrected_measure_vertex(pmesh, mu0_map, mu0_expand_map, v, np); + expand_interpolated_corrected_measure_vertex(pmesh, mu2_map, mu2_expand_map, v, np); - const typename GT::FT f_mu0 = get(mu0_map, f); - if(f_mu0 > 0.000001) - put(fcm, f, get(mu2_map, f) / f_mu0); + typename GT::FT v_mu0 = get(mu0_expand_map, v); + if(v_mu0 > 0.000001) + put(vcm, v, get(mu2_expand_map, v) / v_mu0); else - put(fcm, f, 0); + put(vcm, v, 0); } } diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index 88d86966f1d7..2f9bd19e584b 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -611,11 +611,11 @@ private Q_SLOTS: break; case 4: // Interpolated Corrected Mean Curvature displayInterpolatedCurvatureMeasure(sm_item, PMP::MU1_MEAN_CURVATURE_MEASURE); - sm_item->setRenderingMode(Flat); + sm_item->setRenderingMode(Gouraud); break; case 5: // Interpolated Corrected Gaussian Curvature displayInterpolatedCurvatureMeasure(sm_item, PMP::MU2_GAUSSIAN_CURVATURE_MEASURE); - sm_item->setRenderingMode(Flat); + sm_item->setRenderingMode(Gouraud); break; default: if(dock_widget->propertyBox->currentText().contains("v:")) @@ -652,11 +652,11 @@ private Q_SLOTS: if(does_exist) sm_item->face_graph()->remove_property_map(pmap); std::tie(pmap, does_exist) = - sm_item->face_graph()->property_map("f:interpolated_corrected_mean_curvature"); + sm_item->face_graph()->property_map("v:interpolated_corrected_mean_curvature"); if (does_exist) sm_item->face_graph()->remove_property_map(pmap); std::tie(pmap, does_exist) = - sm_item->face_graph()->property_map("f:interpolated_corrected_gaussian_curvature"); + sm_item->face_graph()->property_map("v:interpolated_corrected_gaussian_curvature"); if (does_exist) sm_item->face_graph()->remove_property_map(pmap); }); @@ -731,14 +731,14 @@ private Q_SLOTS: { smesh.remove_property_map(angles); } - SMesh::Property_map mean_curvature; - std::tie(mean_curvature, found) = smesh.property_map("f:interpolated_corrected_mean_curvature"); + SMesh::Property_map mean_curvature; + std::tie(mean_curvature, found) = smesh.property_map("v:interpolated_corrected_mean_curvature"); if (found) { smesh.remove_property_map(mean_curvature); } - SMesh::Property_map gaussian_curvature; - std::tie(gaussian_curvature, found) = smesh.property_map("f:interpolated_corrected_gaussian_curvature"); + SMesh::Property_map gaussian_curvature; + std::tie(gaussian_curvature, found) = smesh.property_map("v:interpolated_corrected_gaussian_curvature"); if (found) { smesh.remove_property_map(gaussian_curvature); @@ -786,13 +786,13 @@ private Q_SLOTS: void displayInterpolatedCurvatureMeasure(Scene_surface_mesh_item* item, PMP::Curvature_measure_index mu_index) { std::string tied_string = (mu_index == PMP::MU1_MEAN_CURVATURE_MEASURE)? - "f:interpolated_corrected_mean_curvature": "f:interpolated_corrected_gaussian_curvature"; + "v:interpolated_corrected_mean_curvature": "v:interpolated_corrected_gaussian_curvature"; SMesh& smesh = *item->face_graph(); //compute once and store the value per face bool non_init; - SMesh::Property_map mu_i_map; + SMesh::Property_map mu_i_map; std::tie(mu_i_map, non_init) = - smesh.add_property_map(tied_string, 0); + smesh.add_property_map(tied_string, 0); if (non_init) { if (mu_index == PMP::MU1_MEAN_CURVATURE_MEASURE) @@ -802,18 +802,18 @@ private Q_SLOTS: double res_min = ARBITRARY_DBL_MAX, res_max = -ARBITRARY_DBL_MAX; - SMesh::Face_index min_index, max_index; - for (SMesh::Face_index f : faces(smesh)) + SMesh::Vertex_index min_index, max_index; + for (SMesh::Vertex_index v : vertices(smesh)) { - if (mu_i_map[f] > res_max) + if (mu_i_map[v] > res_max) { - res_max = mu_i_map[f]; - max_index = f; + res_max = mu_i_map[v]; + max_index = v; } - if (mu_i_map[f] < res_min) + if (mu_i_map[v] < res_min) { - res_min = mu_i_map[f]; - min_index = f; + res_min = mu_i_map[v]; + min_index = v; } } switch (mu_index) @@ -831,7 +831,7 @@ private Q_SLOTS: connect(item, &Scene_surface_mesh_item::itemChanged, this, &DisplayPropertyPlugin::resetProperty); } - treat_sm_property(tied_string, item->face_graph()); + treat_sm_property(tied_string, item->face_graph()); } @@ -1199,7 +1199,7 @@ private Q_SLOTS: case 4: { ::zoomToId(*item->face_graph(), - QString("f%1").arg(mean_curvature_min[item].second), + QString("v%1").arg(mean_curvature_min[item].second), getActiveViewer(), dummy_fd, dummy_p); @@ -1208,7 +1208,7 @@ private Q_SLOTS: case 5: { ::zoomToId(*item->face_graph(), - QString("f%1").arg(gaussian_curvature_min[item].second), + QString("v%1").arg(gaussian_curvature_min[item].second), getActiveViewer(), dummy_fd, dummy_p); @@ -1252,7 +1252,7 @@ private Q_SLOTS: case 4: { ::zoomToId(*item->face_graph(), - QString("f%1").arg(mean_curvature_max[item].second), + QString("v%1").arg(mean_curvature_max[item].second), getActiveViewer(), dummy_fd, dummy_p); @@ -1261,7 +1261,7 @@ private Q_SLOTS: case 5: { ::zoomToId(*item->face_graph(), - QString("f%1").arg(gaussian_curvature_max[item].second), + QString("v%1").arg(gaussian_curvature_max[item].second), getActiveViewer(), dummy_fd, dummy_p); @@ -1557,11 +1557,11 @@ private Q_SLOTS: std::unordered_map > angles_min; std::unordered_map > angles_max; - std::unordered_map > mean_curvature_min; - std::unordered_map > mean_curvature_max; + std::unordered_map > mean_curvature_min; + std::unordered_map > mean_curvature_max; - std::unordered_map > gaussian_curvature_min; - std::unordered_map > gaussian_curvature_max; + std::unordered_map > gaussian_curvature_min; + std::unordered_map > gaussian_curvature_max; std::unordered_map is_source; From 4ffd2d2a098b3c0bb69db2ade868e770e153de54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 27 Jul 2022 19:05:30 +0200 Subject: [PATCH 025/142] add missing typename --- .../Curvatures/interpolated_corrected_curvature_measures.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 03e5f396e3ce..0c6a370059c4 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 @@ -74,7 +74,7 @@ typename GT::FT interpolated_corrected_measure_triangle(const typename GT::Vecto const typename GT::Vector_3 u2, const Curvature_measure_index mu_i) { - GT::Construct_cross_product_3 cross_product; + typename GT::Construct_cross_product_3 cross_product; switch (mu_i) { case MU0_AREA_MEASURE: @@ -139,7 +139,7 @@ typename GT::FT interpolated_corrected_measure_quad(const typename GT::Vector_3 { // x0 _ x1 // x2 |_| x3 - GT::Construct_cross_product_3 cross_product; + typename GT::Construct_cross_product_3 cross_product; switch (mu_i) { case MU0_AREA_MEASURE: From 62c91c1479fb2396ed6b0e9ef9d707e9ef643f93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 27 Jul 2022 19:10:52 +0200 Subject: [PATCH 026/142] remove trailing whitespaces --- .../Polyhedron/Plugins/Display/Display_property_plugin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index 2f9bd19e584b..0334eb45a972 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -785,13 +785,13 @@ private Q_SLOTS: void displayInterpolatedCurvatureMeasure(Scene_surface_mesh_item* item, PMP::Curvature_measure_index mu_index) { - std::string tied_string = (mu_index == PMP::MU1_MEAN_CURVATURE_MEASURE)? + std::string tied_string = (mu_index == PMP::MU1_MEAN_CURVATURE_MEASURE)? "v:interpolated_corrected_mean_curvature": "v:interpolated_corrected_gaussian_curvature"; SMesh& smesh = *item->face_graph(); //compute once and store the value per face bool non_init; SMesh::Property_map mu_i_map; - std::tie(mu_i_map, non_init) = + std::tie(mu_i_map, non_init) = smesh.add_property_map(tied_string, 0); if (non_init) { From 184fa0c8a4b5be1b0ca9aab7bdcade05de342cc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 27 Jul 2022 19:28:44 +0200 Subject: [PATCH 027/142] fix invalid functor name --- .../Curvatures/interpolated_corrected_curvature_measures.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 0c6a370059c4..c3f349740204 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 @@ -74,7 +74,7 @@ typename GT::FT interpolated_corrected_measure_triangle(const typename GT::Vecto const typename GT::Vector_3 u2, const Curvature_measure_index mu_i) { - typename GT::Construct_cross_product_3 cross_product; + typename GT::Construct_cross_product_vector_3 cross_product; switch (mu_i) { case MU0_AREA_MEASURE: @@ -139,7 +139,7 @@ typename GT::FT interpolated_corrected_measure_quad(const typename GT::Vector_3 { // x0 _ x1 // x2 |_| x3 - typename GT::Construct_cross_product_3 cross_product; + typename GT::Construct_cross_product_vector_3 cross_product; switch (mu_i) { case MU0_AREA_MEASURE: From db753ee6b568c16ce2872a72d21cf9bed62e42c0 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sun, 31 Jul 2022 00:21:55 +0200 Subject: [PATCH 028/142] Demo improvements + minor fixes - Fixed some typos in example file and in comment in display prop plugin - Added an option in random perturbation plugin to compute normals before hand - added slider for expanding radius with an exponential range and with max val dependant on max edge length --- .../interpolated_corrected_curvatures.cpp | 6 +-- ...nterpolated_corrected_curvature_measures.h | 12 ----- .../Plugins/Display/Display_property.ui | 36 ++++++++++++-- .../Display/Display_property_plugin.cpp | 49 ++++++++++++++++++- .../Plugins/PMP/Random_perturbation_dialog.ui | 24 ++++++++- .../PMP/Random_perturbation_plugin.cpp | 7 +++ 6 files changed, 111 insertions(+), 23 deletions(-) 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 63c0b8df528c..5359315f0fa0 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 @@ -17,7 +17,7 @@ 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; -typedef std::unordered_map vertexVectorMap_tag; +typedef std::unordered_map vertexMeasureMap_tag; int main(int argc, char* argv[]) @@ -34,8 +34,8 @@ int main(int argc, char* argv[]) } - vertexVectorMap_tag mean_curvature_init, gaussian_curvature_init; - boost::associative_property_map + vertexMeasureMap_tag mean_curvature_init, gaussian_curvature_init; + boost::associative_property_map mean_curvature_map(mean_curvature_init), gaussian_curvature_map(gaussian_curvature_init); PMP::interpolated_corrected_mean_curvature( 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 c3f349740204..d36e1c67e363 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 @@ -338,7 +338,6 @@ template //typename GT::FT triangle_in_ball_ratio_1(const typename GT::Vector_3 x1, @@ -464,17 +463,6 @@ template -// void expand_interpolated_corrected_measure_mesh(const PolygonMesh& pmesh, -// FaceMeasureMap fmm, -// const NamedParameters& np = parameters::default_values()) -//{ -// typedef typename boost::graph_traits::face_descriptor face_descriptor; -// for (face_descriptor f : faces(pmesh)) -// expand_interpolated_corrected_measure_face(pmesh, fmm, f, np); -//} - template void interpolated_corrected_mean_curvature(const PolygonMesh& pmesh, diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property.ui b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property.ui index 7a5a19621f42..70c22f8348c2 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property.ui @@ -84,18 +84,18 @@ Ramp Colors - + - Color Min... + Min - Color Max... + Max @@ -135,7 +135,7 @@ Zoom - + @@ -158,7 +158,7 @@ Ramp Extrema - + @@ -186,6 +186,32 @@ + + + + 0 + + + 100 + + + true + + + Qt::Horizontal + + + QSlider::TicksAbove + + + + + + + Expanding Radius: 0 + + + diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index 0334eb45a972..a2d25d167c6b 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -783,12 +784,56 @@ private Q_SLOTS: treat_sm_property("f:jacobian", item->face_graph()); } + double sliderRangeToExpandRadius(SMesh& smesh, double val) + { + double sliderMin = dock_widget->expandingRadiusSlider->minimum(); + double sliderMax = dock_widget->expandingRadiusSlider->maximum() - sliderMin; + val -= sliderMin; + sliderMin = 0; + + auto vpm = get(CGAL::vertex_point, smesh); + + auto edge_range = CGAL::edges(smesh); + + if (edge_range.begin() == edge_range.end()) + return 0; + + auto edge_reference = std::max_element(edge_range.begin(), edge_range.end(), [&, vpm, smesh](auto l, auto r) { + auto res = EPICK().compare_squared_distance_3_object()( + get(vpm, source((l), smesh)), + get(vpm, target((l), smesh)), + get(vpm, source((r), smesh)), + get(vpm, target((r), smesh))); + return res == CGAL::SMALLER; + }); + + // if edge_reference is not derefrenceble + if (edge_reference == edge_range.end()) + return 0; + + double L = sqrt( + (get(vpm, source((*edge_reference), smesh)) - get(vpm, target((*edge_reference), smesh))) + .squared_length() + ); + + std::cout << L << std::endl; + + double outMin = 0, outMax = 5 * L, base = 1.2; + + return (pow(base, val) - 1) * outMax / (pow(base, sliderMax) - 1); + + } + void displayInterpolatedCurvatureMeasure(Scene_surface_mesh_item* item, PMP::Curvature_measure_index mu_index) { std::string tied_string = (mu_index == PMP::MU1_MEAN_CURVATURE_MEASURE)? "v:interpolated_corrected_mean_curvature": "v:interpolated_corrected_gaussian_curvature"; SMesh& smesh = *item->face_graph(); - //compute once and store the value per face + + expandRadius = sliderRangeToExpandRadius(smesh, dock_widget->expandingRadiusSlider->value()); + dock_widget->expandingRadiusLabel->setText(tr("Expanding Radius : %1").arg(expandRadius)); + + //compute once and store the value per vertex bool non_init; SMesh::Property_map mu_i_map; std::tie(mu_i_map, non_init) = @@ -1565,7 +1610,7 @@ private Q_SLOTS: std::unordered_map is_source; - + double expandRadius; double minBox; double maxBox; QPixmap legend_; diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Random_perturbation_dialog.ui b/Polyhedron/demo/Polyhedron/Plugins/PMP/Random_perturbation_dialog.ui index 1d368c3dd592..3427d5b12e6a 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Random_perturbation_dialog.ui +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Random_perturbation_dialog.ui @@ -135,6 +135,26 @@ + + + keep vertex normals unperturbed + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + seed_spinbox + + + + + + + + + + + Random seed @@ -147,7 +167,7 @@ - + @@ -163,6 +183,8 @@ seed_spinbox seed_label + keep_normal_label + keep_normal_checkbox deterministic_label deterministic_checkbox diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Random_perturbation_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Random_perturbation_plugin.cpp index 53499b823367..9afb452ab13c 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Random_perturbation_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Random_perturbation_plugin.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -102,6 +103,12 @@ public Q_SLOTS: if (poly_item) { SMesh& pmesh = *poly_item->face_graph(); + if(ui.keep_normal_checkbox->isChecked()) + { + SMesh::Property_map vnormals = + pmesh.add_property_map("v:normal").first; + CGAL::Polygon_mesh_processing::compute_vertex_normals(pmesh,vnormals); + } if(ui.deterministic_checkbox->isChecked()) { unsigned int seed = static_cast(ui.seed_spinbox->value()); From 127c87857cbec43e692dfd94aefbe7755029e376 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sun, 31 Jul 2022 00:32:42 +0200 Subject: [PATCH 029/142] Use slider radius (after remapping) in curvature computation --- .../Polyhedron/Plugins/Display/Display_property_plugin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index a2d25d167c6b..92f9df7b213d 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -841,9 +841,9 @@ private Q_SLOTS: if (non_init) { if (mu_index == PMP::MU1_MEAN_CURVATURE_MEASURE) - PMP::interpolated_corrected_mean_curvature(smesh, mu_i_map); + PMP::interpolated_corrected_mean_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expandRadius)); else - PMP::interpolated_corrected_gaussian_curvature(smesh, mu_i_map); + PMP::interpolated_corrected_gaussian_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expandRadius)); double res_min = ARBITRARY_DBL_MAX, res_max = -ARBITRARY_DBL_MAX; From 22c0859d92fa444f0ca78b2c21bb58cf843d730d Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sun, 31 Jul 2022 00:41:43 +0200 Subject: [PATCH 030/142] trailing spaces --- .../demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index 92f9df7b213d..19afdc6728ec 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -815,7 +815,7 @@ private Q_SLOTS: (get(vpm, source((*edge_reference), smesh)) - get(vpm, target((*edge_reference), smesh))) .squared_length() ); - + std::cout << L << std::endl; double outMin = 0, outMax = 5 * L, base = 1.2; From 9635ec14975c74beaaac9cce6f4fc6c883f5ff98 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sun, 31 Jul 2022 18:55:51 +0200 Subject: [PATCH 031/142] minor changes on demo (wip) --- ...nterpolated_corrected_curvature_measures.h | 9 +-- .../Display/Display_property_plugin.cpp | 77 +++++++++++-------- 2 files changed, 50 insertions(+), 36 deletions(-) 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 d36e1c67e363..1ee24fef37f5 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 @@ -409,9 +409,6 @@ template::type::FT r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0.01); - if (r < 0.000001) - return; - typename GetVertexPointMap::const_type vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), get_const_property_map(CGAL::vertex_point, pmesh)); @@ -446,7 +443,7 @@ template(x, r, c); - if (f_ratio > 0.000001) + if (f_ratio > 0.00000001) { corrected_mui += f_ratio * get(fmm, fi); for (face_descriptor fj : faces_around_face(halfedge(fi, pmesh), pmesh)) @@ -492,7 +489,7 @@ template 0.000001) + if (v_mu0 > 0.00000001) put(vcm, v, 0.5 * get(mu1_expand_map, v) / v_mu0); else put(vcm, v, 0); @@ -528,7 +525,7 @@ template 0.000001) + if(v_mu0 > 0.00000001) put(vcm, v, get(mu2_expand_map, v) / v_mu0); else put(vcm, v, 0); diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index 19afdc6728ec..91deb90680a8 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -487,8 +487,10 @@ class DisplayPropertyPlugin : connect(scene_obj, SIGNAL(itemIndexSelected(int)), this,SLOT(detectScalarProperties(int))); - on_propertyBox_currentIndexChanged(0); + connect(dock_widget->expandingRadiusSlider, SIGNAL(valueChanged(int)), + this, SLOT(setExpandingRadius(int))); + on_propertyBox_currentIndexChanged(0); } private: @@ -716,6 +718,10 @@ private Q_SLOTS: { Scene_surface_mesh_item* item = qobject_cast(sender()); + + maxEdgeLength = -1; + setExpandingRadius(dock_widget->expandingRadiusSlider->value()); + if(!item) return; SMesh& smesh = *item->face_graph(); @@ -784,43 +790,56 @@ private Q_SLOTS: treat_sm_property("f:jacobian", item->face_graph()); } - double sliderRangeToExpandRadius(SMesh& smesh, double val) + void setExpandingRadius(int val_int) { double sliderMin = dock_widget->expandingRadiusSlider->minimum(); double sliderMax = dock_widget->expandingRadiusSlider->maximum() - sliderMin; - val -= sliderMin; + double val = val_int - sliderMin; sliderMin = 0; - auto vpm = get(CGAL::vertex_point, smesh); - - auto edge_range = CGAL::edges(smesh); - - if (edge_range.begin() == edge_range.end()) - return 0; + SMesh& smesh = *(qobject_cast(scene->item(scene->mainSelectionIndex())))->face_graph(); - auto edge_reference = std::max_element(edge_range.begin(), edge_range.end(), [&, vpm, smesh](auto l, auto r) { - auto res = EPICK().compare_squared_distance_3_object()( - get(vpm, source((l), smesh)), - get(vpm, target((l), smesh)), - get(vpm, source((r), smesh)), - get(vpm, target((r), smesh))); - return res == CGAL::SMALLER; - }); + auto vpm = get(CGAL::vertex_point, smesh); - // if edge_reference is not derefrenceble - if (edge_reference == edge_range.end()) - return 0; + if (maxEdgeLength < 0) + { + auto edge_range = CGAL::edges(smesh); - double L = sqrt( - (get(vpm, source((*edge_reference), smesh)) - get(vpm, target((*edge_reference), smesh))) - .squared_length() - ); + if (edge_range.begin() == edge_range.end()) + { + expandRadius = 0; + dock_widget->expandingRadiusLabel->setText(tr("Expanding Radius : %1").arg(expandRadius)); + return; + } - std::cout << L << std::endl; + auto edge_reference = std::max_element(edge_range.begin(), edge_range.end(), [&, vpm, smesh](auto l, auto r) { + auto res = EPICK().compare_squared_distance_3_object()( + get(vpm, source((l), smesh)), + get(vpm, target((l), smesh)), + get(vpm, source((r), smesh)), + get(vpm, target((r), smesh))); + return res == CGAL::SMALLER; + }); + + // if edge_reference is not derefrenceble + if (edge_reference == edge_range.end()) + { + expandRadius = 0; + dock_widget->expandingRadiusLabel->setText(tr("Expanding Radius : %1").arg(expandRadius)); + return; + } - double outMin = 0, outMax = 5 * L, base = 1.2; + maxEdgeLength = sqrt( + (get(vpm, source((*edge_reference), smesh)) - get(vpm, target((*edge_reference), smesh))) + .squared_length() + ); - return (pow(base, val) - 1) * outMax / (pow(base, sliderMax) - 1); + } + + double outMin = 0, outMax = 5 * maxEdgeLength, base = 1.2; + + expandRadius = (pow(base, val) - 1) * outMax / (pow(base, sliderMax) - 1); + dock_widget->expandingRadiusLabel->setText(tr("Expanding Radius : %1").arg(expandRadius)); } @@ -830,9 +849,6 @@ private Q_SLOTS: "v:interpolated_corrected_mean_curvature": "v:interpolated_corrected_gaussian_curvature"; SMesh& smesh = *item->face_graph(); - expandRadius = sliderRangeToExpandRadius(smesh, dock_widget->expandingRadiusSlider->value()); - dock_widget->expandingRadiusLabel->setText(tr("Expanding Radius : %1").arg(expandRadius)); - //compute once and store the value per vertex bool non_init; SMesh::Property_map mu_i_map; @@ -1611,6 +1627,7 @@ private Q_SLOTS: std::unordered_map is_source; double expandRadius; + double maxEdgeLength = -1; double minBox; double maxBox; QPixmap legend_; From 765220a4661743db3367676f6723cdc9dd23ccce Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sun, 31 Jul 2022 20:03:33 +0200 Subject: [PATCH 032/142] removing the switch from measures functions (for optimization) --- ...nterpolated_corrected_curvature_measures.h | 277 ++++++++++-------- 1 file changed, 151 insertions(+), 126 deletions(-) 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 1ee24fef37f5..250ea596c1c3 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 @@ -26,6 +26,7 @@ #include #include #include +#include namespace CGAL { @@ -46,207 +47,215 @@ enum Curvature_measure_index { /** * \ingroup PMP_corrected_curvatures_grp * -* computes the interpolated corrected measure of specific triangle. +* computes the interpolated corrected area measure of a specific face. * * @tparam GT is the geometric traits class. * -* @param x0 is the position of vertex #0. -* @param x1 is the position of vertex #1. -* @param x2 is the position of vertex #2. -* @param u0 is the normal vector of vertex #0. -* @param u1 is the normal vector of vertex #1. -* @param u2 is the normal vector of vertex #2. -* @param mu_i an enum for choosing between computing the area measure, -* the mean curvature measure, or the gaussian curvature measure. +* @param x is a vector of the vertex positions of the face. +* @param u is a vector of the vertex nomrals of the face. * * @return a scalar of type `GT::FT`. -* This is the value of the interpolated corrected measure of the given triangle. +* This is the value of the interpolated corrected area measure of the given face. * -* @see `interpolated_corrected_measure_face()` -* @see `interpolated_corrected_measure_quad()` +* @see `interpolated_corrected_mean_curvature_measure_face()` +* @see `interpolated_corrected_gaussian_curvature_measure_face()` +* @see `interpolated_corrected_measure_mesh()` */ template -typename GT::FT interpolated_corrected_measure_triangle(const typename GT::Vector_3 x0, - const typename GT::Vector_3 x1, - const typename GT::Vector_3 x2, - const typename GT::Vector_3 u0, - const typename GT::Vector_3 u1, - const typename GT::Vector_3 u2, - const Curvature_measure_index mu_i) +typename GT::FT interpolated_corrected_area_measure_face(const std::vector& x, + const std::vector& u) { + std::size_t n = x.size(); + CGAL_precondition(u.size() == n); + CGAL_precondition(n >= 3); + typename GT::Construct_cross_product_vector_3 cross_product; - switch (mu_i) + + // Triangle: use triangle formula + if (n == 3) { - case MU0_AREA_MEASURE: + const typename GT::Vector_3 um = (u[0] + u[1] + u[2]) / 3.0; + return 0.5 * um * cross_product(x[1] - x[0], x[2] - x[0]); + } + // Quad: use bilinear interpolation formula + else if (n == 4) { - const typename GT::Vector_3 um = (u0 + u1 + u2) / 3.0; - - return 0.5 * um * cross_product(x1 - x0, x2 - x0); + // for the formulas below, values of verices 2 & 3 are swapped (compared to paper) to correct order. + return (1 / 36.0) * ( + (4 * u[0] + 2 * u[1] + 2 * u[3] + u[2]) * cross_product(u[1] - u[0], u[3] - u[0]) + + (2 * u[0] + 4 * u[1] + u[3] + 2 * u[2]) * cross_product(u[1] - u[0], u[2] - u[1]) + + (2 * u[0] + u[1] + 4 * u[3] + 2 * u[2]) * cross_product(u[2] - u[3], u[3] - u[0]) + + (u[0] + 2 * u[1] + 2 * u[3] + 4 * u[2]) * cross_product(u[2] - u[3], u[2] - u[1]) + ); } - case MU1_MEAN_CURVATURE_MEASURE: + // N-gon: split into n triangles by polygon center and use triangle formula for each + else { - const typename GT::Vector_3 um = (u0 + u1 + u2) / 3.0; + typename GT::FT mu0 = 0; - return 0.5 * um * (cross_product(u2 - u1, x0) - + cross_product(u0 - u2, x1) - + cross_product(u1 - u0, x2)); - } - case MU2_GAUSSIAN_CURVATURE_MEASURE: + // getting center of points + typename GT::Vector_3 xc = + std::accumulate(x.begin(), x.end(), typename GT::Vector_3(0, 0, 0)); + xc /= n; - return 0.5 * u0 * cross_product(u1, u2); + // getting unit average normal of points + typename GT::Vector_3 uc = + std::accumulate(u.begin(), u.end(), typename GT::Vector_3(0, 0, 0)); + uc /= sqrt(uc * uc); - default: return 0; + // summing each triangle's measure after triangulation by barycenter split. + for (std::size_t i = 0; i < n; i++) + { + const typename GT::Vector_3 um = (u[i] + u[(i + 1) % n] + uc) / 3.0; + mu0 += 0.5 * um * cross_product(x[(i + 1) % n] - x[i], xc - x[i]); + } + return mu0; } } /** * \ingroup PMP_corrected_curvatures_grp * -* 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 +* computes the interpolated corrected mean curvature measure of a specific face. * * @tparam GT is the geometric traits class. * -* @param x0 is the position of vertex #0. -* @param x1 is the position of vertex #1. -* @param x2 is the position of vertex #2. -* @param x3 is the position of vertex #3. -* @param u0 is the normal vector of vertex #0. -* @param u1 is the normal vector of vertex #1. -* @param u2 is the normal vector of vertex #2. -* @param u3 is the normal vector of vertex #3. -* @param mu_i an enum for choosing between computing the area measure, -* the mean curvature measure, or the gaussian curvature measure. +* @param x is a vector of the vertex positions of the face. +* @param u is a vector of the vertex nomrals of the face. * * @return a scalar of type `GT::FT`. -* This is the value of the interpolated corrected measure of the given triangle. +* This is the value of the interpolated corrected mean curvature measure of the given face. * -* @see `interpolated_corrected_measure_face()` -* @see `interpolated_corrected_measure_triangle()` +* @see `interpolated_corrected_gaussian_curvature_measure_face()` +* @see `interpolated_corrected_area_measure_face()` +* @see `interpolated_corrected_measure_mesh()` */ template -typename GT::FT interpolated_corrected_measure_quad(const typename GT::Vector_3 x0, - const typename GT::Vector_3 x1, - const typename GT::Vector_3 x2, - const typename GT::Vector_3 x3, - const typename GT::Vector_3 u0, - const typename GT::Vector_3 u1, - const typename GT::Vector_3 u2, - const typename GT::Vector_3 u3, - const Curvature_measure_index mu_i) +typename GT::FT interpolated_corrected_mean_curvature_measure_face(const std::vector& x, + const std::vector& u) { - // x0 _ x1 - // x2 |_| x3 + std::size_t n = x.size(); + CGAL_precondition(u.size() == n); + CGAL_precondition(n >= 3); + typename GT::Construct_cross_product_vector_3 cross_product; - switch (mu_i) - { - case MU0_AREA_MEASURE: - return (1 / 36.0) * ( - (4 * u0 + 2 * u1 + 2 * u2 + u3) * cross_product(x1 - x0, x2 - x0) - + (2 * u0 + 4 * u1 + u2 + 2 * u3) * cross_product(x1 - x0, x3 - x1) - + (2 * u0 + u1 + 4 * u2 + 2 * u3) * cross_product(x3 - x2, x2 - x0) - + (u0 + 2 * u1 + 2 * u2 + 4 * u3) * cross_product(x3 - x2, x3 - x1) - ); + // Triangle: use triangle formula + if (n == 3) + { + const typename GT::Vector_3 um = (u[0] + u[1] + u[2]) / 3.0; - case MU1_MEAN_CURVATURE_MEASURE: + return 0.5 * um * (cross_product(u[2] - u[1], x[0]) + + cross_product(u[0] - u[2], x[1]) + + cross_product(u[1] - u[0], x[2])); + } + // Quad: use bilinear interpolation formula + else if (n == 4) { - const typename GT::Vector_3 u03 = u3 - u0; - const typename GT::Vector_3 u12 = u2 - u1; - const typename GT::Vector_3 x0_cross = cross_product(u12, x0); - const typename GT::Vector_3 x1_cross = -cross_product(u03, x1); - const typename GT::Vector_3 x2_cross = cross_product(u03, x2); - const typename GT::Vector_3 x3_cross = -cross_product(u12, x3); + // for the formulas below, values of verices 2 & 3 are swapped (compared to paper) to correct order. + const typename GT::Vector_3 u02 = u[2] - u[0]; + const typename GT::Vector_3 u13 = u[3] - u[1]; + const typename GT::Vector_3 x0_cross = cross_product(u13, x[0]); + const typename GT::Vector_3 x1_cross = -cross_product(u02, x[1]); + const typename GT::Vector_3 x3_cross = cross_product(u02, x[3]); + const typename GT::Vector_3 x2_cross = -cross_product(u13, x[2]); return (1 / 12.0) * ( - u0 * (2 * x0_cross - cross_product((u2 + u3), x1) + cross_product((u1 + u3), x2) + x3_cross) - + u1 * (cross_product((u2 + u3), x0) + 2 * x1_cross + x2_cross - cross_product((u0 + u2), x3)) - + u2 * (-cross_product((u1 + u3), x0) + x1_cross + 2 * x2_cross + cross_product((u0 + u1), x3)) - + u3 * (x0_cross + cross_product((u0 + u2), x1) - cross_product((u0 + u1), x2) + 2 * x3_cross) + u[0] * (2 * x0_cross - cross_product((u[3] + u[2]), x[1]) + cross_product((u[1] + u[2]), x[3]) + x2_cross) + + u[1] * (cross_product((u[3] + u[2]), x[0]) + 2 * x1_cross + x3_cross - cross_product((u[0] + u[3]), x[2])) + + u[3] * (-cross_product((u[1] + u[2]), x[0]) + x1_cross + 2 * x3_cross + cross_product((u[0] + u[1]), x[2])) + + u[2] * (x0_cross + cross_product((u[0] + u[3]), x[1]) - cross_product((u[0] + u[1]), x[3]) + 2 * x2_cross) ); } - case MU2_GAUSSIAN_CURVATURE_MEASURE: + // N-gon: split into n triangles by polygon center and use triangle formula for each + else + { + typename GT::FT mu1 = 0; - return (1 / 36.0) * ( - (4 * u0 + 2 * u1 + 2 * u2 + u3) * cross_product(u1 - u0, u2 - u0) - + (2 * u0 + 4 * u1 + u2 + 2 * u3) * cross_product(u1 - u0, u3 - u1) - + (2 * u0 + u1 + 4 * u2 + 2 * u3) * cross_product(u3 - u2, u2 - u0) - + (u0 + 2 * u1 + 2 * u2 + 4 * u3) * cross_product(u3 - u2, u3 - u1) - ); + // getting center of points + typename GT::Vector_3 xc = + std::accumulate(x.begin(), x.end(), typename GT::Vector_3(0, 0, 0)); + xc /= n; + + // getting unit average normal of points + typename GT::Vector_3 uc = + std::accumulate(u.begin(), u.end(), typename GT::Vector_3(0, 0, 0)); + uc /= sqrt(uc * uc); - default: return 0; + // summing each triangle's measure after triangulation by barycenter split. + for (std::size_t i = 0; i < n; i++) + { + const typename GT::Vector_3 um = (u[i] + u[(i+1)%n] + uc) / 3.0; + mu1 += 0.5 * um * (cross_product(uc - u[(i + 1) % n], x[i]) + + cross_product(u[i] - uc, x[(i + 1) % n]) + + cross_product(u[(i + 1) % n] - u[i], xc)); + } + return mu1; } } - /** * \ingroup PMP_corrected_curvatures_grp * -* computes the interpolated corrected measure of specific face. +* computes the interpolated corrected gaussian curvature measure of a specific face. * * @tparam GT is the geometric traits class. * * @param x is a vector of the vertex positions of the face. * @param u is a vector of the vertex nomrals of the face. -* @param mu_i an enum for choosing between computing the area measure, -* the mean curvature measure, or the gaussian curvature measure. * * @return a scalar of type `GT::FT`. -* This is the value of the interpolated corrected measure of the given face. +* This is the value of the interpolated corrected gaussian curvature measure of the given face. * -* @see `interpolated_corrected_measure_triangle()` -* @see `interpolated_corrected_measure_quad()` +* @see `interpolated_corrected_mean_curvature_measure_face()` +* @see `interpolated_corrected_area_measure_face()` * @see `interpolated_corrected_measure_mesh()` */ template -typename GT::FT interpolated_corrected_measure_face(const std::vector& x, - const std::vector& u, - const Curvature_measure_index mu_i) +typename GT::FT interpolated_corrected_gaussian_curvature_measure_face(const std::vector& x, + const std::vector& u) { - std::size_t n = x.size(); - CGAL_precondition(u.size() == n); + std::size_t n = u.size(); CGAL_precondition(n >= 3); - // Triangle: use triangle formulas - if (n == 3) - return interpolated_corrected_measure_triangle(x[0], x[1], x[2], - u[0], u[1], u[2], mu_i); + typename GT::Construct_cross_product_vector_3 cross_product; - // Quad: use bilinear interpolation formulas + // Triangle: use triangle formula + if (n == 3) + { + return 0.5 * u[0] * cross_product(u[1], u[2]); + } + // Quad: use bilinear interpolation formula else if (n == 4) - // x[0] _ x[1] ---> x0 _ x1 (reason for changing order) - // x[3] |_| x[2] ---> x2 |_| x3 - return interpolated_corrected_measure_quad(x[0], x[1], x[3], x[2], - u[0], u[1], u[3], u[2], mu_i); - - // N-gon: split into n triangles by barycenter and use triangle formulas for each - else { - typename GT::FT mu0 = 0; - - // getting center of points - typename GT::Vector_3 xm = - std::accumulate(x.begin(), x.end(), typename GT::Vector_3(0, 0, 0)); - xm /= n; + { + // for the formulas below, values of verices 2 & 3 are swapped (compared to paper) to correct order. + return (1 / 36.0) * ( + (4 * u[0] + 2 * u[1] + 2 * u[3] + u[2]) * cross_product(x[1] - x[0], x[3] - x[0]) + + (2 * u[0] + 4 * u[1] + u[3] + 2 * u[2]) * cross_product(x[1] - x[0], x[2] - x[1]) + + (2 * u[0] + u[1] + 4 * u[3] + 2 * u[2]) * cross_product(x[2] - x[3], x[3] - x[0]) + + (u[0] + 2 * u[1] + 2 * u[3] + 4 * u[2]) * cross_product(x[2] - x[3], x[2] - x[1]) + ); + } + // N-gon: split into n triangles by polygon center and use triangle formula for each + else + { + typename GT::FT mu2 = 0; // getting unit average normal of points - typename GT::Vector_3 um = + typename GT::Vector_3 uc = std::accumulate(u.begin(), u.end(), typename GT::Vector_3(0, 0, 0)); - um /= sqrt(um * um); + uc /= sqrt(uc * uc); // summing each triangle's measure after triangulation by barycenter split. for (std::size_t i = 0; i < n; i++) { - mu0 += interpolated_corrected_measure_triangle(x[i], x[(i + 1) % n], xm, - u[i], u[(i + 1) % n], um, mu_i); + mu2 += 0.5 * u[i] * cross_product(u[(i + 1) % n], uc); } - return mu0; + return mu2; } } - /** * \ingroup PMP_corrected_curvatures_grp * @@ -322,6 +331,22 @@ template::value) compute_vertex_normals(pmesh, vnm, np); + std::function + &, const std::vector&)> + iccm_function; + switch (mu_i) + { + case MU0_AREA_MEASURE: + iccm_function = &interpolated_corrected_area_measure_face; + break; + case MU1_MEAN_CURVATURE_MEASURE: + iccm_function = &interpolated_corrected_mean_curvature_measure_face; + break; + case MU2_GAUSSIAN_CURVATURE_MEASURE: + iccm_function = &interpolated_corrected_gaussian_curvature_measure_face; + break; + } + for (face_descriptor f : faces(pmesh)) { std::vector x; @@ -334,7 +359,7 @@ template(x, u, mu_i)); + put(fmm, f, iccm_function(x, u)); } } From 870c27670b52912cad7946c8e93e2993c473bb0d Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 1 Aug 2022 08:15:18 +0200 Subject: [PATCH 033/142] minor fixes (typename, doc) --- .../Curvatures/interpolated_corrected_curvature_measures.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 250ea596c1c3..c9a70ee12ec8 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 @@ -295,7 +295,9 @@ typename GT::FT interpolated_corrected_gaussian_curvature_measure_face(const std * * \cgalNamedParamsEnd * -* @see `interpolated_corrected_measure_face()` +* @see `interpolated_corrected_area_measure_face()` +* @see `interpolated_corrected_mean_curvature_measure_face()` +* @see `interpolated_corrected_gaussian_curvature_measure_face()` */ template @@ -332,7 +334,7 @@ template&, const std::vector&)> + &, const std::vector&)> iccm_function; switch (mu_i) { From 34b776d6c2e6ce0ec8cf54c6139478fb86b3c48e Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 1 Aug 2022 08:35:06 +0200 Subject: [PATCH 034/142] trailing spaces --- .../Polyhedron/Plugins/Display/Display_property_plugin.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index 91deb90680a8..66187583657e 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -721,7 +721,7 @@ private Q_SLOTS: maxEdgeLength = -1; setExpandingRadius(dock_widget->expandingRadiusSlider->value()); - + if(!item) return; SMesh& smesh = *item->face_graph(); @@ -835,9 +835,9 @@ private Q_SLOTS: ); } - + double outMin = 0, outMax = 5 * maxEdgeLength, base = 1.2; - + expandRadius = (pow(base, val) - 1) * outMax / (pow(base, sliderMax) - 1); dock_widget->expandingRadiusLabel->setText(tr("Expanding Radius : %1").arg(expandRadius)); From 09cb2b1e6d1b78fe4e19031c40abb42fd12505cf Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Tue, 2 Aug 2022 23:12:23 +0200 Subject: [PATCH 035/142] some refactoring + implemented the anisotropic formulas function --- ...nterpolated_corrected_curvature_measures.h | 162 ++++++++++++++++-- 1 file changed, 143 insertions(+), 19 deletions(-) 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 c9a70ee12ec8..1032413a9c5c 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 @@ -47,7 +47,7 @@ enum Curvature_measure_index { /** * \ingroup PMP_corrected_curvatures_grp * -* computes the interpolated corrected area measure of a specific face. +* computes the interpolated corrected area measure (mu0) of a specific face. * * @tparam GT is the geometric traits class. * @@ -62,8 +62,8 @@ enum Curvature_measure_index { * @see `interpolated_corrected_measure_mesh()` */ template -typename GT::FT interpolated_corrected_area_measure_face(const std::vector& x, - const std::vector& u) +typename GT::FT interpolated_corrected_area_measure_face(const std::vector& u, + const std::vector& x = {}) { std::size_t n = x.size(); CGAL_precondition(u.size() == n); @@ -81,6 +81,7 @@ typename GT::FT interpolated_corrected_area_measure_face(const std::vector( + std::vector {u[i], u[i + 1 % n], uc}, + std::vector {x[i], x[i + 1 % n], xc} + ); } return mu0; } @@ -116,7 +119,7 @@ typename GT::FT interpolated_corrected_area_measure_face(const std::vector -typename GT::FT interpolated_corrected_mean_curvature_measure_face(const std::vector& x, - const std::vector& u) +typename GT::FT interpolated_corrected_mean_curvature_measure_face(const std::vector& u, + const std::vector& x = {}) { std::size_t n = x.size(); CGAL_precondition(u.size() == n); @@ -153,6 +156,7 @@ typename GT::FT interpolated_corrected_mean_curvature_measure_face(const std::ve else if (n == 4) { // for the formulas below, values of verices 2 & 3 are swapped (compared to paper) to correct order. + // the indices in paper vs in here are: 00 = 0, 10 = 1, 11 = 2, 01 = 3 const typename GT::Vector_3 u02 = u[2] - u[0]; const typename GT::Vector_3 u13 = u[3] - u[1]; @@ -186,10 +190,10 @@ typename GT::FT interpolated_corrected_mean_curvature_measure_face(const std::ve // summing each triangle's measure after triangulation by barycenter split. for (std::size_t i = 0; i < n; i++) { - const typename GT::Vector_3 um = (u[i] + u[(i+1)%n] + uc) / 3.0; - mu1 += 0.5 * um * (cross_product(uc - u[(i + 1) % n], x[i]) - + cross_product(u[i] - uc, x[(i + 1) % n]) - + cross_product(u[(i + 1) % n] - u[i], xc)); + mu1 += interpolated_corrected_mean_curvature_measure_face( + std::vector {u[i], u[i + 1 % n], uc}, + std::vector {x[i], x[i + 1 % n], xc} + ); } return mu1; } @@ -198,7 +202,7 @@ typename GT::FT interpolated_corrected_mean_curvature_measure_face(const std::ve /** * \ingroup PMP_corrected_curvatures_grp * -* computes the interpolated corrected gaussian curvature measure of a specific face. +* computes the interpolated corrected gaussian curvature measure (mu2) of a specific face. * * @tparam GT is the geometric traits class. * @@ -213,8 +217,8 @@ typename GT::FT interpolated_corrected_mean_curvature_measure_face(const std::ve * @see `interpolated_corrected_measure_mesh()` */ template -typename GT::FT interpolated_corrected_gaussian_curvature_measure_face(const std::vector& x, - const std::vector& u) +typename GT::FT interpolated_corrected_gaussian_curvature_measure_face(const std::vector& u, + const std::vector& x = {}) { std::size_t n = u.size(); CGAL_precondition(n >= 3); @@ -230,6 +234,7 @@ typename GT::FT interpolated_corrected_gaussian_curvature_measure_face(const std else if (n == 4) { // for the formulas below, values of verices 2 & 3 are swapped (compared to paper) to correct order. + // the indices in paper vs in here are: 00 = 0, 10 = 1, 11 = 2, 01 = 3 return (1 / 36.0) * ( (4 * u[0] + 2 * u[1] + 2 * u[3] + u[2]) * cross_product(x[1] - x[0], x[3] - x[0]) + (2 * u[0] + 4 * u[1] + u[3] + 2 * u[2]) * cross_product(x[1] - x[0], x[2] - x[1]) @@ -250,12 +255,131 @@ typename GT::FT interpolated_corrected_gaussian_curvature_measure_face(const std // summing each triangle's measure after triangulation by barycenter split. for (std::size_t i = 0; i < n; i++) { - mu2 += 0.5 * u[i] * cross_product(u[(i + 1) % n], uc); + mu2 += interpolated_corrected_gaussian_curvature_measure_face( + std::vector {u[i], u[i + 1 % n], uc} + ); } return mu2; } } +/** +* \ingroup PMP_corrected_curvatures_grp +* +* computes the interpolated corrected anisotropic measure (muXY) of a specific face. +* +* @tparam GT is the geometric traits class. +* +* @param u is a vector of the vertex nomrals of the face. +* @param x is a vector of the vertex positions of the face. +* +* @return an array of scalar values for each combination of the standard basis (3x3) of type `std::array`. +* These are the values of the interpolated corrected anisotropic measure of the given face. +* +* @see `interpolated_corrected_anisotropic_measure_mesh()` +*/ +template +std::array interpolated_corrected_anisotropic_measure_face(const std::vector& u, + const std::vector& x) +{ + std::size_t n = x.size(); + CGAL_precondition(u.size() == n); + CGAL_precondition(n >= 3); + + typename GT::Construct_cross_product_vector_3 cross_product; + std::array muXY; + + // Triangle: use triangle formula + if (n == 3) + { + const typename GT::Vector_3 u01 = u[1] - u[0]; + const typename GT::Vector_3 u02 = u[2] - u[0]; + const typename GT::Vector_3 x01 = x[1] - x[0]; + const typename GT::Vector_3 x02 = x[2] - x[0]; + const typename GT::Vector_3 um = (u[0] + u[1] + u[2]) / 3.0; + + for (std::size_t ix = 0; ix < 3; ix++) + { + const typename GT::Vector_3 X(0, 0, 0); + X[ix] = 1; + for (std::size_t iy = 0; iy < 3; iy++) + muXY[ix * 3 + iy] = 0.5 * um * (cross_product(u02[iy] * X, x01) - cross_product(u01[iy] * X, x02)); + } + } + // Quad: use bilinear interpolation formula + else if (n == 4) + { + // for the formulas below, values of verices 2 & 3 are swapped (compared to paper) to correct order. + // the indices in paper vs in here are: 00 = 0, 10 = 1, 11 = 2, 01 = 3 + for (std::size_t ix = 0; ix < 3; ix++) + { + const typename GT::Vector_3 X(0, 0, 0); + X[ix] = 1; + const typename GT::Vector_3 u0xX = cross_product(u[0], X); + const typename GT::Vector_3 u1xX = cross_product(u[1], X); + const typename GT::Vector_3 u2xX = cross_product(u[2], X); + const typename GT::Vector_3 u3xX = cross_product(u[3], X); + + for (std::size_t iy = 0; iy < 3; iy++) + muXY[ix * 3 + iy] = (1 / 72.0) * ( + + u[0][iy] * ( u0xX * ( - x[0] - 11 * x[1] + 13 * x[3] - x[2]) + + u1xX * ( -5 * x[0] - 7 * x[1] + 11 * x[3] + x[2]) + + u3xX * ( x[0] - 7 * x[1] + 11 * x[3] - 5 * x[2]) + + u2xX * ( - x[0] - 5 * x[1] + 7 * x[3] - x[2]) + ) + + u[1][iy] * ( u0xX * ( 13 * x[0] - x[1] - 7 * x[3] - 5 * x[2]) + + u1xX * ( 17 * x[0] - 5 * x[1] - 5 * x[3] - 7 * x[2]) + + u3xX * ( 5 * x[0] + x[1] + x[3] - 7 * x[2]) + + u2xX * ( 7 * x[0] - x[1] + 5 * x[3] - 11 * x[2]) + ) + + u[2][iy] * ( u0xX * (-11 * x[0] + 5 * x[1] - x[3] + 7 * x[2]) + + u1xX * (- 7 * x[0] + x[1] + x[3] + 5 * x[2]) + + u3xX * (- 7 * x[0] - 5 * x[1] - 5 * x[3] + 17 * x[2]) + + u2xX * (- 5 * x[0] - 7 * x[1] - x[3] + 13 * x[2]) + ) + + u[3][iy] * ( u0xX * (- x[0] + 7 * x[1] - 5 * x[3] - x[2]) + + u1xX * (- 5 * x[0] + 11 * x[1] - 7 * x[3] + x[2]) + + u3xX * ( x[0] + 11 * x[1] - 7 * x[3] - 5 * x[2]) + + u2xX * (- x[0] + 13 * x[1] - 11 * x[3] - x[2]) + ) + + ); + } + } + // N-gon: split into n triangles by polygon center and use triangle formula for each + else + { + typename GT::FT muXY = 0; + + // getting center of points + typename GT::Vector_3 xc = + std::accumulate(x.begin(), x.end(), typename GT::Vector_3(0, 0, 0)); + xc /= n; + + // getting unit average normal of points + typename GT::Vector_3 uc = + std::accumulate(u.begin(), u.end(), typename GT::Vector_3(0, 0, 0)); + uc /= sqrt(uc * uc); + + // summing each triangle's measure after triangulation by barycenter split. + for (std::size_t i = 0; i < n; i++) + { + std::array muXY_curr_triangle = + interpolated_corrected_anisotropic_measure_face( + std::vector {u[i], u[i + 1 % n], uc}, + std::vector {x[i], x[i + 1 % n], xc} + ); + + for (std::size_t ix = 0; ix < 3; ix++) + for (std::size_t iy = 0; iy < 3; iy++) + muXY[ix * 3 + iy] += muXY_curr_triangle[ix * 3 + iy]; + } + } + return muXY; +} + + /** * \ingroup PMP_corrected_curvatures_grp * @@ -333,6 +457,8 @@ template::value) compute_vertex_normals(pmesh, vnm, np); + typedef typename property_map_value::type measure; + std::function &, const std::vector&)> iccm_function; @@ -361,7 +487,7 @@ template Date: Wed, 3 Aug 2022 14:30:52 +0200 Subject: [PATCH 036/142] Principal Curvatures wip --- .../interpolated_corrected_curvatures.cpp | 2 +- ...nterpolated_corrected_curvature_measures.h | 266 +++++++++++++++++- 2 files changed, 260 insertions(+), 8 deletions(-) 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 5359315f0fa0..4b8a9e6cfe7d 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 @@ -25,7 +25,7 @@ int main(int argc, char* argv[]) Mesh g1; const std::string filename = (argc>1) ? argv[1] : - CGAL::data_file_path("meshes/cylinder.off"); + CGAL::data_file_path("meshes/sphere_diff_faces.obj"); if(!CGAL::IO::read_polygon_mesh(filename, g1)) { 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 1032413a9c5c..618124e7fc74 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 @@ -13,7 +13,6 @@ #ifndef CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURE_MEASURES_H #define CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURE_MEASURES_H -#endif #include @@ -22,6 +21,7 @@ #include #include #include +#include #include #include @@ -82,7 +82,7 @@ typename GT::FT interpolated_corrected_area_measure_face(const std::vector`. +* @return an array of scalar values for each combination of the standard basis (3x3) of type `std::array`. * These are the values of the interpolated corrected anisotropic measure of the given face. * * @see `interpolated_corrected_anisotropic_measure_mesh()` @@ -321,7 +321,7 @@ std::array interpolated_corrected_anisotropic_measure_fa const typename GT::Vector_3 u3xX = cross_product(u[3], X); for (std::size_t iy = 0; iy < 3; iy++) - muXY[ix * 3 + iy] = (1 / 72.0) * ( + muXY[ix * 3 + iy] = (1.0 / 72.0) * ( u[0][iy] * ( u0xX * ( - x[0] - 11 * x[1] + 13 * x[3] - x[2]) + u1xX * ( -5 * x[0] - 7 * x[1] + 11 * x[3] + x[2]) @@ -433,6 +433,7 @@ template::type GT; + typedef dynamic_vertex_property_t Vector_map_tag; typedef typename boost::property_map::const_type Default_vector_map; typedef typename internal_np::Lookup_named_param_def::%face_descriptor` as key type and `std::array` as value type. +* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" +* +* @param pmesh the polygon mesh +* @param fmm (face measure map) the property map used for storing the computed interpolated corrected measure +* @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 `pmesh`} +* \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, pmesh)`} +* \cgalParamExtra{If this parameter is omitted, an internal property map for +* `CGAL::vertex_point_t` must be available in `PolygonMesh`.} +* \cgalParamNEnd +* +* \cgalParamNBegin{vertex_normal_map} +* \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} +* \cgalParamType{a class model of `ReadablePropertyMap` with +* `boost::graph_traits::%vertex_descriptor` +* as key type and `%Vector_3` as value type} +* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} +* \cgalParamExtra{If this parameter is omitted, vertex normals should be +* computed inside the function body.} +* \cgalParamNEnd +* +* \cgalNamedParamsEnd +* +* @see `interpolated_corrected_anisotropic_measure_face()` +* @see `interpolated_corrected_measure_mesh()` +*/ +template + void + interpolated_corrected_anisotropic_measure_mesh(const PolygonMesh& pmesh, + FaceMeasureMap fmm, + const NamedParameters& np = parameters::default_values()) +{ + + typedef typename GetGeomTraits::type GT; + + typedef dynamic_vertex_property_t Vector_map_tag; + typedef typename boost::property_map::const_type Default_vector_map; + typedef typename internal_np::Lookup_named_param_def::type VNM; + + using parameters::choose_parameter; + using parameters::get_parameter; + using parameters::is_default_parameter; + + typedef typename boost::graph_traits::face_descriptor face_descriptor; + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; + + typename GetVertexPointMap::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), + get(Vector_map_tag(), pmesh)); + + if (is_default_parameter::value) + compute_vertex_normals(pmesh, vnm, np); + + for (face_descriptor f : faces(pmesh)) + { + std::vector x; + std::vector u; + + for (vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) + { + typename GT::Point_3 p = get(vpm, v); + x.push_back(typename GT::Vector_3(p.x(), p.y(), p.z())); + u.push_back(get(vnm, v)); + } + + put(fmm, f, interpolated_corrected_anisotropic_measure_face(u, x)); + } +} + + // //template //typename GT::FT triangle_in_ball_ratio_1(const typename GT::Vector_3 x1, @@ -556,6 +649,7 @@ template::type GT; + typedef typename boost::graph_traits::face_descriptor face_descriptor; typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; @@ -613,6 +707,85 @@ template + void expand_interpolated_corrected_anisotropic_measure_vertex(const PolygonMesh& pmesh, + FaceMeasureMap fmm, + VertexCurvatureMap vcm, + const typename boost::graph_traits::vertex_descriptor v, + const NamedParameters& np = parameters::default_values()) +{ + using parameters::choose_parameter; + using parameters::get_parameter; + + typedef typename GetGeomTraits::type GT; + + typedef typename boost::graph_traits::face_descriptor face_descriptor; + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + + const typename GetGeomTraits::type::FT + r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0.01); + + typename GetVertexPointMap::const_type + vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), + get_const_property_map(CGAL::vertex_point, pmesh)); + + + std::queue bfs_q; + std::unordered_set bfs_v; + + typename GT::Point_3 vp = get(vpm, v); + typename GT::Vector_3 c = typename GT::Vector_3(vp.x(), vp.y(), vp.z()); + + Eigen::Matrix corrected_muXY = { + { 0.0, 0.0, 0.0}, + { 0.0, 0.0, 0.0}, + { 0.0, 0.0, 0.0} + }; + + for (face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { + if (f != boost::graph_traits::null_face()) + { + bfs_q.push(f); + bfs_v.insert(f); + } + } + while (!bfs_q.empty()) { + face_descriptor fi = bfs_q.front(); + bfs_q.pop(); + + // looping over vertices in face to get point coordinates + std::vector x; + for (vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh)) + { + typename GT::Point_3 pi = get(vpm, vi); + x.push_back(typename GT::Vector_3(pi.x(), pi.y(), pi.z())); + } + + const typename GT::FT f_ratio = face_in_ball_ratio_2(x, r, c); + + if (f_ratio > 0.00000001) + { + std::array muXY_face = get(fmm, fi); + + for (std::size_t ix = 0; ix < 3; ix++) + for (std::size_t iy = 0; iy < 3; iy++) + corrected_muXY(ix, iy) += muXY_face[ix * 3 + iy]; + + for (face_descriptor fj : faces_around_face(halfedge(fi, pmesh), pmesh)) + { + if (bfs_v.find(fj) == bfs_v.end() && fj != boost::graph_traits::null_face()) + { + bfs_q.push(fj); + bfs_v.insert(fj); + } + } + } + } + + put(vcm, v, corrected_muXY); +} + template void interpolated_corrected_mean_curvature(const PolygonMesh& pmesh, @@ -620,8 +793,10 @@ template::type GT; + typedef typename boost::graph_traits::face_descriptor face_descriptor; typedef std::unordered_map FaceMeasureMap_tag; + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef std::unordered_map VertexMeasureMap_tag; @@ -656,8 +831,10 @@ template::type GT; + typedef typename boost::graph_traits::face_descriptor face_descriptor; typedef std::unordered_map FaceMeasureMap_tag; + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef std::unordered_map VertexMeasureMap_tag; @@ -685,5 +862,80 @@ template + void interpolated_corrected_principal_curvature(const PolygonMesh& pmesh, + VertexCurvatureMap vcm, + const NamedParameters& np = parameters::default_values()) +{ + typedef typename GetGeomTraits::type GT; + + typedef dynamic_vertex_property_t Vector_map_tag; + typedef typename boost::property_map::const_type Default_vector_map; + typedef typename internal_np::Lookup_named_param_def::type VNM; + + using parameters::choose_parameter; + using parameters::get_parameter; + using parameters::is_default_parameter; + + typename GetVertexPointMap::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), + get(Vector_map_tag(), pmesh)); + + if (is_default_parameter::value) + compute_vertex_normals(pmesh, vnm, np); + + typedef typename boost::graph_traits::face_descriptor face_descriptor; + typedef std::unordered_map FaceScalarMeasureMap_tag; + // using std:: array to store FT values on the 9 combinations of the standard 3D basis + typedef std::unordered_map> FaceArrayMeasureMap_tag; + + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef std::unordered_map VertexScalarMeasureMap_tag; + // using Eigen matrix to store & Process FT values on the 9 combinations of the standard 3D basis + typedef std::unordered_map> VertexMatrixMeasureMap_tag; + + + FaceScalarMeasureMap_tag mu0_init; + boost::associative_property_map + mu0_map(mu0_init); + + FaceArrayMeasureMap_tag muXY_init; + boost::associative_property_map + muXY_map(muXY_init); + + VertexScalarMeasureMap_tag mu0_expand_init; + boost::associative_property_map + mu0_expand_map(mu0_expand_init); + + VertexMatrixMeasureMap_tag muXY_expand_init; + boost::associative_property_map + muXY_expand_map(muXY_expand_init); + + interpolated_corrected_measure_mesh(pmesh, mu0_map, MU0_AREA_MEASURE); + interpolated_corrected_anisotropic_measure_mesh(pmesh, muXY_map); + + for (vertex_descriptor v : vertices(pmesh)) + { + expand_interpolated_corrected_measure_vertex(pmesh, mu0_map, mu0_expand_map, v, np); + expand_interpolated_corrected_anisotropic_measure_vertex(pmesh, muXY_map, muXY_expand_map, v, np); + + + + /*typename GT::FT v_mu0 = get(mu0_expand_map, v); + if (v_mu0 > 0.00000001) + put(vcm, v, get(mu2_expand_map, v) / v_mu0); + else + put(vcm, v, 0);*/ + } } -} + +} // namespace Polygon_mesh_processing +} // namespace CGAL + +#endif // CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURE_MEASURES_H \ No newline at end of file From 24edaa24b5fc54bf85ac21b9c291610da6bbbf1c Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Wed, 3 Aug 2022 18:59:08 +0200 Subject: [PATCH 037/142] principal curvatures (yet to decompose MuXY Matrix) --- .../interpolated_corrected_curvatures.cpp | 23 ++++++++++-- ...nterpolated_corrected_curvature_measures.h | 36 +++++++++++++------ 2 files changed, 46 insertions(+), 13 deletions(-) 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 4b8a9e6cfe7d..28e6e0ef81cb 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 @@ -18,6 +18,14 @@ typedef boost::graph_traits::face_descriptor face_descriptor; typedef boost::graph_traits::vertex_descriptor vertex_descriptor; typedef std::unordered_map FaceMeasureMap_tag; typedef std::unordered_map vertexMeasureMap_tag; +typedef std::unordered_map, + Eigen::Vector + >> +vertexPrincipleCurvatureMap_tag; + int main(int argc, char* argv[]) @@ -38,16 +46,27 @@ int main(int argc, char* argv[]) boost::associative_property_map mean_curvature_map(mean_curvature_init), gaussian_curvature_map(gaussian_curvature_init); + vertexPrincipleCurvatureMap_tag principle_curvature_init; + boost::associative_property_map principle_curvature_map(principle_curvature_init); + PMP::interpolated_corrected_mean_curvature( g1, mean_curvature_map - ); + ); PMP::interpolated_corrected_gaussian_curvature( g1, gaussian_curvature_map ); + PMP::interpolated_corrected_principal_curvatures( + g1, + principle_curvature_map + ); for (vertex_descriptor v : vertices(g1)) + { + auto PC = get(principle_curvature_map, v); std::cout << v.idx() << ": HC = " << get(mean_curvature_map, v) - << ", GC = " << get(gaussian_curvature_map, v) << "\n"; + << ", GC = " << get(gaussian_curvature_map, v) << "\n" + << ", PC = [ " << std::get<0>(PC) << " , " << std::get<1>(PC) << " ]\n"; + } } 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 618124e7fc74..83f63b74b54e 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 @@ -690,7 +690,7 @@ template(x, r, c); - if (f_ratio > 0.00000001) + if (f_ratio != 0.0) { corrected_mui += f_ratio * get(fmm, fi); for (face_descriptor fj : faces_around_face(halfedge(fi, pmesh), pmesh)) @@ -764,7 +764,7 @@ template(x, r, c); - if (f_ratio > 0.00000001) + if (f_ratio != 0.0) { std::array muXY_face = get(fmm, fi); @@ -817,7 +817,7 @@ template 0.00000001) + if (v_mu0 != 0.0) put(vcm, v, 0.5 * get(mu1_expand_map, v) / v_mu0); else put(vcm, v, 0); @@ -855,7 +855,7 @@ template 0.00000001) + if(v_mu0 != 0.0) put(vcm, v, get(mu2_expand_map, v) / v_mu0); else put(vcm, v, 0); @@ -864,7 +864,7 @@ template - void interpolated_corrected_principal_curvature(const PolygonMesh& pmesh, + void interpolated_corrected_principal_curvatures(const PolygonMesh& pmesh, VertexCurvatureMap vcm, const NamedParameters& np = parameters::default_values()) { @@ -925,13 +925,27 @@ template v_muXY = get(muXY_expand_map, v); + typename GT::Vector_3 u_GT = get(vnm, v); - - /*typename GT::FT v_mu0 = get(mu0_expand_map, v); - if (v_mu0 > 0.00000001) - put(vcm, v, get(mu2_expand_map, v) / v_mu0); - else - put(vcm, v, 0);*/ + Eigen::Vector u(u_GT.x(), u_GT.y(), u_GT.z()); + + const typename GT::FT K = 1000 * v_mu0; + + v_muXY = 0.5 * (v_muXY + v_muXY.transpose()) + K * u * u.transpose(); + + Eigen::Vector eig_vals; + Eigen::Matrix eig_vecs; + + + //(WIP) + EigenDecomposition< 3, typename GT::FT>::getEigenDecomposition(v_muXY, eig_vecs, eig_vals); + + put(vcm, v, std::make_tuple((v_mu0 != 0.0) ? -eig_vals[0] / v_mu0 : 0.0, + (v_mu0 != 0.0) ? -eig_vals[1] / v_mu0 : 0.0, + eig_vecs.column(0), + eig_vecs.column(1))); } } From 24551e2cbb2b38db5aabc2f31395c38651e3d635 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Thu, 4 Aug 2022 10:51:45 +0200 Subject: [PATCH 038/142] principal curvatures completed (but not properly tested) --- .../interpolated_corrected_curvatures.cpp | 2 +- ...nterpolated_corrected_curvature_measures.h | 60 ++++++++++++------- 2 files changed, 40 insertions(+), 22 deletions(-) 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 28e6e0ef81cb..b804ae061cf4 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 @@ -33,7 +33,7 @@ int main(int argc, char* argv[]) Mesh g1; const std::string filename = (argc>1) ? argv[1] : - CGAL::data_file_path("meshes/sphere_diff_faces.obj"); + CGAL::data_file_path("meshes/small_bunny.obj"); if(!CGAL::IO::read_polygon_mesh(filename, g1)) { 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 83f63b74b54e..4b6a2f5149d9 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 @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include @@ -287,7 +287,7 @@ std::array interpolated_corrected_anisotropic_measure_fa CGAL_precondition(n >= 3); typename GT::Construct_cross_product_vector_3 cross_product; - std::array muXY; + std::array muXY {0}; // Triangle: use triangle formula if (n == 3) @@ -300,8 +300,14 @@ std::array interpolated_corrected_anisotropic_measure_fa for (std::size_t ix = 0; ix < 3; ix++) { - const typename GT::Vector_3 X(0, 0, 0); - X[ix] = 1; + typename GT::Vector_3 X; + if (ix == 0) + X = typename GT::Vector_3(1, 0, 0); + if (ix == 1) + X = typename GT::Vector_3(0, 1, 0); + if (ix == 2) + X = typename GT::Vector_3(0, 0, 1); + for (std::size_t iy = 0; iy < 3; iy++) muXY[ix * 3 + iy] = 0.5 * um * (cross_product(u02[iy] * X, x01) - cross_product(u01[iy] * X, x02)); } @@ -313,8 +319,14 @@ std::array interpolated_corrected_anisotropic_measure_fa // the indices in paper vs in here are: 00 = 0, 10 = 1, 11 = 2, 01 = 3 for (std::size_t ix = 0; ix < 3; ix++) { - const typename GT::Vector_3 X(0, 0, 0); - X[ix] = 1; + typename GT::Vector_3 X; + if (ix == 0) + X = typename GT::Vector_3(1, 0, 0); + if (ix == 1) + X = typename GT::Vector_3(0, 1, 0); + if (ix == 2) + X = typename GT::Vector_3(0, 0, 1); + const typename GT::Vector_3 u0xX = cross_product(u[0], X); const typename GT::Vector_3 u1xX = cross_product(u[1], X); const typename GT::Vector_3 u2xX = cross_product(u[2], X); @@ -350,8 +362,6 @@ std::array interpolated_corrected_anisotropic_measure_fa // N-gon: split into n triangles by polygon center and use triangle formula for each else { - typename GT::FT muXY = 0; - // getting center of points typename GT::Vector_3 xc = std::accumulate(x.begin(), x.end(), typename GT::Vector_3(0, 0, 0)); @@ -654,7 +664,7 @@ template::vertex_descriptor vertex_descriptor; const typename GetGeomTraits::type::FT - r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0.01); + r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0.1); typename GetVertexPointMap::const_type vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), @@ -737,11 +747,7 @@ template corrected_muXY = { - { 0.0, 0.0, 0.0}, - { 0.0, 0.0, 0.0}, - { 0.0, 0.0, 0.0} - }; + Eigen::Matrix corrected_muXY = Eigen::Matrix::Zero(); for (face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { if (f != boost::graph_traits::null_face()) @@ -935,17 +941,29 @@ template eig_vals; - Eigen::Matrix eig_vecs; + //(WIP) + Eigen::SelfAdjointEigenSolver> eigensolver; + eigensolver.computeDirect(v_muXY); + + if (eigensolver.info() != Eigen::Success) + { + put(vcm, v, std::make_tuple( + 0, + 0, + Eigen::Vector(.0,.0,.0), + Eigen::Vector(.0, .0, .0))); + continue; + } - //(WIP) - EigenDecomposition< 3, typename GT::FT>::getEigenDecomposition(v_muXY, eig_vecs, eig_vals); + Eigen::Vector eig_vals = eigensolver.eigenvalues(); + Eigen::Matrix eig_vecs = eigensolver.eigenvectors(); - put(vcm, v, std::make_tuple((v_mu0 != 0.0) ? -eig_vals[0] / v_mu0 : 0.0, + put(vcm, v, std::make_tuple( (v_mu0 != 0.0) ? -eig_vals[1] / v_mu0 : 0.0, - eig_vecs.column(0), - eig_vecs.column(1))); + (v_mu0 != 0.0) ? -eig_vals[0] / v_mu0 : 0.0, + eig_vecs.col(1), + eig_vecs.col(0))); } } From c4db1600fda9f9fa3a50bc005db84f5122107382 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Thu, 4 Aug 2022 11:01:09 +0200 Subject: [PATCH 039/142] trim whitespaces --- .../Curvatures/interpolated_corrected_curvature_measures.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 4b6a2f5149d9..4525628f5645 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 @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include @@ -305,7 +305,7 @@ std::array interpolated_corrected_anisotropic_measure_fa X = typename GT::Vector_3(1, 0, 0); if (ix == 1) X = typename GT::Vector_3(0, 1, 0); - if (ix == 2) + if (ix == 2) X = typename GT::Vector_3(0, 0, 1); for (std::size_t iy = 0; iy < 3; iy++) @@ -945,7 +945,7 @@ template> eigensolver; eigensolver.computeDirect(v_muXY); - + if (eigensolver.info() != Eigen::Success) { put(vcm, v, std::make_tuple( From 85332fed6d9243a03bcb93edf8a08fc05e091799 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Fri, 5 Aug 2022 13:58:52 +0200 Subject: [PATCH 040/142] according to some of the review comments on the pull --- .../Polygon_mesh_processing/CMakeLists.txt | 9 ++-- ...nterpolated_corrected_curvature_measures.h | 51 +++++++++++-------- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt index d6f4e273516f..4783d957589a 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt @@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.1...3.23) project(Polygon_mesh_processing_Examples) # CGAL and its components -find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Qt5) +find_package(CGAL REQUIRED) # Boost and its components find_package(Boost REQUIRED) @@ -102,12 +102,11 @@ create_single_source_cgal_program("orientation_pipeline_example.cpp") #create_single_source_cgal_program( "snapping_example.cpp") create_single_source_cgal_program("match_faces.cpp") create_single_source_cgal_program("cc_compatible_orientations.cpp") -create_single_source_cgal_program("interpolated_corrected_curvatures.cpp") -if(CGAL_Qt5_FOUND) +if(TARGET CGAL::Eigen3_support) - #link it with the required CGAL libraries - target_link_libraries(interpolated_corrected_curvatures PUBLIC CGAL::CGAL_Basic_viewer) + create_single_source_cgal_program("interpolated_corrected_curvatures.cpp") + target_link_libraries(interpolated_corrected_curvatures PUBLIC CGAL::Eigen3_support) endif() 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 4525628f5645..33cbe05e576d 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 @@ -17,10 +17,10 @@ #include #include -#include #include #include #include +#include #include #include @@ -83,10 +83,10 @@ typename GT::FT interpolated_corrected_area_measure_face(const std::vector( - std::vector {u[i], u[i + 1 % n], uc}, - std::vector {x[i], x[i + 1 % n], xc} + std::vector {u[i], u[(i + 1) % n], uc}, + std::vector {x[i], x[(i + 1) % n], xc} ); } return mu0; @@ -191,8 +191,8 @@ typename GT::FT interpolated_corrected_mean_curvature_measure_face(const std::ve for (std::size_t i = 0; i < n; i++) { mu1 += interpolated_corrected_mean_curvature_measure_face( - std::vector {u[i], u[i + 1 % n], uc}, - std::vector {x[i], x[i + 1 % n], xc} + std::vector {u[i], u[(i + 1) % n], uc}, + std::vector {x[i], x[(i + 1) % n], xc} ); } return mu1; @@ -236,10 +236,10 @@ typename GT::FT interpolated_corrected_gaussian_curvature_measure_face(const std // for the formulas below, values of verices 2 & 3 are swapped (compared to paper) to correct order. // the indices in paper vs in here are: 00 = 0, 10 = 1, 11 = 2, 01 = 3 return (1.0 / 36.0) * ( - (4 * u[0] + 2 * u[1] + 2 * u[3] + u[2]) * cross_product(x[1] - x[0], x[3] - x[0]) - + (2 * u[0] + 4 * u[1] + u[3] + 2 * u[2]) * cross_product(x[1] - x[0], x[2] - x[1]) - + (2 * u[0] + u[1] + 4 * u[3] + 2 * u[2]) * cross_product(x[2] - x[3], x[3] - x[0]) - + (u[0] + 2 * u[1] + 2 * u[3] + 4 * u[2]) * cross_product(x[2] - x[3], x[2] - x[1]) + (4 * u[0] + 2 * u[1] + 2 * u[3] + u[2]) * cross_product(u[1] - u[0], u[3] - u[0]) + + (2 * u[0] + 4 * u[1] + u[3] + 2 * u[2]) * cross_product(u[1] - u[0], u[2] - u[1]) + + (2 * u[0] + u[1] + 4 * u[3] + 2 * u[2]) * cross_product(u[2] - u[3], u[3] - u[0]) + + (u[0] + 2 * u[1] + 2 * u[3] + 4 * u[2]) * cross_product(u[2] - u[3], u[2] - u[1]) ); } // N-gon: split into n triangles by polygon center and use triangle formula for each @@ -256,7 +256,7 @@ typename GT::FT interpolated_corrected_gaussian_curvature_measure_face(const std for (std::size_t i = 0; i < n; i++) { mu2 += interpolated_corrected_gaussian_curvature_measure_face( - std::vector {u[i], u[i + 1 % n], uc} + std::vector {u[i], u[(i + 1) % n], uc} ); } return mu2; @@ -377,8 +377,8 @@ std::array interpolated_corrected_anisotropic_measure_fa { std::array muXY_curr_triangle = interpolated_corrected_anisotropic_measure_face( - std::vector {u[i], u[i + 1 % n], uc}, - std::vector {x[i], x[i + 1 % n], xc} + std::vector {u[i], u[(i + 1) % n], uc}, + std::vector {x[i], x[(i + 1) % n], xc} ); for (std::size_t ix = 0; ix < 3; ix++) @@ -486,10 +486,11 @@ template x; + std::vector u; + for (face_descriptor f : faces(pmesh)) { - std::vector x; - std::vector u; for (vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) { @@ -499,6 +500,8 @@ template::value) compute_vertex_normals(pmesh, vnm, np); + std::vector x; + std::vector u; + for (face_descriptor f : faces(pmesh)) { - std::vector x; - std::vector u; for (vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) { @@ -590,6 +594,9 @@ template(u, x)); + x.clear(); + u.clear(); + } } @@ -634,8 +641,8 @@ typename GT::FT face_in_ball_ratio_2(const std::vector& x for (const typename GT::Vector_3 xi : x) { const typename GT::FT d_sq = (xi - c).squared_length(); - d_max = std::max(d_sq, d_max); - d_min = std::min(d_sq, d_min); + d_max = (std::max)(d_sq, d_max); + d_min = (std::min)(d_sq, d_min); } if (d_max <= r * r) return 1.0; From 7473a3e2dc702b1529e40f4931b95faa81430591 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 8 Aug 2022 05:05:28 +0200 Subject: [PATCH 041/142] Optimizing the expanding functions to compute intersections only once per curvature --- ...nterpolated_corrected_curvature_measures.h | 42 +++++++++++-------- 1 file changed, 25 insertions(+), 17 deletions(-) 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 33cbe05e576d..289878b9a9bf 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 @@ -657,8 +657,10 @@ typename GT::FT face_in_ball_ratio_2(const std::vector& x template void expand_interpolated_corrected_measure_vertex(const PolygonMesh& pmesh, - FaceMeasureMap fmm, - VertexCurvatureMap vcm, + FaceMeasureMap area_fmm, + FaceMeasureMap curvature_fmm, + VertexCurvatureMap area_vcm, + VertexCurvatureMap curvature_vcm, const typename boost::graph_traits::vertex_descriptor v, const NamedParameters& np = parameters::default_values()) { @@ -684,6 +686,7 @@ template::null_face()) @@ -720,15 +724,18 @@ template void expand_interpolated_corrected_anisotropic_measure_vertex(const PolygonMesh& pmesh, - FaceMeasureMap fmm, - VertexCurvatureMap vcm, + AreaFaceMeasureMap area_fmm, + AnisotropicFaceMeasureMap aniso_fmm, + AreaVertexCurvatureMap area_vcm, + AnisotropicVertexCurvatureMap aniso_vcm, const typename boost::graph_traits::vertex_descriptor v, const NamedParameters& np = parameters::default_values()) { @@ -754,6 +761,7 @@ template corrected_muXY = Eigen::Matrix::Zero(); for (face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { @@ -779,7 +787,9 @@ template muXY_face = get(fmm, fi); + corrected_mu0 += f_ratio * get(area_fmm, fi); + + std::array muXY_face = get(aniso_fmm, fi); for (std::size_t ix = 0; ix < 3; ix++) for (std::size_t iy = 0; iy < 3; iy++) @@ -795,8 +805,8 @@ template v_muXY = get(muXY_expand_map, v); From 36d0fd4e5b3c5d5bfaed59ef3f9f8528aed486f1 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 8 Aug 2022 05:41:34 +0200 Subject: [PATCH 042/142] using internal property (SurfMesh) in example --- .../interpolated_corrected_curvatures.cpp | 46 +++++++++++-------- 1 file changed, 26 insertions(+), 20 deletions(-) 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 b804ae061cf4..c8b972aca658 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 @@ -9,24 +9,12 @@ #include #include - namespace PMP = CGAL::Polygon_mesh_processing; typedef CGAL::Exact_predicates_inexact_constructions_kernel EpicKernel; 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; -typedef std::unordered_map vertexMeasureMap_tag; -typedef std::unordered_map, - Eigen::Vector - >> -vertexPrincipleCurvatureMap_tag; - - int main(int argc, char* argv[]) { @@ -41,13 +29,31 @@ int main(int argc, char* argv[]) return EXIT_FAILURE; } + bool created = false; + + Mesh::Property_map mean_curvature_map, gaussian_curvature_map; + boost::tie(mean_curvature_map, created) = g1.add_property_map("v:mean_curvature_map", 0); + assert(created); + + boost::tie(gaussian_curvature_map, created) = g1.add_property_map("v:gaussian_curvature_map", 0); + assert(created); - vertexMeasureMap_tag mean_curvature_init, gaussian_curvature_init; - boost::associative_property_map - mean_curvature_map(mean_curvature_init), gaussian_curvature_map(gaussian_curvature_init); + Mesh::Property_map, + Eigen::Vector + >> principle_curvature_map; - vertexPrincipleCurvatureMap_tag principle_curvature_init; - boost::associative_property_map principle_curvature_map(principle_curvature_init); + boost::tie(principle_curvature_map, created) = g1.add_property_map, + Eigen::Vector + >>("v:principle_curvature_map", { 0, 0, + Eigen::Vector::Zero(), + Eigen::Vector::Zero() }); + assert(created); PMP::interpolated_corrected_mean_curvature( g1, @@ -64,9 +70,9 @@ int main(int argc, char* argv[]) for (vertex_descriptor v : vertices(g1)) { - auto PC = get(principle_curvature_map, v); - std::cout << v.idx() << ": HC = " << get(mean_curvature_map, v) - << ", GC = " << get(gaussian_curvature_map, v) << "\n" + auto PC = principle_curvature_map[v]; + std::cout << v.idx() << ": HC = " << mean_curvature_map[v] + << ", GC = " << gaussian_curvature_map[v] << "\n" << ", PC = [ " << std::get<0>(PC) << " , " << std::get<1>(PC) << " ]\n"; } } From a74e05a389dabe01022fcb4d2871bb027996f5fb Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 8 Aug 2022 06:16:05 +0200 Subject: [PATCH 043/142] documentation: fixes & improvements --- ...nterpolated_corrected_curvature_measures.h | 41 ++++++++----------- 1 file changed, 16 insertions(+), 25 deletions(-) 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 289878b9a9bf..3987f473c145 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 @@ -47,15 +47,13 @@ enum Curvature_measure_index { /** * \ingroup PMP_corrected_curvatures_grp * -* computes the interpolated corrected area measure (mu0) of a specific face. +* computes the interpolated corrected area measure \f$ \mu_0 \f$ of a specific face. * -* @tparam GT is the geometric traits class. +* @tparam GT geometric traits class model of `Kernel`. * * @param x is a vector of the vertex positions of the face. -* @param u is a vector of the vertex nomrals of the face. +* @param u is a vector of the vertex normals of the face. * -* @return a scalar of type `GT::FT`. -* This is the value of the interpolated corrected area measure of the given face. * * @see `interpolated_corrected_mean_curvature_measure_face()` * @see `interpolated_corrected_gaussian_curvature_measure_face()` @@ -119,16 +117,13 @@ typename GT::FT interpolated_corrected_area_measure_face(const std::vector`. +* @return an array of scalar values for each combination of the standard basis (3x3) * These are the values of the interpolated corrected anisotropic measure of the given face. * * @see `interpolated_corrected_anisotropic_measure_mesh()` @@ -395,7 +387,7 @@ std::array interpolated_corrected_anisotropic_measure_fa * * computes the interpolated corrected curvature measure on each face of the mesh * -* @tparam PolygonMesh a model of `FaceGraph` +* @tparam PolygonMesh a model of `FaceListGraph` * @tparam FaceMeasureMap a a model of `WritablePropertyMap` with * `boost::graph_traits::%face_descriptor` as key type and `GT::FT` as value type. * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" @@ -423,8 +415,8 @@ std::array interpolated_corrected_anisotropic_measure_fa * `boost::graph_traits::%vertex_descriptor` * as key type and `%Vector_3` as value type} * \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} -* \cgalParamExtra{If this parameter is omitted, vertex normals should be -* computed inside the function body.} +* \cgalParamExtra{If this parameter is omitted, vertex normals will be +* computed using compute_vertex_normals()} * \cgalParamNEnd * * \cgalNamedParamsEnd @@ -511,7 +503,7 @@ template::%face_descriptor` as key type and `std::array` as value type. * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" @@ -537,8 +529,8 @@ template::%vertex_descriptor` * as key type and `%Vector_3` as value type} * \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} -* \cgalParamExtra{If this parameter is omitted, vertex normals should be -* computed inside the function body.} +* \cgalParamExtra{If this parameter is omitted, vertex normals will be +* computed using compute_vertex_normals()} * \cgalParamNEnd * * \cgalNamedParamsEnd @@ -956,7 +948,6 @@ template> eigensolver; eigensolver.computeDirect(v_muXY); From 86ac0fcb74f26336d492859b1d650fb28b5251d0 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 8 Aug 2022 07:04:37 +0200 Subject: [PATCH 044/142] Documenting Expansion functions --- ...nterpolated_corrected_curvature_measures.h | 158 +++++++++++++++--- 1 file changed, 134 insertions(+), 24 deletions(-) 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 3987f473c145..dbe95c28f459 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 @@ -47,7 +47,7 @@ enum Curvature_measure_index { /** * \ingroup PMP_corrected_curvatures_grp * -* computes the interpolated corrected area measure \f$ \mu_0 \f$ of a specific face. +* Computes the interpolated corrected area measure \f$ \mu_0 \f$ of a specific face. * * @tparam GT geometric traits class model of `Kernel`. * @@ -117,7 +117,7 @@ typename GT::FT interpolated_corrected_area_measure_face(const std::vector interpolated_corrected_anisotropic_measure_fa /** * \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 `FaceListGraph` -* @tparam FaceMeasureMap a a model of `WritablePropertyMap` with +* @tparam FaceMeasureMap a model of `WritablePropertyMap` with * `boost::graph_traits::%face_descriptor` as key type and `GT::FT` as value type. * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" * @@ -399,6 +399,7 @@ std::array interpolated_corrected_anisotropic_measure_fa * @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 `pmesh`} * \cgalParamType{a class model of `ReadablePropertyMap` with @@ -501,10 +502,10 @@ template::%face_descriptor` as key type and `std::array` as value type. * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" * @@ -513,6 +514,7 @@ template -typename GT::FT face_in_ball_ratio_2(const std::vector& x, - const typename GT::FT r, - const typename GT::Vector_3 c) +typename GT::FT face_in_ball_ratio(const std::vector& x, + const typename GT::FT r, + const typename GT::Vector_3 c) { std::size_t n = x.size(); @@ -646,13 +662,59 @@ typename GT::FT face_in_ball_ratio_2(const std::vector& x return (r - d_min) / (d_max - d_min); } -template::%face_descriptor` as key type and `GT::FT` as value type. +* @tparam VertexMeasureMap a model of `WritablePropertyMap` with +* `boost::graph_traits::%vertex_descriptor` as key type and `GT::FT` as value type. +* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" +* +* @param pmesh the polygon mesh +* @param area_fmm (area face measure map) the property map storing the already computed area measure on each face. +* @param curvature_fmm (curvature face measure map) the property map storing the already computed curvature measure on each face. +* This curvature measure can be either the Mean Curvature or the Gaussian Curvature. +* @param area_vmm (area vertex measure map) the property map provided to store the expanded area measure on each vertex. +* @param curvature_vmm (curvature vertex measure map) the property map provided to store the expanded curvature measure on each vertex. +* This curvature measure can be either the Mean Curvature or the Gaussian Curvature. +* @param v (vertex) the vertex to expand the area and curvature measure around. +* @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below +* +* \cgalNamedParamsBegin +* +* \cgalParamNBegin{ball_radius} +* \cgalParamDescription{the radius of the ball around the vertex `v` to expand the area and curvature measure} +* \cgalParamType{`GT::FT`} +* \cgalParamDefault{`0.01`} +* \cgalParamNEnd +* +* \cgalParamNBegin{vertex_point_map} +* \cgalParamDescription{a property map associating points to the vertices of `pmesh`} +* \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, pmesh)`} +* \cgalParamExtra{If this parameter is omitted, an internal property map for +* `CGAL::vertex_point_t` must be available in `PolygonMesh`.} +* \cgalParamNEnd +* +* \cgalNamedParamsEnd +* +* @see `expand_interpolated_corrected_anisotropic_measure_vertex()` +* @see `face_in_ball_ratio()` +*/ +template void expand_interpolated_corrected_measure_vertex(const PolygonMesh& pmesh, FaceMeasureMap area_fmm, FaceMeasureMap curvature_fmm, - VertexCurvatureMap area_vcm, - VertexCurvatureMap curvature_vcm, + VertexMeasureMap area_vmm, + VertexMeasureMap curvature_vmm, const typename boost::graph_traits::vertex_descriptor v, const NamedParameters& np = parameters::default_values()) { @@ -700,7 +762,7 @@ template(x, r, c); + const typename GT::FT f_ratio = face_in_ball_ratio(x, r, c); if (f_ratio != 0.0) { @@ -716,18 +778,66 @@ template::%face_descriptor` as key type and `GT::FT` as value type. +* @tparam AnisotropicFaceMeasureMap a model of `WritablePropertyMap` with +* `boost::graph_traits::%face_descriptor` as key type and `std::array` as value type. +* @tparam AreaVertexMeasureMap a model of `WritablePropertyMap` with +* `boost::graph_traits::%vertex_descriptor` as key type and `GT::FT` as value type. +* @tparam AnisotropicVertexMeasureMap a model of `WritablePropertyMap` with +* `boost::graph_traits::%vertex_descriptor` as key type and `std::array` as value type. +* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" +* +* @param pmesh the polygon mesh +* @param area_fmm (area face measure map) the property map storing the already computed area measure on each face. +* @param aniso_fmm (anisotropic face measure map) the property map storing the already computed anisotropic curvature measure on each face. +* @param area_vmm (area vertex measure map) the property map provided to store the expanded area measure on each vertex. +* @param aniso_vmm (anisotropic vertex measure map) the property map provided to store the expanded anisotropic curvature measure on each vertex. +* @param v (vertex) the vertex to expand the area and anisotropic curvature measure around. +* @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below +* +* \cgalNamedParamsBegin +* +* \cgalParamNBegin{ball_radius} +* \cgalParamDescription{the radius of the ball around the vertex `v` to expand the area and curvature measure} +* \cgalParamType{`GT::FT`} +* \cgalParamDefault{`0.01`} +* \cgalParamNEnd +* +* \cgalParamNBegin{vertex_point_map} +* \cgalParamDescription{a property map associating points to the vertices of `pmesh`} +* \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, pmesh)`} +* \cgalParamExtra{If this parameter is omitted, an internal property map for +* `CGAL::vertex_point_t` must be available in `PolygonMesh`.} +* \cgalParamNEnd +* +* \cgalNamedParamsEnd +* +* @see `expand_interpolated_corrected_measure_vertex()` +* @see `face_in_ball_ratio()` +*/ template void expand_interpolated_corrected_anisotropic_measure_vertex(const PolygonMesh& pmesh, AreaFaceMeasureMap area_fmm, AnisotropicFaceMeasureMap aniso_fmm, - AreaVertexCurvatureMap area_vcm, - AnisotropicVertexCurvatureMap aniso_vcm, + AreaVertexMeasureMap area_vmm, + AnisotropicVertexMeasureMap aniso_vmm, const typename boost::graph_traits::vertex_descriptor v, const NamedParameters& np = parameters::default_values()) { @@ -775,7 +885,7 @@ template(x, r, c); + const typename GT::FT f_ratio = face_in_ball_ratio(x, r, c); if (f_ratio != 0.0) { @@ -797,8 +907,8 @@ template Date: Mon, 8 Aug 2022 07:13:14 +0200 Subject: [PATCH 045/142] minor documentation fixes --- .../Polygon_mesh_processing/PackageDescription.txt | 13 ++++++++++--- .../interpolated_corrected_curvature_measures.h | 8 ++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt index d0cab92d6a89..5c9e39811d46 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt @@ -202,9 +202,16 @@ The page \ref bgl_namedparameters "Named Parameters" describes their usage. \cgalCRPSection{Corrected Curvature Functions} - `CGAL::Polygon_mesh_processing::interpolated_corrected_measure_mesh()` -- `CGAL::Polygon_mesh_processing::interpolated_corrected_measure_face()` -- `CGAL::Polygon_mesh_processing::interpolated_corrected_measure_triangle()` -- `CGAL::Polygon_mesh_processing::interpolated_corrected_measure_quad()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_anisotropic_measure_mesh()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_area_measure_face()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature_measure_face()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature_measure_face()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_anisotropic_measure_face()` +- `CGAL::Polygon_mesh_processing::expand_interpolated_corrected_measure_vertex()` +- `CGAL::Polygon_mesh_processing::expand_interpolated_corrected_anisotropic_measure_vertex()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures()` \cgalCRPSection{Normal Computation Functions} - `CGAL::Polygon_mesh_processing::compute_face_normal()` 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 dbe95c28f459..00b17269d6f1 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 @@ -785,7 +785,7 @@ template Date: Mon, 8 Aug 2022 07:41:02 +0200 Subject: [PATCH 046/142] Documenting new functions + minor doc fixes --- ...nterpolated_corrected_curvature_measures.h | 120 +++++++++++++++--- 1 file changed, 103 insertions(+), 17 deletions(-) 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 00b17269d6f1..dc7744a402eb 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 @@ -35,7 +35,7 @@ namespace Polygon_mesh_processing { /*! * \ingroup PMP_corrected_curvatures_grp * Enumeration type used to specify which measure of a given face - * is computed for the interpolated corrected curvature functions + * is computed for the interpolated corrected curvature functions. */ // enum enum Curvature_measure_index { @@ -385,17 +385,17 @@ std::array interpolated_corrected_anisotropic_measure_fa /** * \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 `FaceListGraph` +* @tparam PolygonMesh a model of `FaceListGraph`. * @tparam FaceMeasureMap a model of `WritablePropertyMap` with * `boost::graph_traits::%face_descriptor` as key type and `GT::FT` as value type. -* @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 fmm (face measure map) the property map used for storing the computed interpolated corrected measure +* @param pmesh the polygon mesh. +* @param fmm (face measure map) the property map used for storing the computed interpolated corrected measure. * @param mu_i an enum for choosing between computing -* the area measure, the mean curvature measure or the gaussian curvature measure +* 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 * * \cgalNamedParamsBegin @@ -504,13 +504,13 @@ template::%face_descriptor` as key type and `std::array` as value type. -* @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 fmm (face measure map) the property map used for storing the computed interpolated corrected measure +* @param pmesh the polygon mesh. +* @param fmm (face measure map) the property map used for storing the computed interpolated corrected measure. * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below * * \cgalNamedParamsBegin @@ -622,7 +622,7 @@ template& x, * Expands given face area and curvature (mean or gaussian) measures around a vertex `v`. * Expansion is based on the inclusion ratio of each face in a ball of radius `r` around the vertex `v`. * -* @tparam PolygonMesh a model of `FaceListGraph` +* @tparam PolygonMesh a model of `FaceListGraph`. * @tparam FaceMeasureMap a model of `WritablePropertyMap` with * `boost::graph_traits::%face_descriptor` as key type and `GT::FT` as value type. * @tparam VertexMeasureMap a model of `WritablePropertyMap` with * `boost::graph_traits::%vertex_descriptor` as key type and `GT::FT` as value type. -* @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 area_fmm (area face measure map) the property map storing the already computed area measure on each face. * @param curvature_fmm (curvature face measure map) the property map storing the already computed curvature measure on each face. * This curvature measure can be either the Mean Curvature or the Gaussian Curvature. @@ -797,9 +797,9 @@ template::%vertex_descriptor` as key type and `GT::FT` as value type. * @tparam AnisotropicVertexMeasureMap a model of `WritablePropertyMap` with * `boost::graph_traits::%vertex_descriptor` as key type and `std::array` as value type. -* @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 area_fmm (area face measure map) the property map storing the already computed area measure on each face. * @param aniso_fmm (anisotropic face measure map) the property map storing the already computed anisotropic measure on each face. * @param area_vmm (area vertex measure map) the property map provided to store the expanded area measure on each vertex. @@ -911,6 +911,27 @@ template::%vertex_descriptor` as key type and `GT::FT` as value type. +* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". +* +* @param pmesh the polygon mesh. +* @param vcm the vertex property map in which the computed mean curvatures are stored. +* @param np an optional sequence of \ref bgl_namedparameters "Named Parameters". +* +* @see `interpolated_corrected_gaussian_curvature()` +* @see `interpolated_corrected_principal_curvatures()` +* @see `interpolated_corrected_measure_mesh()` +* @see `expand_interpolated_corrected_measure_vertex()` +*/ + template void interpolated_corrected_mean_curvature(const PolygonMesh& pmesh, @@ -949,6 +970,26 @@ template::%vertex_descriptor` as key type and `GT::FT` as value type. +* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". +* +* @param pmesh the polygon mesh. +* @param vcm the vertex property map in which the computed gaussian curvatures are stored. +* @param np an optional sequence of \ref bgl_namedparameters "Named Parameters". +* +* @see `interpolated_corrected_mean_curvature()` +* @see `interpolated_corrected_principal_curvatures()` +* @see `interpolated_corrected_measure_mesh()` +* @see `expand_interpolated_corrected_measure_vertex()` +*/ template void interpolated_corrected_gaussian_curvature(const PolygonMesh& pmesh, @@ -986,6 +1027,51 @@ template::%vertex_descriptor` as key type and +* `std::tuple, Eigen::Vector>` as value type. +* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". +* +* @param pmesh the polygon mesh. +* @param vcm the vertex property map in which the computed principal curvatures are stored. +* @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 `pmesh`} +* \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, pmesh)`} +* \cgalParamExtra{If this parameter is omitted, an internal property map for +* `CGAL::vertex_point_t` must be available in `PolygonMesh`.} +* \cgalParamNEnd +* +* \cgalParamNBegin{vertex_normal_map} +* \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} +* \cgalParamType{a class model of `ReadablePropertyMap` with +* `boost::graph_traits::%vertex_descriptor` +* as key type and `%Vector_3` as value type} +* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} +* \cgalParamExtra{If this parameter is omitted, vertex normals will be +* computed using compute_vertex_normals()} +* \cgalParamNEnd +* +* \cgalNamedParamsEnd +* +* @see `interpolated_corrected_mean_curvature()` +* @see `interpolated_corrected_gaussian_curvatures()` +* @see `interpolated_corrected_anisotropic_measure_mesh()` +* @see `expand_interpolated_corrected_anisotropic_measure_vertex()` +*/ template void interpolated_corrected_principal_curvatures(const PolygonMesh& pmesh, From 5840eaf9556370c1c4cdc0cb2b76fc1d81380876 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Tue, 9 Aug 2022 17:10:15 +0200 Subject: [PATCH 047/142] Update interpolated_corrected_curvature_measures.h --- .../Curvatures/interpolated_corrected_curvature_measures.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 dc7744a402eb..f16413159cab 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 @@ -1068,7 +1068,7 @@ template Date: Sat, 27 Aug 2022 18:01:59 +0200 Subject: [PATCH 048/142] fixing eigen vector definitions so that it works with other compilers --- .../interpolated_corrected_curvature_measures.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 f16413159cab..6ddfe5feb1a0 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 @@ -1138,7 +1138,7 @@ template v_muXY = get(muXY_expand_map, v); typename GT::Vector_3 u_GT = get(vnm, v); - Eigen::Vector u(u_GT.x(), u_GT.y(), u_GT.z()); + Eigen::Matrix u(u_GT.x(), u_GT.y(), u_GT.z()); const typename GT::FT K = 1000 * v_mu0; @@ -1153,12 +1153,12 @@ template(.0,.0,.0), - Eigen::Vector(.0, .0, .0))); + Eigen::Matrix(.0,.0,.0), + Eigen::Matrix(.0, .0, .0))); continue; } - Eigen::Vector eig_vals = eigensolver.eigenvalues(); + Eigen::Matrix eig_vals = eigensolver.eigenvalues(); Eigen::Matrix eig_vecs = eigensolver.eigenvectors(); put(vcm, v, std::make_tuple( From 48262af4247eb8060e3bda3ccfcec6164512007b Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sat, 27 Aug 2022 19:46:33 +0200 Subject: [PATCH 049/142] fixing eigenvector definitions --- .../interpolated_corrected_curvatures.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 c8b972aca658..3a36aaac5c88 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 @@ -41,18 +41,18 @@ int main(int argc, char* argv[]) Mesh::Property_map, - Eigen::Vector + Eigen::Matrix, + Eigen::Matrix >> principle_curvature_map; boost::tie(principle_curvature_map, created) = g1.add_property_map, - Eigen::Vector + Eigen::Matrix, + Eigen::Matrix >>("v:principle_curvature_map", { 0, 0, - Eigen::Vector::Zero(), - Eigen::Vector::Zero() }); + Eigen::Matrix::Zero(), + Eigen::Matrix::Zero() }); assert(created); PMP::interpolated_corrected_mean_curvature( From 13b056c9d404c9eef9b3cdb630777ecb98db5dcf Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sat, 17 Sep 2022 23:53:18 +0200 Subject: [PATCH 050/142] minor fixes + handled zero expansion radius --- ...nterpolated_corrected_curvature_measures.h | 72 +++++++++++++++---- 1 file changed, 60 insertions(+), 12 deletions(-) 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 6ddfe5feb1a0..7cd2c67ab060 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 @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -28,10 +29,31 @@ #include #include +#define EXPANDING_RADIUS_EPSILON 1e-6 + namespace CGAL { namespace Polygon_mesh_processing { +namespace internal { + +template +typename GT::FT average_edge_length(const PolygonMesh& pmesh) +{ + const std::size_t n = edges(pmesh).size(); + if (n == 0) + return 0; + + GT::FT avg_edge_length = 0; + for (auto e : edges(pmesh)) + avg_edge_length += edge_length(e, pmesh); + + avg_edge_length /= n; + return avg_edge_length; +} + +} + /*! * \ingroup PMP_corrected_curvatures_grp * Enumeration type used to specify which measure of a given face @@ -63,7 +85,7 @@ template typename GT::FT interpolated_corrected_area_measure_face(const std::vector& u, const std::vector& x = {}) { - std::size_t n = x.size(); + const std::size_t n = x.size(); CGAL_precondition(u.size() == n); CGAL_precondition(n >= 3); @@ -132,7 +154,7 @@ template typename GT::FT interpolated_corrected_mean_curvature_measure_face(const std::vector& u, const std::vector& x = {}) { - std::size_t n = x.size(); + const std::size_t n = x.size(); CGAL_precondition(u.size() == n); CGAL_precondition(n >= 3); @@ -212,7 +234,7 @@ template typename GT::FT interpolated_corrected_gaussian_curvature_measure_face(const std::vector& u, const std::vector& x = {}) { - std::size_t n = u.size(); + const std::size_t n = u.size(); CGAL_precondition(n >= 3); typename GT::Construct_cross_product_vector_3 cross_product; @@ -274,7 +296,7 @@ template std::array interpolated_corrected_anisotropic_measure_face(const std::vector& u, const std::vector& x) { - std::size_t n = x.size(); + const std::size_t n = x.size(); CGAL_precondition(u.size() == n); CGAL_precondition(n >= 3); @@ -636,7 +658,7 @@ typename GT::FT face_in_ball_ratio(const std::vector& x, const typename GT::FT r, const typename GT::Vector_3 c) { - std::size_t n = x.size(); + const std::size_t n = x.size(); // getting center of points typename GT::Vector_3 xm = @@ -726,8 +748,8 @@ template::face_descriptor face_descriptor; typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; - const typename GetGeomTraits::type::FT - r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0.1); + const typename GT::FT + r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0); typename GetVertexPointMap::const_type vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), @@ -849,8 +871,8 @@ template::face_descriptor face_descriptor; typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; - const typename GetGeomTraits::type::FT - r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0.01); + const typename GT::FT + r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0); typename GetVertexPointMap::const_type vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), @@ -938,6 +960,9 @@ template::type GT; typedef typename boost::graph_traits::face_descriptor face_descriptor; @@ -946,6 +971,12 @@ template::vertex_descriptor vertex_descriptor; typedef std::unordered_map VertexMeasureMap_tag; + typename GT::FT + r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0); + + if (r == 0) + r = internal::average_edge_length(pmesh) * EXPANDING_RADIUS_EPSILON; + FaceMeasureMap_tag mu0_init, mu1_init; boost::associative_property_map mu0_map(mu0_init), mu1_map(mu1_init); @@ -959,7 +990,7 @@ template::type GT; typedef typename boost::graph_traits::face_descriptor face_descriptor; @@ -1004,6 +1038,12 @@ template::vertex_descriptor vertex_descriptor; typedef std::unordered_map VertexMeasureMap_tag; + typename GT::FT + r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0); + + if (r == 0) + r = internal::average_edge_length(pmesh) * EXPANDING_RADIUS_EPSILON; + FaceMeasureMap_tag mu0_init, mu2_init; boost::associative_property_map mu0_map(mu0_init), mu2_map(mu2_init); @@ -1017,7 +1057,7 @@ template(pmesh) * EXPANDING_RADIUS_EPSILON; + if (is_default_parameter::value) compute_vertex_normals(pmesh, vnm, np); + + typedef typename boost::graph_traits::face_descriptor face_descriptor; typedef std::unordered_map FaceScalarMeasureMap_tag; // using std:: array to store FT values on the 9 combinations of the standard 3D basis @@ -1132,7 +1180,7 @@ template v_muXY = get(muXY_expand_map, v); From 4f1a5dd194822e3e763e5c47bd38c1c4151e575c Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Tue, 20 Sep 2022 04:18:11 +0200 Subject: [PATCH 051/142] minor demo updates --- .../Plugins/Display/Display_property_plugin.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index 66187583657e..e38211ecea85 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -1496,10 +1496,10 @@ private Q_SLOTS: void displayMapLegend(const std::vector& values) { // Create a legend_ and display it - const std::size_t size = (std::min)(color_map.size(), (std::size_t)256); + const std::size_t size = (std::min)(color_map.size(), (std::size_t)2048); const int text_height = 20; const int height = text_height*static_cast(size) + text_height; - const int width = 140; + const int width = 170; const int cell_width = width/3; const int top_margin = 15; const int left_margin = 5; @@ -1525,8 +1525,8 @@ private Q_SLOTS: tick_height, color); QRect text_rect(left_margin + cell_width+10, drawing_height - top_margin - j, - 50, text_height); - painter.drawText(text_rect, Qt::AlignCenter, tr("%1").arg(values[i], 0, 'f', 3, QLatin1Char(' '))); + 100, text_height); + painter.drawText(text_rect, Qt::AlignCenter, tr("%1").arg(values[i], 0, 'f', 7, QLatin1Char(' '))); } if(color_map.size() > size){ QRect text_rect(left_margin + cell_width+10, 0, @@ -1545,7 +1545,7 @@ private Q_SLOTS: { // Create a legend_ and display it const int height = 256; - const int width = 140; + const int width = 170; const int cell_width = width/3; const int top_margin = 5; const int left_margin = 5; @@ -1589,11 +1589,11 @@ private Q_SLOTS: painter.setPen(Qt::blue); QRect min_text_rect(left_margin + cell_width+10,drawing_height - top_margin, 100, text_height); - painter.drawText(min_text_rect, Qt::AlignCenter, tr("%1").arg(min_value, 0, 'f', 1)); + painter.drawText(min_text_rect, Qt::AlignCenter, tr("%1").arg(min_value, 0, 'f', 7)); QRect max_text_rect(left_margin + cell_width+10, drawing_height - top_margin - 200, 100, text_height); - painter.drawText(max_text_rect, Qt::AlignCenter, tr("%1").arg(max_value, 0, 'f', 1)); + painter.drawText(max_text_rect, Qt::AlignCenter, tr("%1").arg(max_value, 0, 'f', 7)); dock_widget->legendLabel->setPixmap(legend_); } From 3d3b2c30fd2aedd43140d9c6a9b60b87a9340fba Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Tue, 20 Sep 2022 11:18:13 +0200 Subject: [PATCH 052/142] testing init --- ...nterpolated_corrected_curvature_measures.h | 20 ++- .../Polygon_mesh_processing/CMakeLists.txt | 1 + ...est_interopolated_corrected_curvatures.cpp | 147 ++++++++++++++++++ .../Display/Display_property_plugin.cpp | 34 ++-- .../PMP/Random_perturbation_plugin.cpp | 2 +- 5 files changed, 180 insertions(+), 24 deletions(-) create mode 100644 Polygon_mesh_processing/test/Polygon_mesh_processing/test_interopolated_corrected_curvatures.cpp 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 7cd2c67ab060..aa05f8aebe47 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 @@ -483,8 +483,6 @@ template::value) compute_vertex_normals(pmesh, vnm, np); - typedef typename property_map_value::type measure; - std::function &, const std::vector&)> iccm_function; @@ -985,12 +983,12 @@ template mu0_expand_map(mu0_expand_init), mu1_expand_map(mu1_expand_init); - interpolated_corrected_measure_mesh(pmesh, mu0_map, MU0_AREA_MEASURE); - interpolated_corrected_measure_mesh(pmesh, mu1_map, MU1_MEAN_CURVATURE_MEASURE); + interpolated_corrected_measure_mesh(pmesh, mu0_map, MU0_AREA_MEASURE, np); + interpolated_corrected_measure_mesh(pmesh, mu1_map, MU1_MEAN_CURVATURE_MEASURE, np); for (vertex_descriptor v : vertices(pmesh)) { - expand_interpolated_corrected_measure_vertex(pmesh, mu0_map, mu1_map, mu0_expand_map, mu1_expand_map, v, CGAL::parameters::ball_radius(r)); + expand_interpolated_corrected_measure_vertex(pmesh, mu0_map, mu1_map, mu0_expand_map, mu1_expand_map, v, np.ball_radius(r)); typename GT::FT v_mu0 = get(mu0_expand_map, v); @@ -1052,12 +1050,12 @@ template mu0_expand_map(mu0_expand_init), mu2_expand_map(mu2_expand_init); - interpolated_corrected_measure_mesh(pmesh, mu0_map, MU0_AREA_MEASURE); - interpolated_corrected_measure_mesh(pmesh, mu2_map, MU2_GAUSSIAN_CURVATURE_MEASURE); + interpolated_corrected_measure_mesh(pmesh, mu0_map, MU0_AREA_MEASURE, np); + interpolated_corrected_measure_mesh(pmesh, mu2_map, MU2_GAUSSIAN_CURVATURE_MEASURE, np); for (vertex_descriptor v : vertices(pmesh)) { - expand_interpolated_corrected_measure_vertex(pmesh, mu0_map, mu2_map, mu0_expand_map, mu2_expand_map, v, CGAL::parameters::ball_radius(r)); + expand_interpolated_corrected_measure_vertex(pmesh, mu0_map, mu2_map, mu0_expand_map, mu2_expand_map, v, np.ball_radius(r)); typename GT::FT v_mu0 = get(mu0_expand_map, v); if(v_mu0 != 0.0) @@ -1175,12 +1173,12 @@ template muXY_expand_map(muXY_expand_init); - interpolated_corrected_measure_mesh(pmesh, mu0_map, MU0_AREA_MEASURE); - interpolated_corrected_anisotropic_measure_mesh(pmesh, muXY_map); + interpolated_corrected_measure_mesh(pmesh, mu0_map, MU0_AREA_MEASURE, np); + interpolated_corrected_anisotropic_measure_mesh(pmesh, muXY_map, np); for (vertex_descriptor v : vertices(pmesh)) { - expand_interpolated_corrected_anisotropic_measure_vertex(pmesh, mu0_map, muXY_map, mu0_expand_map, muXY_expand_map, v, CGAL::parameters::ball_radius(r)); + expand_interpolated_corrected_anisotropic_measure_vertex(pmesh, mu0_map, muXY_map, mu0_expand_map, muXY_expand_map, v, np.ball_radius(r)); typename GT::FT v_mu0 = get(mu0_expand_map, v); Eigen::Matrix v_muXY = get(muXY_expand_map, v); diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt index 909dd292063a..808e6d3a05ef 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt @@ -69,6 +69,7 @@ create_single_source_cgal_program("self_intersection_polyhedron_test.cpp") create_single_source_cgal_program("self_intersection_surface_mesh_test.cpp") create_single_source_cgal_program("pmp_do_intersect_test.cpp") create_single_source_cgal_program("test_is_polygon_soup_a_polygon_mesh.cpp") +create_single_source_cgal_program("test_interopolated_corrected_curvatures.cpp") create_single_source_cgal_program("test_stitching.cpp") create_single_source_cgal_program("remeshing_test.cpp") create_single_source_cgal_program("remeshing_with_isolated_constraints_test.cpp" ) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interopolated_corrected_curvatures.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interopolated_corrected_curvatures.cpp new file mode 100644 index 000000000000..9c2408139a3f --- /dev/null +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interopolated_corrected_curvatures.cpp @@ -0,0 +1,147 @@ +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +namespace PMP = CGAL::Polygon_mesh_processing; + +typedef CGAL::Exact_predicates_inexact_constructions_kernel EpicKernel; +typedef CGAL::Surface_mesh SMesh; +typedef boost::graph_traits::face_descriptor face_descriptor; +typedef boost::graph_traits::edge_descriptor edge_descriptor; +typedef boost::graph_traits::vertex_descriptor vertex_descriptor; + +void test(std::string mesh_path, EpicKernel::FT rel_expansion_radius, EpicKernel::FT rel_noise_magnitude) { + SMesh pmesh; + const std::string filename = CGAL::data_file_path(mesh_path); + + if (!CGAL::IO::read_polygon_mesh(filename, pmesh)) + { + std::cerr << "Invalid input file." << std::endl; + } + + bool created = false; + + SMesh::Property_map mean_curvature_map, gaussian_curvature_map; + boost::tie(mean_curvature_map, created) = pmesh.add_property_map("v:mean_curvature_map", 0); + assert(created); + + boost::tie(gaussian_curvature_map, created) = pmesh.add_property_map("v:gaussian_curvature_map", 0); + assert(created); + + // getting the max and min edge lengthes + const auto edge_range = CGAL::edges(pmesh); + + const auto edge_length_comparator = [&, pmesh](auto l, auto r) { + return PMP::edge_length(l, pmesh) < PMP::edge_length(r, pmesh); + }; + + const edge_descriptor longest_edge = *std::max_element(edge_range.begin(), edge_range.end(), edge_length_comparator); + const EpicKernel::FT max_edge_length = PMP::edge_length(longest_edge, pmesh); + + const edge_descriptor shortest_edge = *std::min_element(edge_range.begin(), edge_range.end(), edge_length_comparator); + const EpicKernel::FT min_edge_length = PMP::edge_length(shortest_edge, pmesh); + + + if (rel_noise_magnitude > 0) + { + if (!CGAL::is_triangle_mesh(pmesh)) + return; + + SMesh::Property_map vnm; + boost::tie(vnm, created) = pmesh.add_property_map("v:vnm", { 0 , 0 , 0 }); + assert(created); + + CGAL::Polygon_mesh_processing::compute_vertex_normals(pmesh, vnm); + + PMP::random_perturbation(pmesh, rel_noise_magnitude * min_edge_length, CGAL::parameters::random_seed(0)); + PMP::interpolated_corrected_mean_curvature( + pmesh, + mean_curvature_map, + CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length).vertex_normal_map(vnm) + ); + PMP::interpolated_corrected_gaussian_curvature( + pmesh, + gaussian_curvature_map, + CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length).vertex_normal_map(vnm) + ); + } + else { + PMP::interpolated_corrected_mean_curvature( + pmesh, + mean_curvature_map, + CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length) + ); + PMP::interpolated_corrected_gaussian_curvature( + pmesh, + gaussian_curvature_map, + CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length) + ); + + } + + + + //PMP::interpolated_corrected_mean_curvature( + // pmesh, + // mean_curvature_map, + // CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length) + //); + //PMP::interpolated_corrected_gaussian_curvature( + // pmesh, + // gaussian_curvature_map, + // CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length) + //); + + + const EpicKernel::FT max_mean_curvature = *std::max_element(mean_curvature_map.begin(), mean_curvature_map.end()); + const EpicKernel::FT min_mean_curvature = *std::min_element(mean_curvature_map.begin(), mean_curvature_map.end()); + const EpicKernel::FT max_gaussian_curvature = *std::max_element(gaussian_curvature_map.begin(), gaussian_curvature_map.end()); + const EpicKernel::FT min_gaussian_curvature = *std::min_element(gaussian_curvature_map.begin(), gaussian_curvature_map.end()); + + std::cout << "# " << mesh_path << ":\n" + << "expansion radius ratio to max length / expansion radius = " << rel_expansion_radius << " / " << rel_expansion_radius * max_edge_length << ",\n" + << "max perturbation ratio to minlength / max perturbation = " << rel_noise_magnitude << " / " << rel_noise_magnitude * min_edge_length << "\n" + << "mean curvature: min = " << min_mean_curvature << " <-> " << max_mean_curvature << " = max" << "\n" + << "gaussian curvature: min = " << min_gaussian_curvature << " <-> " << max_gaussian_curvature << " = max" << "\n\n\n"; + + +} + +int main() +{ + const std::vector mesh_pathes_to_test = { + "meshes/icc_test/Cube with fillet Quads.obj", + "meshes/icc_test/Lantern Quads.obj", + "meshes/icc_test/Lantern Tris.obj", + "meshes/icc_test/Sphere Ngons + Quads + Tris.obj", + "meshes/icc_test/Sphere Quads + Tris 100352.obj", + "meshes/icc_test/Sphere Quads + Tris.obj", + "meshes/icc_test/Sphere Quads Remesh.obj", + "meshes/icc_test/Sphere Quads.obj", + "meshes/icc_test/Sphere Tris Ico.obj", + "meshes/icc_test/Sphere Tris Oct.obj", + "meshes/icc_test/Sphere Tris Tet.obj" + }; + + const std::vector rel_expansion_radii = { 0, 0.1, 0.5, 1 }; + const std::vector rel_noise_magnitudes = { 0, 0.5, 0.9 }; + + for (auto mesh_path : mesh_pathes_to_test) { + for (EpicKernel::FT rel_expansion_radius : rel_expansion_radii) + for (EpicKernel::FT rel_noise_magnitude : rel_noise_magnitudes) + { + test(mesh_path, rel_expansion_radius, rel_noise_magnitude); + } + + std::cout << "_________________________________________________________________________________\n\n"; + } + +} diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index e38211ecea85..cda67cbd9700 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -807,8 +807,8 @@ private Q_SLOTS: if (edge_range.begin() == edge_range.end()) { - expandRadius = 0; - dock_widget->expandingRadiusLabel->setText(tr("Expanding Radius : %1").arg(expandRadius)); + expand_radius = 0; + dock_widget->expandingRadiusLabel->setText(tr("Expanding Radius : %1").arg(expand_radius)); return; } @@ -824,8 +824,8 @@ private Q_SLOTS: // if edge_reference is not derefrenceble if (edge_reference == edge_range.end()) { - expandRadius = 0; - dock_widget->expandingRadiusLabel->setText(tr("Expanding Radius : %1").arg(expandRadius)); + expand_radius = 0; + dock_widget->expandingRadiusLabel->setText(tr("Expanding Radius : %1").arg(expand_radius)); return; } @@ -838,8 +838,8 @@ private Q_SLOTS: double outMin = 0, outMax = 5 * maxEdgeLength, base = 1.2; - expandRadius = (pow(base, val) - 1) * outMax / (pow(base, sliderMax) - 1); - dock_widget->expandingRadiusLabel->setText(tr("Expanding Radius : %1").arg(expandRadius)); + expand_radius = (pow(base, val) - 1) * outMax / (pow(base, sliderMax) - 1); + dock_widget->expandingRadiusLabel->setText(tr("Expanding Radius : %1").arg(expand_radius)); } @@ -849,6 +849,9 @@ private Q_SLOTS: "v:interpolated_corrected_mean_curvature": "v:interpolated_corrected_gaussian_curvature"; SMesh& smesh = *item->face_graph(); + const auto vnm = smesh.property_map("v:normal_before_perturbation").first; + const bool vnm_exists = smesh.property_map("v:normal_before_perturbation").second; + //compute once and store the value per vertex bool non_init; SMesh::Property_map mu_i_map; @@ -856,11 +859,18 @@ private Q_SLOTS: smesh.add_property_map(tied_string, 0); if (non_init) { - if (mu_index == PMP::MU1_MEAN_CURVATURE_MEASURE) - PMP::interpolated_corrected_mean_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expandRadius)); - else - PMP::interpolated_corrected_gaussian_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expandRadius)); - + if (vnm_exists) { + if (mu_index == PMP::MU1_MEAN_CURVATURE_MEASURE) + PMP::interpolated_corrected_mean_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expand_radius).vertex_normal_map(vnm)); + else + PMP::interpolated_corrected_gaussian_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expand_radius).vertex_normal_map(vnm)); + } + else { + if (mu_index == PMP::MU1_MEAN_CURVATURE_MEASURE) + PMP::interpolated_corrected_mean_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expand_radius)); + else + PMP::interpolated_corrected_gaussian_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expand_radius)); + } double res_min = ARBITRARY_DBL_MAX, res_max = -ARBITRARY_DBL_MAX; SMesh::Vertex_index min_index, max_index; @@ -1626,7 +1636,7 @@ private Q_SLOTS: std::unordered_map is_source; - double expandRadius; + double expand_radius; double maxEdgeLength = -1; double minBox; double maxBox; diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Random_perturbation_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Random_perturbation_plugin.cpp index 9afb452ab13c..004768739cd5 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Random_perturbation_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Random_perturbation_plugin.cpp @@ -106,7 +106,7 @@ public Q_SLOTS: if(ui.keep_normal_checkbox->isChecked()) { SMesh::Property_map vnormals = - pmesh.add_property_map("v:normal").first; + pmesh.add_property_map("v:normal_before_perturbation").first; CGAL::Polygon_mesh_processing::compute_vertex_normals(pmesh,vnormals); } if(ui.deterministic_checkbox->isChecked()) From c7a6651c6335f7911c8fb04274abc39030af64bb Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Tue, 20 Sep 2022 17:19:43 +0200 Subject: [PATCH 053/142] GroundTruthtests --- .../test_interopolated_corrected_curvatures.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interopolated_corrected_curvatures.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interopolated_corrected_curvatures.cpp index 9c2408139a3f..0caf0149de28 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interopolated_corrected_curvatures.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interopolated_corrected_curvatures.cpp @@ -118,17 +118,18 @@ void test(std::string mesh_path, EpicKernel::FT rel_expansion_radius, EpicKernel int main() { const std::vector mesh_pathes_to_test = { - "meshes/icc_test/Cube with fillet Quads.obj", - "meshes/icc_test/Lantern Quads.obj", - "meshes/icc_test/Lantern Tris.obj", - "meshes/icc_test/Sphere Ngons + Quads + Tris.obj", - "meshes/icc_test/Sphere Quads + Tris 100352.obj", "meshes/icc_test/Sphere Quads + Tris.obj", - "meshes/icc_test/Sphere Quads Remesh.obj", - "meshes/icc_test/Sphere Quads.obj", + "meshes/icc_test/Sphere Quads + Tris 100352.obj", "meshes/icc_test/Sphere Tris Ico.obj", + "meshes/icc_test/Sphere Tris Tet.obj", "meshes/icc_test/Sphere Tris Oct.obj", - "meshes/icc_test/Sphere Tris Tet.obj" + "meshes/icc_test/Sphere Quads.obj", + "meshes/icc_test/Sphere Quads Remesh.obj", + "meshes/icc_test/Sphere Ngons + Quads + Tris.obj", + "meshes/icc_test/Cube with fillet Quads.obj", + "meshes/cylinder.off", + "meshes/icc_test/Lantern Tris.obj", + "meshes/icc_test/Lantern Quads.obj" }; const std::vector rel_expansion_radii = { 0, 0.1, 0.5, 1 }; From 75c7f83c6848a55b4e15f10ca813df2e0d232659 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Tue, 20 Sep 2022 17:21:19 +0200 Subject: [PATCH 054/142] whitespaces --- .../interpolated_corrected_curvature_measures.h | 2 +- .../test_interopolated_corrected_curvatures.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) 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 aa05f8aebe47..c1c1bcd52877 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 @@ -49,7 +49,7 @@ typename GT::FT average_edge_length(const PolygonMesh& pmesh) avg_edge_length += edge_length(e, pmesh); avg_edge_length /= n; - return avg_edge_length; + return avg_edge_length; } } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interopolated_corrected_curvatures.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interopolated_corrected_curvatures.cpp index 0caf0149de28..e7b473141562 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interopolated_corrected_curvatures.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interopolated_corrected_curvatures.cpp @@ -58,7 +58,7 @@ void test(std::string mesh_path, EpicKernel::FT rel_expansion_radius, EpicKernel SMesh::Property_map vnm; boost::tie(vnm, created) = pmesh.add_property_map("v:vnm", { 0 , 0 , 0 }); assert(created); - + CGAL::Polygon_mesh_processing::compute_vertex_normals(pmesh, vnm); PMP::random_perturbation(pmesh, rel_noise_magnitude * min_edge_length, CGAL::parameters::random_seed(0)); @@ -87,7 +87,7 @@ void test(std::string mesh_path, EpicKernel::FT rel_expansion_radius, EpicKernel } - + //PMP::interpolated_corrected_mean_curvature( // pmesh, @@ -106,8 +106,8 @@ void test(std::string mesh_path, EpicKernel::FT rel_expansion_radius, EpicKernel const EpicKernel::FT max_gaussian_curvature = *std::max_element(gaussian_curvature_map.begin(), gaussian_curvature_map.end()); const EpicKernel::FT min_gaussian_curvature = *std::min_element(gaussian_curvature_map.begin(), gaussian_curvature_map.end()); - std::cout << "# " << mesh_path << ":\n" - << "expansion radius ratio to max length / expansion radius = " << rel_expansion_radius << " / " << rel_expansion_radius * max_edge_length << ",\n" + std::cout << "# " << mesh_path << ":\n" + << "expansion radius ratio to max length / expansion radius = " << rel_expansion_radius << " / " << rel_expansion_radius * max_edge_length << ",\n" << "max perturbation ratio to minlength / max perturbation = " << rel_noise_magnitude << " / " << rel_noise_magnitude * min_edge_length << "\n" << "mean curvature: min = " << min_mean_curvature << " <-> " << max_mean_curvature << " = max" << "\n" << "gaussian curvature: min = " << min_gaussian_curvature << " <-> " << max_gaussian_curvature << " = max" << "\n\n\n"; From e0c596d29e8c10724300d40fecbf6015385f6da4 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sun, 25 Sep 2022 22:03:50 +0200 Subject: [PATCH 055/142] principal curvatures and directions visualization --- .../interpolated_corrected_curvatures.cpp | 12 +- ...nterpolated_corrected_curvature_measures.h | 59 +++--- .../Polygon_mesh_processing/compute_normal.h | 12 +- .../Polyhedron/Plugins/PMP/CMakeLists.txt | 14 ++ ..._corrected_principal_curvatures_plugin.cpp | 186 ++++++++++++++++++ 5 files changed, 240 insertions(+), 43 deletions(-) create mode 100644 Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp 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 3a36aaac5c88..c011d57db41e 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 @@ -41,18 +41,18 @@ int main(int argc, char* argv[]) Mesh::Property_map, - Eigen::Matrix + EpicKernel::Vector_3, + EpicKernel::Vector_3 >> principle_curvature_map; boost::tie(principle_curvature_map, created) = g1.add_property_map, - Eigen::Matrix + EpicKernel::Vector_3, + EpicKernel::Vector_3 >>("v:principle_curvature_map", { 0, 0, - Eigen::Matrix::Zero(), - Eigen::Matrix::Zero() }); + EpicKernel::Vector_3 (0,0,0), + EpicKernel::Vector_3 (0,0,0)}); assert(created); PMP::interpolated_corrected_mean_curvature( 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 c1c1bcd52877..e2e1292aedb4 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 @@ -754,8 +754,8 @@ template bfs_q; - std::unordered_set bfs_v; + std::queue bfs_queue; + std::unordered_set bfs_visited; typename GT::Point_3 vp = get(vpm, v); typename GT::Vector_3 c = typename GT::Vector_3(vp.x(), vp.y(), vp.z()); @@ -766,13 +766,13 @@ template::null_face()) { - bfs_q.push(f); - bfs_v.insert(f); + bfs_queue.push(f); + bfs_visited.insert(f); } } - while (!bfs_q.empty()) { - face_descriptor fi = bfs_q.front(); - bfs_q.pop(); + while (!bfs_queue.empty()) { + face_descriptor fi = bfs_queue.front(); + bfs_queue.pop(); // looping over vertices in face to get point coordinates std::vector x; @@ -790,10 +790,10 @@ template::null_face()) + if (bfs_visited.find(fj) == bfs_visited.end() && fj != boost::graph_traits::null_face()) { - bfs_q.push(fj); - bfs_v.insert(fj); + bfs_queue.push(fj); + bfs_visited.insert(fj); } } } @@ -877,8 +877,8 @@ template bfs_q; - std::unordered_set bfs_v; + std::queue bfs_queue; + std::unordered_set bfs_visited; typename GT::Point_3 vp = get(vpm, v); typename GT::Vector_3 c = typename GT::Vector_3(vp.x(), vp.y(), vp.z()); @@ -889,13 +889,13 @@ template::null_face()) { - bfs_q.push(f); - bfs_v.insert(f); + bfs_queue.push(f); + bfs_visited.insert(f); } } - while (!bfs_q.empty()) { - face_descriptor fi = bfs_q.front(); - bfs_q.pop(); + while (!bfs_queue.empty()) { + face_descriptor fi = bfs_queue.front(); + bfs_queue.pop(); // looping over vertices in face to get point coordinates std::vector x; @@ -915,14 +915,14 @@ template::null_face()) + if (bfs_visited.find(fj) == bfs_visited.end() && fj != boost::graph_traits::null_face()) { - bfs_q.push(fj); - bfs_v.insert(fj); + bfs_queue.push(fj); + bfs_visited.insert(fj); } } } @@ -990,7 +990,6 @@ template v_muXY = get(muXY_expand_map, v); + typename GT::Vector_3 u_GT = get(vnm, v); Eigen::Matrix u(u_GT.x(), u_GT.y(), u_GT.z()); @@ -1199,19 +1199,22 @@ template(.0,.0,.0), - Eigen::Matrix(.0, .0, .0))); + typename GT::Vector_3(0, 0, 0), + typename GT::Vector_3(0, 0, 0))); continue; } - Eigen::Matrix eig_vals = eigensolver.eigenvalues(); - Eigen::Matrix eig_vecs = eigensolver.eigenvectors(); + const Eigen::Matrix eig_vals = eigensolver.eigenvalues(); + const Eigen::Matrix eig_vecs = eigensolver.eigenvectors(); + + const typename GT::Vector_3 min_eig_vec(eig_vecs(0, 1), eig_vecs(1, 1), eig_vecs(2, 1)); + const typename GT::Vector_3 max_eig_vec(eig_vecs(0, 0), eig_vecs(1, 0), eig_vecs(2, 0)); put(vcm, v, std::make_tuple( (v_mu0 != 0.0) ? -eig_vals[1] / v_mu0 : 0.0, (v_mu0 != 0.0) ? -eig_vals[0] / v_mu0 : 0.0, - eig_vecs.col(1), - eig_vecs.col(0))); + min_eig_vec, + max_eig_vec)); } } diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h index 2cd837e7bf84..8dfb16af1bdd 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h @@ -717,15 +717,9 @@ compute_vertex_normal(typename boost::graph_traits::vertex_descript } #endif - Vector_3 normal = internal::compute_vertex_normal_most_visible_min_circle(v, face_normals, pmesh, traits); - if(traits.equal_3_object()(normal, CGAL::NULL_VECTOR)) // can't always find a most visible normal - { -#ifdef CGAL_PMP_COMPUTE_NORMAL_DEBUG_PP - std::cout << "Failed to find most visible normal, use weighted sum of normals" << std::endl; -#endif - normal = internal::compute_vertex_normal_as_sum_of_weighted_normals( - v, internal::SIN_WEIGHT, face_normals, vpmap, pmesh, traits); - } + // Change for debugging (comparing with DGtal) + Vector_3 normal = internal::compute_vertex_normal_as_sum_of_weighted_normals( + v, internal::NO_WEIGHT, face_normals, vpmap, pmesh, traits); if(!traits.equal_3_object()(normal, CGAL::NULL_VECTOR)) internal::normalize(normal, traits); diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt b/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt index 53cfdc9b825a..7d2177b03a11 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/CMakeLists.txt @@ -13,6 +13,20 @@ else() ) endif() +if(TARGET CGAL::Eigen3_support) + + polyhedron_demo_plugin(interpolated_corrected_principal_curvatures_plugin Interpolated_corrected_principal_curvatures_plugin) + target_link_libraries( + interpolated_corrected_principal_curvatures_plugin PUBLIC scene_surface_mesh_item scene_polylines_item + CGAL::Eigen3_support) + +else() + message( + STATUS + "NOTICE: Eigen 3.1 (or greater) was not found. Interpolated corrected principal curvatures plugin will not be available." + ) +endif() + polyhedron_demo_plugin(extrude_plugin Extrude_plugin KEYWORDS PMP) target_link_libraries(extrude_plugin PUBLIC scene_surface_mesh_item scene_selection_item) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp new file mode 100644 index 000000000000..69c2b4fe2dd3 --- /dev/null +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp @@ -0,0 +1,186 @@ +#include +#include +#include +#include "Scene_surface_mesh_item.h" +#include "Scene_polylines_item.h" + +#include + +#include "Scene.h" +#include +#include + +#include +#include + +using namespace CGAL::Three; +class Polyhedron_demo_interpolated_corrected_principal_curvatures_plugin : + public QObject, + public Polyhedron_demo_plugin_interface +{ + Q_OBJECT + Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface) + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0") + +public: + + QList actions() const { + return _actions; + } + void init(QMainWindow* mw, + Scene_interface* scene_interface, + Messages_interface*) + { + scene = scene_interface; + QAction *actionEstimateCurvature = new QAction(tr("Interpolated Corrected Principal Curvatures"), mw); + connect(actionEstimateCurvature, SIGNAL(triggered()), this, SLOT(on_actionEstimateCurvature_triggered())); + _actions <(scene->item(scene->mainSelectionIndex())); + } + +public Q_SLOTS: + void on_actionEstimateCurvature_triggered(); +private : + Scene_interface *scene; + QList _actions; +}; // end Polyhedron_demo_interpolated_corrected_principal_curvatures_plugin + + +void compute(SMesh* sMesh, + Scene_polylines_item* max_curv, + Scene_polylines_item* min_curv, + Scene_polylines_item* max_negative_curv, + Scene_polylines_item* min_negative_curv) +{ + namespace PMP = CGAL::Polygon_mesh_processing; + typedef CGAL::Exact_predicates_inexact_constructions_kernel EpicKernel; + typedef EpicKernel::Point_3 Point; + typedef EpicKernel::Point_3 Point; + typedef EpicKernel::Vector_3 Vector; + typedef boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef std::tuple< + EpicKernel::FT, + EpicKernel::FT, + Vector, + Vector + > PrincipalCurvatureTuple; + + typename boost::property_map::type vpmap = get(CGAL::vertex_point, *sMesh); + + bool created = false; + SMesh::Property_map principle_curvature_map; + + boost::tie(principle_curvature_map, created) = sMesh->add_property_map + ("v:principle_curvature_map", { 0, 0, + Vector(0,0,0), + Vector(0,0,0)}); + assert(created); + + PMP::interpolated_corrected_principal_curvatures( + *sMesh, + principle_curvature_map + ); + + typename EpicKernel::FT max_curvature_magnitude_on_mesh = 0; + for (vertex_descriptor v : vertices(*sMesh)) + { + const PrincipalCurvatureTuple pc = principle_curvature_map[v]; + max_curvature_magnitude_on_mesh = max(max_curvature_magnitude_on_mesh, max(abs(get<0>(pc)), get<1>(pc))); + } + + for(vertex_descriptor v : vertices(*sMesh)) + { + std::vector points; + + // pick central point + const Point& central_point = get(vpmap,v); + points.push_back(central_point); + + // compute min edge len around central vertex + // to scale the ribbons used to display the directions + + typedef EPICK::FT FT; + + const std::size_t n = CGAL::edges(*sMesh).size(); + + EpicKernel::FT avg_edge_length = 0; + if (n > 0) { + for (auto e : CGAL::edges(*sMesh)) + avg_edge_length += PMP::edge_length(e, *sMesh); + avg_edge_length /= n; + } + + const PrincipalCurvatureTuple pc = principle_curvature_map[v]; + + Vector umin = (std::get<0>(pc)/ max_curvature_magnitude_on_mesh) * std::get<2>(pc) * avg_edge_length; + Vector umax = (std::get<1>(pc)/ max_curvature_magnitude_on_mesh) * std::get<3>(pc) * avg_edge_length; + + Scene_polylines_item::Polyline max_segment(2), min_segment(2); + + const double du = 0.4; + + min_segment[0] = central_point + du * umin; + min_segment[1] = central_point - du * umin; + max_segment[0] = central_point + du * umax; + max_segment[1] = central_point - du * umax; + + (std::get<0>(pc) > 0 ? min_curv : min_negative_curv)->polylines.push_back(min_segment); + (std::get<1>(pc) > 0 ? max_curv : max_negative_curv)->polylines.push_back(max_segment); + } +} + +void Polyhedron_demo_interpolated_corrected_principal_curvatures_plugin::on_actionEstimateCurvature_triggered() +{ + // get active polyhedron + const CGAL::Three::Scene_interface::Item_id index = scene->mainSelectionIndex(); + QString name = scene->item(index)->name(); + Scene_surface_mesh_item* sm_item = + qobject_cast(scene->item(index)); + if(! sm_item){ + return; + } + // wait cursor + QApplication::setOverrideCursor(Qt::WaitCursor); + + // types + Scene_polylines_item* max_curv = new Scene_polylines_item; + max_curv->setColor(Qt::red); + max_curv->setWidth(3); + max_curv->setName(tr("%1 (max curvatures)").arg(name)); + + Scene_polylines_item* min_curv = new Scene_polylines_item; + min_curv->setColor(QColor(255,210,0)); + min_curv->setWidth(4); + min_curv->setName(tr("%1 (min curvatures)").arg(name)); + + Scene_polylines_item* max_negative_curv = new Scene_polylines_item; + max_negative_curv->setColor(Qt::cyan); + max_negative_curv->setWidth(4); + max_negative_curv->setName(tr("%1 (min negative curvatures)").arg(name)); + + Scene_polylines_item* min_negative_curv = new Scene_polylines_item; + min_negative_curv->setColor(Qt::blue); + min_negative_curv->setWidth(3); + min_negative_curv->setName(tr("%1 (max negative curvatures)").arg(name)); + + SMesh* pMesh = sm_item->polyhedron(); + compute(pMesh, max_curv, min_curv, max_negative_curv, min_negative_curv); + + scene->addItem(max_curv); + scene->addItem(min_curv); + max_curv->invalidateOpenGLBuffers(); + min_curv->invalidateOpenGLBuffers(); + scene->addItem(max_negative_curv); + scene->addItem(min_negative_curv); + max_negative_curv->invalidateOpenGLBuffers(); + min_negative_curv->invalidateOpenGLBuffers(); + + // default cursor + QApplication::restoreOverrideCursor(); +} + +#include "Interpolated_corrected_principal_curvatures_plugin.moc" From 419745088537cfc6425758ae527048132fde193a Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 26 Sep 2022 02:33:04 +0200 Subject: [PATCH 056/142] restored compute_normal.h --- .../CGAL/Polygon_mesh_processing/compute_normal.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h index 8dfb16af1bdd..2cd837e7bf84 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/compute_normal.h @@ -717,9 +717,15 @@ compute_vertex_normal(typename boost::graph_traits::vertex_descript } #endif - // Change for debugging (comparing with DGtal) - Vector_3 normal = internal::compute_vertex_normal_as_sum_of_weighted_normals( - v, internal::NO_WEIGHT, face_normals, vpmap, pmesh, traits); + Vector_3 normal = internal::compute_vertex_normal_most_visible_min_circle(v, face_normals, pmesh, traits); + if(traits.equal_3_object()(normal, CGAL::NULL_VECTOR)) // can't always find a most visible normal + { +#ifdef CGAL_PMP_COMPUTE_NORMAL_DEBUG_PP + std::cout << "Failed to find most visible normal, use weighted sum of normals" << std::endl; +#endif + normal = internal::compute_vertex_normal_as_sum_of_weighted_normals( + v, internal::SIN_WEIGHT, face_normals, vpmap, pmesh, traits); + } if(!traits.equal_3_object()(normal, CGAL::NULL_VECTOR)) internal::normalize(normal, traits); From 7118646bec18cb0d4192daad64d1f52eb16cae97 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 26 Sep 2022 09:19:17 +0200 Subject: [PATCH 057/142] typo fix --- .../Interpolated_corrected_principal_curvatures_plugin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp index 69c2b4fe2dd3..0b729978c7e7 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp @@ -160,12 +160,12 @@ void Polyhedron_demo_interpolated_corrected_principal_curvatures_plugin::on_acti Scene_polylines_item* max_negative_curv = new Scene_polylines_item; max_negative_curv->setColor(Qt::cyan); max_negative_curv->setWidth(4); - max_negative_curv->setName(tr("%1 (min negative curvatures)").arg(name)); + max_negative_curv->setName(tr("%1 (max negative curvatures)").arg(name)); Scene_polylines_item* min_negative_curv = new Scene_polylines_item; min_negative_curv->setColor(Qt::blue); min_negative_curv->setWidth(3); - min_negative_curv->setName(tr("%1 (max negative curvatures)").arg(name)); + min_negative_curv->setName(tr("%1 (min negative curvatures)").arg(name)); SMesh* pMesh = sm_item->polyhedron(); compute(pMesh, max_curv, min_curv, max_negative_curv, min_negative_curv); From a1e9345a1ece1571b583326a217cb5833822a7b6 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 26 Sep 2022 19:59:36 +0200 Subject: [PATCH 058/142] added principal curvatures plugin to test with cmake --- Polyhedron/demo/Polyhedron/cgal_test_with_cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/Polyhedron/demo/Polyhedron/cgal_test_with_cmake b/Polyhedron/demo/Polyhedron/cgal_test_with_cmake index 6fea79491769..59eb5c1d0211 100755 --- a/Polyhedron/demo/Polyhedron/cgal_test_with_cmake +++ b/Polyhedron/demo/Polyhedron/cgal_test_with_cmake @@ -149,6 +149,7 @@ hole_filling_plugin \ hole_filling_sm_plugin \ hole_filling_polyline_plugin \ inside_out_plugin \ +interpolated_corrected_principal_curvatures_plugin\ surface_intersection_plugin \ surface_intersection_sm_plugin \ io_image_plugin \ From 4f76f267d5b3e9dd08529baf06fefdffba256b4f Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Wed, 5 Oct 2022 00:38:23 +0200 Subject: [PATCH 059/142] mostly docs and examples, moved utils to internal --- .../PackageDescription.txt | 8 - .../Polygon_mesh_processing.txt | 54 ++++ .../doc/Polygon_mesh_processing/examples.txt | 3 +- .../Polygon_mesh_processing/CMakeLists.txt | 6 +- ...rpolated_corrected_curvatures_example.cpp} | 59 ++-- ...orrected_curvatures_polyhedron_example.cpp | 74 +++++ ...nterpolated_corrected_curvature_measures.h | 290 +----------------- 7 files changed, 184 insertions(+), 310 deletions(-) rename Polygon_mesh_processing/examples/Polygon_mesh_processing/{interpolated_corrected_curvatures.cpp => interpolated_corrected_curvatures_example.cpp} (52%) create mode 100644 Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt index 5c9e39811d46..eae47c610011 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt @@ -201,14 +201,6 @@ The page \ref bgl_namedparameters "Named Parameters" describes their usage. - \link PMP_locate_grp Random Location Generation \endlink \cgalCRPSection{Corrected Curvature Functions} -- `CGAL::Polygon_mesh_processing::interpolated_corrected_measure_mesh()` -- `CGAL::Polygon_mesh_processing::interpolated_corrected_anisotropic_measure_mesh()` -- `CGAL::Polygon_mesh_processing::interpolated_corrected_area_measure_face()` -- `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature_measure_face()` -- `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature_measure_face()` -- `CGAL::Polygon_mesh_processing::interpolated_corrected_anisotropic_measure_face()` -- `CGAL::Polygon_mesh_processing::expand_interpolated_corrected_measure_vertex()` -- `CGAL::Polygon_mesh_processing::expand_interpolated_corrected_anisotropic_measure_vertex()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures()` diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index 743d6bc35079..6c684c4419b4 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -876,6 +876,60 @@ not provide storage for the normals. \cgalExample{Polygon_mesh_processing/compute_normals_example_Polyhedron.cpp} +**************************************** +\section PMPICC Computing Curvatures + +This package provides methods to compute curvatures on polygonal meshes based on #PAPER#. +This includes mean curvature, gaussian curvature, principal curvatures and directions. +These can be computed on triangle meshes, quad meshes, and meshes with n-gon faces. +The algorithms used prove to work well in general. Also, on meshes with noise +on vertex positions, they give accurate results, on the condition that the +correct vertex normals are provided. + +The implementation is generic in terms of mesh data structure. It can be used on Surface_mesh, +Polyhedron_3 and other polygonal mesh structures based on the Face Graph Model. + +These computations are performed using : +- `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures()` + +\cgalFigureRef{icc_diff_radius} shows how the mean curvature changes depending on +the ball_radius named parameter which can be set to a value > 0 to get a smoother +distribution of valuesa and "diffuse" the extreme values of curvatures across the mesh. + +\cgalFigureAnchor{icc_diff_radius} +
+ +
+\cgalFigureCaptionBegin{icc_diff_radius} +The mean curvature distrubution on a bear mesh with different values for the expanding ball radius +\cgalFigureCaptionEnd + +Property maps are used to record the computed curvatures as shown in examples. + +\subsection ICCExample Interpolated Corrected Curvature Examples + +Property maps are an API introduced in the boost library that allows to +associate values to keys. In the following examples, for each proberty map, we associate +a curvature value to each vertex. + +\subsubsection ICCExample Interpolated Corrected Curvature on a Surface Mesh. + +The following example illustrates how to +compute the curvatures on vertices +and store them in property maps provided by the class `Surface_mesh`. + +\cgalExample{Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp} + +\subsubsection NormalsExampleNP Interpolated Corrected Curvature on a Polyhedron + +The following example illustrates how to +compute the curvatures on vertices +and store them in unordered (or ordered) maps as the class `Polyhedron_3` does +not provide storage for the curvatures. + +\cgalExample{Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp} **************************************** \section PMPSlicer Slicer diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt index 0317812aa443..0588d1c76e14 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt @@ -19,7 +19,8 @@ \example Polygon_mesh_processing/refine_fair_example.cpp \example Polygon_mesh_processing/mesh_slicer_example.cpp \example Polygon_mesh_processing/isotropic_remeshing_example.cpp -\example Polygon_mesh_processing/interpolated_corrected_curvatures.cpp +\example Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp +\example Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp \example Polygon_mesh_processing/delaunay_remeshing_example.cpp \example Polygon_mesh_processing/compute_normals_example_Polyhedron.cpp \example Polygon_mesh_processing/hausdorff_distance_remeshing_example.cpp diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt index 4783d957589a..ab084384835b 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt @@ -105,8 +105,10 @@ create_single_source_cgal_program("cc_compatible_orientations.cpp") if(TARGET CGAL::Eigen3_support) - create_single_source_cgal_program("interpolated_corrected_curvatures.cpp") - target_link_libraries(interpolated_corrected_curvatures PUBLIC CGAL::Eigen3_support) + create_single_source_cgal_program("interpolated_corrected_curvatures_example.cpp") + target_link_libraries(interpolated_corrected_curvatures_example PUBLIC CGAL::Eigen3_support) + create_single_source_cgal_program("interpolated_corrected_curvatures_polyhedron_example.cpp") + target_link_libraries(interpolated_corrected_curvatures_polyhedron_example PUBLIC CGAL::Eigen3_support) endif() 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_example.cpp similarity index 52% rename from Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures.cpp rename to Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp index c011d57db41e..caaa52eb3af0 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp @@ -7,18 +7,17 @@ #include #include -#include namespace PMP = CGAL::Polygon_mesh_processing; -typedef CGAL::Exact_predicates_inexact_constructions_kernel EpicKernel; -typedef CGAL::Surface_mesh Mesh; -typedef boost::graph_traits::face_descriptor face_descriptor; -typedef boost::graph_traits::vertex_descriptor vertex_descriptor; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic_Kernel; +typedef CGAL::Surface_mesh Surface_Mesh; +typedef boost::graph_traits::face_descriptor face_descriptor; +typedef boost::graph_traits::vertex_descriptor vertex_descriptor; int main(int argc, char* argv[]) { - Mesh g1; + Surface_Mesh g1; const std::string filename = (argc>1) ? argv[1] : CGAL::data_file_path("meshes/small_bunny.obj"); @@ -29,36 +28,54 @@ int main(int argc, char* argv[]) return EXIT_FAILURE; } + // creating and tying surface mesh property maps for curvatures (with defaults = 0) bool created = false; - - Mesh::Property_map mean_curvature_map, gaussian_curvature_map; - boost::tie(mean_curvature_map, created) = g1.add_property_map("v:mean_curvature_map", 0); + Surface_Mesh::Property_map mean_curvature_map, gaussian_curvature_map; + boost::tie(mean_curvature_map, created) = g1.add_property_map("v:mean_curvature_map", 0); assert(created); - boost::tie(gaussian_curvature_map, created) = g1.add_property_map("v:gaussian_curvature_map", 0); + boost::tie(gaussian_curvature_map, created) = g1.add_property_map("v:gaussian_curvature_map", 0); assert(created); - Mesh::Property_map> principle_curvature_map; boost::tie(principle_curvature_map, created) = g1.add_property_map>("v:principle_curvature_map", { 0, 0, - EpicKernel::Vector_3 (0,0,0), - EpicKernel::Vector_3 (0,0,0)}); + Epic_Kernel::Vector_3 (0,0,0), + Epic_Kernel::Vector_3 (0,0,0)}); assert(created); PMP::interpolated_corrected_mean_curvature( g1, mean_curvature_map ); + + // uncomment this to compute a curvature while specifying named parameters + // Example: an expansion ball radius of 0.5 and a vertex normals map (does not have to depend on positions) + + /*Surface_Mesh::Property_map vnm; + boost::tie(vnm, created) = g1.add_property_map( + "v:vnm", Epic_Kernel::Vector_3(0, 0, 0) + ); + + assert(created); + + PMP::interpolated_corrected_mean_curvature( + g1, + mean_curvature_map, + CGAL::parameters::ball_radius(0.5).vertex_normal_map(vnm) + );*/ + PMP::interpolated_corrected_gaussian_curvature( g1, gaussian_curvature_map diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp new file mode 100644 index 000000000000..3e56905068f3 --- /dev/null +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp @@ -0,0 +1,74 @@ +#include +#include +#include +#include +#include + +#include + +#include +#include + +namespace PMP = CGAL::Polygon_mesh_processing; + +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic_Kernel; +typedef CGAL::Polyhedron_3 Polyhedron; +typedef boost::graph_traits::face_descriptor face_descriptor; +typedef boost::graph_traits::vertex_descriptor vertex_descriptor; + +int main(int argc, char* argv[]) +{ + Polyhedron g1; + const std::string filename = (argc>1) ? + argv[1] : + CGAL::data_file_path("meshes/small_bunny.obj"); + + if(!CGAL::IO::read_polygon_mesh(filename, g1)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; + } + + std::unordered_map mean_curvature_map, gaussian_curvature_map; + std::unordered_map> principle_curvature_map; + + PMP::interpolated_corrected_mean_curvature( + g1, + boost::make_assoc_property_map(mean_curvature_map) + ); + + // uncomment this to compute a curvature while specifying named parameters + // Example: an expansion ball radius of 0.5 and a vertex normals map (does not have to depend on positions) + + /*std::unordered_map vnm; + + PMP::interpolated_corrected_mean_curvature( + g1, + boost::make_assoc_property_map(mean_curvature_map), + CGAL::parameters::ball_radius(0.5).vertex_normal_map(boost::make_assoc_property_map(vnm)) + );*/ + + PMP::interpolated_corrected_gaussian_curvature( + g1, + boost::make_assoc_property_map(gaussian_curvature_map) + ); + PMP::interpolated_corrected_principal_curvatures( + g1, + boost::make_assoc_property_map(principle_curvature_map) + ); + + int i = 0; + for (vertex_descriptor v : vertices(g1)) + { + auto PC = principle_curvature_map[v]; + std::cout << i << ": HC = " << mean_curvature_map[v] + << ", GC = " << gaussian_curvature_map[v] << "\n" + << ", PC = [ " << std::get<0>(PC) << " , " << std::get<1>(PC) << " ]\n"; + i++; + } +} 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 e2e1292aedb4..8f5e1d338edb 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 @@ -44,7 +44,7 @@ typename GT::FT average_edge_length(const PolygonMesh& pmesh) if (n == 0) return 0; - GT::FT avg_edge_length = 0; + typename GT::FT avg_edge_length = 0; for (auto e : edges(pmesh)) avg_edge_length += edge_length(e, pmesh); @@ -52,35 +52,12 @@ typename GT::FT average_edge_length(const PolygonMesh& pmesh) return avg_edge_length; } -} - -/*! - * \ingroup PMP_corrected_curvatures_grp - * Enumeration type used to specify which measure of a given face - * is computed for the interpolated corrected curvature functions. - */ -// enum enum Curvature_measure_index { MU0_AREA_MEASURE, ///< corrected area density MU1_MEAN_CURVATURE_MEASURE, ///< corrected mean curvature density MU2_GAUSSIAN_CURVATURE_MEASURE ///< corrected gaussian curvature density }; -/** -* \ingroup PMP_corrected_curvatures_grp -* -* Computes the interpolated corrected area measure \f$ \mu_0 \f$ of a specific face. -* -* @tparam GT geometric traits class model of `Kernel`. -* -* @param x is a vector of the vertex positions of the face. -* @param u is a vector of the vertex normals of the face. -* -* -* @see `interpolated_corrected_mean_curvature_measure_face()` -* @see `interpolated_corrected_gaussian_curvature_measure_face()` -* @see `interpolated_corrected_measure_mesh()` -*/ template typename GT::FT interpolated_corrected_area_measure_face(const std::vector& u, const std::vector& x = {}) @@ -136,20 +113,6 @@ typename GT::FT interpolated_corrected_area_measure_face(const std::vector typename GT::FT interpolated_corrected_mean_curvature_measure_face(const std::vector& u, const std::vector& x = {}) @@ -216,20 +179,6 @@ typename GT::FT interpolated_corrected_mean_curvature_measure_face(const std::ve } } -/** -* \ingroup PMP_corrected_curvatures_grp -* -* Computes the interpolated corrected gaussian curvature measure \f$ \mu_2 \f$ of a specific face. -* -* @tparam GT geometric traits class model of `Kernel`. -* -* @param x is a vector of the vertex positions of the face. -* @param u is a vector of the vertex nomrals of the face. -* -* @see `interpolated_corrected_mean_curvature_measure_face()` -* @see `interpolated_corrected_area_measure_face()` -* @see `interpolated_corrected_measure_mesh()` -*/ template typename GT::FT interpolated_corrected_gaussian_curvature_measure_face(const std::vector& u, const std::vector& x = {}) @@ -277,21 +226,6 @@ typename GT::FT interpolated_corrected_gaussian_curvature_measure_face(const std } } -/** -* \ingroup PMP_corrected_curvatures_grp -* -* Computes the interpolated corrected anisotropic measure \f$ \mu_{XY} \f$ of a specific face. -* -* @tparam GT geometric traits class model of `Kernel`. -* -* @param u is a vector of the vertex nomrals of the face. -* @param x is a vector of the vertex positions of the face. -* -* @return an array of scalar values for each combination of the standard basis (3x3) -* These are the values of the interpolated corrected anisotropic measure of the given face. -* -* @see `interpolated_corrected_anisotropic_measure_mesh()` -*/ template std::array interpolated_corrected_anisotropic_measure_face(const std::vector& u, const std::vector& x) @@ -403,51 +337,6 @@ std::array interpolated_corrected_anisotropic_measure_fa return muXY; } - -/** -* \ingroup PMP_corrected_curvatures_grp -* -* Computes the interpolated corrected curvature measure on each face of the mesh. -* -* @tparam PolygonMesh a model of `FaceListGraph`. -* @tparam FaceMeasureMap a model of `WritablePropertyMap` with -* `boost::graph_traits::%face_descriptor` as key type and `GT::FT` as value type. -* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". -* -* @param pmesh the polygon mesh. -* @param fmm (face measure map) the property map used for storing the computed interpolated corrected 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 -* -* \cgalNamedParamsBegin -* -* \cgalParamNBegin{vertex_point_map} -* \cgalParamDescription{a property map associating points to the vertices of `pmesh`} -* \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, pmesh)`} -* \cgalParamExtra{If this parameter is omitted, an internal property map for -* `CGAL::vertex_point_t` must be available in `PolygonMesh`.} -* \cgalParamNEnd -* -* \cgalParamNBegin{vertex_normal_map} -* \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} -* \cgalParamType{a class model of `ReadablePropertyMap` with -* `boost::graph_traits::%vertex_descriptor` -* as key type and `%Vector_3` as value type} -* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} -* \cgalParamExtra{If this parameter is omitted, vertex normals will be -* computed using compute_vertex_normals()} -* \cgalParamNEnd -* -* \cgalNamedParamsEnd -* -* @see `interpolated_corrected_area_measure_face()` -* @see `interpolated_corrected_mean_curvature_measure_face()` -* @see `interpolated_corrected_gaussian_curvature_measure_face()` -*/ template void @@ -518,48 +407,6 @@ template::%face_descriptor` as key type and `std::array` as value type. -* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". -* -* @param pmesh the polygon mesh. -* @param fmm (face measure map) the property map used for storing the computed interpolated corrected measure. -* @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 `pmesh`} -* \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, pmesh)`} -* \cgalParamExtra{If this parameter is omitted, an internal property map for -* `CGAL::vertex_point_t` must be available in `PolygonMesh`.} -* \cgalParamNEnd -* -* \cgalParamNBegin{vertex_normal_map} -* \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} -* \cgalParamType{a class model of `ReadablePropertyMap` with -* `boost::graph_traits::%vertex_descriptor` -* as key type and `%Vector_3` as value type} -* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} -* \cgalParamExtra{If this parameter is omitted, vertex normals will be -* computed using compute_vertex_normals()} -* \cgalParamNEnd -* -* \cgalNamedParamsEnd -* -* @see `interpolated_corrected_anisotropic_measure_face()` -* @see `interpolated_corrected_measure_mesh()` -*/ template void @@ -636,21 +483,6 @@ template typename GT::FT face_in_ball_ratio(const std::vector& x, const typename GT::FT r, @@ -682,52 +514,6 @@ typename GT::FT face_in_ball_ratio(const std::vector& x, return (r - d_min) / (d_max - d_min); } -/** -* \ingroup PMP_corrected_curvatures_grp -* -* Expands given face area and curvature (mean or gaussian) measures around a vertex `v`. -* Expansion is based on the inclusion ratio of each face in a ball of radius `r` around the vertex `v`. -* -* @tparam PolygonMesh a model of `FaceListGraph`. -* @tparam FaceMeasureMap a model of `WritablePropertyMap` with -* `boost::graph_traits::%face_descriptor` as key type and `GT::FT` as value type. -* @tparam VertexMeasureMap a model of `WritablePropertyMap` with -* `boost::graph_traits::%vertex_descriptor` as key type and `GT::FT` as value type. -* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". -* -* @param pmesh the polygon mesh. -* @param area_fmm (area face measure map) the property map storing the already computed area measure on each face. -* @param curvature_fmm (curvature face measure map) the property map storing the already computed curvature measure on each face. -* This curvature measure can be either the Mean Curvature or the Gaussian Curvature. -* @param area_vmm (area vertex measure map) the property map provided to store the expanded area measure on each vertex. -* @param curvature_vmm (curvature vertex measure map) the property map provided to store the expanded curvature measure on each vertex. -* This curvature measure can be either the Mean Curvature or the Gaussian Curvature. -* @param v (vertex) the vertex to expand the area and curvature measure around. -* @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below -* -* \cgalNamedParamsBegin -* -* \cgalParamNBegin{ball_radius} -* \cgalParamDescription{the radius of the ball around the vertex `v` to expand the area and curvature measure} -* \cgalParamType{`GT::FT`} -* \cgalParamDefault{`0.01`} -* \cgalParamNEnd -* -* \cgalParamNBegin{vertex_point_map} -* \cgalParamDescription{a property map associating points to the vertices of `pmesh`} -* \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, pmesh)`} -* \cgalParamExtra{If this parameter is omitted, an internal property map for -* `CGAL::vertex_point_t` must be available in `PolygonMesh`.} -* \cgalParamNEnd -* -* \cgalNamedParamsEnd -* -* @see `expand_interpolated_corrected_anisotropic_measure_vertex()` -* @see `face_in_ball_ratio()` -*/ template void expand_interpolated_corrected_measure_vertex(const PolygonMesh& pmesh, @@ -802,54 +588,6 @@ template::%face_descriptor` as key type and `GT::FT` as value type. -* @tparam AnisotropicFaceMeasureMap a model of `WritablePropertyMap` with -* `boost::graph_traits::%face_descriptor` as key type and `std::array` as value type. -* @tparam AreaVertexMeasureMap a model of `WritablePropertyMap` with -* `boost::graph_traits::%vertex_descriptor` as key type and `GT::FT` as value type. -* @tparam AnisotropicVertexMeasureMap a model of `WritablePropertyMap` with -* `boost::graph_traits::%vertex_descriptor` as key type and `std::array` as value type. -* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". -* -* @param pmesh the polygon mesh. -* @param area_fmm (area face measure map) the property map storing the already computed area measure on each face. -* @param aniso_fmm (anisotropic face measure map) the property map storing the already computed anisotropic measure on each face. -* @param area_vmm (area vertex measure map) the property map provided to store the expanded area measure on each vertex. -* @param aniso_vmm (anisotropic vertex measure map) the property map provided to store the expanded anisotropic measure on each vertex. -* @param v (vertex) the vertex to expand the area and anisotropic measure around. -* @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below -* -* \cgalNamedParamsBegin -* -* \cgalParamNBegin{ball_radius} -* \cgalParamDescription{the radius of the ball around the vertex `v` to expand the area and curvature measure} -* \cgalParamType{`GT::FT`} -* \cgalParamDefault{`0.01`} -* \cgalParamNEnd -* -* \cgalParamNBegin{vertex_point_map} -* \cgalParamDescription{a property map associating points to the vertices of `pmesh`} -* \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, pmesh)`} -* \cgalParamExtra{If this parameter is omitted, an internal property map for -* `CGAL::vertex_point_t` must be available in `PolygonMesh`.} -* \cgalParamNEnd -* -* \cgalNamedParamsEnd -* -* @see `expand_interpolated_corrected_measure_vertex()` -* @see `face_in_ball_ratio()` -*/ template @@ -931,6 +669,8 @@ template mu0_expand_map(mu0_expand_init), mu1_expand_map(mu1_expand_init); - interpolated_corrected_measure_mesh(pmesh, mu0_map, MU0_AREA_MEASURE, np); - interpolated_corrected_measure_mesh(pmesh, mu1_map, MU1_MEAN_CURVATURE_MEASURE, np); + internal::interpolated_corrected_measure_mesh(pmesh, mu0_map, internal::MU0_AREA_MEASURE, np); + internal::interpolated_corrected_measure_mesh(pmesh, mu1_map, internal::MU1_MEAN_CURVATURE_MEASURE, np); for (vertex_descriptor v : vertices(pmesh)) { - expand_interpolated_corrected_measure_vertex(pmesh, mu0_map, mu1_map, mu0_expand_map, mu1_expand_map, v, np.ball_radius(r)); + internal::expand_interpolated_corrected_measure_vertex(pmesh, mu0_map, mu1_map, mu0_expand_map, mu1_expand_map, v, np.ball_radius(r)); typename GT::FT v_mu0 = get(mu0_expand_map, v); if (v_mu0 != 0.0) @@ -1015,8 +753,6 @@ template @@ -1049,12 +785,12 @@ template mu0_expand_map(mu0_expand_init), mu2_expand_map(mu2_expand_init); - interpolated_corrected_measure_mesh(pmesh, mu0_map, MU0_AREA_MEASURE, np); - interpolated_corrected_measure_mesh(pmesh, mu2_map, MU2_GAUSSIAN_CURVATURE_MEASURE, np); + internal::interpolated_corrected_measure_mesh(pmesh, mu0_map, internal::MU0_AREA_MEASURE, np); + internal::interpolated_corrected_measure_mesh(pmesh, mu2_map, internal::MU2_GAUSSIAN_CURVATURE_MEASURE, np); for (vertex_descriptor v : vertices(pmesh)) { - expand_interpolated_corrected_measure_vertex(pmesh, mu0_map, mu2_map, mu0_expand_map, mu2_expand_map, v, np.ball_radius(r)); + internal::expand_interpolated_corrected_measure_vertex(pmesh, mu0_map, mu2_map, mu0_expand_map, mu2_expand_map, v, np.ball_radius(r)); typename GT::FT v_mu0 = get(mu0_expand_map, v); if(v_mu0 != 0.0) @@ -1106,8 +842,6 @@ template @@ -1172,12 +906,12 @@ template muXY_expand_map(muXY_expand_init); - interpolated_corrected_measure_mesh(pmesh, mu0_map, MU0_AREA_MEASURE, np); - interpolated_corrected_anisotropic_measure_mesh(pmesh, muXY_map, np); + internal::interpolated_corrected_measure_mesh(pmesh, mu0_map, internal::MU0_AREA_MEASURE, np); + internal::interpolated_corrected_anisotropic_measure_mesh(pmesh, muXY_map, np); for (vertex_descriptor v : vertices(pmesh)) { - expand_interpolated_corrected_anisotropic_measure_vertex(pmesh, mu0_map, muXY_map, mu0_expand_map, muXY_expand_map, v, np.ball_radius(r)); + internal::expand_interpolated_corrected_anisotropic_measure_vertex(pmesh, mu0_map, muXY_map, mu0_expand_map, muXY_expand_map, v, np.ball_radius(r)); typename GT::FT v_mu0 = get(mu0_expand_map, v); Eigen::Matrix v_muXY = get(muXY_expand_map, v); From bb6d3e4f07b372972e942f4198a1666289ac3916 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Wed, 5 Oct 2022 10:30:27 +0200 Subject: [PATCH 060/142] doc fix --- .../doc/Polygon_mesh_processing/Polygon_mesh_processing.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index 6c684c4419b4..8f222497a527 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -914,7 +914,7 @@ Property maps are an API introduced in the boost library that allows to associate values to keys. In the following examples, for each proberty map, we associate a curvature value to each vertex. -\subsubsection ICCExample Interpolated Corrected Curvature on a Surface Mesh. +\subsubsection ICCExampleSM Interpolated Corrected Curvature on a Surface Mesh. The following example illustrates how to compute the curvatures on vertices @@ -922,7 +922,7 @@ and store them in property maps provided by the class `Surface_mesh`. \cgalExample{Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp} -\subsubsection NormalsExampleNP Interpolated Corrected Curvature on a Polyhedron +\subsubsection ICCExamplePH Interpolated Corrected Curvature on a Polyhedron The following example illustrates how to compute the curvatures on vertices From e80a4c8cc57e375356090e07da3a7ff4c5d452a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 5 Oct 2022 10:32:45 +0200 Subject: [PATCH 061/142] change ref --- .../doc/Polygon_mesh_processing/Polygon_mesh_processing.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index 6c684c4419b4..6bb9140939c2 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -914,7 +914,7 @@ Property maps are an API introduced in the boost library that allows to associate values to keys. In the following examples, for each proberty map, we associate a curvature value to each vertex. -\subsubsection ICCExample Interpolated Corrected Curvature on a Surface Mesh. +\subsubsection ICCExampleSM Interpolated Corrected Curvature on a Surface Mesh. The following example illustrates how to compute the curvatures on vertices From 2cb8906639e3aea577bd9c98dcd5005b78c44004 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Fri, 7 Oct 2022 21:36:30 +0200 Subject: [PATCH 062/142] principle -> principal typo fixed --- .../interpolated_corrected_curvatures_example.cpp | 12 ++++++------ ...lated_corrected_curvatures_polyhedron_example.cpp | 8 ++++---- ...polated_corrected_principal_curvatures_plugin.cpp | 12 ++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp index caaa52eb3af0..78307b952e4f 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp @@ -43,14 +43,14 @@ int main(int argc, char* argv[]) Epic_Kernel::FT, Epic_Kernel::Vector_3, Epic_Kernel::Vector_3 - >> principle_curvature_map; + >> principal_curvature_map; - boost::tie(principle_curvature_map, created) = g1.add_property_map>("v:principle_curvature_map", { 0, 0, + >>("v:principal_curvature_map", { 0, 0, Epic_Kernel::Vector_3 (0,0,0), Epic_Kernel::Vector_3 (0,0,0)}); assert(created); @@ -62,7 +62,7 @@ int main(int argc, char* argv[]) // uncomment this to compute a curvature while specifying named parameters // Example: an expansion ball radius of 0.5 and a vertex normals map (does not have to depend on positions) - + /*Surface_Mesh::Property_map vnm; boost::tie(vnm, created) = g1.add_property_map( "v:vnm", Epic_Kernel::Vector_3(0, 0, 0) @@ -82,12 +82,12 @@ int main(int argc, char* argv[]) ); PMP::interpolated_corrected_principal_curvatures( g1, - principle_curvature_map + principal_curvature_map ); for (vertex_descriptor v : vertices(g1)) { - auto PC = principle_curvature_map[v]; + auto PC = principal_curvature_map[v]; std::cout << v.idx() << ": HC = " << mean_curvature_map[v] << ", GC = " << gaussian_curvature_map[v] << "\n" << ", PC = [ " << std::get<0>(PC) << " , " << std::get<1>(PC) << " ]\n"; diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp index 3e56905068f3..43aff72dec2b 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp @@ -35,7 +35,7 @@ int main(int argc, char* argv[]) Epic_Kernel::FT, Epic_Kernel::Vector_3, Epic_Kernel::Vector_3 - >> principle_curvature_map; + >> principal_curvature_map; PMP::interpolated_corrected_mean_curvature( g1, @@ -44,7 +44,7 @@ int main(int argc, char* argv[]) // uncomment this to compute a curvature while specifying named parameters // Example: an expansion ball radius of 0.5 and a vertex normals map (does not have to depend on positions) - + /*std::unordered_map vnm; PMP::interpolated_corrected_mean_curvature( @@ -59,13 +59,13 @@ int main(int argc, char* argv[]) ); PMP::interpolated_corrected_principal_curvatures( g1, - boost::make_assoc_property_map(principle_curvature_map) + boost::make_assoc_property_map(principal_curvature_map) ); int i = 0; for (vertex_descriptor v : vertices(g1)) { - auto PC = principle_curvature_map[v]; + auto PC = principal_curvature_map[v]; std::cout << i << ": HC = " << mean_curvature_map[v] << ", GC = " << gaussian_curvature_map[v] << "\n" << ", PC = [ " << std::get<0>(PC) << " , " << std::get<1>(PC) << " ]\n"; diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp index 0b729978c7e7..59e6438b6763 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp @@ -72,23 +72,23 @@ void compute(SMesh* sMesh, typename boost::property_map::type vpmap = get(CGAL::vertex_point, *sMesh); bool created = false; - SMesh::Property_map principle_curvature_map; + SMesh::Property_map principal_curvature_map; - boost::tie(principle_curvature_map, created) = sMesh->add_property_map - ("v:principle_curvature_map", { 0, 0, + boost::tie(principal_curvature_map, created) = sMesh->add_property_map + ("v:principal_curvature_map", { 0, 0, Vector(0,0,0), Vector(0,0,0)}); assert(created); PMP::interpolated_corrected_principal_curvatures( *sMesh, - principle_curvature_map + principal_curvature_map ); typename EpicKernel::FT max_curvature_magnitude_on_mesh = 0; for (vertex_descriptor v : vertices(*sMesh)) { - const PrincipalCurvatureTuple pc = principle_curvature_map[v]; + const PrincipalCurvatureTuple pc = principal_curvature_map[v]; max_curvature_magnitude_on_mesh = max(max_curvature_magnitude_on_mesh, max(abs(get<0>(pc)), get<1>(pc))); } @@ -114,7 +114,7 @@ void compute(SMesh* sMesh, avg_edge_length /= n; } - const PrincipalCurvatureTuple pc = principle_curvature_map[v]; + const PrincipalCurvatureTuple pc = principal_curvature_map[v]; Vector umin = (std::get<0>(pc)/ max_curvature_magnitude_on_mesh) * std::get<2>(pc) * avg_edge_length; Vector umax = (std::get<1>(pc)/ max_curvature_magnitude_on_mesh) * std::get<3>(pc) * avg_edge_length; From 48fc5aeebd9cb076daf20d42c769bb0fa73f797a Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sun, 6 Nov 2022 18:19:39 +0200 Subject: [PATCH 063/142] dynamic property maps --- ...nterpolated_corrected_curvature_measures.h | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) 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 8f5e1d338edb..d2765c8aa527 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 @@ -702,10 +702,12 @@ template::type GT; typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef std::unordered_map FaceMeasureMap_tag; + typedef typename boost::property_map>::const_type FaceMeasureMap; typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; - typedef std::unordered_map VertexMeasureMap_tag; + typedef typename boost::property_map>::const_type VertexMeasureMap; typename GT::FT r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0); @@ -713,13 +715,11 @@ template(pmesh) * EXPANDING_RADIUS_EPSILON; - FaceMeasureMap_tag mu0_init, mu1_init; - boost::associative_property_map - mu0_map(mu0_init), mu1_map(mu1_init); + FaceMeasureMap mu0_map = get(CGAL::dynamic_face_property_t(), pmesh); + FaceMeasureMap mu1_map = get(CGAL::dynamic_face_property_t(), pmesh); - VertexMeasureMap_tag mu0_expand_init, mu1_expand_init; - boost::associative_property_map - mu0_expand_map(mu0_expand_init), mu1_expand_map(mu1_expand_init); + VertexMeasureMap mu0_expand_map = get(CGAL::dynamic_vertex_property_t(), pmesh); + VertexMeasureMap mu1_expand_map = get(CGAL::dynamic_vertex_property_t(), pmesh); internal::interpolated_corrected_measure_mesh(pmesh, mu0_map, internal::MU0_AREA_MEASURE, np); internal::interpolated_corrected_measure_mesh(pmesh, mu1_map, internal::MU1_MEAN_CURVATURE_MEASURE, np); @@ -766,10 +766,12 @@ template::type GT; typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef std::unordered_map FaceMeasureMap_tag; + typedef typename boost::property_map>::const_type FaceMeasureMap; typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; - typedef std::unordered_map VertexMeasureMap_tag; + typedef typename boost::property_map>::const_type VertexMeasureMap; typename GT::FT r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0); @@ -777,13 +779,11 @@ template(pmesh) * EXPANDING_RADIUS_EPSILON; - FaceMeasureMap_tag mu0_init, mu2_init; - boost::associative_property_map - mu0_map(mu0_init), mu2_map(mu2_init); + FaceMeasureMap mu0_map = get(CGAL::dynamic_face_property_t(), pmesh); + FaceMeasureMap mu2_map = get(CGAL::dynamic_face_property_t(), pmesh); - VertexMeasureMap_tag mu0_expand_init, mu2_expand_init; - boost::associative_property_map - mu0_expand_map(mu0_expand_init), mu2_expand_map(mu2_expand_init); + VertexMeasureMap mu0_expand_map = get(CGAL::dynamic_vertex_property_t(), pmesh); + VertexMeasureMap mu2_expand_map = get(CGAL::dynamic_vertex_property_t(), pmesh); internal::interpolated_corrected_measure_mesh(pmesh, mu0_map, internal::MU0_AREA_MEASURE, np); internal::interpolated_corrected_measure_mesh(pmesh, mu2_map, internal::MU2_GAUSSIAN_CURVATURE_MEASURE, np); From 38c66a61e338950689bf6efcbe6aea42f6b74e8a Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sun, 6 Nov 2022 18:23:51 +0200 Subject: [PATCH 064/142] typo fixes --- .../interpolated_corrected_curvatures_example.cpp | 2 +- .../Curvatures/interpolated_corrected_curvature_measures.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp index 78307b952e4f..3916b1ea3e1a 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp @@ -37,7 +37,7 @@ int main(int argc, char* argv[]) boost::tie(gaussian_curvature_map, created) = g1.add_property_map("v:gaussian_curvature_map", 0); assert(created); - // we use a tuble of 2 scalar values and 2 vectors for principal curvatures and directions + // we use a tuple of 2 scalar values and 2 vectors for principal curvatures and directions Surface_Mesh::Property_map Date: Sun, 6 Nov 2022 19:06:19 +0200 Subject: [PATCH 065/142] tab to space --- ...est_interopolated_corrected_curvatures.cpp | 238 +++++++++--------- 1 file changed, 119 insertions(+), 119 deletions(-) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interopolated_corrected_curvatures.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interopolated_corrected_curvatures.cpp index e7b473141562..7e376c887716 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interopolated_corrected_curvatures.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interopolated_corrected_curvatures.cpp @@ -19,130 +19,130 @@ typedef boost::graph_traits::edge_descriptor edge_descriptor; typedef boost::graph_traits::vertex_descriptor vertex_descriptor; void test(std::string mesh_path, EpicKernel::FT rel_expansion_radius, EpicKernel::FT rel_noise_magnitude) { - SMesh pmesh; - const std::string filename = CGAL::data_file_path(mesh_path); - - if (!CGAL::IO::read_polygon_mesh(filename, pmesh)) - { - std::cerr << "Invalid input file." << std::endl; - } - - bool created = false; - - SMesh::Property_map mean_curvature_map, gaussian_curvature_map; - boost::tie(mean_curvature_map, created) = pmesh.add_property_map("v:mean_curvature_map", 0); - assert(created); - - boost::tie(gaussian_curvature_map, created) = pmesh.add_property_map("v:gaussian_curvature_map", 0); - assert(created); - - // getting the max and min edge lengthes - const auto edge_range = CGAL::edges(pmesh); - - const auto edge_length_comparator = [&, pmesh](auto l, auto r) { - return PMP::edge_length(l, pmesh) < PMP::edge_length(r, pmesh); - }; - - const edge_descriptor longest_edge = *std::max_element(edge_range.begin(), edge_range.end(), edge_length_comparator); - const EpicKernel::FT max_edge_length = PMP::edge_length(longest_edge, pmesh); - - const edge_descriptor shortest_edge = *std::min_element(edge_range.begin(), edge_range.end(), edge_length_comparator); - const EpicKernel::FT min_edge_length = PMP::edge_length(shortest_edge, pmesh); - - - if (rel_noise_magnitude > 0) - { - if (!CGAL::is_triangle_mesh(pmesh)) - return; - - SMesh::Property_map vnm; - boost::tie(vnm, created) = pmesh.add_property_map("v:vnm", { 0 , 0 , 0 }); - assert(created); - - CGAL::Polygon_mesh_processing::compute_vertex_normals(pmesh, vnm); - - PMP::random_perturbation(pmesh, rel_noise_magnitude * min_edge_length, CGAL::parameters::random_seed(0)); - PMP::interpolated_corrected_mean_curvature( - pmesh, - mean_curvature_map, - CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length).vertex_normal_map(vnm) - ); - PMP::interpolated_corrected_gaussian_curvature( - pmesh, - gaussian_curvature_map, - CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length).vertex_normal_map(vnm) - ); - } - else { - PMP::interpolated_corrected_mean_curvature( - pmesh, - mean_curvature_map, - CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length) - ); - PMP::interpolated_corrected_gaussian_curvature( - pmesh, - gaussian_curvature_map, - CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length) - ); - - } - - - - //PMP::interpolated_corrected_mean_curvature( - // pmesh, - // mean_curvature_map, - // CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length) - //); - //PMP::interpolated_corrected_gaussian_curvature( - // pmesh, - // gaussian_curvature_map, - // CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length) - //); - - - const EpicKernel::FT max_mean_curvature = *std::max_element(mean_curvature_map.begin(), mean_curvature_map.end()); - const EpicKernel::FT min_mean_curvature = *std::min_element(mean_curvature_map.begin(), mean_curvature_map.end()); - const EpicKernel::FT max_gaussian_curvature = *std::max_element(gaussian_curvature_map.begin(), gaussian_curvature_map.end()); - const EpicKernel::FT min_gaussian_curvature = *std::min_element(gaussian_curvature_map.begin(), gaussian_curvature_map.end()); - - std::cout << "# " << mesh_path << ":\n" - << "expansion radius ratio to max length / expansion radius = " << rel_expansion_radius << " / " << rel_expansion_radius * max_edge_length << ",\n" - << "max perturbation ratio to minlength / max perturbation = " << rel_noise_magnitude << " / " << rel_noise_magnitude * min_edge_length << "\n" - << "mean curvature: min = " << min_mean_curvature << " <-> " << max_mean_curvature << " = max" << "\n" - << "gaussian curvature: min = " << min_gaussian_curvature << " <-> " << max_gaussian_curvature << " = max" << "\n\n\n"; + SMesh pmesh; + const std::string filename = CGAL::data_file_path(mesh_path); + + if (!CGAL::IO::read_polygon_mesh(filename, pmesh)) + { + std::cerr << "Invalid input file." << std::endl; + } + + bool created = false; + + SMesh::Property_map mean_curvature_map, gaussian_curvature_map; + boost::tie(mean_curvature_map, created) = pmesh.add_property_map("v:mean_curvature_map", 0); + assert(created); + + boost::tie(gaussian_curvature_map, created) = pmesh.add_property_map("v:gaussian_curvature_map", 0); + assert(created); + + // getting the max and min edge lengthes + const auto edge_range = CGAL::edges(pmesh); + + const auto edge_length_comparator = [&, pmesh](auto l, auto r) { + return PMP::edge_length(l, pmesh) < PMP::edge_length(r, pmesh); + }; + + const edge_descriptor longest_edge = *std::max_element(edge_range.begin(), edge_range.end(), edge_length_comparator); + const EpicKernel::FT max_edge_length = PMP::edge_length(longest_edge, pmesh); + + const edge_descriptor shortest_edge = *std::min_element(edge_range.begin(), edge_range.end(), edge_length_comparator); + const EpicKernel::FT min_edge_length = PMP::edge_length(shortest_edge, pmesh); + + + if (rel_noise_magnitude > 0) + { + if (!CGAL::is_triangle_mesh(pmesh)) + return; + + SMesh::Property_map vnm; + boost::tie(vnm, created) = pmesh.add_property_map("v:vnm", { 0 , 0 , 0 }); + assert(created); + + CGAL::Polygon_mesh_processing::compute_vertex_normals(pmesh, vnm); + + PMP::random_perturbation(pmesh, rel_noise_magnitude * min_edge_length, CGAL::parameters::random_seed(0)); + PMP::interpolated_corrected_mean_curvature( + pmesh, + mean_curvature_map, + CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length).vertex_normal_map(vnm) + ); + PMP::interpolated_corrected_gaussian_curvature( + pmesh, + gaussian_curvature_map, + CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length).vertex_normal_map(vnm) + ); + } + else { + PMP::interpolated_corrected_mean_curvature( + pmesh, + mean_curvature_map, + CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length) + ); + PMP::interpolated_corrected_gaussian_curvature( + pmesh, + gaussian_curvature_map, + CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length) + ); + + } + + + + //PMP::interpolated_corrected_mean_curvature( + // pmesh, + // mean_curvature_map, + // CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length) + //); + //PMP::interpolated_corrected_gaussian_curvature( + // pmesh, + // gaussian_curvature_map, + // CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length) + //); + + + const EpicKernel::FT max_mean_curvature = *std::max_element(mean_curvature_map.begin(), mean_curvature_map.end()); + const EpicKernel::FT min_mean_curvature = *std::min_element(mean_curvature_map.begin(), mean_curvature_map.end()); + const EpicKernel::FT max_gaussian_curvature = *std::max_element(gaussian_curvature_map.begin(), gaussian_curvature_map.end()); + const EpicKernel::FT min_gaussian_curvature = *std::min_element(gaussian_curvature_map.begin(), gaussian_curvature_map.end()); + + std::cout << "# " << mesh_path << ":\n" + << "expansion radius ratio to max length / expansion radius = " << rel_expansion_radius << " / " << rel_expansion_radius * max_edge_length << ",\n" + << "max perturbation ratio to minlength / max perturbation = " << rel_noise_magnitude << " / " << rel_noise_magnitude * min_edge_length << "\n" + << "mean curvature: min = " << min_mean_curvature << " <-> " << max_mean_curvature << " = max" << "\n" + << "gaussian curvature: min = " << min_gaussian_curvature << " <-> " << max_gaussian_curvature << " = max" << "\n\n\n"; } int main() { - const std::vector mesh_pathes_to_test = { - "meshes/icc_test/Sphere Quads + Tris.obj", - "meshes/icc_test/Sphere Quads + Tris 100352.obj", - "meshes/icc_test/Sphere Tris Ico.obj", - "meshes/icc_test/Sphere Tris Tet.obj", - "meshes/icc_test/Sphere Tris Oct.obj", - "meshes/icc_test/Sphere Quads.obj", - "meshes/icc_test/Sphere Quads Remesh.obj", - "meshes/icc_test/Sphere Ngons + Quads + Tris.obj", - "meshes/icc_test/Cube with fillet Quads.obj", - "meshes/cylinder.off", - "meshes/icc_test/Lantern Tris.obj", - "meshes/icc_test/Lantern Quads.obj" - }; - - const std::vector rel_expansion_radii = { 0, 0.1, 0.5, 1 }; - const std::vector rel_noise_magnitudes = { 0, 0.5, 0.9 }; - - for (auto mesh_path : mesh_pathes_to_test) { - for (EpicKernel::FT rel_expansion_radius : rel_expansion_radii) - for (EpicKernel::FT rel_noise_magnitude : rel_noise_magnitudes) - { - test(mesh_path, rel_expansion_radius, rel_noise_magnitude); - } - - std::cout << "_________________________________________________________________________________\n\n"; - } + const std::vector mesh_pathes_to_test = { + "meshes/icc_test/Sphere Quads + Tris.obj", + "meshes/icc_test/Sphere Quads + Tris 100352.obj", + "meshes/icc_test/Sphere Tris Ico.obj", + "meshes/icc_test/Sphere Tris Tet.obj", + "meshes/icc_test/Sphere Tris Oct.obj", + "meshes/icc_test/Sphere Quads.obj", + "meshes/icc_test/Sphere Quads Remesh.obj", + "meshes/icc_test/Sphere Ngons + Quads + Tris.obj", + "meshes/icc_test/Cube with fillet Quads.obj", + "meshes/cylinder.off", + "meshes/icc_test/Lantern Tris.obj", + "meshes/icc_test/Lantern Quads.obj" + }; + + const std::vector rel_expansion_radii = { 0, 0.1, 0.5, 1 }; + const std::vector rel_noise_magnitudes = { 0, 0.5, 0.9 }; + + for (auto mesh_path : mesh_pathes_to_test) { + for (EpicKernel::FT rel_expansion_radius : rel_expansion_radii) + for (EpicKernel::FT rel_noise_magnitude : rel_noise_magnitudes) + { + test(mesh_path, rel_expansion_radius, rel_noise_magnitude); + } + + std::cout << "_________________________________________________________________________________\n\n"; + } } From 4295fd4e07645213ab3ac097cfa60821a2900d7b Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sun, 6 Nov 2022 19:49:37 +0200 Subject: [PATCH 066/142] enum minor fix --- .../Display/Display_property_plugin.cpp | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index cda67cbd9700..c69b73694980 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -338,7 +338,10 @@ class DisplayPropertyPlugin : typedef CGAL::Heat_method_3::Surface_mesh_geodesic_distances_3 Heat_method_idt; typedef CGAL::dynamic_vertex_property_t Vertex_source_tag; typedef boost::property_map::type Vertex_source_map; - + enum CurvatureType { + MEAN_CURVATURE, + GAUSSIAN_CURVATURE, +}; public: bool applicable(QAction* action) const Q_DECL_OVERRIDE @@ -613,11 +616,11 @@ private Q_SLOTS: sm_item->setRenderingMode(Gouraud); break; case 4: // Interpolated Corrected Mean Curvature - displayInterpolatedCurvatureMeasure(sm_item, PMP::MU1_MEAN_CURVATURE_MEASURE); + displayInterpolatedCurvatureMeasure(sm_item, MEAN_CURVATURE); sm_item->setRenderingMode(Gouraud); break; case 5: // Interpolated Corrected Gaussian Curvature - displayInterpolatedCurvatureMeasure(sm_item, PMP::MU2_GAUSSIAN_CURVATURE_MEASURE); + displayInterpolatedCurvatureMeasure(sm_item, GAUSSIAN_CURVATURE); sm_item->setRenderingMode(Gouraud); break; default: @@ -843,9 +846,11 @@ private Q_SLOTS: } - void displayInterpolatedCurvatureMeasure(Scene_surface_mesh_item* item, PMP::Curvature_measure_index mu_index) + void displayInterpolatedCurvatureMeasure(Scene_surface_mesh_item* item, CurvatureType mu_index) { - std::string tied_string = (mu_index == PMP::MU1_MEAN_CURVATURE_MEASURE)? + if (mu_index != MEAN_CURVATURE && mu_index != GAUSSIAN_CURVATURE) return; + + std::string tied_string = (mu_index == MEAN_CURVATURE)? "v:interpolated_corrected_mean_curvature": "v:interpolated_corrected_gaussian_curvature"; SMesh& smesh = *item->face_graph(); @@ -860,13 +865,13 @@ private Q_SLOTS: if (non_init) { if (vnm_exists) { - if (mu_index == PMP::MU1_MEAN_CURVATURE_MEASURE) + if (mu_index == MEAN_CURVATURE) PMP::interpolated_corrected_mean_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expand_radius).vertex_normal_map(vnm)); else PMP::interpolated_corrected_gaussian_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expand_radius).vertex_normal_map(vnm)); } else { - if (mu_index == PMP::MU1_MEAN_CURVATURE_MEASURE) + if (mu_index == MEAN_CURVATURE) PMP::interpolated_corrected_mean_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expand_radius)); else PMP::interpolated_corrected_gaussian_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expand_radius)); @@ -887,16 +892,13 @@ private Q_SLOTS: min_index = v; } } - switch (mu_index) - { - case PMP::MU1_MEAN_CURVATURE_MEASURE: + if (mu_index == MEAN_CURVATURE){ mean_curvature_max[item] = std::make_pair(res_max, max_index); mean_curvature_min[item] = std::make_pair(res_min, min_index); - break; - case PMP::MU2_GAUSSIAN_CURVATURE_MEASURE: + } + else { gaussian_curvature_max[item] = std::make_pair(res_max, max_index); gaussian_curvature_min[item] = std::make_pair(res_min, min_index); - break; } connect(item, &Scene_surface_mesh_item::itemChanged, From aeaf881c49c8969ec6b1024fb93e4de8e3306ff6 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sun, 6 Nov 2022 20:35:05 +0200 Subject: [PATCH 067/142] minor fix max func --- .../PMP/Interpolated_corrected_principal_curvatures_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp index 59e6438b6763..21b292b05d0c 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp @@ -89,7 +89,7 @@ void compute(SMesh* sMesh, for (vertex_descriptor v : vertices(*sMesh)) { const PrincipalCurvatureTuple pc = principal_curvature_map[v]; - max_curvature_magnitude_on_mesh = max(max_curvature_magnitude_on_mesh, max(abs(get<0>(pc)), get<1>(pc))); + max_curvature_magnitude_on_mesh = std::max(max_curvature_magnitude_on_mesh, std::max(abs(get<0>(pc)), get<1>(pc))); } for(vertex_descriptor v : vertices(*sMesh)) From 8efd947d53a12aa751eaec67f2ae4a37a1b862a3 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 7 Nov 2022 10:58:45 +0200 Subject: [PATCH 068/142] doc fixes --- ...nterpolated_corrected_curvature_measures.h | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) 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 6426cae12de7..6e659e4e6ec8 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 @@ -686,6 +686,41 @@ template::%vertex_descriptor` +* as key type and `%Point_3` as value type} +* \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`} +* \cgalParamExtra{If this parameter is omitted, an internal property map for +* `CGAL::vertex_point_t` must be available in `PolygonMesh`.} +* \cgalParamNEnd +* +* \cgalParamNBegin{vertex_normal_map} +* \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} +* \cgalParamType{a class model of `ReadablePropertyMap` with +* `boost::graph_traits::%vertex_descriptor` +* as key type and `%Vector_3` as value type} +* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} +* \cgalParamExtra{If this parameter is omitted, vertex normals will be +* computed using compute_vertex_normals()} +* \cgalParamNEnd +* +* \cgalParamNBegin{ball_radius} +* \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures +* by summing measures of faces inside a ball of this radius centered at the +* vertex expanded from. The summed face measures are weighted by their +* inclusion ratio inside this ball} +* \cgalParamType{`GT::FT`} +* \cgalParamDefault{`-1`} +* \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of +* measures on faces around the vertex} +* \cgalParamNEnd +* +* \cgalNamedParamsEnd +* * @see `interpolated_corrected_gaussian_curvature()` * @see `interpolated_corrected_principal_curvatures()` */ @@ -751,6 +786,41 @@ template::%vertex_descriptor` +* as key type and `%Point_3` as value type} +* \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`} +* \cgalParamExtra{If this parameter is omitted, an internal property map for +* `CGAL::vertex_point_t` must be available in `PolygonMesh`.} +* \cgalParamNEnd +* +* \cgalParamNBegin{vertex_normal_map} +* \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} +* \cgalParamType{a class model of `ReadablePropertyMap` with +* `boost::graph_traits::%vertex_descriptor` +* as key type and `%Vector_3` as value type} +* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} +* \cgalParamExtra{If this parameter is omitted, vertex normals will be +* computed using compute_vertex_normals()} +* \cgalParamNEnd +* +* \cgalParamNBegin{ball_radius} +* \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures +* by summing measures of faces inside a ball of this radius centered at the +* vertex expanded from. The summed face measures are weighted by their +* inclusion ratio inside this ball} +* \cgalParamType{`GT::FT`} +* \cgalParamDefault{`-1`} +* \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of +* measures on faces around the vertex} +* \cgalParamNEnd +* +* \cgalNamedParamsEnd +* * @see `interpolated_corrected_mean_curvature()` * @see `interpolated_corrected_principal_curvatures()` */ @@ -837,6 +907,17 @@ template Date: Mon, 7 Nov 2022 11:00:29 +0200 Subject: [PATCH 069/142] trailing white spaces --- ...nterpolated_corrected_curvature_measures.h | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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 6e659e4e6ec8..7658f1f4dbb1 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 @@ -720,7 +720,7 @@ template Date: Tue, 8 Nov 2022 19:19:40 +0200 Subject: [PATCH 070/142] dynamic property maps --- ...nterpolated_corrected_curvature_measures.h | 44 +++++++------------ 1 file changed, 16 insertions(+), 28 deletions(-) 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 7658f1f4dbb1..8a9949b073c8 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 @@ -26,7 +26,6 @@ #include #include -#include #include #define EXPANDING_RADIUS_EPSILON 1e-6 @@ -932,6 +931,18 @@ template::type GT; + typedef typename boost::graph_traits::face_descriptor face_descriptor; + typedef typename boost::property_map>::const_type FaceScalarMeasureMap; + typedef typename boost::property_map>>::const_type FaceArrayMeasureMap; + + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef typename boost::property_map>::const_type VertexScalarMeasureMap; + typedef typename boost::property_map>>::const_type VertexMatrixMeasureMap; + typedef dynamic_vertex_property_t Vector_map_tag; typedef typename boost::property_map::const_type Default_vector_map; typedef typename internal_np::Lookup_named_param_def::value) compute_vertex_normals(pmesh, vnm, np); + FaceScalarMeasureMap mu0_map = get(CGAL::dynamic_face_property_t(), pmesh); + FaceArrayMeasureMap muXY_map = get(CGAL::dynamic_face_property_t>(), pmesh); - - typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef std::unordered_map FaceScalarMeasureMap_tag; - // using std:: array to store FT values on the 9 combinations of the standard 3D basis - typedef std::unordered_map> FaceArrayMeasureMap_tag; - - typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; - typedef std::unordered_map VertexScalarMeasureMap_tag; - // using Eigen matrix to store & Process FT values on the 9 combinations of the standard 3D basis - typedef std::unordered_map> VertexMatrixMeasureMap_tag; - - - FaceScalarMeasureMap_tag mu0_init; - boost::associative_property_map - mu0_map(mu0_init); - - FaceArrayMeasureMap_tag muXY_init; - boost::associative_property_map - muXY_map(muXY_init); - - VertexScalarMeasureMap_tag mu0_expand_init; - boost::associative_property_map - mu0_expand_map(mu0_expand_init); - - VertexMatrixMeasureMap_tag muXY_expand_init; - boost::associative_property_map - muXY_expand_map(muXY_expand_init); + VertexScalarMeasureMap mu0_expand_map = get(CGAL::dynamic_vertex_property_t(), pmesh); + VertexMatrixMeasureMap muXY_expand_map = get(CGAL::dynamic_vertex_property_t>(), pmesh); internal::interpolated_corrected_measure_mesh(pmesh, mu0_map, internal::MU0_AREA_MEASURE, np); internal::interpolated_corrected_anisotropic_measure_mesh(pmesh, muXY_map, np); From 866287a98ee0aa02e213873d8c50a1240e109f20 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Tue, 8 Nov 2022 20:13:04 +0200 Subject: [PATCH 071/142] minor naming conventions fixes --- ...nterpolated_corrected_curvature_measures.h | 140 +++++++++--------- .../internal/parameters_interface.h | 3 + 2 files changed, 73 insertions(+), 70 deletions(-) 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 8a9949b073c8..32c8fcdfcd47 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 @@ -351,21 +351,21 @@ template::const_type Default_vector_map; typedef typename internal_np::Lookup_named_param_def::type VNM; + Default_vector_map>::type Vertex_normal_map; using parameters::choose_parameter; using parameters::get_parameter; using parameters::is_default_parameter; - typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; - typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; + typedef typename boost::graph_traits::face_descriptor Face_descriptor; + typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; + typedef typename boost::graph_traits::halfedge_descriptor Halfedge_descriptor; typename GetVertexPointMap::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), + Vertex_normal_map vnm = choose_parameter(get_parameter(np, internal_np::vertex_normal_map), get(Vector_map_tag(), pmesh)); if (is_default_parameter::value) @@ -390,10 +390,10 @@ template x; std::vector u; - for (face_descriptor f : faces(pmesh)) + for (Face_descriptor f : faces(pmesh)) { - for (vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) + for (Vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) { typename GT::Point_3 p = get(vpm, v); x.push_back(typename GT::Vector_3(p.x(), p.y(), p.z())); @@ -420,21 +420,21 @@ template::const_type Default_vector_map; typedef typename internal_np::Lookup_named_param_def::type VNM; + Default_vector_map>::type VertexNormalMap; using parameters::choose_parameter; using parameters::get_parameter; using parameters::is_default_parameter; - typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; - typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; + typedef typename boost::graph_traits::face_descriptor Face_descriptor; + typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; + typedef typename boost::graph_traits::halfedge_descriptor Halfedge_descriptor; typename GetVertexPointMap::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), + VertexNormalMap vnm = choose_parameter(get_parameter(np, internal_np::vertex_normal_map), get(Vector_map_tag(), pmesh)); if (is_default_parameter::value) @@ -443,10 +443,10 @@ template x; std::vector u; - for (face_descriptor f : faces(pmesh)) + for (Face_descriptor f : faces(pmesh)) { - for (vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) + for (Vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) { typename GT::Point_3 p = get(vpm, v); x.push_back(typename GT::Vector_3(p.x(), p.y(), p.z())); @@ -528,8 +528,8 @@ template::type GT; - typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef typename boost::graph_traits::face_descriptor Face_descriptor; + typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; const typename GT::FT r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0); @@ -539,8 +539,8 @@ template bfs_queue; - std::unordered_set bfs_visited; + std::queue bfs_queue; + std::unordered_set bfs_visited; typename GT::Point_3 vp = get(vpm, v); typename GT::Vector_3 c = typename GT::Vector_3(vp.x(), vp.y(), vp.z()); @@ -548,7 +548,7 @@ template::null_face()) { bfs_queue.push(f); @@ -556,12 +556,12 @@ template x; - for (vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh)) + for (Vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh)) { typename GT::Point_3 pi = get(vpm, vi); x.push_back(typename GT::Vector_3(pi.x(), pi.y(), pi.z())); @@ -573,7 +573,7 @@ template::null_face()) { @@ -603,8 +603,8 @@ template::type GT; - typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef typename boost::graph_traits::face_descriptor Face_descriptor; + typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; const typename GT::FT r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0); @@ -614,8 +614,8 @@ template bfs_queue; - std::unordered_set bfs_visited; + std::queue bfs_queue; + std::unordered_set bfs_visited; typename GT::Point_3 vp = get(vpm, v); typename GT::Vector_3 c = typename GT::Vector_3(vp.x(), vp.y(), vp.z()); @@ -623,7 +623,7 @@ template corrected_muXY = Eigen::Matrix::Zero(); - for (face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { + for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { if (f != boost::graph_traits::null_face()) { bfs_queue.push(f); @@ -631,12 +631,12 @@ template x; - for (vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh)) + for (Vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh)) { typename GT::Point_3 pi = get(vpm, vi); x.push_back(typename GT::Vector_3(pi.x(), pi.y(), pi.z())); @@ -654,7 +654,7 @@ template::null_face()) { @@ -678,7 +678,7 @@ template::%vertex_descriptor` as key type and `GT::FT` as value type. +* `boost::graph_traits::%Vertex_descriptor` as key type and `GT::FT` as value type. * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". * * @param pmesh the polygon mesh. @@ -690,7 +690,7 @@ template::%vertex_descriptor` +* `boost::graph_traits::%Vertex_descriptor` * as key type and `%Point_3` as value type} * \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`} * \cgalParamExtra{If this parameter is omitted, an internal property map for @@ -700,7 +700,7 @@ template::%vertex_descriptor` +* `boost::graph_traits::%Vertex_descriptor` * as key type and `%Vector_3` as value type} * \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} * \cgalParamExtra{If this parameter is omitted, vertex normals will be @@ -735,13 +735,13 @@ template::type GT; - typedef typename boost::graph_traits::face_descriptor face_descriptor; + typedef typename boost::graph_traits::face_descriptor Face_descriptor; typedef typename boost::property_map>::const_type FaceMeasureMap; + CGAL::dynamic_face_property_t>::const_type Face_measure_map; - typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; typedef typename boost::property_map>::const_type VertexMeasureMap; + CGAL::dynamic_vertex_property_t>::const_type Vertex_measure_map; typename GT::FT r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0); @@ -749,16 +749,16 @@ template(pmesh) * EXPANDING_RADIUS_EPSILON; - FaceMeasureMap mu0_map = get(CGAL::dynamic_face_property_t(), pmesh); - FaceMeasureMap mu1_map = get(CGAL::dynamic_face_property_t(), pmesh); + Face_measure_map mu0_map = get(CGAL::dynamic_face_property_t(), pmesh); + Face_measure_map mu1_map = get(CGAL::dynamic_face_property_t(), pmesh); - VertexMeasureMap mu0_expand_map = get(CGAL::dynamic_vertex_property_t(), pmesh); - VertexMeasureMap mu1_expand_map = get(CGAL::dynamic_vertex_property_t(), pmesh); + Vertex_measure_map mu0_expand_map = get(CGAL::dynamic_vertex_property_t(), pmesh); + Vertex_measure_map mu1_expand_map = get(CGAL::dynamic_vertex_property_t(), pmesh); internal::interpolated_corrected_measure_mesh(pmesh, mu0_map, internal::MU0_AREA_MEASURE, np); internal::interpolated_corrected_measure_mesh(pmesh, mu1_map, internal::MU1_MEAN_CURVATURE_MEASURE, np); - for (vertex_descriptor v : vertices(pmesh)) + for (Vertex_descriptor v : vertices(pmesh)) { internal::expand_interpolated_corrected_measure_vertex(pmesh, mu0_map, mu1_map, mu0_expand_map, mu1_expand_map, v, np.ball_radius(r)); @@ -778,7 +778,7 @@ template::%vertex_descriptor` as key type and `GT::FT` as value type. +* `boost::graph_traits::%Vertex_descriptor` as key type and `GT::FT` as value type. * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". * * @param pmesh the polygon mesh. @@ -790,7 +790,7 @@ template::%vertex_descriptor` +* `boost::graph_traits::%Vertex_descriptor` * as key type and `%Point_3` as value type} * \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`} * \cgalParamExtra{If this parameter is omitted, an internal property map for @@ -800,7 +800,7 @@ template::%vertex_descriptor` +* `boost::graph_traits::%Vertex_descriptor` * as key type and `%Vector_3` as value type} * \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} * \cgalParamExtra{If this parameter is omitted, vertex normals will be @@ -834,13 +834,13 @@ template::type GT; - typedef typename boost::graph_traits::face_descriptor face_descriptor; + typedef typename boost::graph_traits::face_descriptor Face_descriptor; typedef typename boost::property_map>::const_type FaceMeasureMap; + CGAL::dynamic_face_property_t>::const_type Face_measure_map; - typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; typedef typename boost::property_map>::const_type VertexMeasureMap; + CGAL::dynamic_vertex_property_t>::const_type Vertex_measure_map; typename GT::FT r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0); @@ -848,16 +848,16 @@ template(pmesh) * EXPANDING_RADIUS_EPSILON; - FaceMeasureMap mu0_map = get(CGAL::dynamic_face_property_t(), pmesh); - FaceMeasureMap mu2_map = get(CGAL::dynamic_face_property_t(), pmesh); + Face_measure_map mu0_map = get(CGAL::dynamic_face_property_t(), pmesh); + Face_measure_map mu2_map = get(CGAL::dynamic_face_property_t(), pmesh); - VertexMeasureMap mu0_expand_map = get(CGAL::dynamic_vertex_property_t(), pmesh); - VertexMeasureMap mu2_expand_map = get(CGAL::dynamic_vertex_property_t(), pmesh); + Vertex_measure_map mu0_expand_map = get(CGAL::dynamic_vertex_property_t(), pmesh); + Vertex_measure_map mu2_expand_map = get(CGAL::dynamic_vertex_property_t(), pmesh); internal::interpolated_corrected_measure_mesh(pmesh, mu0_map, internal::MU0_AREA_MEASURE, np); internal::interpolated_corrected_measure_mesh(pmesh, mu2_map, internal::MU2_GAUSSIAN_CURVATURE_MEASURE, np); - for (vertex_descriptor v : vertices(pmesh)) + for (Vertex_descriptor v : vertices(pmesh)) { internal::expand_interpolated_corrected_measure_vertex(pmesh, mu0_map, mu2_map, mu0_expand_map, mu2_expand_map, v, np.ball_radius(r)); @@ -877,7 +877,7 @@ template::%vertex_descriptor` as key type and +* `boost::graph_traits::%Vertex_descriptor` as key type and * `std::tuple, Eigen::Vector>` as value type. * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". * @@ -890,7 +890,7 @@ template::%vertex_descriptor` +* `boost::graph_traits::%Vertex_descriptor` * as key type and `%Point_3` as value type} * \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`} * \cgalParamExtra{If this parameter is omitted, an internal property map for @@ -900,7 +900,7 @@ template::%vertex_descriptor` +* `boost::graph_traits::%Vertex_descriptor` * as key type and `%Vector_3` as value type} * \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} * \cgalParamExtra{If this parameter is omitted, vertex normals will be @@ -931,23 +931,23 @@ template::type GT; - typedef typename boost::graph_traits::face_descriptor face_descriptor; + typedef typename boost::graph_traits::face_descriptor Face_descriptor; typedef typename boost::property_map>::const_type FaceScalarMeasureMap; + CGAL::dynamic_face_property_t>::const_type Face_scalar_measure_map; typedef typename boost::property_map>>::const_type FaceArrayMeasureMap; + CGAL::dynamic_face_property_t>>::const_type Face_array_measure_map; - typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; typedef typename boost::property_map>::const_type VertexScalarMeasureMap; + CGAL::dynamic_vertex_property_t>::const_type Vertex_scalar_measure_map; typedef typename boost::property_map>>::const_type VertexMatrixMeasureMap; + CGAL::dynamic_vertex_property_t>>::const_type Vertex_matrix_measure_map; typedef dynamic_vertex_property_t Vector_map_tag; typedef typename boost::property_map::const_type Default_vector_map; typedef typename internal_np::Lookup_named_param_def::type VNM; + Default_vector_map>::type VertexNormalMap; using parameters::choose_parameter; using parameters::get_parameter; @@ -957,7 +957,7 @@ template::value) compute_vertex_normals(pmesh, vnm, np); - FaceScalarMeasureMap mu0_map = get(CGAL::dynamic_face_property_t(), pmesh); - FaceArrayMeasureMap muXY_map = get(CGAL::dynamic_face_property_t>(), pmesh); + Face_scalar_measure_map mu0_map = get(CGAL::dynamic_face_property_t(), pmesh); + Face_array_measure_map muXY_map = get(CGAL::dynamic_face_property_t>(), pmesh); - VertexScalarMeasureMap mu0_expand_map = get(CGAL::dynamic_vertex_property_t(), pmesh); - VertexMatrixMeasureMap muXY_expand_map = get(CGAL::dynamic_vertex_property_t>(), pmesh); + Vertex_scalar_measure_map mu0_expand_map = get(CGAL::dynamic_vertex_property_t(), pmesh); + Vertex_matrix_measure_map muXY_expand_map = get(CGAL::dynamic_vertex_property_t>(), pmesh); internal::interpolated_corrected_measure_mesh(pmesh, mu0_map, internal::MU0_AREA_MEASURE, np); internal::interpolated_corrected_anisotropic_measure_mesh(pmesh, muXY_map, np); - for (vertex_descriptor v : vertices(pmesh)) + for (Vertex_descriptor v : vertices(pmesh)) { internal::expand_interpolated_corrected_anisotropic_measure_vertex(pmesh, mu0_map, muXY_map, mu0_expand_map, muXY_expand_map, v, np.ball_radius(r)); diff --git a/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h index 9eea7e71e442..03ee822d0bc9 100644 --- a/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h +++ b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h @@ -87,6 +87,9 @@ CGAL_add_named_parameter(number_of_points_per_edge_t, number_of_points_per_edge, CGAL_add_named_parameter(number_of_points_on_edges_t, number_of_points_on_edges, number_of_points_on_edges) CGAL_add_named_parameter(nb_points_per_area_unit_t, nb_points_per_area_unit, number_of_points_per_area_unit) CGAL_add_named_parameter(nb_points_per_distance_unit_t, nb_points_per_distance_unit, number_of_points_per_distance_unit) +CGAL_add_named_parameter(vertex_mean_curvature_map_t, vertex_mean_curvature_map, vertex_mean_curvature_map) +CGAL_add_named_parameter(vertex_gaussian_curvature_map_t, vertex_gaussian_curvature_map, vertex_gaussian_curvature_map) +CGAL_add_named_parameter(vertex_principal_curvature_map_t, vertex_principal_curvature_map, vertex_principal_curvature_map) CGAL_add_named_parameter(ball_radius_t, ball_radius, ball_radius) CGAL_add_named_parameter(outward_orientation_t, outward_orientation, outward_orientation) CGAL_add_named_parameter(overlap_test_t, overlap_test, do_overlap_test_of_bounded_sides) From aff46b61624328468311bfe3e83172ade9bed7ec Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Wed, 9 Nov 2022 17:32:42 +0200 Subject: [PATCH 072/142] incomplete (integrating class for combined curvature computations) --- ...erpolated_corrected_curvatures_example.cpp | 19 +- ...nterpolated_corrected_curvature_measures.h | 1054 ++++++++++------- 2 files changed, 663 insertions(+), 410 deletions(-) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp index 3916b1ea3e1a..da6e9d2252f0 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp @@ -38,19 +38,10 @@ int main(int argc, char* argv[]) assert(created); // we use a tuple of 2 scalar values and 2 vectors for principal curvatures and directions - Surface_Mesh::Property_map> principal_curvature_map; - - boost::tie(principal_curvature_map, created) = g1.add_property_map>("v:principal_curvature_map", { 0, 0, + Surface_Mesh::Property_map> principal_curvature_map; + + boost::tie(principal_curvature_map, created) = g1.add_property_map> + ("v:principal_curvature_map", { 0, 0, Epic_Kernel::Vector_3 (0,0,0), Epic_Kernel::Vector_3 (0,0,0)}); assert(created); @@ -90,6 +81,6 @@ int main(int argc, char* argv[]) auto PC = principal_curvature_map[v]; std::cout << v.idx() << ": HC = " << mean_curvature_map[v] << ", GC = " << gaussian_curvature_map[v] << "\n" - << ", PC = [ " << std::get<0>(PC) << " , " << std::get<1>(PC) << " ]\n"; + << ", PC = [ " << PC.min_curvature << " , " << PC.max_curvature << " ]\n"; } } 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 32c8fcdfcd47..c4a9154c1aa2 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 @@ -26,6 +26,7 @@ #include #include +#include #include #define EXPANDING_RADIUS_EPSILON 1e-6 @@ -34,6 +35,32 @@ namespace CGAL { namespace Polygon_mesh_processing { +template +struct Principal_curvature { + typename GT::FT min_curvature; + typename GT::FT max_curvature; + typename GT::Vector_3 min_direction; + typename GT::Vector_3 max_direction; + + Principal_curvature() { + min_curvature = 0; + max_curvature = 0; + min_direction = typename GT::Vector_3(0, 0, 0); + max_direction = typename GT::Vector_3(0, 0, 0); + } + + Principal_curvature( + typename GT::FT min_curvature, + typename GT::FT max_curvature, + typename GT::Vector_3 min_direction, + typename GT::Vector_3 max_direction) { + this->min_curvature = min_curvature; + this->max_curvature = max_curvature; + this->min_direction = min_direction; + this->max_direction = max_direction; + } +}; + namespace internal { template @@ -57,6 +84,16 @@ enum Curvature_measure_index { MU2_GAUSSIAN_CURVATURE_MEASURE ///< corrected gaussian curvature density }; +template +struct Vertex_measures { + typename GT::FT area_measure = 0; + typename GT::FT mean_curvature_measure = 0; + typename GT::FT gaussian_curvature_measure = 0; + std::array anisotropic_measure = { 0, 0, 0, + 0, 0, 0, + 0, 0, 0 }; +}; + template typename GT::FT interpolated_corrected_area_measure_face(const std::vector& u, const std::vector& x = {}) @@ -336,130 +373,129 @@ std::array interpolated_corrected_anisotropic_measure_fa return muXY; } -template - void - interpolated_corrected_measure_mesh(const PolygonMesh& pmesh, - FaceMeasureMap fmm, - const Curvature_measure_index mu_i, - const NamedParameters& np = parameters::default_values()) -{ - - typedef typename GetGeomTraits::type GT; - - typedef dynamic_vertex_property_t Vector_map_tag; - typedef typename boost::property_map::const_type Default_vector_map; - typedef typename internal_np::Lookup_named_param_def::type Vertex_normal_map; - - using parameters::choose_parameter; - using parameters::get_parameter; - using parameters::is_default_parameter; - - typedef typename boost::graph_traits::face_descriptor Face_descriptor; - typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; - typedef typename boost::graph_traits::halfedge_descriptor Halfedge_descriptor; - - typename GetVertexPointMap::const_type - vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), - get_const_property_map(CGAL::vertex_point, pmesh)); - - Vertex_normal_map 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::function - &, const std::vector&)> - iccm_function; - switch (mu_i) - { - case MU0_AREA_MEASURE: - iccm_function = &interpolated_corrected_area_measure_face; - break; - case MU1_MEAN_CURVATURE_MEASURE: - iccm_function = &interpolated_corrected_mean_curvature_measure_face; - break; - case MU2_GAUSSIAN_CURVATURE_MEASURE: - iccm_function = &interpolated_corrected_gaussian_curvature_measure_face; - break; - } - - std::vector x; - std::vector u; - - for (Face_descriptor f : faces(pmesh)) - { - - for (Vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) - { - typename GT::Point_3 p = get(vpm, v); - x.push_back(typename GT::Vector_3(p.x(), p.y(), p.z())); - u.push_back(get(vnm, v)); - } - - put(fmm, f, iccm_function(u, x)); - x.clear(); - u.clear(); - } -} - -template - void - interpolated_corrected_anisotropic_measure_mesh(const PolygonMesh& pmesh, - FaceMeasureMap fmm, - const NamedParameters& np = parameters::default_values()) -{ - - typedef typename GetGeomTraits::type GT; - - typedef dynamic_vertex_property_t Vector_map_tag; - typedef typename boost::property_map::const_type Default_vector_map; - typedef typename internal_np::Lookup_named_param_def::type VertexNormalMap; - - using parameters::choose_parameter; - using parameters::get_parameter; - using parameters::is_default_parameter; - - typedef typename boost::graph_traits::face_descriptor Face_descriptor; - typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; - typedef typename boost::graph_traits::halfedge_descriptor Halfedge_descriptor; - - typename GetVertexPointMap::const_type - vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), - get_const_property_map(CGAL::vertex_point, pmesh)); - - VertexNormalMap 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 x; - std::vector u; - - for (Face_descriptor f : faces(pmesh)) - { - - for (Vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) - { - typename GT::Point_3 p = get(vpm, v); - x.push_back(typename GT::Vector_3(p.x(), p.y(), p.z())); - u.push_back(get(vnm, v)); - } - - put(fmm, f, interpolated_corrected_anisotropic_measure_face(u, x)); - x.clear(); - u.clear(); - - } -} - +//template +// void +// interpolated_corrected_measure_mesh(const PolygonMesh& pmesh, +// FaceMeasureMap fmm, +// const Curvature_measure_index mu_i, +// const NamedParameters& np = parameters::default_values()) +//{ +// +// typedef typename GetGeomTraits::type GT; +// +// typedef dynamic_vertex_property_t Vector_map_tag; +// typedef typename boost::property_map::const_type Default_vector_map; +// typedef typename internal_np::Lookup_named_param_def::type Vertex_normal_map; +// +// using parameters::choose_parameter; +// using parameters::get_parameter; +// using parameters::is_default_parameter; +// +// typedef typename boost::graph_traits::face_descriptor Face_descriptor; +// typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; +// typedef typename boost::graph_traits::halfedge_descriptor Halfedge_descriptor; +// +// typename GetVertexPointMap::const_type +// vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), +// get_const_property_map(CGAL::vertex_point, pmesh)); +// +// Vertex_normal_map 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::function +// &, const std::vector&)> +// iccm_function; +// switch (mu_i) +// { +// case MU0_AREA_MEASURE: +// iccm_function = &interpolated_corrected_area_measure_face; +// break; +// case MU1_MEAN_CURVATURE_MEASURE: +// iccm_function = &interpolated_corrected_mean_curvature_measure_face; +// break; +// case MU2_GAUSSIAN_CURVATURE_MEASURE: +// iccm_function = &interpolated_corrected_gaussian_curvature_measure_face; +// break; +// } +// +// std::vector x; +// std::vector u; +// +// for (Face_descriptor f : faces(pmesh)) +// { +// +// for (Vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) +// { +// typename GT::Point_3 p = get(vpm, v); +// x.push_back(typename GT::Vector_3(p.x(), p.y(), p.z())); +// u.push_back(get(vnm, v)); +// } +// +// put(fmm, f, iccm_function(u, x)); +// x.clear(); +// u.clear(); +// } +//} +// +//template +// void +// interpolated_corrected_anisotropic_measure_mesh(const PolygonMesh& pmesh, +// FaceMeasureMap fmm, +// const NamedParameters& np = parameters::default_values()) +//{ +// +// typedef typename GetGeomTraits::type GT; +// +// typedef dynamic_vertex_property_t Vector_map_tag; +// typedef typename boost::property_map::const_type Default_vector_map; +// typedef typename internal_np::Lookup_named_param_def::type VertexNormalMap; +// +// using parameters::choose_parameter; +// using parameters::get_parameter; +// using parameters::is_default_parameter; +// +// typedef typename boost::graph_traits::face_descriptor Face_descriptor; +// typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; +// typedef typename boost::graph_traits::halfedge_descriptor Halfedge_descriptor; +// +// typename GetVertexPointMap::const_type +// vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), +// get_const_property_map(CGAL::vertex_point, pmesh)); +// +// VertexNormalMap 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 x; +// std::vector u; +// +// for (Face_descriptor f : faces(pmesh)) +// { +// +// for (Vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) +// { +// typename GT::Point_3 p = get(vpm, v); +// x.push_back(typename GT::Vector_3(p.x(), p.y(), p.z())); +// u.push_back(get(vnm, v)); +// } +// +// put(fmm, f, interpolated_corrected_anisotropic_measure_face(u, x)); +// x.clear(); +// u.clear(); +// +// } +//} // //template @@ -513,160 +549,472 @@ typename GT::FT face_in_ball_ratio(const std::vector& x, return (r - d_min) / (d_max - d_min); } -template - void expand_interpolated_corrected_measure_vertex(const PolygonMesh& pmesh, - FaceMeasureMap area_fmm, - FaceMeasureMap curvature_fmm, - VertexMeasureMap area_vmm, - VertexMeasureMap curvature_vmm, - const typename boost::graph_traits::vertex_descriptor v, - const NamedParameters& np = parameters::default_values()) +//template +// void expand_interpolated_corrected_measure_vertex(const PolygonMesh& pmesh, +// FaceMeasureMap area_fmm, +// FaceMeasureMap curvature_fmm, +// VertexMeasureMap area_vmm, +// VertexMeasureMap curvature_vmm, +// const typename boost::graph_traits::vertex_descriptor v, +// const NamedParameters& np = parameters::default_values()) +//{ +// using parameters::choose_parameter; +// using parameters::get_parameter; +// +// typedef typename GetGeomTraits::type GT; +// +// typedef typename boost::graph_traits::face_descriptor Face_descriptor; +// typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; +// +// const typename GT::FT +// r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0); +// +// typename GetVertexPointMap::const_type +// vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), +// get_const_property_map(CGAL::vertex_point, pmesh)); +// +// +// std::queue bfs_queue; +// std::unordered_set bfs_visited; +// +// typename GT::Point_3 vp = get(vpm, v); +// typename GT::Vector_3 c = typename GT::Vector_3(vp.x(), vp.y(), vp.z()); +// +// typename GT::FT corrected_mu0 = 0; +// typename GT::FT corrected_mui = 0; +// +// for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { +// if (f != boost::graph_traits::null_face()) +// { +// bfs_queue.push(f); +// bfs_visited.insert(f); +// } +// } +// while (!bfs_queue.empty()) { +// Face_descriptor fi = bfs_queue.front(); +// bfs_queue.pop(); +// +// // looping over vertices in face to get point coordinates +// std::vector x; +// for (Vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh)) +// { +// typename GT::Point_3 pi = get(vpm, vi); +// x.push_back(typename GT::Vector_3(pi.x(), pi.y(), pi.z())); +// } +// +// const typename GT::FT f_ratio = face_in_ball_ratio(x, r, c); +// +// if (f_ratio != 0.0) +// { +// corrected_mu0 += f_ratio * get(area_fmm, fi); +// corrected_mui += f_ratio * get(curvature_fmm, fi); +// for (Face_descriptor fj : faces_around_face(halfedge(fi, pmesh), pmesh)) +// { +// if (bfs_visited.find(fj) == bfs_visited.end() && fj != boost::graph_traits::null_face()) +// { +// bfs_queue.push(fj); +// bfs_visited.insert(fj); +// } +// } +// } +// } +// put(area_vmm, v, corrected_mu0); +// put(curvature_vmm, v, corrected_mui); +//} +// +//template +// void expand_interpolated_corrected_anisotropic_measure_vertex(const PolygonMesh& pmesh, +// AreaFaceMeasureMap area_fmm, +// AnisotropicFaceMeasureMap aniso_fmm, +// AreaVertexMeasureMap area_vmm, +// AnisotropicVertexMeasureMap aniso_vmm, +// const typename boost::graph_traits::vertex_descriptor v, +// const NamedParameters& np = parameters::default_values()) +//{ +// using parameters::choose_parameter; +// using parameters::get_parameter; +// +// typedef typename GetGeomTraits::type GT; +// +// typedef typename boost::graph_traits::face_descriptor Face_descriptor; +// typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; +// +// const typename GT::FT +// r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0); +// +// typename GetVertexPointMap::const_type +// vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), +// get_const_property_map(CGAL::vertex_point, pmesh)); +// +// +// std::queue bfs_queue; +// std::unordered_set bfs_visited; +// +// typename GT::Point_3 vp = get(vpm, v); +// typename GT::Vector_3 c = typename GT::Vector_3(vp.x(), vp.y(), vp.z()); +// +// typename GT::FT corrected_mu0 = 0; +// Eigen::Matrix corrected_muXY = Eigen::Matrix::Zero(); +// +// for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { +// if (f != boost::graph_traits::null_face()) +// { +// bfs_queue.push(f); +// bfs_visited.insert(f); +// } +// } +// while (!bfs_queue.empty()) { +// Face_descriptor fi = bfs_queue.front(); +// bfs_queue.pop(); +// +// // looping over vertices in face to get point coordinates +// std::vector x; +// for (Vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh)) +// { +// typename GT::Point_3 pi = get(vpm, vi); +// x.push_back(typename GT::Vector_3(pi.x(), pi.y(), pi.z())); +// } +// +// const typename GT::FT f_ratio = face_in_ball_ratio(x, r, c); +// +// if (f_ratio != 0.0) +// { +// corrected_mu0 += f_ratio * get(area_fmm, fi); +// +// std::array muXY_face = get(aniso_fmm, fi); +// +// for (std::size_t ix = 0; ix < 3; ix++) +// for (std::size_t iy = 0; iy < 3; iy++) +// corrected_muXY(ix, iy) += f_ratio * muXY_face[ix * 3 + iy]; +// +// for (Face_descriptor fj : faces_around_face(halfedge(fi, pmesh), pmesh)) +// { +// if (bfs_visited.find(fj) == bfs_visited.end() && fj != boost::graph_traits::null_face()) +// { +// bfs_queue.push(fj); +// bfs_visited.insert(fj); +// } +// } +// } +// } +// put(area_vmm, v, corrected_mu0); +// put(aniso_vmm, v, corrected_muXY); +//} + + +template +Principal_curvature principal_curvature_from_anisotropic_measures( + const std::array anisotropic_measure, + const typename GT::FT v_mu0, + const typename GT::Vector_3 u_GT +) { - using parameters::choose_parameter; - using parameters::get_parameter; + Eigen::Matrix v_muXY = Eigen::Matrix::Zero(); + + for (std::size_t ix = 0; ix < 3; ix++) + for (std::size_t iy = 0; iy < 3; iy++) + v_muXY(ix, iy) = anisotropic_measure[ix * 3 + iy]; + + Eigen::Matrix u(u_GT.x(), u_GT.y(), u_GT.z()); + const typename GT::FT K = 1000 * v_mu0; + v_muXY = 0.5 * (v_muXY + v_muXY.transpose()) + K * u * u.transpose(); + + Eigen::SelfAdjointEigenSolver> eigensolver; + + eigensolver.computeDirect(v_muXY); + + if (eigensolver.info() != Eigen::Success) + return Principal_curvature(); + + const Eigen::Matrix eig_vals = eigensolver.eigenvalues(); + const Eigen::Matrix eig_vecs = eigensolver.eigenvectors(); + + const typename GT::Vector_3 min_eig_vec(eig_vecs(0, 1), eig_vecs(1, 1), eig_vecs(2, 1)); + const typename GT::Vector_3 max_eig_vec(eig_vecs(0, 0), eig_vecs(1, 0), eig_vecs(2, 0)); + + return Principal_curvature( + (v_mu0 != 0.0) ? -eig_vals[1] / v_mu0 : 0.0, + (v_mu0 != 0.0) ? -eig_vals[0] / v_mu0 : 0.0, + min_eig_vec, + max_eig_vec + ); +} + +template +class Interpolated_corrected_curvatures_computer +{ typedef typename GetGeomTraits::type GT; + typedef typename GT::FT FT; + typedef typename GT::Point_3 Point_3; + typedef typename GT::Vector_3 Vector_3; + + typedef typename GetVertexPointMap::const_type Vertex_position_map; + + typedef dynamic_vertex_property_t Vector_map_tag; + typedef typename boost::property_map::const_type Default_vector_map; + typedef typename internal_np::Lookup_named_param_def::type Vertex_normal_map; + + typedef dynamic_vertex_property_t Scalar_map_tag; + typedef typename boost::property_map::const_type Default_scalar_map; + typedef typename internal_np::Lookup_named_param_def::type Vertex_scalar_curvature_map; + + typedef dynamic_vertex_property_t> Principal_map_tag; + typedef typename boost::property_map::const_type Default_principal_map; + typedef typename internal_np::Lookup_named_param_def::type Vertex_principal_curvature_map; + + + + typedef typename boost::graph_traits::halfedge_descriptor Halfedge_descriptor; + typedef typename boost::graph_traits::edge_descriptor Edge_descriptor; typedef typename boost::graph_traits::face_descriptor Face_descriptor; typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; - const typename GT::FT - r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0); + typedef typename boost::property_map>::type Face_scalar_measure_map; + typedef typename boost::property_map>>::type Face_anisotropic_measure_map; + +private: + const PolygonMesh& pmesh; + Vertex_position_map vpm; + Vertex_normal_map vnm; + FT ball_radius; + + bool is_mean_curvature_selected; + bool is_gaussian_curvature_selected; + bool is_principal_curvature_selected; + + Vertex_scalar_curvature_map mean_curvature_map, gaussian_curvature_map; + Vertex_principal_curvature_map principal_curvature_map; + + Face_scalar_measure_map mu0_map, mu1_map, mu2_map; + Face_anisotropic_measure_map muXY_map; + + void set_property_maps() { + mu0_map = get(CGAL::dynamic_face_property_t(), pmesh); + mu1_map = get(CGAL::dynamic_face_property_t(), pmesh); + mu2_map = get(CGAL::dynamic_face_property_t(), pmesh); + muXY_map = get(CGAL::dynamic_face_property_t>(), pmesh); + + } + + void set_named_params(const NamedParameters& np = parameters::default_values()) + { + using parameters::choose_parameter; + using parameters::get_parameter; + using parameters::is_default_parameter; - typename GetVertexPointMap::const_type vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), get_const_property_map(CGAL::vertex_point, pmesh)); + vnm = choose_parameter(get_parameter(np, internal_np::vertex_normal_map), + get(Vector_map_tag(), pmesh)); - std::queue bfs_queue; - std::unordered_set bfs_visited; + if (is_default_parameter::value) + compute_vertex_normals(pmesh, vnm, np); - typename GT::Point_3 vp = get(vpm, v); - typename GT::Vector_3 c = typename GT::Vector_3(vp.x(), vp.y(), vp.z()); + const FT radius = choose_parameter(get_parameter(np, internal_np::ball_radius), -1); - typename GT::FT corrected_mu0 = 0; - typename GT::FT corrected_mui = 0; + if (is_mean_curvature_selected) + mean_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_mean_curvature_map), get(CGAL::dynamic_vertex_property_t(), pmesh)); + if (is_gaussian_curvature_selected) + gaussian_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_gaussian_curvature_map), get(CGAL::dynamic_vertex_property_t(), pmesh)); + if (is_principal_curvature_selected) + principal_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_principal_curvature_map), get(CGAL::dynamic_vertex_property_t>(), pmesh)); - for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { - if (f != boost::graph_traits::null_face()) - { - bfs_queue.push(f); - bfs_visited.insert(f); - } + set_ball_radius(radius); } - while (!bfs_queue.empty()) { - Face_descriptor fi = bfs_queue.front(); - bfs_queue.pop(); - // looping over vertices in face to get point coordinates - std::vector x; - for (Vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh)) - { - typename GT::Point_3 pi = get(vpm, vi); - x.push_back(typename GT::Vector_3(pi.x(), pi.y(), pi.z())); - } + void set_ball_radius(const FT radius) { + if (radius == 0) + ball_radius = average_edge_length(pmesh) * EXPANDING_RADIUS_EPSILON; + } + +public: + + Interpolated_corrected_curvatures_computer(const PolygonMesh& pmesh, + bool is_mean_curvature_selected, + bool is_gaussian_curvature_selected, + bool is_principal_curvature_selected, + const NamedParameters& np = parameters::default_values() + ) : + pmesh(pmesh), + is_mean_curvature_selected(is_mean_curvature_selected), + is_gaussian_curvature_selected(is_gaussian_curvature_selected), + is_principal_curvature_selected(is_principal_curvature_selected) + { + if (!is_mean_curvature_selected && !is_gaussian_curvature_selected && !is_principal_curvature_selected) + return; + + set_named_params(); - const typename GT::FT f_ratio = face_in_ball_ratio(x, r, c); + set_property_maps(); - if (f_ratio != 0.0) + compute_selected_curvatures(); + + } + + void interpolated_corrected_all_measures_all_faces() + { + std::vector x; + std::vector u; + + for (Face_descriptor f : faces(pmesh)) { - corrected_mu0 += f_ratio * get(area_fmm, fi); - corrected_mui += f_ratio * get(curvature_fmm, fi); - for (Face_descriptor fj : faces_around_face(halfedge(fi, pmesh), pmesh)) + for (Vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) { - if (bfs_visited.find(fj) == bfs_visited.end() && fj != boost::graph_traits::null_face()) - { - bfs_queue.push(fj); - bfs_visited.insert(fj); - } + Point_3 p = get(vpm, v); + x.push_back(Vector_3(p.x(), p.y(), p.z())); + u.push_back(get(vnm, v)); } - } - } - put(area_vmm, v, corrected_mu0); - put(curvature_vmm, v, corrected_mui); -} - -template - void expand_interpolated_corrected_anisotropic_measure_vertex(const PolygonMesh& pmesh, - AreaFaceMeasureMap area_fmm, - AnisotropicFaceMeasureMap aniso_fmm, - AreaVertexMeasureMap area_vmm, - AnisotropicVertexMeasureMap aniso_vmm, - const typename boost::graph_traits::vertex_descriptor v, - const NamedParameters& np = parameters::default_values()) -{ - using parameters::choose_parameter; - using parameters::get_parameter; + put(mu0_map, f, interpolated_corrected_area_measure_face(u, x)); - typedef typename GetGeomTraits::type GT; + if (is_mean_curvature_selected) + put(mu1_map, f, interpolated_corrected_mean_curvature_measure_face(u, x)); - typedef typename boost::graph_traits::face_descriptor Face_descriptor; - typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; + if (is_gaussian_curvature_selected) + put(mu2_map, f, interpolated_corrected_gaussian_curvature_measure_face(u, x)); - const typename GT::FT - r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0); + if (is_principal_curvature_selected) + put(muXY_map, f, interpolated_corrected_anisotropic_measure_face(u, x)); - typename GetVertexPointMap::const_type - vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), - get_const_property_map(CGAL::vertex_point, pmesh)); + x.clear(); + u.clear(); + } + } + Vertex_measures expand_interpolated_corrected_measure_vertex_no_radius(Vertex_descriptor v) + { + Vertex_measures vertex_curvatures; - std::queue bfs_queue; - std::unordered_set bfs_visited; + for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { + vertex_curvatures.area_measure += get(mu0_map, f); - typename GT::Point_3 vp = get(vpm, v); - typename GT::Vector_3 c = typename GT::Vector_3(vp.x(), vp.y(), vp.z()); + if (is_mean_curvature_selected) + vertex_curvatures.mean_curvature_measure += get(mu1_map, f); - typename GT::FT corrected_mu0 = 0; - Eigen::Matrix corrected_muXY = Eigen::Matrix::Zero(); + if (is_gaussian_curvature_selected) + vertex_curvatures.gaussian_curvature_measure += get(mu2_map, f); - for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { - if (f != boost::graph_traits::null_face()) - { - bfs_queue.push(f); - bfs_visited.insert(f); + if (is_principal_curvature_selected) + { + const std::array face_anisotropic_measure = get(muXY_map, f); + for (std::size_t i = 0; i < 3 * 3; i++) + vertex_curvatures.anisotropic_measure[i] += face_anisotropic_measure[i]; + } } + + return vertex_curvatures; } - while (!bfs_queue.empty()) { - Face_descriptor fi = bfs_queue.front(); - bfs_queue.pop(); - // looping over vertices in face to get point coordinates - std::vector x; - for (Vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh)) - { - typename GT::Point_3 pi = get(vpm, vi); - x.push_back(typename GT::Vector_3(pi.x(), pi.y(), pi.z())); - } + Vertex_measures expand_interpolated_corrected_measure_vertex(Vertex_descriptor v) + { + std::queue bfs_queue; + std::unordered_set bfs_visited; - const typename GT::FT f_ratio = face_in_ball_ratio(x, r, c); + Point_3 vp = get(vpm, v); + Vector_3 c = Vector_3(vp.x(), vp.y(), vp.z()); - if (f_ratio != 0.0) - { - corrected_mu0 += f_ratio * get(area_fmm, fi); + Vertex_measures vertex_curvatures; + + for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { + if (f != boost::graph_traits::null_face()) + { + bfs_queue.push(f); + bfs_visited.insert(f); + } + } + while (!bfs_queue.empty()) { + Face_descriptor fi = bfs_queue.front(); + bfs_queue.pop(); - std::array muXY_face = get(aniso_fmm, fi); + // looping over vertices in face to get point coordinates + std::vector x; + for (Vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh)) + { + Point_3 pi = get(vpm, vi); + x.push_back(Vector_3(pi.x(), pi.y(), pi.z())); + } - for (std::size_t ix = 0; ix < 3; ix++) - for (std::size_t iy = 0; iy < 3; iy++) - corrected_muXY(ix, iy) += f_ratio * muXY_face[ix * 3 + iy]; + const FT f_ratio = face_in_ball_ratio(x, ball_radius, c); - for (Face_descriptor fj : faces_around_face(halfedge(fi, pmesh), pmesh)) + if (f_ratio != 0.0) { - if (bfs_visited.find(fj) == bfs_visited.end() && fj != boost::graph_traits::null_face()) + vertex_curvatures.area_measure += f_ratio * get(mu0_map, fi); + + if (is_mean_curvature_selected) + vertex_curvatures.mean_curvature_measure += f_ratio * get(mu1_map, fi); + + if (is_gaussian_curvature_selected) + vertex_curvatures.gaussian_curvature_measure += f_ratio * get(mu2_map, fi); + + if (is_principal_curvature_selected) { - bfs_queue.push(fj); - bfs_visited.insert(fj); + const std::array face_anisotropic_measure = get(muXY_map, fi); + for (std::size_t i = 0; i < 3 * 3; i++) + vertex_curvatures.anisotropic_measure[i] += f_ratio * face_anisotropic_measure[i]; + } + + for (Face_descriptor fj : faces_around_face(halfedge(fi, pmesh), pmesh)) + { + if (bfs_visited.find(fj) == bfs_visited.end() && fj != boost::graph_traits::null_face()) + { + bfs_queue.push(fj); + bfs_visited.insert(fj); + } } } } + return vertex_curvatures; + } + + void compute_selected_curvatures() { + interpolated_corrected_all_measures_all_faces(); + + for (Vertex_descriptor v : vertices(pmesh)) + { + Vertex_measures vertex_curvatures = (ball_radius < 0)? + expand_interpolated_corrected_measure_vertex_no_radius(v) : + expand_interpolated_corrected_measure_vertex(v); + + if (is_mean_curvature_selected) { + vertex_curvatures.area_measure != 0 ? + put(mean_curvature_map, v, 0.5 * vertex_curvatures.mean_curvature_measure / vertex_curvatures.area_measure) : + put(mean_curvature_map, v, 0); + } + + if (is_gaussian_curvature_selected) { + vertex_curvatures.area_measure != 0 ? + put(gaussian_curvature_map, v, vertex_curvatures.gaussian_curvature_measure / vertex_curvatures.area_measure) : + put(gaussian_curvature_map, v, 0); + } + + if (is_principal_curvature_selected) { + const Vector_3 v_normal = get(vnm, v); + const Principal_curvature principal_curvature = principal_curvature_from_anisotropic_measures( + vertex_curvatures.anisotropic_measure, + vertex_curvatures.area_measure, + v_normal + ); + put(principal_curvature_map, v, principal_curvature); + } + } } - put(area_vmm, v, corrected_mu0); - put(aniso_vmm, v, corrected_muXY); -} + + + +}; } // namespace internal @@ -722,6 +1070,7 @@ template::type GT; - - typedef typename boost::graph_traits::face_descriptor Face_descriptor; - typedef typename boost::property_map>::const_type Face_measure_map; - - typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; - typedef typename boost::property_map>::const_type Vertex_measure_map; - - typename GT::FT - r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0); - - if (r == 0) - r = internal::average_edge_length(pmesh) * EXPANDING_RADIUS_EPSILON; - - Face_measure_map mu0_map = get(CGAL::dynamic_face_property_t(), pmesh); - Face_measure_map mu1_map = get(CGAL::dynamic_face_property_t(), pmesh); - - Vertex_measure_map mu0_expand_map = get(CGAL::dynamic_vertex_property_t(), pmesh); - Vertex_measure_map mu1_expand_map = get(CGAL::dynamic_vertex_property_t(), pmesh); - - internal::interpolated_corrected_measure_mesh(pmesh, mu0_map, internal::MU0_AREA_MEASURE, np); - internal::interpolated_corrected_measure_mesh(pmesh, mu1_map, internal::MU1_MEAN_CURVATURE_MEASURE, np); - - for (Vertex_descriptor v : vertices(pmesh)) - { - internal::expand_interpolated_corrected_measure_vertex(pmesh, mu0_map, mu1_map, mu0_expand_map, mu1_expand_map, v, np.ball_radius(r)); - - typename GT::FT v_mu0 = get(mu0_expand_map, v); - if (v_mu0 != 0.0) - put(vcm, v, 0.5 * get(mu1_expand_map, v) / v_mu0); - else - put(vcm, v, 0); - } + internal::Interpolated_corrected_curvatures_computer(pmesh, true, false, false, np.vertex_mean_curvature_map(vcm)); } /** @@ -822,6 +1134,7 @@ template @@ -829,44 +1142,7 @@ template::type GT; - - typedef typename boost::graph_traits::face_descriptor Face_descriptor; - typedef typename boost::property_map>::const_type Face_measure_map; - - typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; - typedef typename boost::property_map>::const_type Vertex_measure_map; - - typename GT::FT - r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0); - - if (r == 0) - r = internal::average_edge_length(pmesh) * EXPANDING_RADIUS_EPSILON; - - Face_measure_map mu0_map = get(CGAL::dynamic_face_property_t(), pmesh); - Face_measure_map mu2_map = get(CGAL::dynamic_face_property_t(), pmesh); - - Vertex_measure_map mu0_expand_map = get(CGAL::dynamic_vertex_property_t(), pmesh); - Vertex_measure_map mu2_expand_map = get(CGAL::dynamic_vertex_property_t(), pmesh); - - internal::interpolated_corrected_measure_mesh(pmesh, mu0_map, internal::MU0_AREA_MEASURE, np); - internal::interpolated_corrected_measure_mesh(pmesh, mu2_map, internal::MU2_GAUSSIAN_CURVATURE_MEASURE, np); - - for (Vertex_descriptor v : vertices(pmesh)) - { - internal::expand_interpolated_corrected_measure_vertex(pmesh, mu0_map, mu2_map, mu0_expand_map, mu2_expand_map, v, np.ball_radius(r)); - - typename GT::FT v_mu0 = get(mu0_expand_map, v); - if(v_mu0 != 0.0) - put(vcm, v, get(mu2_expand_map, v) / v_mu0); - else - put(vcm, v, 0); - } + internal::Interpolated_corrected_curvatures_computer(pmesh, false, true, false, np.vertex_gaussian_curvature_map(vcm)); } /** @@ -922,6 +1198,7 @@ template @@ -929,98 +1206,83 @@ template::type GT; - - typedef typename boost::graph_traits::face_descriptor Face_descriptor; - typedef typename boost::property_map>::const_type Face_scalar_measure_map; - typedef typename boost::property_map>>::const_type Face_array_measure_map; - - typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; - typedef typename boost::property_map>::const_type Vertex_scalar_measure_map; - typedef typename boost::property_map>>::const_type Vertex_matrix_measure_map; - - typedef dynamic_vertex_property_t Vector_map_tag; - typedef typename boost::property_map::const_type Default_vector_map; - typedef typename internal_np::Lookup_named_param_def::type VertexNormalMap; - - using parameters::choose_parameter; - using parameters::get_parameter; - using parameters::is_default_parameter; - - typename GetVertexPointMap::const_type - vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), - get_const_property_map(CGAL::vertex_point, pmesh)); - - VertexNormalMap vnm = choose_parameter(get_parameter(np, internal_np::vertex_normal_map), - get(Vector_map_tag(), pmesh)); - - typename GT::FT - r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0); - - if (r == 0) - r = internal::average_edge_length(pmesh) * EXPANDING_RADIUS_EPSILON; - - if (is_default_parameter::value) - compute_vertex_normals(pmesh, vnm, np); - - Face_scalar_measure_map mu0_map = get(CGAL::dynamic_face_property_t(), pmesh); - Face_array_measure_map muXY_map = get(CGAL::dynamic_face_property_t>(), pmesh); - - Vertex_scalar_measure_map mu0_expand_map = get(CGAL::dynamic_vertex_property_t(), pmesh); - Vertex_matrix_measure_map muXY_expand_map = get(CGAL::dynamic_vertex_property_t>(), pmesh); - - internal::interpolated_corrected_measure_mesh(pmesh, mu0_map, internal::MU0_AREA_MEASURE, np); - internal::interpolated_corrected_anisotropic_measure_mesh(pmesh, muXY_map, np); + internal::Interpolated_corrected_curvatures_computer(pmesh, false, false, true, np.vertex_principal_curvature_map(vcm)); +} - for (Vertex_descriptor v : vertices(pmesh)) +// TODO: DOC +/** +* \ingroup PMP_corrected_curvatures_grp +* +* Computes the interpolated corrected curvatures across the mesh, based on the provided property maps. +* By providing mean, gaussian and/or principal curvature property maps, the user +* can choose which curvatures to compute. +* +* @tparam PolygonMesh a model of `FaceListGraph`. +* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". +* +* @param pmesh the polygon 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 `pmesh`} +* \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, pmesh)`} +* \cgalParamExtra{If this parameter is omitted, an internal property map for +* `CGAL::vertex_point_t` must be available in `PolygonMesh`.} +* \cgalParamNEnd +* +* \cgalParamNBegin{vertex_normal_map} +* \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} +* \cgalParamType{a class model of `ReadablePropertyMap` with +* `boost::graph_traits::%Vertex_descriptor` +* as key type and `%Vector_3` as value type} +* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} +* \cgalParamExtra{If this parameter is omitted, vertex normals will be +* computed using compute_vertex_normals()} +* \cgalParamNEnd +* +* \cgalParamNBegin{ball_radius} +* \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures +* by summing measures of faces inside a ball of this radius centered at the +* vertex expanded from. The summed face measures are weighted by their +* inclusion ratio inside this ball} +* \cgalParamType{`GT::FT`} +* \cgalParamDefault{`-1`} +* \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of +* measures on faces around the vertex} +* \cgalParamNEnd +* +* \cgalNamedParamsEnd +* +* @see `interpolated_corrected_mean_curvature()` +* @see `interpolated_corrected_gaussian_curvature()` +* @see `interpolated_corrected_principal_curvatures()` +*/ +template + void interpolated_corrected_curvatures(const PolygonMesh& pmesh, + bool is_mean_curvature_selected, + bool is_gaussian_curvature_selected, + bool is_principal_curvature_selected, + const NamedParameters& np = parameters::default_values()) +{ + if (is_mean_curvature_selected || is_gaussian_curvature_selected || is_principal_curvature_selected) { - internal::expand_interpolated_corrected_anisotropic_measure_vertex(pmesh, mu0_map, muXY_map, mu0_expand_map, muXY_expand_map, v, np.ball_radius(r)); - - typename GT::FT v_mu0 = get(mu0_expand_map, v); - Eigen::Matrix v_muXY = get(muXY_expand_map, v); - - typename GT::Vector_3 u_GT = get(vnm, v); - - Eigen::Matrix u(u_GT.x(), u_GT.y(), u_GT.z()); - - const typename GT::FT K = 1000 * v_mu0; - - v_muXY = 0.5 * (v_muXY + v_muXY.transpose()) + K * u * u.transpose(); - - Eigen::SelfAdjointEigenSolver> eigensolver; - - eigensolver.computeDirect(v_muXY); - - if (eigensolver.info() != Eigen::Success) - { - put(vcm, v, std::make_tuple( - 0, - 0, - typename GT::Vector_3(0, 0, 0), - typename GT::Vector_3(0, 0, 0))); - continue; - } - - const Eigen::Matrix eig_vals = eigensolver.eigenvalues(); - const Eigen::Matrix eig_vecs = eigensolver.eigenvectors(); - - const typename GT::Vector_3 min_eig_vec(eig_vecs(0, 1), eig_vecs(1, 1), eig_vecs(2, 1)); - const typename GT::Vector_3 max_eig_vec(eig_vecs(0, 0), eig_vecs(1, 0), eig_vecs(2, 0)); - - put(vcm, v, std::make_tuple( - (v_mu0 != 0.0) ? -eig_vals[1] / v_mu0 : 0.0, - (v_mu0 != 0.0) ? -eig_vals[0] / v_mu0 : 0.0, - min_eig_vec, - max_eig_vec)); + internal::Interpolated_corrected_curvatures_computer( + pmesh, + is_mean_curvature_selected, + is_gaussian_curvature_selected, + is_principal_curvature_selected, + np + ); } } + } // namespace Polygon_mesh_processing } // namespace CGAL From 2dcb2939b9011cb3e6fa0b199d1ac226f996a0e8 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sun, 13 Nov 2022 13:32:38 +0200 Subject: [PATCH 073/142] compute multiple curvatures at same time + no radius handled --- ...erpolated_corrected_curvatures_example.cpp | 8 ++ ...nterpolated_corrected_curvature_measures.h | 83 ++++++++----------- 2 files changed, 42 insertions(+), 49 deletions(-) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp index da6e9d2252f0..a2fd69fff1a7 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp @@ -76,6 +76,14 @@ int main(int argc, char* argv[]) principal_curvature_map ); + PMP::interpolated_corrected_curvatures( + g1, + CGAL::parameters::ball_radius(0) + .vertex_mean_curvature_map(mean_curvature_map) + .vertex_gaussian_curvature_map(gaussian_curvature_map) + .vertex_principal_curvature_map(principal_curvature_map) + ); + for (vertex_descriptor v : vertices(g1)) { auto PC = principal_curvature_map[v]; 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 c4a9154c1aa2..b83bf0e70dff 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 @@ -753,6 +753,11 @@ class Interpolated_corrected_curvatures_computer typedef typename GT::Point_3 Point_3; typedef typename GT::Vector_3 Vector_3; + typedef typename boost::graph_traits::halfedge_descriptor Halfedge_descriptor; + typedef typename boost::graph_traits::edge_descriptor Edge_descriptor; + typedef typename boost::graph_traits::face_descriptor Face_descriptor; + typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; + typedef typename GetVertexPointMap::const_type Vertex_position_map; typedef dynamic_vertex_property_t Vector_map_tag; @@ -761,29 +766,24 @@ class Interpolated_corrected_curvatures_computer NamedParameters, Default_vector_map>::type Vertex_normal_map; - typedef dynamic_vertex_property_t Scalar_map_tag; - typedef typename boost::property_map::const_type Default_scalar_map; + typedef Constant_property_map Default_scalar_map; typedef typename internal_np::Lookup_named_param_def::type Vertex_scalar_curvature_map; + Default_scalar_map>::type Vertex_mean_curvature_map; - typedef dynamic_vertex_property_t> Principal_map_tag; - typedef typename boost::property_map::const_type Default_principal_map; + typedef typename internal_np::Lookup_named_param_def::type Vertex_gaussian_curvature_map; + + typedef Constant_property_map> Default_principal_map; typedef typename internal_np::Lookup_named_param_def::type Vertex_principal_curvature_map; - - - typedef typename boost::graph_traits::halfedge_descriptor Halfedge_descriptor; - typedef typename boost::graph_traits::edge_descriptor Edge_descriptor; - typedef typename boost::graph_traits::face_descriptor Face_descriptor; - typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; - typedef typename boost::property_map>::type Face_scalar_measure_map; + CGAL::dynamic_face_property_t>::const_type Face_scalar_measure_map; typedef typename boost::property_map>>::type Face_anisotropic_measure_map; + CGAL::dynamic_face_property_t>>::const_type Face_anisotropic_measure_map; private: const PolygonMesh& pmesh; @@ -795,7 +795,8 @@ class Interpolated_corrected_curvatures_computer bool is_gaussian_curvature_selected; bool is_principal_curvature_selected; - Vertex_scalar_curvature_map mean_curvature_map, gaussian_curvature_map; + Vertex_mean_curvature_map mean_curvature_map; + Vertex_gaussian_curvature_map gaussian_curvature_map; Vertex_principal_curvature_map principal_curvature_map; Face_scalar_measure_map mu0_map, mu1_map, mu2_map; @@ -809,7 +810,7 @@ class Interpolated_corrected_curvatures_computer } - void set_named_params(const NamedParameters& np = parameters::default_values()) + void set_named_params(const NamedParameters& np) { using parameters::choose_parameter; using parameters::get_parameter; @@ -826,12 +827,15 @@ class Interpolated_corrected_curvatures_computer const FT radius = choose_parameter(get_parameter(np, internal_np::ball_radius), -1); - if (is_mean_curvature_selected) - mean_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_mean_curvature_map), get(CGAL::dynamic_vertex_property_t(), pmesh)); - if (is_gaussian_curvature_selected) - gaussian_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_gaussian_curvature_map), get(CGAL::dynamic_vertex_property_t(), pmesh)); - if (is_principal_curvature_selected) - principal_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_principal_curvature_map), get(CGAL::dynamic_vertex_property_t>(), pmesh)); + is_mean_curvature_selected = !is_default_parameter::value; + is_gaussian_curvature_selected = !is_default_parameter::value; + is_principal_curvature_selected = !is_default_parameter::value; + + mean_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_mean_curvature_map), Default_scalar_map()); + gaussian_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_gaussian_curvature_map), Default_scalar_map()); + principal_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_principal_curvature_map), Default_principal_map()); + + std::cout << is_mean_curvature_selected << is_gaussian_curvature_selected << is_principal_curvature_selected << std::endl; set_ball_radius(radius); } @@ -839,25 +843,18 @@ class Interpolated_corrected_curvatures_computer void set_ball_radius(const FT radius) { if (radius == 0) ball_radius = average_edge_length(pmesh) * EXPANDING_RADIUS_EPSILON; + else + ball_radius = radius; } public: Interpolated_corrected_curvatures_computer(const PolygonMesh& pmesh, - bool is_mean_curvature_selected, - bool is_gaussian_curvature_selected, - bool is_principal_curvature_selected, const NamedParameters& np = parameters::default_values() ) : - pmesh(pmesh), - is_mean_curvature_selected(is_mean_curvature_selected), - is_gaussian_curvature_selected(is_gaussian_curvature_selected), - is_principal_curvature_selected(is_principal_curvature_selected) + pmesh(pmesh) { - if (!is_mean_curvature_selected && !is_gaussian_curvature_selected && !is_principal_curvature_selected) - return; - - set_named_params(); + set_named_params(np); set_property_maps(); @@ -1079,7 +1076,7 @@ template(pmesh, true, false, false, np.vertex_mean_curvature_map(vcm)); + internal::Interpolated_corrected_curvatures_computer(pmesh, np.vertex_mean_curvature_map(vcm)); } /** @@ -1142,7 +1139,7 @@ template(pmesh, false, true, false, np.vertex_gaussian_curvature_map(vcm)); + internal::Interpolated_corrected_curvatures_computer(pmesh, np.vertex_gaussian_curvature_map(vcm)); } /** @@ -1206,7 +1203,7 @@ template(pmesh, false, false, true, np.vertex_principal_curvature_map(vcm)); + internal::Interpolated_corrected_curvatures_computer(pmesh, np.vertex_principal_curvature_map(vcm)); } // TODO: DOC @@ -1265,21 +1262,9 @@ template void interpolated_corrected_curvatures(const PolygonMesh& pmesh, - bool is_mean_curvature_selected, - bool is_gaussian_curvature_selected, - bool is_principal_curvature_selected, const NamedParameters& np = parameters::default_values()) { - if (is_mean_curvature_selected || is_gaussian_curvature_selected || is_principal_curvature_selected) - { - internal::Interpolated_corrected_curvatures_computer( - pmesh, - is_mean_curvature_selected, - is_gaussian_curvature_selected, - is_principal_curvature_selected, - np - ); - } + internal::Interpolated_corrected_curvatures_computer(pmesh, np); } From dbd18ed101a6e407f05201468bd04c814778f060 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sun, 13 Nov 2022 13:34:18 +0200 Subject: [PATCH 074/142] trailing whitespaces --- .../interpolated_corrected_curvature_measures.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 b83bf0e70dff..183f823e8483 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 @@ -848,7 +848,7 @@ class Interpolated_corrected_curvatures_computer } public: - + Interpolated_corrected_curvatures_computer(const PolygonMesh& pmesh, const NamedParameters& np = parameters::default_values() ) : @@ -911,7 +911,7 @@ class Interpolated_corrected_curvatures_computer vertex_curvatures.anisotropic_measure[i] += face_anisotropic_measure[i]; } } - + return vertex_curvatures; } @@ -981,8 +981,8 @@ class Interpolated_corrected_curvatures_computer for (Vertex_descriptor v : vertices(pmesh)) { - Vertex_measures vertex_curvatures = (ball_radius < 0)? - expand_interpolated_corrected_measure_vertex_no_radius(v) : + Vertex_measures vertex_curvatures = (ball_radius < 0)? + expand_interpolated_corrected_measure_vertex_no_radius(v) : expand_interpolated_corrected_measure_vertex(v); if (is_mean_curvature_selected) { @@ -1241,7 +1241,7 @@ template Date: Sun, 13 Nov 2022 17:59:01 +0200 Subject: [PATCH 075/142] minor fix --- ...nterpolated_corrected_curvature_measures.h | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) 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 183f823e8483..1a0ef9891b00 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 @@ -835,8 +835,6 @@ class Interpolated_corrected_curvatures_computer gaussian_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_gaussian_curvature_map), Default_scalar_map()); principal_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_principal_curvature_map), Default_principal_map()); - std::cout << is_mean_curvature_selected << is_gaussian_curvature_selected << is_principal_curvature_selected << std::endl; - set_ball_radius(radius); } @@ -856,12 +854,16 @@ class Interpolated_corrected_curvatures_computer { set_named_params(np); - set_property_maps(); - - compute_selected_curvatures(); + if (is_mean_curvature_selected || is_gaussian_curvature_selected || is_principal_curvature_selected) + { + set_property_maps(); + compute_selected_curvatures(); + } } +private: + void interpolated_corrected_all_measures_all_faces() { std::vector x; @@ -1073,10 +1075,10 @@ class Interpolated_corrected_curvatures_computer template void interpolated_corrected_mean_curvature(const PolygonMesh& pmesh, - VertexCurvatureMap vcm, - const NamedParameters& np = parameters::default_values()) + VertexCurvatureMap& vcm, + NamedParameters& np = parameters::default_values()) { - internal::Interpolated_corrected_curvatures_computer(pmesh, np.vertex_mean_curvature_map(vcm)); + interpolated_corrected_curvatures(pmesh, np.vertex_mean_curvature_map(vcm)); } /** @@ -1136,10 +1138,10 @@ template void interpolated_corrected_gaussian_curvature(const PolygonMesh& pmesh, - VertexCurvatureMap vcm, - const NamedParameters& np = parameters::default_values()) + VertexCurvatureMap& vcm, + NamedParameters& np = parameters::default_values()) { - internal::Interpolated_corrected_curvatures_computer(pmesh, np.vertex_gaussian_curvature_map(vcm)); + interpolated_corrected_curvatures(pmesh, np.vertex_gaussian_curvature_map(vcm)); } /** @@ -1200,10 +1202,10 @@ template void interpolated_corrected_principal_curvatures(const PolygonMesh& pmesh, - VertexCurvatureMap vcm, - const NamedParameters& np = parameters::default_values()) + VertexCurvatureMap& vcm, + NamedParameters& np = parameters::default_values()) { - internal::Interpolated_corrected_curvatures_computer(pmesh, np.vertex_principal_curvature_map(vcm)); + interpolated_corrected_curvatures(pmesh, np.vertex_principal_curvature_map(vcm)); } // TODO: DOC From 6ca73315496d290e77c67d5c8c10930801364adc Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 14 Nov 2022 11:26:13 +0200 Subject: [PATCH 076/142] fixes, doc, examples, general cleanup --- .../PackageDescription.txt | 2 + .../Polygon_mesh_processing.txt | 19 +- ...erpolated_corrected_curvatures_example.cpp | 68 ++-- ...orrected_curvatures_polyhedron_example.cpp | 61 ++-- ...nterpolated_corrected_curvature_measures.h | 343 +++--------------- 5 files changed, 136 insertions(+), 357 deletions(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt index eae47c610011..93f25c89f1fb 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt @@ -204,6 +204,8 @@ The page \ref bgl_namedparameters "Named Parameters" describes their usage. - `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures()` +- `CGAL::Polygon_mesh_processing::Principal_curvature` \cgalCRPSection{Normal Computation Functions} - `CGAL::Polygon_mesh_processing::compute_face_normal()` diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index 8f222497a527..7932051ec000 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -879,7 +879,10 @@ not provide storage for the normals. **************************************** \section PMPICC Computing Curvatures -This package provides methods to compute curvatures on polygonal meshes based on #PAPER#. +This package provides methods to compute curvatures on polygonal meshes based on + + Interpolated corrected curvature measures for polygonal surfaces +. This includes mean curvature, gaussian curvature, principal curvatures and directions. These can be computed on triangle meshes, quad meshes, and meshes with n-gon faces. The algorithms used prove to work well in general. Also, on meshes with noise @@ -893,25 +896,29 @@ These computations are performed using : - `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures()` + +Where it is recommended to use the last function for computing multiple curvatures (example: mean and gaussian) +as the implementation performs the shared computations only once, making it more efficient. \cgalFigureRef{icc_diff_radius} shows how the mean curvature changes depending on the ball_radius named parameter which can be set to a value > 0 to get a smoother -distribution of valuesa and "diffuse" the extreme values of curvatures across the mesh. +distribution of values and "diffuse" the extreme values of curvatures across the mesh. \cgalFigureAnchor{icc_diff_radius}
\cgalFigureCaptionBegin{icc_diff_radius} -The mean curvature distrubution on a bear mesh with different values for the expanding ball radius +The mean curvature distribution on a bear mesh with different values for the expanding ball radius \cgalFigureCaptionEnd Property maps are used to record the computed curvatures as shown in examples. \subsection ICCExample Interpolated Corrected Curvature Examples -Property maps are an API introduced in the boost library that allows to -associate values to keys. In the following examples, for each proberty map, we associate +Property maps are an API introduced in the boost library that allows associating +values to keys. In the following examples, for each property map, we associate a curvature value to each vertex. \subsubsection ICCExampleSM Interpolated Corrected Curvature on a Surface Mesh. @@ -926,7 +933,7 @@ and store them in property maps provided by the class `Surface_mesh`. The following example illustrates how to compute the curvatures on vertices -and store them in unordered (or ordered) maps as the class `Polyhedron_3` does +and store them in dynamic property maps as the class `Polyhedron_3` does not provide storage for the curvatures. \cgalExample{Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp} diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp index a2fd69fff1a7..ffb86d94795c 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp @@ -10,19 +10,19 @@ namespace PMP = CGAL::Polygon_mesh_processing; -typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic_Kernel; -typedef CGAL::Surface_mesh Surface_Mesh; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic_kernel; +typedef CGAL::Surface_mesh Surface_Mesh; typedef boost::graph_traits::face_descriptor face_descriptor; typedef boost::graph_traits::vertex_descriptor vertex_descriptor; int main(int argc, char* argv[]) { - Surface_Mesh g1; + Surface_Mesh smesh; const std::string filename = (argc>1) ? argv[1] : CGAL::data_file_path("meshes/small_bunny.obj"); - if(!CGAL::IO::read_polygon_mesh(filename, g1)) + if(!CGAL::IO::read_polygon_mesh(filename, smesh)) { std::cerr << "Invalid input file." << std::endl; return EXIT_FAILURE; @@ -30,65 +30,67 @@ int main(int argc, char* argv[]) // creating and tying surface mesh property maps for curvatures (with defaults = 0) bool created = false; - Surface_Mesh::Property_map mean_curvature_map, gaussian_curvature_map; - boost::tie(mean_curvature_map, created) = g1.add_property_map("v:mean_curvature_map", 0); + Surface_Mesh::Property_map mean_curvature_map, gaussian_curvature_map; + boost::tie(mean_curvature_map, created) = smesh.add_property_map("v:mean_curvature_map", 0); assert(created); - boost::tie(gaussian_curvature_map, created) = g1.add_property_map("v:gaussian_curvature_map", 0); + boost::tie(gaussian_curvature_map, created) = smesh.add_property_map("v:gaussian_curvature_map", 0); assert(created); // we use a tuple of 2 scalar values and 2 vectors for principal curvatures and directions - Surface_Mesh::Property_map> principal_curvature_map; + Surface_Mesh::Property_map> principal_curvature_map; - boost::tie(principal_curvature_map, created) = g1.add_property_map> + boost::tie(principal_curvature_map, created) = smesh.add_property_map> ("v:principal_curvature_map", { 0, 0, - Epic_Kernel::Vector_3 (0,0,0), - Epic_Kernel::Vector_3 (0,0,0)}); + Epic_kernel::Vector_3(0,0,0), + Epic_kernel::Vector_3(0,0,0) }); assert(created); + // user can call these fucntions to compute a specfic curvature type on each vertex. PMP::interpolated_corrected_mean_curvature( - g1, + smesh, mean_curvature_map ); + PMP::interpolated_corrected_gaussian_curvature( + smesh, + gaussian_curvature_map + ); + + PMP::interpolated_corrected_principal_curvatures( + smesh, + principal_curvature_map + ); + // uncomment this to compute a curvature while specifying named parameters // Example: an expansion ball radius of 0.5 and a vertex normals map (does not have to depend on positions) - /*Surface_Mesh::Property_map vnm; - boost::tie(vnm, created) = g1.add_property_map( - "v:vnm", Epic_Kernel::Vector_3(0, 0, 0) + /*Surface_Mesh::Property_map vnm; + boost::tie(vnm, created) = smesh.add_property_map( + "v:vnm", Epic_kernel::Vector_3(0, 0, 0) ); assert(created); PMP::interpolated_corrected_mean_curvature( - g1, + smesh, mean_curvature_map, CGAL::parameters::ball_radius(0.5).vertex_normal_map(vnm) );*/ - PMP::interpolated_corrected_gaussian_curvature( - g1, - gaussian_curvature_map - ); - PMP::interpolated_corrected_principal_curvatures( - g1, - principal_curvature_map - ); - + // This function can be used to compute multiple curvature types by specifiying them as named parameters + // This is more efficient than computing each one separately (shared computations). PMP::interpolated_corrected_curvatures( - g1, - CGAL::parameters::ball_radius(0) - .vertex_mean_curvature_map(mean_curvature_map) - .vertex_gaussian_curvature_map(gaussian_curvature_map) + smesh, + CGAL::parameters::vertex_mean_curvature_map(mean_curvature_map) .vertex_principal_curvature_map(principal_curvature_map) ); - for (vertex_descriptor v : vertices(g1)) + for (vertex_descriptor v : vertices(smesh)) { auto PC = principal_curvature_map[v]; - std::cout << v.idx() << ": HC = " << mean_curvature_map[v] - << ", GC = " << gaussian_curvature_map[v] << "\n" - << ", PC = [ " << PC.min_curvature << " , " << PC.max_curvature << " ]\n"; + std::cout << v.idx() << ": HC = " << mean_curvature_map[v] + << ", GC = " << gaussian_curvature_map[v] << "\n" + << ", PC = [ " << PC.min_curvature << " , " << PC.max_curvature << " ]\n"; } } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp index 43aff72dec2b..207625fd8485 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp @@ -11,35 +11,43 @@ namespace PMP = CGAL::Polygon_mesh_processing; -typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic_Kernel; -typedef CGAL::Polyhedron_3 Polyhedron; +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic_kernel; +typedef CGAL::Polyhedron_3 Polyhedron; typedef boost::graph_traits::face_descriptor face_descriptor; typedef boost::graph_traits::vertex_descriptor vertex_descriptor; int main(int argc, char* argv[]) { - Polyhedron g1; + Polyhedron polyhedron; const std::string filename = (argc>1) ? argv[1] : CGAL::data_file_path("meshes/small_bunny.obj"); - if(!CGAL::IO::read_polygon_mesh(filename, g1)) + if(!CGAL::IO::read_polygon_mesh(filename, polyhedron)) { std::cerr << "Invalid input file." << std::endl; return EXIT_FAILURE; } - std::unordered_map mean_curvature_map, gaussian_curvature_map; - std::unordered_map> principal_curvature_map; + boost::property_map>::type + mean_curvature_map = get(CGAL::dynamic_vertex_property_t(), polyhedron), + gaussian_curvature_map = get(CGAL::dynamic_vertex_property_t(), polyhedron); + boost::property_map>>::type + principal_curvature_map = get(CGAL::dynamic_vertex_property_t< PMP::Principal_curvature>(), polyhedron); PMP::interpolated_corrected_mean_curvature( - g1, - boost::make_assoc_property_map(mean_curvature_map) + polyhedron, + mean_curvature_map + ); + + PMP::interpolated_corrected_gaussian_curvature( + polyhedron, + gaussian_curvature_map + ); + + PMP::interpolated_corrected_principal_curvatures( + polyhedron, + principal_curvature_map ); // uncomment this to compute a curvature while specifying named parameters @@ -48,27 +56,26 @@ int main(int argc, char* argv[]) /*std::unordered_map vnm; PMP::interpolated_corrected_mean_curvature( - g1, - boost::make_assoc_property_map(mean_curvature_map), + polyhedron, + mean_curvature_map, CGAL::parameters::ball_radius(0.5).vertex_normal_map(boost::make_assoc_property_map(vnm)) );*/ - PMP::interpolated_corrected_gaussian_curvature( - g1, - boost::make_assoc_property_map(gaussian_curvature_map) - ); - PMP::interpolated_corrected_principal_curvatures( - g1, - boost::make_assoc_property_map(principal_curvature_map) + // This function can be used to compute multiple curvature types by specifiying them as named parameters + // This is more efficient than computing each one separately (shared computations). + PMP::interpolated_corrected_curvatures( + polyhedron, + CGAL::parameters::vertex_mean_curvature_map(mean_curvature_map) + .vertex_principal_curvature_map(principal_curvature_map) ); int i = 0; - for (vertex_descriptor v : vertices(g1)) + for (vertex_descriptor v : vertices(polyhedron)) { - auto PC = principal_curvature_map[v]; - std::cout << i << ": HC = " << mean_curvature_map[v] - << ", GC = " << gaussian_curvature_map[v] << "\n" - << ", PC = [ " << std::get<0>(PC) << " , " << std::get<1>(PC) << " ]\n"; + auto PC = get(principal_curvature_map, v); + std::cout << i << ": HC = " << get(mean_curvature_map, v) + << ", GC = " << get(gaussian_curvature_map, v) << "\n" + << ", PC = [ " << PC.min_curvature << " , " << PC.max_curvature << " ]\n"; i++; } } 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 1a0ef9891b00..0ed47db00584 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 @@ -35,11 +35,26 @@ namespace CGAL { namespace Polygon_mesh_processing { +/** +* \ingroup PMP_corrected_curvatures_grp +* +* \brief a struct for storing principal curvatures and directions. +* +* @tparam GT is the geometric traits class. +*/ template struct Principal_curvature { + + /// min curvature magnitude typename GT::FT min_curvature; + + /// max curvature magnitude typename GT::FT max_curvature; + + /// min curvature direction vector typename GT::Vector_3 min_direction; + + /// max curvature direction vector typename GT::Vector_3 max_direction; Principal_curvature() { @@ -373,138 +388,13 @@ std::array interpolated_corrected_anisotropic_measure_fa return muXY; } -//template -// void -// interpolated_corrected_measure_mesh(const PolygonMesh& pmesh, -// FaceMeasureMap fmm, -// const Curvature_measure_index mu_i, -// const NamedParameters& np = parameters::default_values()) -//{ -// -// typedef typename GetGeomTraits::type GT; -// -// typedef dynamic_vertex_property_t Vector_map_tag; -// typedef typename boost::property_map::const_type Default_vector_map; -// typedef typename internal_np::Lookup_named_param_def::type Vertex_normal_map; -// -// using parameters::choose_parameter; -// using parameters::get_parameter; -// using parameters::is_default_parameter; -// -// typedef typename boost::graph_traits::face_descriptor Face_descriptor; -// typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; -// typedef typename boost::graph_traits::halfedge_descriptor Halfedge_descriptor; -// -// typename GetVertexPointMap::const_type -// vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), -// get_const_property_map(CGAL::vertex_point, pmesh)); -// -// Vertex_normal_map 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::function -// &, const std::vector&)> -// iccm_function; -// switch (mu_i) -// { -// case MU0_AREA_MEASURE: -// iccm_function = &interpolated_corrected_area_measure_face; -// break; -// case MU1_MEAN_CURVATURE_MEASURE: -// iccm_function = &interpolated_corrected_mean_curvature_measure_face; -// break; -// case MU2_GAUSSIAN_CURVATURE_MEASURE: -// iccm_function = &interpolated_corrected_gaussian_curvature_measure_face; -// break; -// } -// -// std::vector x; -// std::vector u; -// -// for (Face_descriptor f : faces(pmesh)) -// { -// -// for (Vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) -// { -// typename GT::Point_3 p = get(vpm, v); -// x.push_back(typename GT::Vector_3(p.x(), p.y(), p.z())); -// u.push_back(get(vnm, v)); -// } -// -// put(fmm, f, iccm_function(u, x)); -// x.clear(); -// u.clear(); -// } -//} -// -//template -// void -// interpolated_corrected_anisotropic_measure_mesh(const PolygonMesh& pmesh, -// FaceMeasureMap fmm, -// const NamedParameters& np = parameters::default_values()) -//{ -// -// typedef typename GetGeomTraits::type GT; -// -// typedef dynamic_vertex_property_t Vector_map_tag; -// typedef typename boost::property_map::const_type Default_vector_map; -// typedef typename internal_np::Lookup_named_param_def::type VertexNormalMap; -// -// using parameters::choose_parameter; -// using parameters::get_parameter; -// using parameters::is_default_parameter; -// -// typedef typename boost::graph_traits::face_descriptor Face_descriptor; -// typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; -// typedef typename boost::graph_traits::halfedge_descriptor Halfedge_descriptor; -// -// typename GetVertexPointMap::const_type -// vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), -// get_const_property_map(CGAL::vertex_point, pmesh)); -// -// VertexNormalMap 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 x; -// std::vector u; -// -// for (Face_descriptor f : faces(pmesh)) -// { -// -// for (Vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) -// { -// typename GT::Point_3 p = get(vpm, v); -// x.push_back(typename GT::Vector_3(p.x(), p.y(), p.z())); -// u.push_back(get(vnm, v)); -// } -// -// put(fmm, f, interpolated_corrected_anisotropic_measure_face(u, x)); -// x.clear(); -// u.clear(); -// -// } -//} - -// //template -//typename GT::FT triangle_in_ball_ratio_1(const typename GT::Vector_3 x1, -// const typename GT::Vector_3 x2, -// const typename GT::Vector_3 x3, -// const typename GT::FT r, -// const typename GT::Vector_3 c, -// const std::size_t res = 3) +//typename GT::FT triangle_in_ball_ratio(const typename GT::Vector_3 x1, +// const typename GT::Vector_3 x2, +// const typename GT::Vector_3 x3, +// const typename GT::FT r, +// const typename GT::Vector_3 c, +// const std::size_t res = 3) //{ // const typename GT::FT R = r * r; // const typename GT::FT acc = 1.0 / res; @@ -549,162 +439,6 @@ typename GT::FT face_in_ball_ratio(const std::vector& x, return (r - d_min) / (d_max - d_min); } -//template -// void expand_interpolated_corrected_measure_vertex(const PolygonMesh& pmesh, -// FaceMeasureMap area_fmm, -// FaceMeasureMap curvature_fmm, -// VertexMeasureMap area_vmm, -// VertexMeasureMap curvature_vmm, -// const typename boost::graph_traits::vertex_descriptor v, -// const NamedParameters& np = parameters::default_values()) -//{ -// using parameters::choose_parameter; -// using parameters::get_parameter; -// -// typedef typename GetGeomTraits::type GT; -// -// typedef typename boost::graph_traits::face_descriptor Face_descriptor; -// typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; -// -// const typename GT::FT -// r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0); -// -// typename GetVertexPointMap::const_type -// vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), -// get_const_property_map(CGAL::vertex_point, pmesh)); -// -// -// std::queue bfs_queue; -// std::unordered_set bfs_visited; -// -// typename GT::Point_3 vp = get(vpm, v); -// typename GT::Vector_3 c = typename GT::Vector_3(vp.x(), vp.y(), vp.z()); -// -// typename GT::FT corrected_mu0 = 0; -// typename GT::FT corrected_mui = 0; -// -// for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { -// if (f != boost::graph_traits::null_face()) -// { -// bfs_queue.push(f); -// bfs_visited.insert(f); -// } -// } -// while (!bfs_queue.empty()) { -// Face_descriptor fi = bfs_queue.front(); -// bfs_queue.pop(); -// -// // looping over vertices in face to get point coordinates -// std::vector x; -// for (Vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh)) -// { -// typename GT::Point_3 pi = get(vpm, vi); -// x.push_back(typename GT::Vector_3(pi.x(), pi.y(), pi.z())); -// } -// -// const typename GT::FT f_ratio = face_in_ball_ratio(x, r, c); -// -// if (f_ratio != 0.0) -// { -// corrected_mu0 += f_ratio * get(area_fmm, fi); -// corrected_mui += f_ratio * get(curvature_fmm, fi); -// for (Face_descriptor fj : faces_around_face(halfedge(fi, pmesh), pmesh)) -// { -// if (bfs_visited.find(fj) == bfs_visited.end() && fj != boost::graph_traits::null_face()) -// { -// bfs_queue.push(fj); -// bfs_visited.insert(fj); -// } -// } -// } -// } -// put(area_vmm, v, corrected_mu0); -// put(curvature_vmm, v, corrected_mui); -//} -// -//template -// void expand_interpolated_corrected_anisotropic_measure_vertex(const PolygonMesh& pmesh, -// AreaFaceMeasureMap area_fmm, -// AnisotropicFaceMeasureMap aniso_fmm, -// AreaVertexMeasureMap area_vmm, -// AnisotropicVertexMeasureMap aniso_vmm, -// const typename boost::graph_traits::vertex_descriptor v, -// const NamedParameters& np = parameters::default_values()) -//{ -// using parameters::choose_parameter; -// using parameters::get_parameter; -// -// typedef typename GetGeomTraits::type GT; -// -// typedef typename boost::graph_traits::face_descriptor Face_descriptor; -// typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; -// -// const typename GT::FT -// r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0); -// -// typename GetVertexPointMap::const_type -// vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), -// get_const_property_map(CGAL::vertex_point, pmesh)); -// -// -// std::queue bfs_queue; -// std::unordered_set bfs_visited; -// -// typename GT::Point_3 vp = get(vpm, v); -// typename GT::Vector_3 c = typename GT::Vector_3(vp.x(), vp.y(), vp.z()); -// -// typename GT::FT corrected_mu0 = 0; -// Eigen::Matrix corrected_muXY = Eigen::Matrix::Zero(); -// -// for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { -// if (f != boost::graph_traits::null_face()) -// { -// bfs_queue.push(f); -// bfs_visited.insert(f); -// } -// } -// while (!bfs_queue.empty()) { -// Face_descriptor fi = bfs_queue.front(); -// bfs_queue.pop(); -// -// // looping over vertices in face to get point coordinates -// std::vector x; -// for (Vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh)) -// { -// typename GT::Point_3 pi = get(vpm, vi); -// x.push_back(typename GT::Vector_3(pi.x(), pi.y(), pi.z())); -// } -// -// const typename GT::FT f_ratio = face_in_ball_ratio(x, r, c); -// -// if (f_ratio != 0.0) -// { -// corrected_mu0 += f_ratio * get(area_fmm, fi); -// -// std::array muXY_face = get(aniso_fmm, fi); -// -// for (std::size_t ix = 0; ix < 3; ix++) -// for (std::size_t iy = 0; iy < 3; iy++) -// corrected_muXY(ix, iy) += f_ratio * muXY_face[ix * 3 + iy]; -// -// for (Face_descriptor fj : faces_around_face(halfedge(fi, pmesh), pmesh)) -// { -// if (bfs_visited.find(fj) == bfs_visited.end() && fj != boost::graph_traits::null_face()) -// { -// bfs_queue.push(fj); -// bfs_visited.insert(fj); -// } -// } -// } -// } -// put(area_vmm, v, corrected_mu0); -// put(aniso_vmm, v, corrected_muXY); -//} - - template Principal_curvature principal_curvature_from_anisotropic_measures( const std::array anisotropic_measure, @@ -1208,12 +942,11 @@ template::%Vertex_descriptor` +* as key type and `%FT` as value type} +* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} +* \cgalParamExtra{If this parameter is omitted, mean curvatures won't be computed} +* \cgalParamNEnd +* +* \cgalParamNBegin{vertex_gaussian_curvature_map} +* \cgalParamDescription{a property map associating mean curvatures to the vertices of `pmesh`} +* \cgalParamType{a class model of `WritablePropertyMap` with +* `boost::graph_traits::%Vertex_descriptor` +* as key type and `%FT` as value type} +* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} +* \cgalParamExtra{If this parameter is omitted, gaussian curvatures won't be computed} +* \cgalParamNEnd +* +* +* \cgalParamNBegin{vertex_prinicipal_curvature_map} +* \cgalParamDescription{a property map associating mean curvatures to the vertices of `pmesh`} +* \cgalParamType{a class model of `WritablePropertyMap` with +* `boost::graph_traits::%Vertex_descriptor` +* as key type and `%Principal_curvature` as value type} +* \cgalParamDefault{`get(dynamic_vertex_property_t>(), pmesh)`} +* \cgalParamExtra{If this parameter is omitted, mean principal won't be computed} +* \cgalParamNEnd * * \cgalParamNBegin{ball_radius} * \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures * by summing measures of faces inside a ball of this radius centered at the * vertex expanded from. The summed face measures are weighted by their -* inclusion ratio inside this ball} +* inclusion ratio inside this ball.} * \cgalParamType{`GT::FT`} * \cgalParamDefault{`-1`} -* \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of +* \cgalParamExtra{If this parameter is omitted (`-1`), the epansion is then just a sum of * measures on faces around the vertex} * \cgalParamNEnd * From 59c3605a0689e20a54a8998d9ed3296fd8862cbb Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 14 Nov 2022 11:28:37 +0200 Subject: [PATCH 077/142] trailing whitespace --- .../interpolated_corrected_curvature_measures.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 0ed47db00584..5bcff27cc2ee 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 @@ -37,14 +37,14 @@ namespace Polygon_mesh_processing { /** * \ingroup PMP_corrected_curvatures_grp -* +* * \brief a struct for storing principal curvatures and directions. * * @tparam GT is the geometric traits class. */ template struct Principal_curvature { - + /// min curvature magnitude typename GT::FT min_curvature; @@ -976,7 +976,7 @@ template(), pmesh)`} * \cgalParamExtra{If this parameter is omitted, gaussian curvatures won't be computed} * \cgalParamNEnd -* +* * * \cgalParamNBegin{vertex_prinicipal_curvature_map} * \cgalParamDescription{a property map associating mean curvatures to the vertices of `pmesh`} From b0a82c4569c6f9483ed45f76f2224f9b9212fad8 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 14 Nov 2022 11:37:14 +0200 Subject: [PATCH 078/142] typo fix --- .../Curvatures/interpolated_corrected_curvature_measures.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 5bcff27cc2ee..9da751c7f83b 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 @@ -996,7 +996,7 @@ template::%Vertex_descriptor` From 25eb94f1ec4996a46ec443888e768ff3e9ba6dd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 14 Nov 2022 14:24:24 +0100 Subject: [PATCH 079/142] force copy fig --- .../doc/Polygon_mesh_processing/Doxyfile.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Doxyfile.in b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Doxyfile.in index fa3b8b8f1bf5..f2e738b4d23c 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Doxyfile.in +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Doxyfile.in @@ -21,4 +21,5 @@ EXCLUDE_SYMBOLS += experimental HTML_EXTRA_FILES = ${CGAL_PACKAGE_DOC_DIR}/fig/selfintersections.jpg \ ${CGAL_PACKAGE_DOC_DIR}/fig/mesh_smoothing.png \ - ${CGAL_PACKAGE_DOC_DIR}/fig/shape_smoothing.png + ${CGAL_PACKAGE_DOC_DIR}/fig/shape_smoothing.png \ + ${CGAL_PACKAGE_DOC_DIR}/fig/icc_diff_radius.png From b56500d0fc8edbf4971c367bfbde6a9d2dd1a915 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Wed, 16 Nov 2022 12:51:14 +0200 Subject: [PATCH 080/142] 4-space -> 2-space indents --- ...erpolated_corrected_curvatures_example.cpp | 36 +- ...orrected_curvatures_polyhedron_example.cpp | 26 +- ...nterpolated_corrected_curvature_measures.h | 920 +++++++++--------- ...est_interopolated_corrected_curvatures.cpp | 226 ++--- .../Display/Display_property_plugin.cpp | 214 ++-- 5 files changed, 708 insertions(+), 714 deletions(-) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp index ffb86d94795c..7bf182c3ce3d 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp @@ -18,11 +18,11 @@ typedef boost::graph_traits::vertex_descriptor vertex_descriptor; int main(int argc, char* argv[]) { Surface_Mesh smesh; - const std::string filename = (argc>1) ? - argv[1] : - CGAL::data_file_path("meshes/small_bunny.obj"); + const std::string filename = (argc > 1) ? + argv[1] : + CGAL::data_file_path("meshes/small_bunny.obj"); - if(!CGAL::IO::read_polygon_mesh(filename, smesh)) + if (!CGAL::IO::read_polygon_mesh(filename, smesh)) { std::cerr << "Invalid input file." << std::endl; return EXIT_FAILURE; @@ -41,25 +41,25 @@ int main(int argc, char* argv[]) Surface_Mesh::Property_map> principal_curvature_map; boost::tie(principal_curvature_map, created) = smesh.add_property_map> - ("v:principal_curvature_map", { 0, 0, - Epic_kernel::Vector_3(0,0,0), - Epic_kernel::Vector_3(0,0,0) }); + ("v:principal_curvature_map", { 0, 0, + Epic_kernel::Vector_3(0,0,0), + Epic_kernel::Vector_3(0,0,0) }); assert(created); // user can call these fucntions to compute a specfic curvature type on each vertex. PMP::interpolated_corrected_mean_curvature( - smesh, - mean_curvature_map + smesh, + mean_curvature_map ); PMP::interpolated_corrected_gaussian_curvature( - smesh, - gaussian_curvature_map + smesh, + gaussian_curvature_map ); PMP::interpolated_corrected_principal_curvatures( - smesh, - principal_curvature_map + smesh, + principal_curvature_map ); // uncomment this to compute a curvature while specifying named parameters @@ -81,16 +81,16 @@ int main(int argc, char* argv[]) // This function can be used to compute multiple curvature types by specifiying them as named parameters // This is more efficient than computing each one separately (shared computations). PMP::interpolated_corrected_curvatures( - smesh, - CGAL::parameters::vertex_mean_curvature_map(mean_curvature_map) - .vertex_principal_curvature_map(principal_curvature_map) + smesh, + CGAL::parameters::vertex_mean_curvature_map(mean_curvature_map) + .vertex_principal_curvature_map(principal_curvature_map) ); for (vertex_descriptor v : vertices(smesh)) { auto PC = principal_curvature_map[v]; std::cout << v.idx() << ": HC = " << mean_curvature_map[v] - << ", GC = " << gaussian_curvature_map[v] << "\n" - << ", PC = [ " << PC.min_curvature << " , " << PC.max_curvature << " ]\n"; + << ", GC = " << gaussian_curvature_map[v] << "\n" + << ", PC = [ " << PC.min_curvature << " , " << PC.max_curvature << " ]\n"; } } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp index 207625fd8485..929fc8d96a67 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp @@ -16,14 +16,12 @@ typedef CGAL::Polyhedron_3 Polyhedron; typedef boost::graph_traits::face_descriptor face_descriptor; typedef boost::graph_traits::vertex_descriptor vertex_descriptor; -int main(int argc, char* argv[]) +int main(int argc, char *argv[]) { Polyhedron polyhedron; - const std::string filename = (argc>1) ? - argv[1] : - CGAL::data_file_path("meshes/small_bunny.obj"); + const std::string filename = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/small_bunny.obj"); - if(!CGAL::IO::read_polygon_mesh(filename, polyhedron)) + if (!CGAL::IO::read_polygon_mesh(filename, polyhedron)) { std::cerr << "Invalid input file." << std::endl; return EXIT_FAILURE; @@ -33,22 +31,19 @@ int main(int argc, char* argv[]) mean_curvature_map = get(CGAL::dynamic_vertex_property_t(), polyhedron), gaussian_curvature_map = get(CGAL::dynamic_vertex_property_t(), polyhedron); boost::property_map>>::type - principal_curvature_map = get(CGAL::dynamic_vertex_property_t< PMP::Principal_curvature>(), polyhedron); + principal_curvature_map = get(CGAL::dynamic_vertex_property_t>(), polyhedron); PMP::interpolated_corrected_mean_curvature( polyhedron, - mean_curvature_map - ); + mean_curvature_map); PMP::interpolated_corrected_gaussian_curvature( polyhedron, - gaussian_curvature_map - ); + gaussian_curvature_map); PMP::interpolated_corrected_principal_curvatures( polyhedron, - principal_curvature_map - ); + principal_curvature_map); // uncomment this to compute a curvature while specifying named parameters // Example: an expansion ball radius of 0.5 and a vertex normals map (does not have to depend on positions) @@ -66,16 +61,15 @@ int main(int argc, char* argv[]) PMP::interpolated_corrected_curvatures( polyhedron, CGAL::parameters::vertex_mean_curvature_map(mean_curvature_map) - .vertex_principal_curvature_map(principal_curvature_map) - ); + .vertex_principal_curvature_map(principal_curvature_map)); int i = 0; for (vertex_descriptor v : vertices(polyhedron)) { auto PC = get(principal_curvature_map, v); std::cout << i << ": HC = " << get(mean_curvature_map, v) - << ", GC = " << get(gaussian_curvature_map, v) << "\n" - << ", PC = [ " << PC.min_curvature << " , " << PC.max_curvature << " ]\n"; + << ", GC = " << get(gaussian_curvature_map, v) << "\n" + << ", PC = [ " << PC.min_curvature << " , " << PC.max_curvature << " ]\n"; i++; } } 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 9da751c7f83b..4006b761679f 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 @@ -45,74 +45,74 @@ namespace Polygon_mesh_processing { template struct Principal_curvature { - /// min curvature magnitude - typename GT::FT min_curvature; - - /// max curvature magnitude - typename GT::FT max_curvature; - - /// min curvature direction vector - typename GT::Vector_3 min_direction; - - /// max curvature direction vector - typename GT::Vector_3 max_direction; - - Principal_curvature() { - min_curvature = 0; - max_curvature = 0; - min_direction = typename GT::Vector_3(0, 0, 0); - max_direction = typename GT::Vector_3(0, 0, 0); - } - - Principal_curvature( - typename GT::FT min_curvature, - typename GT::FT max_curvature, - typename GT::Vector_3 min_direction, - typename GT::Vector_3 max_direction) { - this->min_curvature = min_curvature; - this->max_curvature = max_curvature; - this->min_direction = min_direction; - this->max_direction = max_direction; - } + /// min curvature magnitude + typename GT::FT min_curvature; + + /// max curvature magnitude + typename GT::FT max_curvature; + + /// min curvature direction vector + typename GT::Vector_3 min_direction; + + /// max curvature direction vector + typename GT::Vector_3 max_direction; + + Principal_curvature() { + min_curvature = 0; + max_curvature = 0; + min_direction = typename GT::Vector_3(0, 0, 0); + max_direction = typename GT::Vector_3(0, 0, 0); + } + + Principal_curvature( + typename GT::FT min_curvature, + typename GT::FT max_curvature, + typename GT::Vector_3 min_direction, + typename GT::Vector_3 max_direction + ) { + min_curvature = min_curvature; + max_curvature = max_curvature; + min_direction = min_direction; + max_direction = max_direction; + } }; namespace internal { -template -typename GT::FT average_edge_length(const PolygonMesh& pmesh) -{ + template + typename GT::FT average_edge_length(const PolygonMesh& pmesh) { const std::size_t n = edges(pmesh).size(); if (n == 0) - return 0; + return 0; typename GT::FT avg_edge_length = 0; for (auto e : edges(pmesh)) - avg_edge_length += edge_length(e, pmesh); + avg_edge_length += edge_length(e, pmesh); avg_edge_length /= n; return avg_edge_length; -} + } -enum Curvature_measure_index { + enum Curvature_measure_index { MU0_AREA_MEASURE, ///< corrected area density MU1_MEAN_CURVATURE_MEASURE, ///< corrected mean curvature density MU2_GAUSSIAN_CURVATURE_MEASURE ///< corrected gaussian curvature density -}; + }; -template -struct Vertex_measures { + template + struct Vertex_measures { typename GT::FT area_measure = 0; typename GT::FT mean_curvature_measure = 0; typename GT::FT gaussian_curvature_measure = 0; std::array anisotropic_measure = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -}; + }; -template -typename GT::FT interpolated_corrected_area_measure_face(const std::vector& u, - const std::vector& x = {}) -{ + template + typename GT::FT interpolated_corrected_area_measure_face(const std::vector& u, + const std::vector& x = {}) + { const std::size_t n = x.size(); CGAL_precondition(u.size() == n); CGAL_precondition(n >= 3); @@ -122,52 +122,52 @@ typename GT::FT interpolated_corrected_area_measure_face(const std::vector( - std::vector {u[i], u[(i + 1) % n], uc}, - std::vector {x[i], x[(i + 1) % n], xc} - ); - } - return mu0; + // getting center of points + typename GT::Vector_3 xc = + std::accumulate(x.begin(), x.end(), typename GT::Vector_3(0, 0, 0)); + xc /= n; + + // getting unit average normal of points + typename GT::Vector_3 uc = + std::accumulate(u.begin(), u.end(), typename GT::Vector_3(0, 0, 0)); + uc /= sqrt(uc * uc); + + // summing each triangle's measure after triangulation by barycenter split. + for (std::size_t i = 0; i < n; i++) + { + mu0 += interpolated_corrected_area_measure_face( + std::vector {u[i], u[(i + 1) % n], uc}, + std::vector {x[i], x[(i + 1) % n], xc} + ); + } + return mu0; } -} + } -template -typename GT::FT interpolated_corrected_mean_curvature_measure_face(const std::vector& u, - const std::vector& x = {}) -{ + template + typename GT::FT interpolated_corrected_mean_curvature_measure_face(const std::vector& u, + const std::vector& x = {}) + { const std::size_t n = x.size(); CGAL_precondition(u.size() == n); CGAL_precondition(n >= 3); @@ -177,63 +177,63 @@ typename GT::FT interpolated_corrected_mean_curvature_measure_face(const std::ve // Triangle: use triangle formula if (n == 3) { - const typename GT::Vector_3 um = (u[0] + u[1] + u[2]) / 3.0; + const typename GT::Vector_3 um = (u[0] + u[1] + u[2]) / 3.0; - return 0.5 * um * (cross_product(u[2] - u[1], x[0]) - + cross_product(u[0] - u[2], x[1]) - + cross_product(u[1] - u[0], x[2])); + return 0.5 * um * (cross_product(u[2] - u[1], x[0]) + + cross_product(u[0] - u[2], x[1]) + + cross_product(u[1] - u[0], x[2])); } // Quad: use bilinear interpolation formula else if (n == 4) { - // for the formulas below, values of verices 2 & 3 are swapped (compared to paper) to correct order. - // the indices in paper vs in here are: 00 = 0, 10 = 1, 11 = 2, 01 = 3 - - const typename GT::Vector_3 u02 = u[2] - u[0]; - const typename GT::Vector_3 u13 = u[3] - u[1]; - const typename GT::Vector_3 x0_cross = cross_product(u13, x[0]); - const typename GT::Vector_3 x1_cross = -cross_product(u02, x[1]); - const typename GT::Vector_3 x3_cross = cross_product(u02, x[3]); - const typename GT::Vector_3 x2_cross = -cross_product(u13, x[2]); - - return (1.0 / 12.0) * ( - u[0] * (2 * x0_cross - cross_product((u[3] + u[2]), x[1]) + cross_product((u[1] + u[2]), x[3]) + x2_cross) - + u[1] * (cross_product((u[3] + u[2]), x[0]) + 2 * x1_cross + x3_cross - cross_product((u[0] + u[3]), x[2])) - + u[3] * (-cross_product((u[1] + u[2]), x[0]) + x1_cross + 2 * x3_cross + cross_product((u[0] + u[1]), x[2])) - + u[2] * (x0_cross + cross_product((u[0] + u[3]), x[1]) - cross_product((u[0] + u[1]), x[3]) + 2 * x2_cross) - ); + // for the formulas below, values of verices 2 & 3 are swapped (compared to paper) to correct order. + // the indices in paper vs in here are: 00 = 0, 10 = 1, 11 = 2, 01 = 3 + + const typename GT::Vector_3 u02 = u[2] - u[0]; + const typename GT::Vector_3 u13 = u[3] - u[1]; + const typename GT::Vector_3 x0_cross = cross_product(u13, x[0]); + const typename GT::Vector_3 x1_cross = -cross_product(u02, x[1]); + const typename GT::Vector_3 x3_cross = cross_product(u02, x[3]); + const typename GT::Vector_3 x2_cross = -cross_product(u13, x[2]); + + return (1.0 / 12.0) * ( + u[0] * (2 * x0_cross - cross_product((u[3] + u[2]), x[1]) + cross_product((u[1] + u[2]), x[3]) + x2_cross) + + u[1] * (cross_product((u[3] + u[2]), x[0]) + 2 * x1_cross + x3_cross - cross_product((u[0] + u[3]), x[2])) + + u[3] * (-cross_product((u[1] + u[2]), x[0]) + x1_cross + 2 * x3_cross + cross_product((u[0] + u[1]), x[2])) + + u[2] * (x0_cross + cross_product((u[0] + u[3]), x[1]) - cross_product((u[0] + u[1]), x[3]) + 2 * x2_cross) + ); } // N-gon: split into n triangles by polygon center and use triangle formula for each else { - typename GT::FT mu1 = 0; + typename GT::FT mu1 = 0; - // getting center of points - typename GT::Vector_3 xc = - std::accumulate(x.begin(), x.end(), typename GT::Vector_3(0, 0, 0)); - xc /= n; - - // getting unit average normal of points - typename GT::Vector_3 uc = - std::accumulate(u.begin(), u.end(), typename GT::Vector_3(0, 0, 0)); - uc /= sqrt(uc * uc); - - // summing each triangle's measure after triangulation by barycenter split. - for (std::size_t i = 0; i < n; i++) - { - mu1 += interpolated_corrected_mean_curvature_measure_face( - std::vector {u[i], u[(i + 1) % n], uc}, - std::vector {x[i], x[(i + 1) % n], xc} - ); - } - return mu1; + // getting center of points + typename GT::Vector_3 xc = + std::accumulate(x.begin(), x.end(), typename GT::Vector_3(0, 0, 0)); + xc /= n; + + // getting unit average normal of points + typename GT::Vector_3 uc = + std::accumulate(u.begin(), u.end(), typename GT::Vector_3(0, 0, 0)); + uc /= sqrt(uc * uc); + + // summing each triangle's measure after triangulation by barycenter split. + for (std::size_t i = 0; i < n; i++) + { + mu1 += interpolated_corrected_mean_curvature_measure_face( + std::vector {u[i], u[(i + 1) % n], uc}, + std::vector {x[i], x[(i + 1) % n], xc} + ); + } + return mu1; } -} + } -template -typename GT::FT interpolated_corrected_gaussian_curvature_measure_face(const std::vector& u, - const std::vector& x = {}) -{ + template + typename GT::FT interpolated_corrected_gaussian_curvature_measure_face(const std::vector& u, + const std::vector& x = {}) + { const std::size_t n = u.size(); CGAL_precondition(n >= 3); @@ -242,182 +242,182 @@ typename GT::FT interpolated_corrected_gaussian_curvature_measure_face(const std // Triangle: use triangle formula if (n == 3) { - return 0.5 * u[0] * cross_product(u[1], u[2]); + return 0.5 * u[0] * cross_product(u[1], u[2]); } // Quad: use bilinear interpolation formula else if (n == 4) { - // for the formulas below, values of verices 2 & 3 are swapped (compared to paper) to correct order. - // the indices in paper vs in here are: 00 = 0, 10 = 1, 11 = 2, 01 = 3 - return (1.0 / 36.0) * ( - (4 * u[0] + 2 * u[1] + 2 * u[3] + u[2]) * cross_product(u[1] - u[0], u[3] - u[0]) - + (2 * u[0] + 4 * u[1] + u[3] + 2 * u[2]) * cross_product(u[1] - u[0], u[2] - u[1]) - + (2 * u[0] + u[1] + 4 * u[3] + 2 * u[2]) * cross_product(u[2] - u[3], u[3] - u[0]) - + (u[0] + 2 * u[1] + 2 * u[3] + 4 * u[2]) * cross_product(u[2] - u[3], u[2] - u[1]) - ); + // for the formulas below, values of verices 2 & 3 are swapped (compared to paper) to correct order. + // the indices in paper vs in here are: 00 = 0, 10 = 1, 11 = 2, 01 = 3 + return (1.0 / 36.0) * ( + (4 * u[0] + 2 * u[1] + 2 * u[3] + u[2]) * cross_product(u[1] - u[0], u[3] - u[0]) + + (2 * u[0] + 4 * u[1] + u[3] + 2 * u[2]) * cross_product(u[1] - u[0], u[2] - u[1]) + + (2 * u[0] + u[1] + 4 * u[3] + 2 * u[2]) * cross_product(u[2] - u[3], u[3] - u[0]) + + (u[0] + 2 * u[1] + 2 * u[3] + 4 * u[2]) * cross_product(u[2] - u[3], u[2] - u[1]) + ); } // N-gon: split into n triangles by polygon center and use triangle formula for each else { - typename GT::FT mu2 = 0; - - // getting unit average normal of points - typename GT::Vector_3 uc = - std::accumulate(u.begin(), u.end(), typename GT::Vector_3(0, 0, 0)); - uc /= sqrt(uc * uc); - - // summing each triangle's measure after triangulation by barycenter split. - for (std::size_t i = 0; i < n; i++) - { - mu2 += interpolated_corrected_gaussian_curvature_measure_face( - std::vector {u[i], u[(i + 1) % n], uc} - ); - } - return mu2; + typename GT::FT mu2 = 0; + + // getting unit average normal of points + typename GT::Vector_3 uc = + std::accumulate(u.begin(), u.end(), typename GT::Vector_3(0, 0, 0)); + uc /= sqrt(uc * uc); + + // summing each triangle's measure after triangulation by barycenter split. + for (std::size_t i = 0; i < n; i++) + { + mu2 += interpolated_corrected_gaussian_curvature_measure_face( + std::vector {u[i], u[(i + 1) % n], uc} + ); + } + return mu2; } -} + } -template -std::array interpolated_corrected_anisotropic_measure_face(const std::vector& u, - const std::vector& x) -{ + template + std::array interpolated_corrected_anisotropic_measure_face(const std::vector& u, + const std::vector& x) + { const std::size_t n = x.size(); CGAL_precondition(u.size() == n); CGAL_precondition(n >= 3); typename GT::Construct_cross_product_vector_3 cross_product; - std::array muXY {0}; + std::array muXY{ 0 }; // Triangle: use triangle formula if (n == 3) { - const typename GT::Vector_3 u01 = u[1] - u[0]; - const typename GT::Vector_3 u02 = u[2] - u[0]; - const typename GT::Vector_3 x01 = x[1] - x[0]; - const typename GT::Vector_3 x02 = x[2] - x[0]; - const typename GT::Vector_3 um = (u[0] + u[1] + u[2]) / 3.0; + const typename GT::Vector_3 u01 = u[1] - u[0]; + const typename GT::Vector_3 u02 = u[2] - u[0]; + const typename GT::Vector_3 x01 = x[1] - x[0]; + const typename GT::Vector_3 x02 = x[2] - x[0]; + const typename GT::Vector_3 um = (u[0] + u[1] + u[2]) / 3.0; + + for (std::size_t ix = 0; ix < 3; ix++) + { + typename GT::Vector_3 X; + if (ix == 0) + X = typename GT::Vector_3(1, 0, 0); + if (ix == 1) + X = typename GT::Vector_3(0, 1, 0); + if (ix == 2) + X = typename GT::Vector_3(0, 0, 1); - for (std::size_t ix = 0; ix < 3; ix++) - { - typename GT::Vector_3 X; - if (ix == 0) - X = typename GT::Vector_3(1, 0, 0); - if (ix == 1) - X = typename GT::Vector_3(0, 1, 0); - if (ix == 2) - X = typename GT::Vector_3(0, 0, 1); - - for (std::size_t iy = 0; iy < 3; iy++) - muXY[ix * 3 + iy] = 0.5 * um * (cross_product(u02[iy] * X, x01) - cross_product(u01[iy] * X, x02)); - } + for (std::size_t iy = 0; iy < 3; iy++) + muXY[ix * 3 + iy] = 0.5 * um * (cross_product(u02[iy] * X, x01) - cross_product(u01[iy] * X, x02)); + } } // Quad: use bilinear interpolation formula else if (n == 4) { - // for the formulas below, values of verices 2 & 3 are swapped (compared to paper) to correct order. - // the indices in paper vs in here are: 00 = 0, 10 = 1, 11 = 2, 01 = 3 - for (std::size_t ix = 0; ix < 3; ix++) - { - typename GT::Vector_3 X; - if (ix == 0) - X = typename GT::Vector_3(1, 0, 0); - if (ix == 1) - X = typename GT::Vector_3(0, 1, 0); - if (ix == 2) - X = typename GT::Vector_3(0, 0, 1); - - const typename GT::Vector_3 u0xX = cross_product(u[0], X); - const typename GT::Vector_3 u1xX = cross_product(u[1], X); - const typename GT::Vector_3 u2xX = cross_product(u[2], X); - const typename GT::Vector_3 u3xX = cross_product(u[3], X); - - for (std::size_t iy = 0; iy < 3; iy++) - muXY[ix * 3 + iy] = (1.0 / 72.0) * ( - - u[0][iy] * ( u0xX * ( - x[0] - 11 * x[1] + 13 * x[3] - x[2]) - + u1xX * ( -5 * x[0] - 7 * x[1] + 11 * x[3] + x[2]) - + u3xX * ( x[0] - 7 * x[1] + 11 * x[3] - 5 * x[2]) - + u2xX * ( - x[0] - 5 * x[1] + 7 * x[3] - x[2]) - ) - + u[1][iy] * ( u0xX * ( 13 * x[0] - x[1] - 7 * x[3] - 5 * x[2]) - + u1xX * ( 17 * x[0] - 5 * x[1] - 5 * x[3] - 7 * x[2]) - + u3xX * ( 5 * x[0] + x[1] + x[3] - 7 * x[2]) - + u2xX * ( 7 * x[0] - x[1] + 5 * x[3] - 11 * x[2]) - ) - + u[2][iy] * ( u0xX * (-11 * x[0] + 5 * x[1] - x[3] + 7 * x[2]) - + u1xX * (- 7 * x[0] + x[1] + x[3] + 5 * x[2]) - + u3xX * (- 7 * x[0] - 5 * x[1] - 5 * x[3] + 17 * x[2]) - + u2xX * (- 5 * x[0] - 7 * x[1] - x[3] + 13 * x[2]) - ) - + u[3][iy] * ( u0xX * (- x[0] + 7 * x[1] - 5 * x[3] - x[2]) - + u1xX * (- 5 * x[0] + 11 * x[1] - 7 * x[3] + x[2]) - + u3xX * ( x[0] + 11 * x[1] - 7 * x[3] - 5 * x[2]) - + u2xX * (- x[0] + 13 * x[1] - 11 * x[3] - x[2]) - ) - - ); - } + // for the formulas below, values of verices 2 & 3 are swapped (compared to paper) to correct order. + // the indices in paper vs in here are: 00 = 0, 10 = 1, 11 = 2, 01 = 3 + for (std::size_t ix = 0; ix < 3; ix++) + { + typename GT::Vector_3 X; + if (ix == 0) + X = typename GT::Vector_3(1, 0, 0); + if (ix == 1) + X = typename GT::Vector_3(0, 1, 0); + if (ix == 2) + X = typename GT::Vector_3(0, 0, 1); + + const typename GT::Vector_3 u0xX = cross_product(u[0], X); + const typename GT::Vector_3 u1xX = cross_product(u[1], X); + const typename GT::Vector_3 u2xX = cross_product(u[2], X); + const typename GT::Vector_3 u3xX = cross_product(u[3], X); + + for (std::size_t iy = 0; iy < 3; iy++) + muXY[ix * 3 + iy] = (1.0 / 72.0) * ( + + u[0][iy] * (u0xX * (-x[0] - 11 * x[1] + 13 * x[3] - x[2]) + + u1xX * (-5 * x[0] - 7 * x[1] + 11 * x[3] + x[2]) + + u3xX * (x[0] - 7 * x[1] + 11 * x[3] - 5 * x[2]) + + u2xX * (-x[0] - 5 * x[1] + 7 * x[3] - x[2]) + ) + + u[1][iy] * (u0xX * (13 * x[0] - x[1] - 7 * x[3] - 5 * x[2]) + + u1xX * (17 * x[0] - 5 * x[1] - 5 * x[3] - 7 * x[2]) + + u3xX * (5 * x[0] + x[1] + x[3] - 7 * x[2]) + + u2xX * (7 * x[0] - x[1] + 5 * x[3] - 11 * x[2]) + ) + + u[2][iy] * (u0xX * (-11 * x[0] + 5 * x[1] - x[3] + 7 * x[2]) + + u1xX * (-7 * x[0] + x[1] + x[3] + 5 * x[2]) + + u3xX * (-7 * x[0] - 5 * x[1] - 5 * x[3] + 17 * x[2]) + + u2xX * (-5 * x[0] - 7 * x[1] - x[3] + 13 * x[2]) + ) + + u[3][iy] * (u0xX * (-x[0] + 7 * x[1] - 5 * x[3] - x[2]) + + u1xX * (-5 * x[0] + 11 * x[1] - 7 * x[3] + x[2]) + + u3xX * (x[0] + 11 * x[1] - 7 * x[3] - 5 * x[2]) + + u2xX * (-x[0] + 13 * x[1] - 11 * x[3] - x[2]) + ) + + ); + } } // N-gon: split into n triangles by polygon center and use triangle formula for each else { - // getting center of points - typename GT::Vector_3 xc = - std::accumulate(x.begin(), x.end(), typename GT::Vector_3(0, 0, 0)); - xc /= n; - - // getting unit average normal of points - typename GT::Vector_3 uc = - std::accumulate(u.begin(), u.end(), typename GT::Vector_3(0, 0, 0)); - uc /= sqrt(uc * uc); - - // summing each triangle's measure after triangulation by barycenter split. - for (std::size_t i = 0; i < n; i++) - { - std::array muXY_curr_triangle = - interpolated_corrected_anisotropic_measure_face( - std::vector {u[i], u[(i + 1) % n], uc}, - std::vector {x[i], x[(i + 1) % n], xc} - ); - - for (std::size_t ix = 0; ix < 3; ix++) - for (std::size_t iy = 0; iy < 3; iy++) - muXY[ix * 3 + iy] += muXY_curr_triangle[ix * 3 + iy]; - } + // getting center of points + typename GT::Vector_3 xc = + std::accumulate(x.begin(), x.end(), typename GT::Vector_3(0, 0, 0)); + xc /= n; + + // getting unit average normal of points + typename GT::Vector_3 uc = + std::accumulate(u.begin(), u.end(), typename GT::Vector_3(0, 0, 0)); + uc /= sqrt(uc * uc); + + // summing each triangle's measure after triangulation by barycenter split. + for (std::size_t i = 0; i < n; i++) + { + std::array muXY_curr_triangle = + interpolated_corrected_anisotropic_measure_face( + std::vector {u[i], u[(i + 1) % n], uc}, + std::vector {x[i], x[(i + 1) % n], xc} + ); + + for (std::size_t ix = 0; ix < 3; ix++) + for (std::size_t iy = 0; iy < 3; iy++) + muXY[ix * 3 + iy] += muXY_curr_triangle[ix * 3 + iy]; + } } return muXY; -} - -//template -//typename GT::FT triangle_in_ball_ratio(const typename GT::Vector_3 x1, -// const typename GT::Vector_3 x2, -// const typename GT::Vector_3 x3, -// const typename GT::FT r, -// const typename GT::Vector_3 c, -// const std::size_t res = 3) -//{ -// const typename GT::FT R = r * r; -// const typename GT::FT acc = 1.0 / res; -// std::size_t samples_in = 0; -// for (GT::FT alpha = acc / 3; alpha < 1; alpha += acc) -// for (GT::FT beta = acc / 3; beta < 1 - alpha; beta += acc) -// { -// if ((alpha * x1 + beta * x2 + (1 - alpha - beta) * x3 - c).squared_length() < R) -// samples_in++; -// } -// return samples_in / (typename GT::FT)(res * (res + 1) / 2); -//} - -template -typename GT::FT face_in_ball_ratio(const std::vector& x, - const typename GT::FT r, - const typename GT::Vector_3 c) -{ + } + + //template + //typename GT::FT triangle_in_ball_ratio(const typename GT::Vector_3 x1, + // const typename GT::Vector_3 x2, + // const typename GT::Vector_3 x3, + // const typename GT::FT r, + // const typename GT::Vector_3 c, + // const std::size_t res = 3) + //{ + // const typename GT::FT R = r * r; + // const typename GT::FT acc = 1.0 / res; + // std::size_t samples_in = 0; + // for (GT::FT alpha = acc / 3; alpha < 1; alpha += acc) + // for (GT::FT beta = acc / 3; beta < 1 - alpha; beta += acc) + // { + // if ((alpha * x1 + beta * x2 + (1 - alpha - beta) * x3 - c).squared_length() < R) + // samples_in++; + // } + // return samples_in / (typename GT::FT)(res * (res + 1) / 2); + //} + + template + typename GT::FT face_in_ball_ratio(const std::vector& x, + const typename GT::FT r, + const typename GT::Vector_3 c) + { const std::size_t n = x.size(); // getting center of points typename GT::Vector_3 xm = - std::accumulate(x.begin(), x.end(), typename GT::Vector_3(0, 0, 0)); + std::accumulate(x.begin(), x.end(), typename GT::Vector_3(0, 0, 0)); xm /= n; typename GT::FT d_min = (xm - c).squared_length(); @@ -425,9 +425,9 @@ typename GT::FT face_in_ball_ratio(const std::vector& x, for (const typename GT::Vector_3 xi : x) { - const typename GT::FT d_sq = (xi - c).squared_length(); - d_max = (std::max)(d_sq, d_max); - d_min = (std::min)(d_sq, d_min); + const typename GT::FT d_sq = (xi - c).squared_length(); + d_max = (std::max)(d_sq, d_max); + d_min = (std::min)(d_sq, d_min); } if (d_max <= r * r) return 1.0; @@ -437,20 +437,20 @@ typename GT::FT face_in_ball_ratio(const std::vector& x, d_min = sqrt(d_min); return (r - d_min) / (d_max - d_min); -} + } -template -Principal_curvature principal_curvature_from_anisotropic_measures( + template + Principal_curvature principal_curvature_from_anisotropic_measures( const std::array anisotropic_measure, const typename GT::FT v_mu0, const typename GT::Vector_3 u_GT -) -{ + ) + { Eigen::Matrix v_muXY = Eigen::Matrix::Zero(); for (std::size_t ix = 0; ix < 3; ix++) - for (std::size_t iy = 0; iy < 3; iy++) - v_muXY(ix, iy) = anisotropic_measure[ix * 3 + iy]; + for (std::size_t iy = 0; iy < 3; iy++) + v_muXY(ix, iy) = anisotropic_measure[ix * 3 + iy]; Eigen::Matrix u(u_GT.x(), u_GT.y(), u_GT.z()); const typename GT::FT K = 1000 * v_mu0; @@ -462,7 +462,7 @@ Principal_curvature principal_curvature_from_anisotropic_measures( eigensolver.computeDirect(v_muXY); if (eigensolver.info() != Eigen::Success) - return Principal_curvature(); + return Principal_curvature(); const Eigen::Matrix eig_vals = eigensolver.eigenvalues(); const Eigen::Matrix eig_vecs = eigensolver.eigenvectors(); @@ -471,16 +471,16 @@ Principal_curvature principal_curvature_from_anisotropic_measures( const typename GT::Vector_3 max_eig_vec(eig_vecs(0, 0), eig_vecs(1, 0), eig_vecs(2, 0)); return Principal_curvature( - (v_mu0 != 0.0) ? -eig_vals[1] / v_mu0 : 0.0, - (v_mu0 != 0.0) ? -eig_vals[0] / v_mu0 : 0.0, - min_eig_vec, - max_eig_vec - ); -} - -template -class Interpolated_corrected_curvatures_computer -{ + (v_mu0 != 0.0) ? -eig_vals[1] / v_mu0 : 0.0, + (v_mu0 != 0.0) ? -eig_vals[0] / v_mu0 : 0.0, + min_eig_vec, + max_eig_vec + ); + } + + template + class Interpolated_corrected_curvatures_computer + { typedef typename GetGeomTraits::type GT; typedef typename GT::FT FT; @@ -497,29 +497,29 @@ class Interpolated_corrected_curvatures_computer typedef dynamic_vertex_property_t Vector_map_tag; typedef typename boost::property_map::const_type Default_vector_map; typedef typename internal_np::Lookup_named_param_def::type Vertex_normal_map; + NamedParameters, + Default_vector_map>::type Vertex_normal_map; typedef Constant_property_map Default_scalar_map; typedef typename internal_np::Lookup_named_param_def::type Vertex_mean_curvature_map; + NamedParameters, + Default_scalar_map>::type Vertex_mean_curvature_map; typedef typename internal_np::Lookup_named_param_def::type Vertex_gaussian_curvature_map; + NamedParameters, + Default_scalar_map>::type Vertex_gaussian_curvature_map; typedef Constant_property_map> Default_principal_map; typedef typename internal_np::Lookup_named_param_def::type Vertex_principal_curvature_map; + NamedParameters, + Default_principal_map>::type Vertex_principal_curvature_map; typedef typename boost::property_map>::const_type Face_scalar_measure_map; + CGAL::dynamic_face_property_t>::const_type Face_scalar_measure_map; typedef typename boost::property_map>>::const_type Face_anisotropic_measure_map; + CGAL::dynamic_face_property_t>>::const_type Face_anisotropic_measure_map; -private: + private: const PolygonMesh& pmesh; Vertex_position_map vpm; Vertex_normal_map vnm; @@ -537,217 +537,217 @@ class Interpolated_corrected_curvatures_computer Face_anisotropic_measure_map muXY_map; void set_property_maps() { - mu0_map = get(CGAL::dynamic_face_property_t(), pmesh); - mu1_map = get(CGAL::dynamic_face_property_t(), pmesh); - mu2_map = get(CGAL::dynamic_face_property_t(), pmesh); - muXY_map = get(CGAL::dynamic_face_property_t>(), pmesh); + mu0_map = get(CGAL::dynamic_face_property_t(), pmesh); + mu1_map = get(CGAL::dynamic_face_property_t(), pmesh); + mu2_map = get(CGAL::dynamic_face_property_t(), pmesh); + muXY_map = get(CGAL::dynamic_face_property_t>(), pmesh); } void set_named_params(const NamedParameters& np) { - using parameters::choose_parameter; - using parameters::get_parameter; - using parameters::is_default_parameter; + using parameters::choose_parameter; + using parameters::get_parameter; + using parameters::is_default_parameter; - vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), - get_const_property_map(CGAL::vertex_point, pmesh)); + vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), + get_const_property_map(CGAL::vertex_point, pmesh)); - vnm = choose_parameter(get_parameter(np, internal_np::vertex_normal_map), - get(Vector_map_tag(), pmesh)); + 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); + if (is_default_parameter::value) + compute_vertex_normals(pmesh, vnm, np); - const FT radius = choose_parameter(get_parameter(np, internal_np::ball_radius), -1); + const FT radius = choose_parameter(get_parameter(np, internal_np::ball_radius), -1); - is_mean_curvature_selected = !is_default_parameter::value; - is_gaussian_curvature_selected = !is_default_parameter::value; - is_principal_curvature_selected = !is_default_parameter::value; + is_mean_curvature_selected = !is_default_parameter::value; + is_gaussian_curvature_selected = !is_default_parameter::value; + is_principal_curvature_selected = !is_default_parameter::value; - mean_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_mean_curvature_map), Default_scalar_map()); - gaussian_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_gaussian_curvature_map), Default_scalar_map()); - principal_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_principal_curvature_map), Default_principal_map()); + mean_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_mean_curvature_map), Default_scalar_map()); + gaussian_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_gaussian_curvature_map), Default_scalar_map()); + principal_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_principal_curvature_map), Default_principal_map()); - set_ball_radius(radius); + set_ball_radius(radius); } void set_ball_radius(const FT radius) { - if (radius == 0) - ball_radius = average_edge_length(pmesh) * EXPANDING_RADIUS_EPSILON; - else - ball_radius = radius; + if (radius == 0) + ball_radius = average_edge_length(pmesh) * EXPANDING_RADIUS_EPSILON; + else + ball_radius = radius; } -public: + public: Interpolated_corrected_curvatures_computer(const PolygonMesh& pmesh, - const NamedParameters& np = parameters::default_values() + const NamedParameters& np = parameters::default_values() ) : - pmesh(pmesh) + pmesh(pmesh) { - set_named_params(np); + set_named_params(np); - if (is_mean_curvature_selected || is_gaussian_curvature_selected || is_principal_curvature_selected) - { - set_property_maps(); + if (is_mean_curvature_selected || is_gaussian_curvature_selected || is_principal_curvature_selected) + { + set_property_maps(); - compute_selected_curvatures(); - } + compute_selected_curvatures(); + } } -private: + private: void interpolated_corrected_all_measures_all_faces() { - std::vector x; - std::vector u; + std::vector x; + std::vector u; - for (Face_descriptor f : faces(pmesh)) + for (Face_descriptor f : faces(pmesh)) + { + for (Vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) { - for (Vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) - { - Point_3 p = get(vpm, v); - x.push_back(Vector_3(p.x(), p.y(), p.z())); - u.push_back(get(vnm, v)); - } - put(mu0_map, f, interpolated_corrected_area_measure_face(u, x)); + Point_3 p = get(vpm, v); + x.push_back(Vector_3(p.x(), p.y(), p.z())); + u.push_back(get(vnm, v)); + } + put(mu0_map, f, interpolated_corrected_area_measure_face(u, x)); - if (is_mean_curvature_selected) - put(mu1_map, f, interpolated_corrected_mean_curvature_measure_face(u, x)); + if (is_mean_curvature_selected) + put(mu1_map, f, interpolated_corrected_mean_curvature_measure_face(u, x)); - if (is_gaussian_curvature_selected) - put(mu2_map, f, interpolated_corrected_gaussian_curvature_measure_face(u, x)); + if (is_gaussian_curvature_selected) + put(mu2_map, f, interpolated_corrected_gaussian_curvature_measure_face(u, x)); - if (is_principal_curvature_selected) - put(muXY_map, f, interpolated_corrected_anisotropic_measure_face(u, x)); + if (is_principal_curvature_selected) + put(muXY_map, f, interpolated_corrected_anisotropic_measure_face(u, x)); - x.clear(); - u.clear(); - } + x.clear(); + u.clear(); + } } Vertex_measures expand_interpolated_corrected_measure_vertex_no_radius(Vertex_descriptor v) { - Vertex_measures vertex_curvatures; + Vertex_measures vertex_curvatures; - for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { - vertex_curvatures.area_measure += get(mu0_map, f); + for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { + vertex_curvatures.area_measure += get(mu0_map, f); - if (is_mean_curvature_selected) - vertex_curvatures.mean_curvature_measure += get(mu1_map, f); + if (is_mean_curvature_selected) + vertex_curvatures.mean_curvature_measure += get(mu1_map, f); - if (is_gaussian_curvature_selected) - vertex_curvatures.gaussian_curvature_measure += get(mu2_map, f); + if (is_gaussian_curvature_selected) + vertex_curvatures.gaussian_curvature_measure += get(mu2_map, f); - if (is_principal_curvature_selected) - { - const std::array face_anisotropic_measure = get(muXY_map, f); - for (std::size_t i = 0; i < 3 * 3; i++) - vertex_curvatures.anisotropic_measure[i] += face_anisotropic_measure[i]; - } + if (is_principal_curvature_selected) + { + const std::array face_anisotropic_measure = get(muXY_map, f); + for (std::size_t i = 0; i < 3 * 3; i++) + vertex_curvatures.anisotropic_measure[i] += face_anisotropic_measure[i]; } + } - return vertex_curvatures; + return vertex_curvatures; } Vertex_measures expand_interpolated_corrected_measure_vertex(Vertex_descriptor v) { - std::queue bfs_queue; - std::unordered_set bfs_visited; + std::queue bfs_queue; + std::unordered_set bfs_visited; - Point_3 vp = get(vpm, v); - Vector_3 c = Vector_3(vp.x(), vp.y(), vp.z()); + Point_3 vp = get(vpm, v); + Vector_3 c = Vector_3(vp.x(), vp.y(), vp.z()); - Vertex_measures vertex_curvatures; + Vertex_measures vertex_curvatures; - for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { - if (f != boost::graph_traits::null_face()) - { - bfs_queue.push(f); - bfs_visited.insert(f); - } + for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { + if (f != boost::graph_traits::null_face()) + { + bfs_queue.push(f); + bfs_visited.insert(f); } - while (!bfs_queue.empty()) { - Face_descriptor fi = bfs_queue.front(); - bfs_queue.pop(); + } + while (!bfs_queue.empty()) { + Face_descriptor fi = bfs_queue.front(); + bfs_queue.pop(); - // looping over vertices in face to get point coordinates - std::vector x; - for (Vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh)) - { - Point_3 pi = get(vpm, vi); - x.push_back(Vector_3(pi.x(), pi.y(), pi.z())); - } + // looping over vertices in face to get point coordinates + std::vector x; + for (Vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh)) + { + Point_3 pi = get(vpm, vi); + x.push_back(Vector_3(pi.x(), pi.y(), pi.z())); + } - const FT f_ratio = face_in_ball_ratio(x, ball_radius, c); + const FT f_ratio = face_in_ball_ratio(x, ball_radius, c); - if (f_ratio != 0.0) + if (f_ratio != 0.0) + { + vertex_curvatures.area_measure += f_ratio * get(mu0_map, fi); + + if (is_mean_curvature_selected) + vertex_curvatures.mean_curvature_measure += f_ratio * get(mu1_map, fi); + + if (is_gaussian_curvature_selected) + vertex_curvatures.gaussian_curvature_measure += f_ratio * get(mu2_map, fi); + + if (is_principal_curvature_selected) + { + const std::array face_anisotropic_measure = get(muXY_map, fi); + for (std::size_t i = 0; i < 3 * 3; i++) + vertex_curvatures.anisotropic_measure[i] += f_ratio * face_anisotropic_measure[i]; + } + + for (Face_descriptor fj : faces_around_face(halfedge(fi, pmesh), pmesh)) + { + if (bfs_visited.find(fj) == bfs_visited.end() && fj != boost::graph_traits::null_face()) { - vertex_curvatures.area_measure += f_ratio * get(mu0_map, fi); - - if (is_mean_curvature_selected) - vertex_curvatures.mean_curvature_measure += f_ratio * get(mu1_map, fi); - - if (is_gaussian_curvature_selected) - vertex_curvatures.gaussian_curvature_measure += f_ratio * get(mu2_map, fi); - - if (is_principal_curvature_selected) - { - const std::array face_anisotropic_measure = get(muXY_map, fi); - for (std::size_t i = 0; i < 3 * 3; i++) - vertex_curvatures.anisotropic_measure[i] += f_ratio * face_anisotropic_measure[i]; - } - - for (Face_descriptor fj : faces_around_face(halfedge(fi, pmesh), pmesh)) - { - if (bfs_visited.find(fj) == bfs_visited.end() && fj != boost::graph_traits::null_face()) - { - bfs_queue.push(fj); - bfs_visited.insert(fj); - } - } + bfs_queue.push(fj); + bfs_visited.insert(fj); } + } } - return vertex_curvatures; + } + return vertex_curvatures; } void compute_selected_curvatures() { - interpolated_corrected_all_measures_all_faces(); - - for (Vertex_descriptor v : vertices(pmesh)) - { - Vertex_measures vertex_curvatures = (ball_radius < 0)? - expand_interpolated_corrected_measure_vertex_no_radius(v) : - expand_interpolated_corrected_measure_vertex(v); - - if (is_mean_curvature_selected) { - vertex_curvatures.area_measure != 0 ? - put(mean_curvature_map, v, 0.5 * vertex_curvatures.mean_curvature_measure / vertex_curvatures.area_measure) : - put(mean_curvature_map, v, 0); - } + interpolated_corrected_all_measures_all_faces(); + + for (Vertex_descriptor v : vertices(pmesh)) + { + Vertex_measures vertex_curvatures = (ball_radius < 0) ? + expand_interpolated_corrected_measure_vertex_no_radius(v) : + expand_interpolated_corrected_measure_vertex(v); + + if (is_mean_curvature_selected) { + vertex_curvatures.area_measure != 0 ? + put(mean_curvature_map, v, 0.5 * vertex_curvatures.mean_curvature_measure / vertex_curvatures.area_measure) : + put(mean_curvature_map, v, 0); + } - if (is_gaussian_curvature_selected) { - vertex_curvatures.area_measure != 0 ? - put(gaussian_curvature_map, v, vertex_curvatures.gaussian_curvature_measure / vertex_curvatures.area_measure) : - put(gaussian_curvature_map, v, 0); - } + if (is_gaussian_curvature_selected) { + vertex_curvatures.area_measure != 0 ? + put(gaussian_curvature_map, v, vertex_curvatures.gaussian_curvature_measure / vertex_curvatures.area_measure) : + put(gaussian_curvature_map, v, 0); + } - if (is_principal_curvature_selected) { - const Vector_3 v_normal = get(vnm, v); - const Principal_curvature principal_curvature = principal_curvature_from_anisotropic_measures( - vertex_curvatures.anisotropic_measure, - vertex_curvatures.area_measure, - v_normal - ); - put(principal_curvature_map, v, principal_curvature); - } + if (is_principal_curvature_selected) { + const Vector_3 v_normal = get(vnm, v); + const Principal_curvature principal_curvature = principal_curvature_from_anisotropic_measures( + vertex_curvatures.anisotropic_measure, + vertex_curvatures.area_measure, + v_normal + ); + put(principal_curvature_map, v, principal_curvature); } + } } -}; + }; } // namespace internal @@ -807,12 +807,12 @@ class Interpolated_corrected_curvatures_computer */ template - void interpolated_corrected_mean_curvature(const PolygonMesh& pmesh, - VertexCurvatureMap& vcm, - NamedParameters& np = parameters::default_values()) + typename NamedParameters = parameters::Default_named_parameters> + void interpolated_corrected_mean_curvature(const PolygonMesh& pmesh, + VertexCurvatureMap& vcm, + NamedParameters& np = parameters::default_values()) { - interpolated_corrected_curvatures(pmesh, np.vertex_mean_curvature_map(vcm)); + interpolated_corrected_curvatures(pmesh, np.vertex_mean_curvature_map(vcm)); } /** @@ -870,12 +870,12 @@ template - void interpolated_corrected_gaussian_curvature(const PolygonMesh& pmesh, - VertexCurvatureMap& vcm, - NamedParameters& np = parameters::default_values()) + typename NamedParameters = parameters::Default_named_parameters> + void interpolated_corrected_gaussian_curvature(const PolygonMesh& pmesh, + VertexCurvatureMap& vcm, + NamedParameters& np = parameters::default_values()) { - interpolated_corrected_curvatures(pmesh, np.vertex_gaussian_curvature_map(vcm)); + interpolated_corrected_curvatures(pmesh, np.vertex_gaussian_curvature_map(vcm)); } /** @@ -934,12 +934,12 @@ template - void interpolated_corrected_principal_curvatures(const PolygonMesh& pmesh, - VertexCurvatureMap& vcm, - NamedParameters& np = parameters::default_values()) + typename NamedParameters = parameters::Default_named_parameters> + void interpolated_corrected_principal_curvatures(const PolygonMesh& pmesh, + VertexCurvatureMap& vcm, + NamedParameters& np = parameters::default_values()) { - interpolated_corrected_curvatures(pmesh, np.vertex_principal_curvature_map(vcm)); + interpolated_corrected_curvatures(pmesh, np.vertex_principal_curvature_map(vcm)); } /** @@ -1023,11 +1023,11 @@ template - void interpolated_corrected_curvatures(const PolygonMesh& pmesh, - const NamedParameters& np = parameters::default_values()) + typename NamedParameters = parameters::Default_named_parameters> + void interpolated_corrected_curvatures(const PolygonMesh& pmesh, + const NamedParameters& np = parameters::default_values()) { - internal::Interpolated_corrected_curvatures_computer(pmesh, np); + internal::Interpolated_corrected_curvatures_computer(pmesh, np); } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interopolated_corrected_curvatures.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interopolated_corrected_curvatures.cpp index 7e376c887716..b2dbcc0850bb 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interopolated_corrected_curvatures.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interopolated_corrected_curvatures.cpp @@ -19,130 +19,130 @@ typedef boost::graph_traits::edge_descriptor edge_descriptor; typedef boost::graph_traits::vertex_descriptor vertex_descriptor; void test(std::string mesh_path, EpicKernel::FT rel_expansion_radius, EpicKernel::FT rel_noise_magnitude) { - SMesh pmesh; - const std::string filename = CGAL::data_file_path(mesh_path); + SMesh pmesh; + const std::string filename = CGAL::data_file_path(mesh_path); - if (!CGAL::IO::read_polygon_mesh(filename, pmesh)) - { - std::cerr << "Invalid input file." << std::endl; - } + if (!CGAL::IO::read_polygon_mesh(filename, pmesh)) + { + std::cerr << "Invalid input file." << std::endl; + } - bool created = false; + bool created = false; - SMesh::Property_map mean_curvature_map, gaussian_curvature_map; - boost::tie(mean_curvature_map, created) = pmesh.add_property_map("v:mean_curvature_map", 0); - assert(created); + SMesh::Property_map mean_curvature_map, gaussian_curvature_map; + boost::tie(mean_curvature_map, created) = pmesh.add_property_map("v:mean_curvature_map", 0); + assert(created); + + boost::tie(gaussian_curvature_map, created) = pmesh.add_property_map("v:gaussian_curvature_map", 0); + assert(created); + + // getting the max and min edge lengthes + const auto edge_range = CGAL::edges(pmesh); + + const auto edge_length_comparator = [&, pmesh](auto l, auto r) { + return PMP::edge_length(l, pmesh) < PMP::edge_length(r, pmesh); + }; + + const edge_descriptor longest_edge = *std::max_element(edge_range.begin(), edge_range.end(), edge_length_comparator); + const EpicKernel::FT max_edge_length = PMP::edge_length(longest_edge, pmesh); + + const edge_descriptor shortest_edge = *std::min_element(edge_range.begin(), edge_range.end(), edge_length_comparator); + const EpicKernel::FT min_edge_length = PMP::edge_length(shortest_edge, pmesh); + + + if (rel_noise_magnitude > 0) + { + if (!CGAL::is_triangle_mesh(pmesh)) + return; - boost::tie(gaussian_curvature_map, created) = pmesh.add_property_map("v:gaussian_curvature_map", 0); + SMesh::Property_map vnm; + boost::tie(vnm, created) = pmesh.add_property_map("v:vnm", { 0 , 0 , 0 }); assert(created); - // getting the max and min edge lengthes - const auto edge_range = CGAL::edges(pmesh); - - const auto edge_length_comparator = [&, pmesh](auto l, auto r) { - return PMP::edge_length(l, pmesh) < PMP::edge_length(r, pmesh); - }; - - const edge_descriptor longest_edge = *std::max_element(edge_range.begin(), edge_range.end(), edge_length_comparator); - const EpicKernel::FT max_edge_length = PMP::edge_length(longest_edge, pmesh); - - const edge_descriptor shortest_edge = *std::min_element(edge_range.begin(), edge_range.end(), edge_length_comparator); - const EpicKernel::FT min_edge_length = PMP::edge_length(shortest_edge, pmesh); - - - if (rel_noise_magnitude > 0) - { - if (!CGAL::is_triangle_mesh(pmesh)) - return; - - SMesh::Property_map vnm; - boost::tie(vnm, created) = pmesh.add_property_map("v:vnm", { 0 , 0 , 0 }); - assert(created); - - CGAL::Polygon_mesh_processing::compute_vertex_normals(pmesh, vnm); - - PMP::random_perturbation(pmesh, rel_noise_magnitude * min_edge_length, CGAL::parameters::random_seed(0)); - PMP::interpolated_corrected_mean_curvature( - pmesh, - mean_curvature_map, - CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length).vertex_normal_map(vnm) - ); - PMP::interpolated_corrected_gaussian_curvature( - pmesh, - gaussian_curvature_map, - CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length).vertex_normal_map(vnm) - ); - } - else { - PMP::interpolated_corrected_mean_curvature( - pmesh, - mean_curvature_map, - CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length) - ); - PMP::interpolated_corrected_gaussian_curvature( - pmesh, - gaussian_curvature_map, - CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length) - ); - - } - - - - //PMP::interpolated_corrected_mean_curvature( - // pmesh, - // mean_curvature_map, - // CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length) - //); - //PMP::interpolated_corrected_gaussian_curvature( - // pmesh, - // gaussian_curvature_map, - // CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length) - //); - - - const EpicKernel::FT max_mean_curvature = *std::max_element(mean_curvature_map.begin(), mean_curvature_map.end()); - const EpicKernel::FT min_mean_curvature = *std::min_element(mean_curvature_map.begin(), mean_curvature_map.end()); - const EpicKernel::FT max_gaussian_curvature = *std::max_element(gaussian_curvature_map.begin(), gaussian_curvature_map.end()); - const EpicKernel::FT min_gaussian_curvature = *std::min_element(gaussian_curvature_map.begin(), gaussian_curvature_map.end()); - - std::cout << "# " << mesh_path << ":\n" - << "expansion radius ratio to max length / expansion radius = " << rel_expansion_radius << " / " << rel_expansion_radius * max_edge_length << ",\n" - << "max perturbation ratio to minlength / max perturbation = " << rel_noise_magnitude << " / " << rel_noise_magnitude * min_edge_length << "\n" - << "mean curvature: min = " << min_mean_curvature << " <-> " << max_mean_curvature << " = max" << "\n" - << "gaussian curvature: min = " << min_gaussian_curvature << " <-> " << max_gaussian_curvature << " = max" << "\n\n\n"; + CGAL::Polygon_mesh_processing::compute_vertex_normals(pmesh, vnm); + + PMP::random_perturbation(pmesh, rel_noise_magnitude * min_edge_length, CGAL::parameters::random_seed(0)); + PMP::interpolated_corrected_mean_curvature( + pmesh, + mean_curvature_map, + CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length).vertex_normal_map(vnm) + ); + PMP::interpolated_corrected_gaussian_curvature( + pmesh, + gaussian_curvature_map, + CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length).vertex_normal_map(vnm) + ); + } + else { + PMP::interpolated_corrected_mean_curvature( + pmesh, + mean_curvature_map, + CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length) + ); + PMP::interpolated_corrected_gaussian_curvature( + pmesh, + gaussian_curvature_map, + CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length) + ); + + } + + + + //PMP::interpolated_corrected_mean_curvature( + // pmesh, + // mean_curvature_map, + // CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length) + //); + //PMP::interpolated_corrected_gaussian_curvature( + // pmesh, + // gaussian_curvature_map, + // CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length) + //); + + + const EpicKernel::FT max_mean_curvature = *std::max_element(mean_curvature_map.begin(), mean_curvature_map.end()); + const EpicKernel::FT min_mean_curvature = *std::min_element(mean_curvature_map.begin(), mean_curvature_map.end()); + const EpicKernel::FT max_gaussian_curvature = *std::max_element(gaussian_curvature_map.begin(), gaussian_curvature_map.end()); + const EpicKernel::FT min_gaussian_curvature = *std::min_element(gaussian_curvature_map.begin(), gaussian_curvature_map.end()); + + std::cout << "# " << mesh_path << ":\n" + << "expansion radius ratio to max length / expansion radius = " << rel_expansion_radius << " / " << rel_expansion_radius * max_edge_length << ",\n" + << "max perturbation ratio to minlength / max perturbation = " << rel_noise_magnitude << " / " << rel_noise_magnitude * min_edge_length << "\n" + << "mean curvature: min = " << min_mean_curvature << " <-> " << max_mean_curvature << " = max" << "\n" + << "gaussian curvature: min = " << min_gaussian_curvature << " <-> " << max_gaussian_curvature << " = max" << "\n\n\n"; } int main() { - const std::vector mesh_pathes_to_test = { - "meshes/icc_test/Sphere Quads + Tris.obj", - "meshes/icc_test/Sphere Quads + Tris 100352.obj", - "meshes/icc_test/Sphere Tris Ico.obj", - "meshes/icc_test/Sphere Tris Tet.obj", - "meshes/icc_test/Sphere Tris Oct.obj", - "meshes/icc_test/Sphere Quads.obj", - "meshes/icc_test/Sphere Quads Remesh.obj", - "meshes/icc_test/Sphere Ngons + Quads + Tris.obj", - "meshes/icc_test/Cube with fillet Quads.obj", - "meshes/cylinder.off", - "meshes/icc_test/Lantern Tris.obj", - "meshes/icc_test/Lantern Quads.obj" - }; - - const std::vector rel_expansion_radii = { 0, 0.1, 0.5, 1 }; - const std::vector rel_noise_magnitudes = { 0, 0.5, 0.9 }; - - for (auto mesh_path : mesh_pathes_to_test) { - for (EpicKernel::FT rel_expansion_radius : rel_expansion_radii) - for (EpicKernel::FT rel_noise_magnitude : rel_noise_magnitudes) - { - test(mesh_path, rel_expansion_radius, rel_noise_magnitude); - } - - std::cout << "_________________________________________________________________________________\n\n"; - } + const std::vector mesh_pathes_to_test = { + "meshes/icc_test/Sphere Quads + Tris.obj", + "meshes/icc_test/Sphere Quads + Tris 100352.obj", + "meshes/icc_test/Sphere Tris Ico.obj", + "meshes/icc_test/Sphere Tris Tet.obj", + "meshes/icc_test/Sphere Tris Oct.obj", + "meshes/icc_test/Sphere Quads.obj", + "meshes/icc_test/Sphere Quads Remesh.obj", + "meshes/icc_test/Sphere Ngons + Quads + Tris.obj", + "meshes/icc_test/Cube with fillet Quads.obj", + "meshes/cylinder.off", + "meshes/icc_test/Lantern Tris.obj", + "meshes/icc_test/Lantern Quads.obj" + }; + + const std::vector rel_expansion_radii = { 0, 0.1, 0.5, 1 }; + const std::vector rel_noise_magnitudes = { 0, 0.5, 0.9 }; + + for (auto mesh_path : mesh_pathes_to_test) { + for (EpicKernel::FT rel_expansion_radius : rel_expansion_radii) + for (EpicKernel::FT rel_noise_magnitude : rel_noise_magnitudes) + { + test(mesh_path, rel_expansion_radius, rel_noise_magnitude); + } + + std::cout << "_________________________________________________________________________________\n\n"; + } } diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index c69b73694980..db26f59168a8 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -658,13 +658,13 @@ private Q_SLOTS: if(does_exist) sm_item->face_graph()->remove_property_map(pmap); std::tie(pmap, does_exist) = - sm_item->face_graph()->property_map("v:interpolated_corrected_mean_curvature"); + sm_item->face_graph()->property_map("v:interpolated_corrected_mean_curvature"); if (does_exist) sm_item->face_graph()->remove_property_map(pmap); std::tie(pmap, does_exist) = - sm_item->face_graph()->property_map("v:interpolated_corrected_gaussian_curvature"); + sm_item->face_graph()->property_map("v:interpolated_corrected_gaussian_curvature"); if (does_exist) - sm_item->face_graph()->remove_property_map(pmap); + sm_item->face_graph()->remove_property_map(pmap); }); QApplication::restoreOverrideCursor(); sm_item->invalidateOpenGLBuffers(); @@ -704,13 +704,13 @@ private Q_SLOTS: dock_widget->zoomToMaxButton->setEnabled(jacobian_max.count(sm_item)>0); break; case 4: - dock_widget->zoomToMinButton->setEnabled(mean_curvature_min.count(sm_item) > 0); - dock_widget->zoomToMaxButton->setEnabled(mean_curvature_max.count(sm_item) > 0); - break; + dock_widget->zoomToMinButton->setEnabled(mean_curvature_min.count(sm_item) > 0); + dock_widget->zoomToMaxButton->setEnabled(mean_curvature_max.count(sm_item) > 0); + break; case 5: - dock_widget->zoomToMinButton->setEnabled(gaussian_curvature_min.count(sm_item) > 0); - dock_widget->zoomToMaxButton->setEnabled(gaussian_curvature_max.count(sm_item) > 0); - break; + dock_widget->zoomToMinButton->setEnabled(gaussian_curvature_min.count(sm_item) > 0); + dock_widget->zoomToMaxButton->setEnabled(gaussian_curvature_max.count(sm_item) > 0); + break; default: break; } @@ -745,13 +745,13 @@ private Q_SLOTS: std::tie(mean_curvature, found) = smesh.property_map("v:interpolated_corrected_mean_curvature"); if (found) { - smesh.remove_property_map(mean_curvature); + smesh.remove_property_map(mean_curvature); } SMesh::Property_map gaussian_curvature; std::tie(gaussian_curvature, found) = smesh.property_map("v:interpolated_corrected_gaussian_curvature"); if (found) { - smesh.remove_property_map(gaussian_curvature); + smesh.remove_property_map(gaussian_curvature); } } @@ -795,54 +795,54 @@ private Q_SLOTS: void setExpandingRadius(int val_int) { - double sliderMin = dock_widget->expandingRadiusSlider->minimum(); - double sliderMax = dock_widget->expandingRadiusSlider->maximum() - sliderMin; - double val = val_int - sliderMin; - sliderMin = 0; + double sliderMin = dock_widget->expandingRadiusSlider->minimum(); + double sliderMax = dock_widget->expandingRadiusSlider->maximum() - sliderMin; + double val = val_int - sliderMin; + sliderMin = 0; - SMesh& smesh = *(qobject_cast(scene->item(scene->mainSelectionIndex())))->face_graph(); + SMesh& smesh = *(qobject_cast(scene->item(scene->mainSelectionIndex())))->face_graph(); - auto vpm = get(CGAL::vertex_point, smesh); + auto vpm = get(CGAL::vertex_point, smesh); - if (maxEdgeLength < 0) + if (maxEdgeLength < 0) + { + auto edge_range = CGAL::edges(smesh); + + if (edge_range.begin() == edge_range.end()) { - auto edge_range = CGAL::edges(smesh); - - if (edge_range.begin() == edge_range.end()) - { - expand_radius = 0; - dock_widget->expandingRadiusLabel->setText(tr("Expanding Radius : %1").arg(expand_radius)); - return; - } - - auto edge_reference = std::max_element(edge_range.begin(), edge_range.end(), [&, vpm, smesh](auto l, auto r) { - auto res = EPICK().compare_squared_distance_3_object()( - get(vpm, source((l), smesh)), - get(vpm, target((l), smesh)), - get(vpm, source((r), smesh)), - get(vpm, target((r), smesh))); - return res == CGAL::SMALLER; - }); - - // if edge_reference is not derefrenceble - if (edge_reference == edge_range.end()) - { - expand_radius = 0; - dock_widget->expandingRadiusLabel->setText(tr("Expanding Radius : %1").arg(expand_radius)); - return; - } - - maxEdgeLength = sqrt( - (get(vpm, source((*edge_reference), smesh)) - get(vpm, target((*edge_reference), smesh))) - .squared_length() - ); - + expand_radius = 0; + dock_widget->expandingRadiusLabel->setText(tr("Expanding Radius : %1").arg(expand_radius)); + return; + } + + auto edge_reference = std::max_element(edge_range.begin(), edge_range.end(), [&, vpm, smesh](auto l, auto r) { + auto res = EPICK().compare_squared_distance_3_object()( + get(vpm, source((l), smesh)), + get(vpm, target((l), smesh)), + get(vpm, source((r), smesh)), + get(vpm, target((r), smesh))); + return res == CGAL::SMALLER; + }); + + // if edge_reference is not derefrenceble + if (edge_reference == edge_range.end()) + { + expand_radius = 0; + dock_widget->expandingRadiusLabel->setText(tr("Expanding Radius : %1").arg(expand_radius)); + return; } + + maxEdgeLength = sqrt( + (get(vpm, source((*edge_reference), smesh)) - get(vpm, target((*edge_reference), smesh))) + .squared_length() + ); + + } - double outMin = 0, outMax = 5 * maxEdgeLength, base = 1.2; + double outMin = 0, outMax = 5 * maxEdgeLength, base = 1.2; - expand_radius = (pow(base, val) - 1) * outMax / (pow(base, sliderMax) - 1); - dock_widget->expandingRadiusLabel->setText(tr("Expanding Radius : %1").arg(expand_radius)); + expand_radius = (pow(base, val) - 1) * outMax / (pow(base, sliderMax) - 1); + dock_widget->expandingRadiusLabel->setText(tr("Expanding Radius : %1").arg(expand_radius)); } @@ -864,45 +864,45 @@ private Q_SLOTS: smesh.add_property_map(tied_string, 0); if (non_init) { - if (vnm_exists) { - if (mu_index == MEAN_CURVATURE) - PMP::interpolated_corrected_mean_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expand_radius).vertex_normal_map(vnm)); - else - PMP::interpolated_corrected_gaussian_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expand_radius).vertex_normal_map(vnm)); - } - else { - if (mu_index == MEAN_CURVATURE) - PMP::interpolated_corrected_mean_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expand_radius)); - else - PMP::interpolated_corrected_gaussian_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expand_radius)); - } - double res_min = ARBITRARY_DBL_MAX, - res_max = -ARBITRARY_DBL_MAX; - SMesh::Vertex_index min_index, max_index; - for (SMesh::Vertex_index v : vertices(smesh)) + if (vnm_exists) { + if (mu_index == MEAN_CURVATURE) + PMP::interpolated_corrected_mean_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expand_radius).vertex_normal_map(vnm)); + else + PMP::interpolated_corrected_gaussian_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expand_radius).vertex_normal_map(vnm)); + } + else { + if (mu_index == MEAN_CURVATURE) + PMP::interpolated_corrected_mean_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expand_radius)); + else + PMP::interpolated_corrected_gaussian_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expand_radius)); + } + double res_min = ARBITRARY_DBL_MAX, + res_max = -ARBITRARY_DBL_MAX; + SMesh::Vertex_index min_index, max_index; + for (SMesh::Vertex_index v : vertices(smesh)) + { + if (mu_i_map[v] > res_max) { - if (mu_i_map[v] > res_max) - { - res_max = mu_i_map[v]; - max_index = v; - } - if (mu_i_map[v] < res_min) - { - res_min = mu_i_map[v]; - min_index = v; - } - } - if (mu_index == MEAN_CURVATURE){ - mean_curvature_max[item] = std::make_pair(res_max, max_index); - mean_curvature_min[item] = std::make_pair(res_min, min_index); + res_max = mu_i_map[v]; + max_index = v; } - else { - gaussian_curvature_max[item] = std::make_pair(res_max, max_index); - gaussian_curvature_min[item] = std::make_pair(res_min, min_index); + if (mu_i_map[v] < res_min) + { + res_min = mu_i_map[v]; + min_index = v; } + } + if (mu_index == MEAN_CURVATURE){ + mean_curvature_max[item] = std::make_pair(res_max, max_index); + mean_curvature_min[item] = std::make_pair(res_min, min_index); + } + else { + gaussian_curvature_max[item] = std::make_pair(res_max, max_index); + gaussian_curvature_min[item] = std::make_pair(res_min, min_index); + } - connect(item, &Scene_surface_mesh_item::itemChanged, - this, &DisplayPropertyPlugin::resetProperty); + connect(item, &Scene_surface_mesh_item::itemChanged, + this, &DisplayPropertyPlugin::resetProperty); } treat_sm_property(tied_string, item->face_graph()); } @@ -1271,20 +1271,20 @@ private Q_SLOTS: break; case 4: { - ::zoomToId(*item->face_graph(), - QString("v%1").arg(mean_curvature_min[item].second), - getActiveViewer(), - dummy_fd, - dummy_p); + ::zoomToId(*item->face_graph(), + QString("v%1").arg(mean_curvature_min[item].second), + getActiveViewer(), + dummy_fd, + dummy_p); } break; case 5: { - ::zoomToId(*item->face_graph(), - QString("v%1").arg(gaussian_curvature_min[item].second), - getActiveViewer(), - dummy_fd, - dummy_p); + ::zoomToId(*item->face_graph(), + QString("v%1").arg(gaussian_curvature_min[item].second), + getActiveViewer(), + dummy_fd, + dummy_p); } break; break; @@ -1324,20 +1324,20 @@ private Q_SLOTS: break; case 4: { - ::zoomToId(*item->face_graph(), - QString("v%1").arg(mean_curvature_max[item].second), - getActiveViewer(), - dummy_fd, - dummy_p); + ::zoomToId(*item->face_graph(), + QString("v%1").arg(mean_curvature_max[item].second), + getActiveViewer(), + dummy_fd, + dummy_p); } break; case 5: { - ::zoomToId(*item->face_graph(), - QString("v%1").arg(gaussian_curvature_max[item].second), - getActiveViewer(), - dummy_fd, - dummy_p); + ::zoomToId(*item->face_graph(), + QString("v%1").arg(gaussian_curvature_max[item].second), + getActiveViewer(), + dummy_fd, + dummy_p); } break; default: From e79e34df4fe4e69279865c3b8294159774ad04dc Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Wed, 16 Nov 2022 12:53:43 +0200 Subject: [PATCH 081/142] trim trailing whitespaces --- .../Plugins/Display/Display_property_plugin.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index db26f59168a8..6efc7f213fe2 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -807,14 +807,14 @@ private Q_SLOTS: if (maxEdgeLength < 0) { auto edge_range = CGAL::edges(smesh); - + if (edge_range.begin() == edge_range.end()) { expand_radius = 0; dock_widget->expandingRadiusLabel->setText(tr("Expanding Radius : %1").arg(expand_radius)); return; } - + auto edge_reference = std::max_element(edge_range.begin(), edge_range.end(), [&, vpm, smesh](auto l, auto r) { auto res = EPICK().compare_squared_distance_3_object()( get(vpm, source((l), smesh)), @@ -823,7 +823,7 @@ private Q_SLOTS: get(vpm, target((r), smesh))); return res == CGAL::SMALLER; }); - + // if edge_reference is not derefrenceble if (edge_reference == edge_range.end()) { @@ -831,12 +831,12 @@ private Q_SLOTS: dock_widget->expandingRadiusLabel->setText(tr("Expanding Radius : %1").arg(expand_radius)); return; } - + maxEdgeLength = sqrt( (get(vpm, source((*edge_reference), smesh)) - get(vpm, target((*edge_reference), smesh))) .squared_length() ); - + } double outMin = 0, outMax = 5 * maxEdgeLength, base = 1.2; From 400f9de47c68df5ac92a9eba42f0865af1c60515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 17 Nov 2022 19:49:42 +0100 Subject: [PATCH 082/142] first draft version for getting the triangulation of a face WARNING: COMPILATION NOT TESTED! --- .../triangulate_faces.h | 147 ++++++++++++++++++ 1 file changed, 147 insertions(+) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h index 0b48967f2733..abe56ea35a61 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h @@ -499,6 +499,153 @@ bool triangulate_face(typename boost::graph_traits::face_descriptor return modifier.triangulate_face(f, pmesh, use_cdt, visitor); } + +#ifndef CGAL_TRIANGULATE_FACES_DO_NOT_USE_CDT2 +template +OutputIterator +face_triangulation(typename boost::graph_traits::face_descriptor f, + PolygonMesh& pmesh, + OutputIterator out, + const NamedParameters& np = parameters::default_values()) +{ + using parameters::choose_parameter; + using parameters::get_parameter; + + //VertexPointMap + typedef typename GetVertexPointMap::type VPMap; + VPMap vpmap = choose_parameter(get_parameter(np, internal_np::vertex_point), + get_property_map(vertex_point, pmesh)); + + //Kernel + typedef typename GetGeomTraits::type Kernel; + Kernel traits = choose_parameter(get_parameter(np, internal_np::geom_traits)); + + //Face_info + typedef typename internal::Triangulate_modifier>::Face_info Face_info; + + //CDT + typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; + typedef CGAL::Projection_traits_3 P_traits; + typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; + typedef CGAL::Triangulation_face_base_with_info_2 Fb1; + typedef CGAL::Constrained_triangulation_face_base_2 Fb; + typedef CGAL::Triangulation_data_structure_2 TDS; + typedef CGAL::Exact_intersections_tag Itag; + typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; + P_traits cdt_traits(normal); + CDT cdt(cdt_traits); + + std::size_t original_size = CGAL::halfedges_around_face(halfedge(f, pmesh), pmesh).size(); + + // Halfedge_around_facet_circulator + typedef typename CDT::Vertex_handle Tr_Vertex_handle; + halfedge_descriptor start = halfedge(f, pmesh); + halfedge_descriptor h = start; + Tr_Vertex_handle previous, first; + do + { + Tr_Vertex_handle vh = cdt.insert(get(_vpmap, target(h, pmesh))); + if (first == Tr_Vertex_handle()) { + first = vh; + } + vh->info() = h; + if(previous != Tr_Vertex_handle() && previous != vh) { + cdt.insert_constraint(previous, vh); + } + previous = vh; + h = next(h, pmesh); + + } while( h != start ); + cdt.insert_constraint(previous, first); + + // sets mark is_external + for(typename CDT::All_faces_iterator fit = cdt.all_faces_begin(), + end = cdt.all_faces_end(); + fit != end; ++fit) + { + fit->info().is_external = false; + } + std::queue face_queue; + face_queue.push(cdt.infinite_vertex()->face()); + while(! face_queue.empty() ) + { + typename CDT::Face_handle fh = face_queue.front(); + face_queue.pop(); + + if(fh->info().is_external) + continue; + + fh->info().is_external = true; + for(int i = 0; i <3; ++i) + { + if(!cdt.is_constrained(typename CDT::Edge(fh, i))) + { + face_queue.push(fh->neighbor(i)); + } + } + } + + if(cdt.dimension() != 2 || cdt.number_of_vertices() != original_size) + return out; + + for(typename CDT::Finite_edges_iterator eit = cdt.finite_edges_begin(), + end = cdt.finite_edges_end(); + eit != end; ++eit) + { + typename CDT::Face_handle fh = eit->first; + const int index = eit->second; + typename CDT::Face_handle opposite_fh = fh->neighbor(eit->second); + const int opposite_index = opposite_fh->index(fh); + + const Tr_Vertex_handle va = fh->vertex(cdt. cw(index)); + const Tr_Vertex_handle vb = fh->vertex(cdt.ccw(index)); + + if( ! (is_external(fh) && is_external(opposite_fh))//not both fh are external + && ! cdt.is_constrained(*eit) ) //and edge is not constrained + { + // strictly internal edge + halfedge_descriptor hnew = halfedge(add_edge(pmesh), pmesh), + hnewopp = opposite(hnew, pmesh); + + fh->info().e[index] = hnew; + opposite_fh->info().e[opposite_index] = hnewopp; + + set_target(hnew, target(va->info(), pmesh), pmesh); + set_target(hnewopp, target(vb->info(), pmesh), pmesh); + } + if( cdt.is_constrained(*eit) ) //edge is constrained + { + if(!is_external(fh)) { + fh->info().e[index] = va->info(); + } + if(!is_external(opposite_fh)) { + opposite_fh->info().e[opposite_index] = vb->info(); + } + } + } + for(typename CDT::Finite_faces_iterator fit = cdt.finite_faces_begin(), + end = cdt.finite_faces_end(); + fit != end; ++fit) + { + if(!is_external(fit)) + { + halfedge_descriptor h0 = fit->info().e[0]; + halfedge_descriptor h1 = fit->info().e[1]; + halfedge_descriptor h2 = fit->info().e[2]; + *out++=std::make_tuple(target(h0, pmesh), target(h1, pmesh), target(h2,pmesh)); + } + } + + return out; +} +#endif + + + /** * \ingroup PMP_meshing_grp * From 80e3522eaa294462a26c758745908c5ff5cc9ffb Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Fri, 18 Nov 2022 12:56:08 +0200 Subject: [PATCH 083/142] incomplete (single vertex curvature) --- ...nterpolated_corrected_curvature_measures.h | 465 +++++++++++++++++- 1 file changed, 455 insertions(+), 10 deletions(-) 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 4006b761679f..3f118bdba45d 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 @@ -598,7 +598,7 @@ namespace internal { private: - void interpolated_corrected_all_measures_all_faces() + void interpolated_corrected_selected_measures_all_faces() { std::vector x; std::vector u; @@ -629,23 +629,239 @@ namespace internal { Vertex_measures expand_interpolated_corrected_measure_vertex_no_radius(Vertex_descriptor v) { - Vertex_measures vertex_curvatures; + Vertex_measures vertex_measures; for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { - vertex_curvatures.area_measure += get(mu0_map, f); + vertex_measures.area_measure += get(mu0_map, f); if (is_mean_curvature_selected) - vertex_curvatures.mean_curvature_measure += get(mu1_map, f); + vertex_measures.mean_curvature_measure += get(mu1_map, f); if (is_gaussian_curvature_selected) - vertex_curvatures.gaussian_curvature_measure += get(mu2_map, f); + vertex_measures.gaussian_curvature_measure += get(mu2_map, f); if (is_principal_curvature_selected) { const std::array face_anisotropic_measure = get(muXY_map, f); + for (std::size_t i = 0; i < 3 * 3; i++) + vertex_measures.anisotropic_measure[i] += face_anisotropic_measure[i]; + } + } + + return vertex_measures; + } + + Vertex_measures expand_interpolated_corrected_measure_vertex(Vertex_descriptor v) + { + std::queue bfs_queue; + std::unordered_set bfs_visited; + + Point_3 vp = get(vpm, v); + Vector_3 c = Vector_3(vp.x(), vp.y(), vp.z()); + + Vertex_measures vertex_measures; + + for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { + if (f != boost::graph_traits::null_face()) + { + bfs_queue.push(f); + bfs_visited.insert(f); + } + } + while (!bfs_queue.empty()) { + Face_descriptor fi = bfs_queue.front(); + bfs_queue.pop(); + + // looping over vertices in face to get point coordinates + std::vector x; + for (Vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh)) + { + Point_3 pi = get(vpm, vi); + x.push_back(Vector_3(pi.x(), pi.y(), pi.z())); + } + + const FT f_ratio = face_in_ball_ratio(x, ball_radius, c); + + if (f_ratio != 0.0) + { + vertex_measures.area_measure += f_ratio * get(mu0_map, fi); + + if (is_mean_curvature_selected) + vertex_measures.mean_curvature_measure += f_ratio * get(mu1_map, fi); + + if (is_gaussian_curvature_selected) + vertex_measures.gaussian_curvature_measure += f_ratio * get(mu2_map, fi); + + if (is_principal_curvature_selected) + { + const std::array face_anisotropic_measure = get(muXY_map, fi); + for (std::size_t i = 0; i < 3 * 3; i++) + vertex_measures.anisotropic_measure[i] += f_ratio * face_anisotropic_measure[i]; + } + + for (Face_descriptor fj : faces_around_face(halfedge(fi, pmesh), pmesh)) + { + if (bfs_visited.find(fj) == bfs_visited.end() && fj != boost::graph_traits::null_face()) + { + bfs_queue.push(fj); + bfs_visited.insert(fj); + } + } + } + } + return vertex_measures; + } + + void compute_selected_curvatures() { + interpolated_corrected_selected_measures_all_faces(); + + for (Vertex_descriptor v : vertices(pmesh)) + { + Vertex_measures vertex_measures = (ball_radius < 0) ? + expand_interpolated_corrected_measure_vertex_no_radius(v) : + expand_interpolated_corrected_measure_vertex(v); + + if (is_mean_curvature_selected) { + vertex_measures.area_measure != 0 ? + put(mean_curvature_map, v, 0.5 * vertex_measures.mean_curvature_measure / vertex_measures.area_measure) : + put(mean_curvature_map, v, 0); + } + + if (is_gaussian_curvature_selected) { + vertex_measures.area_measure != 0 ? + put(gaussian_curvature_map, v, vertex_measures.gaussian_curvature_measure / vertex_measures.area_measure) : + put(gaussian_curvature_map, v, 0); + } + + if (is_principal_curvature_selected) { + const Vector_3 v_normal = get(vnm, v); + const Principal_curvature principal_curvature = principal_curvature_from_anisotropic_measures( + vertex_measures.anisotropic_measure, + vertex_measures.area_measure, + v_normal + ); + put(principal_curvature_map, v, principal_curvature); + } + } + } + }; + + template + class Interpolated_corrected_curvatures_point_computer + { + typedef typename GetGeomTraits::type GT; + + typedef typename GT::FT FT; + typedef typename GT::Point_3 Point_3; + typedef typename GT::Vector_3 Vector_3; + + typedef typename boost::graph_traits::halfedge_descriptor Halfedge_descriptor; + typedef typename boost::graph_traits::edge_descriptor Edge_descriptor; + typedef typename boost::graph_traits::face_descriptor Face_descriptor; + typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; + + typedef typename GetVertexPointMap::const_type Vertex_position_map; + + typedef dynamic_vertex_property_t Vector_map_tag; + typedef typename boost::property_map::const_type Default_vector_map; + typedef typename internal_np::Lookup_named_param_def::type Vertex_normal_map; + + private: + const PolygonMesh& pmesh; + Vertex_position_map vpm; + Vertex_normal_map vnm; + FT ball_radius; + + bool is_mean_curvature_selected; + bool is_gaussian_curvature_selected; + bool is_principal_curvature_selected; + + Point_3 point; + + void set_named_params(const NamedParameters& np) + { + using parameters::choose_parameter; + using parameters::get_parameter; + using parameters::is_default_parameter; + + vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), + get_const_property_map(CGAL::vertex_point, pmesh)); + + 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); + + const FT radius = choose_parameter(get_parameter(np, internal_np::ball_radius), -1); + + is_mean_curvature_selected = !is_default_parameter::value; + is_gaussian_curvature_selected = !is_default_parameter::value; + is_principal_curvature_selected = !is_default_parameter::value; + + set_ball_radius(radius); + } + + void set_ball_radius(const FT radius) { + if (radius == 0) + ball_radius = average_edge_length(pmesh) * EXPANDING_RADIUS_EPSILON; + else + ball_radius = radius; + } + + public: + + Interpolated_corrected_curvatures_computer(const PolygonMesh& pmesh, + const NamedParameters& np = parameters::default_values() + ) : + pmesh(pmesh) + { + set_named_params(np); + + if (is_mean_curvature_selected || is_gaussian_curvature_selected || is_principal_curvature_selected) + { + set_property_maps(); + + compute_selected_curvatures(); + } + } + + private: + Vertex_measures expand_interpolated_corrected_measure_vertex_no_radius(Vertex_descriptor v) + { + Vertex_measures vertex_curvatures; + + std::vector x; + std::vector u; + + for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { + + for (Vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) + { + Point_3 p = get(vpm, v); + x.push_back(Vector_3(p.x(), p.y(), p.z())); + u.push_back(get(vnm, v)); + } + + vertex_curvatures.area_measure += interpolated_corrected_area_measure_face(u, x); + + if (is_mean_curvature_selected) + vertex_curvatures.mean_curvature_measure += interpolated_corrected_mean_curvature_measure_face(u, x); + + if (is_gaussian_curvature_selected) + vertex_curvatures.gaussian_curvature_measure += interpolated_corrected_gaussian_curvature_measure_face(u, x); + + if (is_principal_curvature_selected) + { + const std::array face_anisotropic_measure = interpolated_corrected_anisotropic_measure_face(u, x); for (std::size_t i = 0; i < 3 * 3; i++) vertex_curvatures.anisotropic_measure[i] += face_anisotropic_measure[i]; } + + x.clear(); + u.clear(); } return vertex_curvatures; @@ -668,12 +884,15 @@ namespace internal { bfs_visited.insert(f); } } + + std::vector x; + std::vector u; + while (!bfs_queue.empty()) { Face_descriptor fi = bfs_queue.front(); bfs_queue.pop(); // looping over vertices in face to get point coordinates - std::vector x; for (Vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh)) { Point_3 pi = get(vpm, vi); @@ -684,6 +903,11 @@ namespace internal { if (f_ratio != 0.0) { + for (Vertex_descriptor vi : vertices_around_face(halfedge(f, pmesh), pmesh)) + { + u.push_back(get(vnm, vi)); + } + vertex_curvatures.area_measure += f_ratio * get(mu0_map, fi); if (is_mean_curvature_selected) @@ -699,6 +923,9 @@ namespace internal { vertex_curvatures.anisotropic_measure[i] += f_ratio * face_anisotropic_measure[i]; } + x.clear(); + u.clear(); + for (Face_descriptor fj : faces_around_face(halfedge(fi, pmesh), pmesh)) { if (bfs_visited.find(fj) == bfs_visited.end() && fj != boost::graph_traits::null_face()) @@ -713,13 +940,11 @@ namespace internal { } void compute_selected_curvatures() { - interpolated_corrected_all_measures_all_faces(); - for (Vertex_descriptor v : vertices(pmesh)) { Vertex_measures vertex_curvatures = (ball_radius < 0) ? - expand_interpolated_corrected_measure_vertex_no_radius(v) : - expand_interpolated_corrected_measure_vertex(v); + compute_expanded_interpolated_corrected_measure_vertex_no_radius(v) : + compute_expanded_interpolated_corrected_measure_vertex(v); if (is_mean_curvature_selected) { vertex_curvatures.area_measure != 0 ? @@ -745,7 +970,227 @@ namespace internal { } } + }; + template + class Interpolated_corrected_curvatures_element_computer + { + typedef typename GetGeomTraits::type GT; + + typedef typename GT::FT FT; + typedef typename GT::Point_3 Point_3; + typedef typename GT::Vector_3 Vector_3; + + typedef typename boost::graph_traits::halfedge_descriptor Halfedge_descriptor; + typedef typename boost::graph_traits::edge_descriptor Edge_descriptor; + typedef typename boost::graph_traits::face_descriptor Face_descriptor; + typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; + + typedef typename GetVertexPointMap::const_type Vertex_position_map; + + typedef dynamic_vertex_property_t Vector_map_tag; + typedef typename boost::property_map::const_type Default_vector_map; + typedef typename internal_np::Lookup_named_param_def::type Vertex_normal_map; + + private: + const PolygonMesh& pmesh; + Vertex_position_map vpm; + Vertex_normal_map vnm; + FT ball_radius; + + bool is_mean_curvature_selected; + bool is_gaussian_curvature_selected; + bool is_principal_curvature_selected; + + void set_named_params(const NamedParameters& np) + { + using parameters::choose_parameter; + using parameters::get_parameter; + using parameters::is_default_parameter; + + vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), + get_const_property_map(CGAL::vertex_point, pmesh)); + + 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); + + const FT radius = choose_parameter(get_parameter(np, internal_np::ball_radius), -1); + + is_mean_curvature_selected = !is_default_parameter::value; + is_gaussian_curvature_selected = !is_default_parameter::value; + is_principal_curvature_selected = !is_default_parameter::value; + + set_ball_radius(radius); + } + + void set_ball_radius(const FT radius) { + if (radius == 0) + ball_radius = average_edge_length(pmesh) * EXPANDING_RADIUS_EPSILON; + else + ball_radius = radius; + } + + public: + + Interpolated_corrected_curvatures_computer(const PolygonMesh& pmesh, + const NamedParameters& np = parameters::default_values() + ) : + pmesh(pmesh) + { + set_named_params(np); + + if (is_mean_curvature_selected || is_gaussian_curvature_selected || is_principal_curvature_selected) + { + set_property_maps(); + } + } + + private: + Vertex_measures expand_interpolated_corrected_measure_vertex_no_radius(Vertex_descriptor v) + { + Vertex_measures vertex_curvatures; + + std::vector x; + std::vector u; + + for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { + + for (Vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) + { + Point_3 p = get(vpm, v); + x.push_back(Vector_3(p.x(), p.y(), p.z())); + u.push_back(get(vnm, v)); + } + + vertex_curvatures.area_measure += interpolated_corrected_area_measure_face(u, x); + + if (is_mean_curvature_selected) + vertex_curvatures.mean_curvature_measure += interpolated_corrected_mean_curvature_measure_face(u, x); + + if (is_gaussian_curvature_selected) + vertex_curvatures.gaussian_curvature_measure += interpolated_corrected_gaussian_curvature_measure_face(u, x); + + if (is_principal_curvature_selected) + { + const std::array face_anisotropic_measure = interpolated_corrected_anisotropic_measure_face(u, x); + for (std::size_t i = 0; i < 3 * 3; i++) + vertex_curvatures.anisotropic_measure[i] += face_anisotropic_measure[i]; + } + + x.clear(); + u.clear(); + } + + return vertex_curvatures; + } + + Vertex_measures expand_interpolated_corrected_measure_vertex(Vertex_descriptor v) + { + std::queue bfs_queue; + std::unordered_set bfs_visited; + + Point_3 vp = get(vpm, v); + Vector_3 c = Vector_3(vp.x(), vp.y(), vp.z()); + + Vertex_measures vertex_curvatures; + + for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { + if (f != boost::graph_traits::null_face()) + { + bfs_queue.push(f); + bfs_visited.insert(f); + } + } + + std::vector x; + std::vector u; + + while (!bfs_queue.empty()) { + Face_descriptor fi = bfs_queue.front(); + bfs_queue.pop(); + + // looping over vertices in face to get point coordinates + for (Vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh)) + { + Point_3 pi = get(vpm, vi); + x.push_back(Vector_3(pi.x(), pi.y(), pi.z())); + } + + const FT f_ratio = face_in_ball_ratio(x, ball_radius, c); + + if (f_ratio != 0.0) + { + for (Vertex_descriptor vi : vertices_around_face(halfedge(f, pmesh), pmesh)) + { + u.push_back(get(vnm, vi)); + } + + vertex_curvatures.area_measure += f_ratio * get(mu0_map, fi); + + if (is_mean_curvature_selected) + vertex_curvatures.mean_curvature_measure += f_ratio * get(mu1_map, fi); + + if (is_gaussian_curvature_selected) + vertex_curvatures.gaussian_curvature_measure += f_ratio * get(mu2_map, fi); + + if (is_principal_curvature_selected) + { + const std::array face_anisotropic_measure = get(muXY_map, fi); + for (std::size_t i = 0; i < 3 * 3; i++) + vertex_curvatures.anisotropic_measure[i] += f_ratio * face_anisotropic_measure[i]; + } + + x.clear(); + u.clear(); + + for (Face_descriptor fj : faces_around_face(halfedge(fi, pmesh), pmesh)) + { + if (bfs_visited.find(fj) == bfs_visited.end() && fj != boost::graph_traits::null_face()) + { + bfs_queue.push(fj); + bfs_visited.insert(fj); + } + } + } + } + return vertex_curvatures; + } + + void compute_selected_curvatures() { + for (Vertex_descriptor v : vertices(pmesh)) + { + Vertex_measures vertex_curvatures = (ball_radius < 0) ? + compute_expanded_interpolated_corrected_measure_vertex_no_radius(v) : + compute_expanded_interpolated_corrected_measure_vertex(v); + + if (is_mean_curvature_selected) { + vertex_curvatures.area_measure != 0 ? + put(mean_curvature_map, v, 0.5 * vertex_curvatures.mean_curvature_measure / vertex_curvatures.area_measure) : + put(mean_curvature_map, v, 0); + } + + if (is_gaussian_curvature_selected) { + vertex_curvatures.area_measure != 0 ? + put(gaussian_curvature_map, v, vertex_curvatures.gaussian_curvature_measure / vertex_curvatures.area_measure) : + put(gaussian_curvature_map, v, 0); + } + + if (is_principal_curvature_selected) { + const Vector_3 v_normal = get(vnm, v); + const Principal_curvature principal_curvature = principal_curvature_from_anisotropic_measures( + vertex_curvatures.anisotropic_measure, + vertex_curvatures.area_measure, + v_normal + ); + put(principal_curvature_map, v, principal_curvature); + } + } + } }; From e302b02f764301209548fae1c435f8a92c892d02 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sat, 19 Nov 2022 11:02:26 +0200 Subject: [PATCH 084/142] Docs: adding bibtex, ack of DGtal, Authors + Renaming vars + minor fix + removing last commit's approach --- Documentation/doc/biblio/geom.bib | 11 + .../PackageDescription.txt | 2 +- .../Polygon_mesh_processing.txt | 11 +- ...erpolated_corrected_curvatures_example.cpp | 14 +- ...orrected_curvatures_polyhedron_example.cpp | 10 +- ...nterpolated_corrected_curvature_measures.h | 496 +----------------- ..._corrected_principal_curvatures_plugin.cpp | 22 +- .../internal/parameters_interface.h | 2 +- 8 files changed, 66 insertions(+), 502 deletions(-) diff --git a/Documentation/doc/biblio/geom.bib b/Documentation/doc/biblio/geom.bib index 270f537e1394..37c42071a85f 100644 --- a/Documentation/doc/biblio/geom.bib +++ b/Documentation/doc/biblio/geom.bib @@ -152060,6 +152060,7 @@ @article{cvl-ew-12 Pages = {215--224}, Year = {2012}, Url = {http://monge.univ-mlv.fr/~colinde/pub/09edgewidth.pdf} +} @inproceedings{tang2009interactive, title={Interactive Hausdorff distance computation for general polygonal models}, @@ -152071,3 +152072,13 @@ @inproceedings{tang2009interactive year={2009}, organization={ACM} } + +@article{lachaud2020, + author = {Jacques-Olivier Lachaud and Pascal Romon and Boris Thibert and David Coeurjolly}, + journal = {Computer Graphics Forum (Proceedings of Symposium on Geometry Processing)}, + number = {5}, + title = {Interpolated corrected curvature measures for polygonal surfaces}, + volume = {39}, + month = jul, + year = {2020} +} diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt index 93f25c89f1fb..5090535be250 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt @@ -203,7 +203,7 @@ The page \ref bgl_namedparameters "Named Parameters" describes their usage. \cgalCRPSection{Corrected Curvature Functions} - `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature()` -- `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures()` - `CGAL::Polygon_mesh_processing::Principal_curvature` diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index 7932051ec000..2347ae1c7ae8 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -879,10 +879,7 @@ not provide storage for the normals. **************************************** \section PMPICC Computing Curvatures -This package provides methods to compute curvatures on polygonal meshes based on - - Interpolated corrected curvature measures for polygonal surfaces -. +This package provides methods to compute curvatures on polygonal meshes based on \cgalCite{lachaud2020} This includes mean curvature, gaussian curvature, principal curvatures and directions. These can be computed on triangle meshes, quad meshes, and meshes with n-gon faces. The algorithms used prove to work well in general. Also, on meshes with noise @@ -895,7 +892,7 @@ Polyhedron_3 and other polygonal mesh structures based on the Face Graph Model. These computations are performed using : - `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature()` -- `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures()` Where it is recommended to use the last function for computing multiple curvatures (example: mean and gaussian) @@ -1145,6 +1142,10 @@ available on 7th of October 2020. It only uses the high level algorithm of chec is covered by a set of prisms, where each prism is an offset for an input triangle. That is, the implementation in \cgal does not use indirect predicates. +The interpolated corrected curvatures were implemented during GSoC 2022. This was implemented by Hossam Saeed and under +supervision of Sebastien Loriot, Jaques-Olivier Lachaud and David Coeurjolly. The implementation is based \cgalCite{lachaud2020}. +DGtal's implementation was also +used as a reference during the project. */ } /* namespace CGAL */ diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp index 7bf182c3ce3d..71aa06a8caec 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp @@ -38,10 +38,10 @@ int main(int argc, char* argv[]) assert(created); // we use a tuple of 2 scalar values and 2 vectors for principal curvatures and directions - Surface_Mesh::Property_map> principal_curvature_map; + Surface_Mesh::Property_map> principal_curvatures_and_directions_map; - boost::tie(principal_curvature_map, created) = smesh.add_property_map> - ("v:principal_curvature_map", { 0, 0, + boost::tie(principal_curvatures_and_directions_map, created) = smesh.add_property_map> + ("v:principal_curvatures_and_directions_map", { 0, 0, Epic_kernel::Vector_3(0,0,0), Epic_kernel::Vector_3(0,0,0) }); assert(created); @@ -57,9 +57,9 @@ int main(int argc, char* argv[]) gaussian_curvature_map ); - PMP::interpolated_corrected_principal_curvatures( + PMP::interpolated_corrected_principal_curvatures_and_directions( smesh, - principal_curvature_map + principal_curvatures_and_directions_map ); // uncomment this to compute a curvature while specifying named parameters @@ -83,12 +83,12 @@ int main(int argc, char* argv[]) PMP::interpolated_corrected_curvatures( smesh, CGAL::parameters::vertex_mean_curvature_map(mean_curvature_map) - .vertex_principal_curvature_map(principal_curvature_map) + .vertex_principal_curvatures_and_directions_map(principal_curvatures_and_directions_map) ); for (vertex_descriptor v : vertices(smesh)) { - auto PC = principal_curvature_map[v]; + auto PC = principal_curvatures_and_directions_map[v]; std::cout << v.idx() << ": HC = " << mean_curvature_map[v] << ", GC = " << gaussian_curvature_map[v] << "\n" << ", PC = [ " << PC.min_curvature << " , " << PC.max_curvature << " ]\n"; diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp index 929fc8d96a67..50fe1a014d8e 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp @@ -31,7 +31,7 @@ int main(int argc, char *argv[]) mean_curvature_map = get(CGAL::dynamic_vertex_property_t(), polyhedron), gaussian_curvature_map = get(CGAL::dynamic_vertex_property_t(), polyhedron); boost::property_map>>::type - principal_curvature_map = get(CGAL::dynamic_vertex_property_t>(), polyhedron); + principal_curvatures_and_directions_map = get(CGAL::dynamic_vertex_property_t>(), polyhedron); PMP::interpolated_corrected_mean_curvature( polyhedron, @@ -41,9 +41,9 @@ int main(int argc, char *argv[]) polyhedron, gaussian_curvature_map); - PMP::interpolated_corrected_principal_curvatures( + PMP::interpolated_corrected_principal_curvatures_and_directions( polyhedron, - principal_curvature_map); + principal_curvatures_and_directions_map); // uncomment this to compute a curvature while specifying named parameters // Example: an expansion ball radius of 0.5 and a vertex normals map (does not have to depend on positions) @@ -61,12 +61,12 @@ int main(int argc, char *argv[]) PMP::interpolated_corrected_curvatures( polyhedron, CGAL::parameters::vertex_mean_curvature_map(mean_curvature_map) - .vertex_principal_curvature_map(principal_curvature_map)); + .vertex_principal_curvatures_and_directions_map(principal_curvatures_and_directions_map)); int i = 0; for (vertex_descriptor v : vertices(polyhedron)) { - auto PC = get(principal_curvature_map, v); + auto PC = get(principal_curvatures_and_directions_map, v); std::cout << i << ": HC = " << get(mean_curvature_map, v) << ", GC = " << get(gaussian_curvature_map, v) << "\n" << ", PC = [ " << PC.min_curvature << " , " << PC.max_curvature << " ]\n"; 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 3f118bdba45d..3b02341a2129 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 @@ -70,10 +70,10 @@ struct Principal_curvature { typename GT::Vector_3 min_direction, typename GT::Vector_3 max_direction ) { - min_curvature = min_curvature; - max_curvature = max_curvature; - min_direction = min_direction; - max_direction = max_direction; + this->min_curvature = min_curvature; + this->max_curvature = max_curvature; + this->min_direction = min_direction; + this->max_direction = max_direction; } }; @@ -440,7 +440,7 @@ namespace internal { } template - Principal_curvature principal_curvature_from_anisotropic_measures( + Principal_curvature principal_curvatures_and_directions_from_anisotropic_measures( const std::array anisotropic_measure, const typename GT::FT v_mu0, const typename GT::Vector_3 u_GT @@ -510,9 +510,9 @@ namespace internal { Default_scalar_map>::type Vertex_gaussian_curvature_map; typedef Constant_property_map> Default_principal_map; - typedef typename internal_np::Lookup_named_param_def::type Vertex_principal_curvature_map; + Default_principal_map>::type Vertex_principal_curvatures_and_directions_map; typedef typename boost::property_map>::const_type Face_scalar_measure_map; @@ -527,11 +527,11 @@ namespace internal { bool is_mean_curvature_selected; bool is_gaussian_curvature_selected; - bool is_principal_curvature_selected; + bool is_principal_curvatures_and_directions_selected; Vertex_mean_curvature_map mean_curvature_map; Vertex_gaussian_curvature_map gaussian_curvature_map; - Vertex_principal_curvature_map principal_curvature_map; + Vertex_principal_curvatures_and_directions_map principal_curvatures_and_directions_map; Face_scalar_measure_map mu0_map, mu1_map, mu2_map; Face_anisotropic_measure_map muXY_map; @@ -563,11 +563,11 @@ namespace internal { is_mean_curvature_selected = !is_default_parameter::value; is_gaussian_curvature_selected = !is_default_parameter::value; - is_principal_curvature_selected = !is_default_parameter::value; + is_principal_curvatures_and_directions_selected = !is_default_parameter::value; mean_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_mean_curvature_map), Default_scalar_map()); gaussian_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_gaussian_curvature_map), Default_scalar_map()); - principal_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_principal_curvature_map), Default_principal_map()); + principal_curvatures_and_directions_map = choose_parameter(get_parameter(np, internal_np::vertex_principal_curvatures_and_directions_map), Default_principal_map()); set_ball_radius(radius); } @@ -588,7 +588,7 @@ namespace internal { { set_named_params(np); - if (is_mean_curvature_selected || is_gaussian_curvature_selected || is_principal_curvature_selected) + if (is_mean_curvature_selected || is_gaussian_curvature_selected || is_principal_curvatures_and_directions_selected) { set_property_maps(); @@ -619,7 +619,7 @@ namespace internal { if (is_gaussian_curvature_selected) put(mu2_map, f, interpolated_corrected_gaussian_curvature_measure_face(u, x)); - if (is_principal_curvature_selected) + if (is_principal_curvatures_and_directions_selected) put(muXY_map, f, interpolated_corrected_anisotropic_measure_face(u, x)); x.clear(); @@ -640,7 +640,7 @@ namespace internal { if (is_gaussian_curvature_selected) vertex_measures.gaussian_curvature_measure += get(mu2_map, f); - if (is_principal_curvature_selected) + if (is_principal_curvatures_and_directions_selected) { const std::array face_anisotropic_measure = get(muXY_map, f); for (std::size_t i = 0; i < 3 * 3; i++) @@ -692,7 +692,7 @@ namespace internal { if (is_gaussian_curvature_selected) vertex_measures.gaussian_curvature_measure += f_ratio * get(mu2_map, fi); - if (is_principal_curvature_selected) + if (is_principal_curvatures_and_directions_selected) { const std::array face_anisotropic_measure = get(muXY_map, fi); for (std::size_t i = 0; i < 3 * 3; i++) @@ -733,467 +733,19 @@ namespace internal { put(gaussian_curvature_map, v, 0); } - if (is_principal_curvature_selected) { + if (is_principal_curvatures_and_directions_selected) { const Vector_3 v_normal = get(vnm, v); - const Principal_curvature principal_curvature = principal_curvature_from_anisotropic_measures( + const Principal_curvature principal_curvatures_and_directions = principal_curvatures_and_directions_from_anisotropic_measures( vertex_measures.anisotropic_measure, vertex_measures.area_measure, v_normal ); - put(principal_curvature_map, v, principal_curvature); + put(principal_curvatures_and_directions_map, v, principal_curvatures_and_directions); } } } }; - template - class Interpolated_corrected_curvatures_point_computer - { - typedef typename GetGeomTraits::type GT; - - typedef typename GT::FT FT; - typedef typename GT::Point_3 Point_3; - typedef typename GT::Vector_3 Vector_3; - - typedef typename boost::graph_traits::halfedge_descriptor Halfedge_descriptor; - typedef typename boost::graph_traits::edge_descriptor Edge_descriptor; - typedef typename boost::graph_traits::face_descriptor Face_descriptor; - typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; - - typedef typename GetVertexPointMap::const_type Vertex_position_map; - - typedef dynamic_vertex_property_t Vector_map_tag; - typedef typename boost::property_map::const_type Default_vector_map; - typedef typename internal_np::Lookup_named_param_def::type Vertex_normal_map; - - private: - const PolygonMesh& pmesh; - Vertex_position_map vpm; - Vertex_normal_map vnm; - FT ball_radius; - - bool is_mean_curvature_selected; - bool is_gaussian_curvature_selected; - bool is_principal_curvature_selected; - - Point_3 point; - - void set_named_params(const NamedParameters& np) - { - using parameters::choose_parameter; - using parameters::get_parameter; - using parameters::is_default_parameter; - - vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), - get_const_property_map(CGAL::vertex_point, pmesh)); - - 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); - - const FT radius = choose_parameter(get_parameter(np, internal_np::ball_radius), -1); - - is_mean_curvature_selected = !is_default_parameter::value; - is_gaussian_curvature_selected = !is_default_parameter::value; - is_principal_curvature_selected = !is_default_parameter::value; - - set_ball_radius(radius); - } - - void set_ball_radius(const FT radius) { - if (radius == 0) - ball_radius = average_edge_length(pmesh) * EXPANDING_RADIUS_EPSILON; - else - ball_radius = radius; - } - - public: - - Interpolated_corrected_curvatures_computer(const PolygonMesh& pmesh, - const NamedParameters& np = parameters::default_values() - ) : - pmesh(pmesh) - { - set_named_params(np); - - if (is_mean_curvature_selected || is_gaussian_curvature_selected || is_principal_curvature_selected) - { - set_property_maps(); - - compute_selected_curvatures(); - } - } - - private: - Vertex_measures expand_interpolated_corrected_measure_vertex_no_radius(Vertex_descriptor v) - { - Vertex_measures vertex_curvatures; - - std::vector x; - std::vector u; - - for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { - - for (Vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) - { - Point_3 p = get(vpm, v); - x.push_back(Vector_3(p.x(), p.y(), p.z())); - u.push_back(get(vnm, v)); - } - - vertex_curvatures.area_measure += interpolated_corrected_area_measure_face(u, x); - - if (is_mean_curvature_selected) - vertex_curvatures.mean_curvature_measure += interpolated_corrected_mean_curvature_measure_face(u, x); - - if (is_gaussian_curvature_selected) - vertex_curvatures.gaussian_curvature_measure += interpolated_corrected_gaussian_curvature_measure_face(u, x); - - if (is_principal_curvature_selected) - { - const std::array face_anisotropic_measure = interpolated_corrected_anisotropic_measure_face(u, x); - for (std::size_t i = 0; i < 3 * 3; i++) - vertex_curvatures.anisotropic_measure[i] += face_anisotropic_measure[i]; - } - - x.clear(); - u.clear(); - } - - return vertex_curvatures; - } - - Vertex_measures expand_interpolated_corrected_measure_vertex(Vertex_descriptor v) - { - std::queue bfs_queue; - std::unordered_set bfs_visited; - - Point_3 vp = get(vpm, v); - Vector_3 c = Vector_3(vp.x(), vp.y(), vp.z()); - - Vertex_measures vertex_curvatures; - - for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { - if (f != boost::graph_traits::null_face()) - { - bfs_queue.push(f); - bfs_visited.insert(f); - } - } - - std::vector x; - std::vector u; - - while (!bfs_queue.empty()) { - Face_descriptor fi = bfs_queue.front(); - bfs_queue.pop(); - - // looping over vertices in face to get point coordinates - for (Vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh)) - { - Point_3 pi = get(vpm, vi); - x.push_back(Vector_3(pi.x(), pi.y(), pi.z())); - } - - const FT f_ratio = face_in_ball_ratio(x, ball_radius, c); - - if (f_ratio != 0.0) - { - for (Vertex_descriptor vi : vertices_around_face(halfedge(f, pmesh), pmesh)) - { - u.push_back(get(vnm, vi)); - } - - vertex_curvatures.area_measure += f_ratio * get(mu0_map, fi); - - if (is_mean_curvature_selected) - vertex_curvatures.mean_curvature_measure += f_ratio * get(mu1_map, fi); - - if (is_gaussian_curvature_selected) - vertex_curvatures.gaussian_curvature_measure += f_ratio * get(mu2_map, fi); - - if (is_principal_curvature_selected) - { - const std::array face_anisotropic_measure = get(muXY_map, fi); - for (std::size_t i = 0; i < 3 * 3; i++) - vertex_curvatures.anisotropic_measure[i] += f_ratio * face_anisotropic_measure[i]; - } - - x.clear(); - u.clear(); - - for (Face_descriptor fj : faces_around_face(halfedge(fi, pmesh), pmesh)) - { - if (bfs_visited.find(fj) == bfs_visited.end() && fj != boost::graph_traits::null_face()) - { - bfs_queue.push(fj); - bfs_visited.insert(fj); - } - } - } - } - return vertex_curvatures; - } - - void compute_selected_curvatures() { - for (Vertex_descriptor v : vertices(pmesh)) - { - Vertex_measures vertex_curvatures = (ball_radius < 0) ? - compute_expanded_interpolated_corrected_measure_vertex_no_radius(v) : - compute_expanded_interpolated_corrected_measure_vertex(v); - - if (is_mean_curvature_selected) { - vertex_curvatures.area_measure != 0 ? - put(mean_curvature_map, v, 0.5 * vertex_curvatures.mean_curvature_measure / vertex_curvatures.area_measure) : - put(mean_curvature_map, v, 0); - } - - if (is_gaussian_curvature_selected) { - vertex_curvatures.area_measure != 0 ? - put(gaussian_curvature_map, v, vertex_curvatures.gaussian_curvature_measure / vertex_curvatures.area_measure) : - put(gaussian_curvature_map, v, 0); - } - - if (is_principal_curvature_selected) { - const Vector_3 v_normal = get(vnm, v); - const Principal_curvature principal_curvature = principal_curvature_from_anisotropic_measures( - vertex_curvatures.anisotropic_measure, - vertex_curvatures.area_measure, - v_normal - ); - put(principal_curvature_map, v, principal_curvature); - } - } - } - - }; - - template - class Interpolated_corrected_curvatures_element_computer - { - typedef typename GetGeomTraits::type GT; - - typedef typename GT::FT FT; - typedef typename GT::Point_3 Point_3; - typedef typename GT::Vector_3 Vector_3; - - typedef typename boost::graph_traits::halfedge_descriptor Halfedge_descriptor; - typedef typename boost::graph_traits::edge_descriptor Edge_descriptor; - typedef typename boost::graph_traits::face_descriptor Face_descriptor; - typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; - - typedef typename GetVertexPointMap::const_type Vertex_position_map; - - typedef dynamic_vertex_property_t Vector_map_tag; - typedef typename boost::property_map::const_type Default_vector_map; - typedef typename internal_np::Lookup_named_param_def::type Vertex_normal_map; - - private: - const PolygonMesh& pmesh; - Vertex_position_map vpm; - Vertex_normal_map vnm; - FT ball_radius; - - bool is_mean_curvature_selected; - bool is_gaussian_curvature_selected; - bool is_principal_curvature_selected; - - void set_named_params(const NamedParameters& np) - { - using parameters::choose_parameter; - using parameters::get_parameter; - using parameters::is_default_parameter; - - vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), - get_const_property_map(CGAL::vertex_point, pmesh)); - - 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); - - const FT radius = choose_parameter(get_parameter(np, internal_np::ball_radius), -1); - - is_mean_curvature_selected = !is_default_parameter::value; - is_gaussian_curvature_selected = !is_default_parameter::value; - is_principal_curvature_selected = !is_default_parameter::value; - - set_ball_radius(radius); - } - - void set_ball_radius(const FT radius) { - if (radius == 0) - ball_radius = average_edge_length(pmesh) * EXPANDING_RADIUS_EPSILON; - else - ball_radius = radius; - } - - public: - - Interpolated_corrected_curvatures_computer(const PolygonMesh& pmesh, - const NamedParameters& np = parameters::default_values() - ) : - pmesh(pmesh) - { - set_named_params(np); - - if (is_mean_curvature_selected || is_gaussian_curvature_selected || is_principal_curvature_selected) - { - set_property_maps(); - } - } - - private: - Vertex_measures expand_interpolated_corrected_measure_vertex_no_radius(Vertex_descriptor v) - { - Vertex_measures vertex_curvatures; - - std::vector x; - std::vector u; - - for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { - - for (Vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) - { - Point_3 p = get(vpm, v); - x.push_back(Vector_3(p.x(), p.y(), p.z())); - u.push_back(get(vnm, v)); - } - - vertex_curvatures.area_measure += interpolated_corrected_area_measure_face(u, x); - - if (is_mean_curvature_selected) - vertex_curvatures.mean_curvature_measure += interpolated_corrected_mean_curvature_measure_face(u, x); - - if (is_gaussian_curvature_selected) - vertex_curvatures.gaussian_curvature_measure += interpolated_corrected_gaussian_curvature_measure_face(u, x); - - if (is_principal_curvature_selected) - { - const std::array face_anisotropic_measure = interpolated_corrected_anisotropic_measure_face(u, x); - for (std::size_t i = 0; i < 3 * 3; i++) - vertex_curvatures.anisotropic_measure[i] += face_anisotropic_measure[i]; - } - - x.clear(); - u.clear(); - } - - return vertex_curvatures; - } - - Vertex_measures expand_interpolated_corrected_measure_vertex(Vertex_descriptor v) - { - std::queue bfs_queue; - std::unordered_set bfs_visited; - - Point_3 vp = get(vpm, v); - Vector_3 c = Vector_3(vp.x(), vp.y(), vp.z()); - - Vertex_measures vertex_curvatures; - - for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { - if (f != boost::graph_traits::null_face()) - { - bfs_queue.push(f); - bfs_visited.insert(f); - } - } - - std::vector x; - std::vector u; - - while (!bfs_queue.empty()) { - Face_descriptor fi = bfs_queue.front(); - bfs_queue.pop(); - - // looping over vertices in face to get point coordinates - for (Vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh)) - { - Point_3 pi = get(vpm, vi); - x.push_back(Vector_3(pi.x(), pi.y(), pi.z())); - } - - const FT f_ratio = face_in_ball_ratio(x, ball_radius, c); - - if (f_ratio != 0.0) - { - for (Vertex_descriptor vi : vertices_around_face(halfedge(f, pmesh), pmesh)) - { - u.push_back(get(vnm, vi)); - } - - vertex_curvatures.area_measure += f_ratio * get(mu0_map, fi); - - if (is_mean_curvature_selected) - vertex_curvatures.mean_curvature_measure += f_ratio * get(mu1_map, fi); - - if (is_gaussian_curvature_selected) - vertex_curvatures.gaussian_curvature_measure += f_ratio * get(mu2_map, fi); - - if (is_principal_curvature_selected) - { - const std::array face_anisotropic_measure = get(muXY_map, fi); - for (std::size_t i = 0; i < 3 * 3; i++) - vertex_curvatures.anisotropic_measure[i] += f_ratio * face_anisotropic_measure[i]; - } - - x.clear(); - u.clear(); - - for (Face_descriptor fj : faces_around_face(halfedge(fi, pmesh), pmesh)) - { - if (bfs_visited.find(fj) == bfs_visited.end() && fj != boost::graph_traits::null_face()) - { - bfs_queue.push(fj); - bfs_visited.insert(fj); - } - } - } - } - return vertex_curvatures; - } - - void compute_selected_curvatures() { - for (Vertex_descriptor v : vertices(pmesh)) - { - Vertex_measures vertex_curvatures = (ball_radius < 0) ? - compute_expanded_interpolated_corrected_measure_vertex_no_radius(v) : - compute_expanded_interpolated_corrected_measure_vertex(v); - - if (is_mean_curvature_selected) { - vertex_curvatures.area_measure != 0 ? - put(mean_curvature_map, v, 0.5 * vertex_curvatures.mean_curvature_measure / vertex_curvatures.area_measure) : - put(mean_curvature_map, v, 0); - } - - if (is_gaussian_curvature_selected) { - vertex_curvatures.area_measure != 0 ? - put(gaussian_curvature_map, v, vertex_curvatures.gaussian_curvature_measure / vertex_curvatures.area_measure) : - put(gaussian_curvature_map, v, 0); - } - - if (is_principal_curvature_selected) { - const Vector_3 v_normal = get(vnm, v); - const Principal_curvature principal_curvature = principal_curvature_from_anisotropic_measures( - vertex_curvatures.anisotropic_measure, - vertex_curvatures.area_measure, - v_normal - ); - put(principal_curvature_map, v, principal_curvature); - } - } - } - - }; - } // namespace internal /** @@ -1247,7 +799,7 @@ namespace internal { * \cgalNamedParamsEnd * * @see `interpolated_corrected_gaussian_curvature()` -* @see `interpolated_corrected_principal_curvatures()` +* @see `interpolated_corrected_principal_curvatures_and_directions()` * @see `interpolated_corrected_curvatures()` */ @@ -1311,7 +863,7 @@ template - void interpolated_corrected_principal_curvatures(const PolygonMesh& pmesh, + void interpolated_corrected_principal_curvatures_and_directions(const PolygonMesh& pmesh, VertexCurvatureMap& vcm, NamedParameters& np = parameters::default_values()) { - interpolated_corrected_curvatures(pmesh, np.vertex_principal_curvature_map(vcm)); + interpolated_corrected_curvatures(pmesh, np.vertex_principal_curvatures_and_directions_map(vcm)); } /** @@ -1441,7 +993,7 @@ template::%Vertex_descriptor` @@ -1465,7 +1017,7 @@ template diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp index 21b292b05d0c..09df28bc2816 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp @@ -14,7 +14,7 @@ #include using namespace CGAL::Three; -class Polyhedron_demo_interpolated_corrected_principal_curvatures_plugin : +class Polyhedron_demo_interpolated_corrected_principal_curvatures_and_directions_plugin : public QObject, public Polyhedron_demo_plugin_interface { @@ -47,7 +47,7 @@ public Q_SLOTS: private : Scene_interface *scene; QList _actions; -}; // end Polyhedron_demo_interpolated_corrected_principal_curvatures_plugin +}; // end Polyhedron_demo_interpolated_corrected_principal_curvatures_and_directions_plugin void compute(SMesh* sMesh, @@ -72,23 +72,23 @@ void compute(SMesh* sMesh, typename boost::property_map::type vpmap = get(CGAL::vertex_point, *sMesh); bool created = false; - SMesh::Property_map principal_curvature_map; + SMesh::Property_map principal_curvatures_and_directions_map; - boost::tie(principal_curvature_map, created) = sMesh->add_property_map - ("v:principal_curvature_map", { 0, 0, + boost::tie(principal_curvatures_and_directions_map, created) = sMesh->add_property_map + ("v:principal_curvatures_and_directions_map", { 0, 0, Vector(0,0,0), Vector(0,0,0)}); assert(created); - PMP::interpolated_corrected_principal_curvatures( + PMP::interpolated_corrected_principal_curvatures_and_directions( *sMesh, - principal_curvature_map + principal_curvatures_and_directions_map ); typename EpicKernel::FT max_curvature_magnitude_on_mesh = 0; for (vertex_descriptor v : vertices(*sMesh)) { - const PrincipalCurvatureTuple pc = principal_curvature_map[v]; + const PrincipalCurvatureTuple pc = principal_curvatures_and_directions_map[v]; max_curvature_magnitude_on_mesh = std::max(max_curvature_magnitude_on_mesh, std::max(abs(get<0>(pc)), get<1>(pc))); } @@ -114,7 +114,7 @@ void compute(SMesh* sMesh, avg_edge_length /= n; } - const PrincipalCurvatureTuple pc = principal_curvature_map[v]; + const PrincipalCurvatureTuple pc = principal_curvatures_and_directions_map[v]; Vector umin = (std::get<0>(pc)/ max_curvature_magnitude_on_mesh) * std::get<2>(pc) * avg_edge_length; Vector umax = (std::get<1>(pc)/ max_curvature_magnitude_on_mesh) * std::get<3>(pc) * avg_edge_length; @@ -133,7 +133,7 @@ void compute(SMesh* sMesh, } } -void Polyhedron_demo_interpolated_corrected_principal_curvatures_plugin::on_actionEstimateCurvature_triggered() +void Polyhedron_demo_interpolated_corrected_principal_curvatures_and_directions_plugin::on_actionEstimateCurvature_triggered() { // get active polyhedron const CGAL::Three::Scene_interface::Item_id index = scene->mainSelectionIndex(); @@ -183,4 +183,4 @@ void Polyhedron_demo_interpolated_corrected_principal_curvatures_plugin::on_acti QApplication::restoreOverrideCursor(); } -#include "Interpolated_corrected_principal_curvatures_plugin.moc" +#include "Interpolated_corrected_principal_curvatures_and_directions_plugin.moc" diff --git a/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h index 03ee822d0bc9..21b8227e86c9 100644 --- a/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h +++ b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h @@ -89,7 +89,7 @@ CGAL_add_named_parameter(nb_points_per_area_unit_t, nb_points_per_area_unit, num CGAL_add_named_parameter(nb_points_per_distance_unit_t, nb_points_per_distance_unit, number_of_points_per_distance_unit) CGAL_add_named_parameter(vertex_mean_curvature_map_t, vertex_mean_curvature_map, vertex_mean_curvature_map) CGAL_add_named_parameter(vertex_gaussian_curvature_map_t, vertex_gaussian_curvature_map, vertex_gaussian_curvature_map) -CGAL_add_named_parameter(vertex_principal_curvature_map_t, vertex_principal_curvature_map, vertex_principal_curvature_map) +CGAL_add_named_parameter(vertex_principal_curvatures_and_directions_map_t, vertex_principal_curvatures_and_directions_map, vertex_principal_curvatures_and_directions_map) CGAL_add_named_parameter(ball_radius_t, ball_radius, ball_radius) CGAL_add_named_parameter(outward_orientation_t, outward_orientation, outward_orientation) CGAL_add_named_parameter(overlap_test_t, overlap_test, do_overlap_test_of_bounded_sides) From f35faf60e18ace1d90646823bd7c1ff1ff8ddb1e Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sat, 19 Nov 2022 11:54:20 +0200 Subject: [PATCH 085/142] minor doc fixes and renaming --- .../PackageDescription.txt | 4 ++-- .../Polygon_mesh_processing.txt | 17 ++++++++-------- ...erpolated_corrected_curvatures_example.cpp | 4 ++-- ...orrected_curvatures_polyhedron_example.cpp | 4 ++-- ...nterpolated_corrected_curvature_measures.h | 20 +++++++++---------- 5 files changed, 24 insertions(+), 25 deletions(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt index 5090535be250..f62b2816cf7f 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt @@ -200,12 +200,12 @@ The page \ref bgl_namedparameters "Named Parameters" describes their usage. - \link PMP_locate_grp Nearest Face Location Queries \endlink - \link PMP_locate_grp Random Location Generation \endlink -\cgalCRPSection{Corrected Curvature Functions} +\cgalCRPSection{Corrected Curvatures} - `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures()` -- `CGAL::Polygon_mesh_processing::Principal_curvature` +- `CGAL::Polygon_mesh_processing::Principal_curvatures_and_directions` \cgalCRPSection{Normal Computation Functions} - `CGAL::Polygon_mesh_processing::compute_face_normal()` diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index 2347ae1c7ae8..1d7184561a80 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -879,11 +879,11 @@ not provide storage for the normals. **************************************** \section PMPICC Computing Curvatures -This package provides methods to compute curvatures on polygonal meshes based on \cgalCite{lachaud2020} -This includes mean curvature, gaussian curvature, principal curvatures and directions. -These can be computed on triangle meshes, quad meshes, and meshes with n-gon faces. -The algorithms used prove to work well in general. Also, on meshes with noise -on vertex positions, they give accurate results, on the condition that the +This package provides methods to compute curvatures on polygonal meshes based on Interpolated Corrected Curvatures +on Polyhedral Surfaces \cgalCite{lachaud2020}. This includes mean curvature, gaussian curvature, +principal curvatures and directions. These can be computed on triangle meshes, quad meshes, +and meshes with n-gon faces. The algorithms used prove to work well in general. Also, on meshes +with noise on vertex positions, they give accurate results, on the condition that the correct vertex normals are provided. The implementation is generic in terms of mesh data structure. It can be used on Surface_mesh, @@ -912,13 +912,12 @@ The mean curvature distribution on a bear mesh with different values for the exp Property maps are used to record the computed curvatures as shown in examples. -\subsection ICCExample Interpolated Corrected Curvature Examples Property maps are an API introduced in the boost library that allows associating values to keys. In the following examples, for each property map, we associate a curvature value to each vertex. -\subsubsection ICCExampleSM Interpolated Corrected Curvature on a Surface Mesh. +\subsection ICCExampleSM Interpolated Corrected Curvature on a Surface Mesh Example The following example illustrates how to compute the curvatures on vertices @@ -926,7 +925,7 @@ and store them in property maps provided by the class `Surface_mesh`. \cgalExample{Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp} -\subsubsection ICCExamplePH Interpolated Corrected Curvature on a Polyhedron +\subsection ICCExamplePH Interpolated Corrected Curvature on a Polyhedron Example The following example illustrates how to compute the curvatures on vertices @@ -1143,7 +1142,7 @@ is covered by a set of prisms, where each prism is an offset for an input triang That is, the implementation in \cgal does not use indirect predicates. The interpolated corrected curvatures were implemented during GSoC 2022. This was implemented by Hossam Saeed and under -supervision of Sebastien Loriot, Jaques-Olivier Lachaud and David Coeurjolly. The implementation is based \cgalCite{lachaud2020}. +supervision of Sebastien Loriot, Jaques-Olivier Lachaud and David Coeurjolly. The implementation is based on \cgalCite{lachaud2020}. DGtal's implementation was also used as a reference during the project. diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp index 71aa06a8caec..33d34cd34f13 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp @@ -38,9 +38,9 @@ int main(int argc, char* argv[]) assert(created); // we use a tuple of 2 scalar values and 2 vectors for principal curvatures and directions - Surface_Mesh::Property_map> principal_curvatures_and_directions_map; + Surface_Mesh::Property_map> principal_curvatures_and_directions_map; - boost::tie(principal_curvatures_and_directions_map, created) = smesh.add_property_map> + boost::tie(principal_curvatures_and_directions_map, created) = smesh.add_property_map> ("v:principal_curvatures_and_directions_map", { 0, 0, Epic_kernel::Vector_3(0,0,0), Epic_kernel::Vector_3(0,0,0) }); diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp index 50fe1a014d8e..6bbe49ce37e5 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp @@ -30,8 +30,8 @@ int main(int argc, char *argv[]) boost::property_map>::type mean_curvature_map = get(CGAL::dynamic_vertex_property_t(), polyhedron), gaussian_curvature_map = get(CGAL::dynamic_vertex_property_t(), polyhedron); - boost::property_map>>::type - principal_curvatures_and_directions_map = get(CGAL::dynamic_vertex_property_t>(), polyhedron); + boost::property_map>>::type + principal_curvatures_and_directions_map = get(CGAL::dynamic_vertex_property_t>(), polyhedron); PMP::interpolated_corrected_mean_curvature( polyhedron, 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 3b02341a2129..6ed11404a257 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 @@ -43,7 +43,7 @@ namespace Polygon_mesh_processing { * @tparam GT is the geometric traits class. */ template -struct Principal_curvature { +struct Principal_curvatures_and_directions { /// min curvature magnitude typename GT::FT min_curvature; @@ -57,14 +57,14 @@ struct Principal_curvature { /// max curvature direction vector typename GT::Vector_3 max_direction; - Principal_curvature() { + Principal_curvatures_and_directions() { min_curvature = 0; max_curvature = 0; min_direction = typename GT::Vector_3(0, 0, 0); max_direction = typename GT::Vector_3(0, 0, 0); } - Principal_curvature( + Principal_curvatures_and_directions( typename GT::FT min_curvature, typename GT::FT max_curvature, typename GT::Vector_3 min_direction, @@ -440,7 +440,7 @@ namespace internal { } template - Principal_curvature principal_curvatures_and_directions_from_anisotropic_measures( + Principal_curvatures_and_directions principal_curvatures_and_directions_from_anisotropic_measures( const std::array anisotropic_measure, const typename GT::FT v_mu0, const typename GT::Vector_3 u_GT @@ -462,7 +462,7 @@ namespace internal { eigensolver.computeDirect(v_muXY); if (eigensolver.info() != Eigen::Success) - return Principal_curvature(); + return Principal_curvatures_and_directions(); const Eigen::Matrix eig_vals = eigensolver.eigenvalues(); const Eigen::Matrix eig_vecs = eigensolver.eigenvectors(); @@ -470,7 +470,7 @@ namespace internal { const typename GT::Vector_3 min_eig_vec(eig_vecs(0, 1), eig_vecs(1, 1), eig_vecs(2, 1)); const typename GT::Vector_3 max_eig_vec(eig_vecs(0, 0), eig_vecs(1, 0), eig_vecs(2, 0)); - return Principal_curvature( + return Principal_curvatures_and_directions( (v_mu0 != 0.0) ? -eig_vals[1] / v_mu0 : 0.0, (v_mu0 != 0.0) ? -eig_vals[0] / v_mu0 : 0.0, min_eig_vec, @@ -509,7 +509,7 @@ namespace internal { NamedParameters, Default_scalar_map>::type Vertex_gaussian_curvature_map; - typedef Constant_property_map> Default_principal_map; + typedef Constant_property_map> Default_principal_map; typedef typename internal_np::Lookup_named_param_def::type Vertex_principal_curvatures_and_directions_map; @@ -735,7 +735,7 @@ namespace internal { if (is_principal_curvatures_and_directions_selected) { const Vector_3 v_normal = get(vnm, v); - const Principal_curvature principal_curvatures_and_directions = principal_curvatures_and_directions_from_anisotropic_measures( + const Principal_curvatures_and_directions principal_curvatures_and_directions = principal_curvatures_and_directions_from_anisotropic_measures( vertex_measures.anisotropic_measure, vertex_measures.area_measure, v_normal @@ -997,8 +997,8 @@ template::%Vertex_descriptor` -* as key type and `%Principal_curvature` as value type} -* \cgalParamDefault{`get(dynamic_vertex_property_t>(), pmesh)`} +* as key type and `%Principal_curvatures_and_directions` as value type} +* \cgalParamDefault{`get(dynamic_vertex_property_t>(), pmesh)`} * \cgalParamExtra{If this parameter is omitted, mean principal won't be computed} * \cgalParamNEnd * From fe8988b650046236a9dc26c39707c915de4c4147 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sat, 19 Nov 2022 12:16:27 +0200 Subject: [PATCH 086/142] demo fixes --- .../demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index 6efc7f213fe2..404bb20f8072 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -1638,7 +1638,7 @@ private Q_SLOTS: std::unordered_map is_source; - double expand_radius; + double expand_radius = 0; double maxEdgeLength = -1; double minBox; double maxBox; From dd49b0c0d87eb344efc3ef994c32b74ca2916706 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sat, 19 Nov 2022 12:18:28 +0200 Subject: [PATCH 087/142] demo fixes --- ..._corrected_principal_curvatures_plugin.cpp | 64 +++++++++---------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp index 09df28bc2816..789ba4a06567 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp @@ -57,42 +57,38 @@ void compute(SMesh* sMesh, Scene_polylines_item* min_negative_curv) { namespace PMP = CGAL::Polygon_mesh_processing; - typedef CGAL::Exact_predicates_inexact_constructions_kernel EpicKernel; - typedef EpicKernel::Point_3 Point; - typedef EpicKernel::Point_3 Point; - typedef EpicKernel::Vector_3 Vector; - typedef boost::graph_traits::vertex_descriptor vertex_descriptor; - typedef std::tuple< - EpicKernel::FT, - EpicKernel::FT, - Vector, - Vector - > PrincipalCurvatureTuple; + typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic_kernel; + typedef Epic_kernel::Point_3 Point; + typedef Epic_kernel::Point_3 Point; + typedef Epic_kernel::Vector_3 Vector; + typedef boost::graph_traits::vertex_descriptor Vertex_descriptor; typename boost::property_map::type vpmap = get(CGAL::vertex_point, *sMesh); bool created = false; - SMesh::Property_map principal_curvatures_and_directions_map; + SMesh::Property_map> principal_curvatures_and_directions_map; + + boost::tie(principal_curvatures_and_directions_map, created) = sMesh->add_property_map> + ("v:principal_curvatures_and_directions_map", { 0, 0, + Vector(0,0,0), + Vector(0,0,0) }); + assert(created); - boost::tie(principal_curvatures_and_directions_map, created) = sMesh->add_property_map - ("v:principal_curvatures_and_directions_map", { 0, 0, - Vector(0,0,0), - Vector(0,0,0)}); - assert(created); PMP::interpolated_corrected_principal_curvatures_and_directions( - *sMesh, - principal_curvatures_and_directions_map + *sMesh, + principal_curvatures_and_directions_map, + CGAL::parameters::ball_radius(0) ); - typename EpicKernel::FT max_curvature_magnitude_on_mesh = 0; - for (vertex_descriptor v : vertices(*sMesh)) + typename Epic_kernel::FT max_curvature_magnitude_on_mesh = 0; + for (Vertex_descriptor v : vertices(*sMesh)) { - const PrincipalCurvatureTuple pc = principal_curvatures_and_directions_map[v]; - max_curvature_magnitude_on_mesh = std::max(max_curvature_magnitude_on_mesh, std::max(abs(get<0>(pc)), get<1>(pc))); + const PMP::Principal_curvatures_and_directions pc = principal_curvatures_and_directions_map[v]; + max_curvature_magnitude_on_mesh = std::max(max_curvature_magnitude_on_mesh, std::max(abs(pc.min_curvature), abs(pc.max_curvature))); } - for(vertex_descriptor v : vertices(*sMesh)) + for(Vertex_descriptor v : vertices(*sMesh)) { std::vector points; @@ -107,17 +103,17 @@ void compute(SMesh* sMesh, const std::size_t n = CGAL::edges(*sMesh).size(); - EpicKernel::FT avg_edge_length = 0; + Epic_kernel::FT avg_edge_length = 0; if (n > 0) { - for (auto e : CGAL::edges(*sMesh)) - avg_edge_length += PMP::edge_length(e, *sMesh); - avg_edge_length /= n; + for (auto e : CGAL::edges(*sMesh)) + avg_edge_length += PMP::edge_length(e, *sMesh); + avg_edge_length /= n; } - const PrincipalCurvatureTuple pc = principal_curvatures_and_directions_map[v]; + const PMP::Principal_curvatures_and_directions pc = principal_curvatures_and_directions_map[v]; - Vector umin = (std::get<0>(pc)/ max_curvature_magnitude_on_mesh) * std::get<2>(pc) * avg_edge_length; - Vector umax = (std::get<1>(pc)/ max_curvature_magnitude_on_mesh) * std::get<3>(pc) * avg_edge_length; + Vector umin = (pc.min_curvature / max_curvature_magnitude_on_mesh) * pc.min_direction * avg_edge_length; + Vector umax = (pc.max_curvature / max_curvature_magnitude_on_mesh) * pc.max_direction * avg_edge_length; Scene_polylines_item::Polyline max_segment(2), min_segment(2); @@ -128,8 +124,8 @@ void compute(SMesh* sMesh, max_segment[0] = central_point + du * umax; max_segment[1] = central_point - du * umax; - (std::get<0>(pc) > 0 ? min_curv : min_negative_curv)->polylines.push_back(min_segment); - (std::get<1>(pc) > 0 ? max_curv : max_negative_curv)->polylines.push_back(max_segment); + (pc.min_curvature > 0 ? min_curv : min_negative_curv)->polylines.push_back(min_segment); + (pc.max_curvature > 0 ? max_curv : max_negative_curv)->polylines.push_back(max_segment); } } @@ -183,4 +179,4 @@ void Polyhedron_demo_interpolated_corrected_principal_curvatures_and_directions_ QApplication::restoreOverrideCursor(); } -#include "Interpolated_corrected_principal_curvatures_and_directions_plugin.moc" +#include "Interpolated_corrected_principal_curvatures_plugin.moc" From d96dca1264c3f53a836d6410165c60910967e005 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sat, 19 Nov 2022 17:16:28 +0200 Subject: [PATCH 088/142] Skipping concave n-gons case for now remove face triangulation function draft --- .../triangulate_faces.h | 147 ------------------ 1 file changed, 147 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h index abe56ea35a61..0b48967f2733 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/triangulate_faces.h @@ -499,153 +499,6 @@ bool triangulate_face(typename boost::graph_traits::face_descriptor return modifier.triangulate_face(f, pmesh, use_cdt, visitor); } - -#ifndef CGAL_TRIANGULATE_FACES_DO_NOT_USE_CDT2 -template -OutputIterator -face_triangulation(typename boost::graph_traits::face_descriptor f, - PolygonMesh& pmesh, - OutputIterator out, - const NamedParameters& np = parameters::default_values()) -{ - using parameters::choose_parameter; - using parameters::get_parameter; - - //VertexPointMap - typedef typename GetVertexPointMap::type VPMap; - VPMap vpmap = choose_parameter(get_parameter(np, internal_np::vertex_point), - get_property_map(vertex_point, pmesh)); - - //Kernel - typedef typename GetGeomTraits::type Kernel; - Kernel traits = choose_parameter(get_parameter(np, internal_np::geom_traits)); - - //Face_info - typedef typename internal::Triangulate_modifier>::Face_info Face_info; - - //CDT - typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - typedef CGAL::Projection_traits_3 P_traits; - typedef CGAL::Triangulation_vertex_base_with_info_2 Vb; - typedef CGAL::Triangulation_face_base_with_info_2 Fb1; - typedef CGAL::Constrained_triangulation_face_base_2 Fb; - typedef CGAL::Triangulation_data_structure_2 TDS; - typedef CGAL::Exact_intersections_tag Itag; - typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; - P_traits cdt_traits(normal); - CDT cdt(cdt_traits); - - std::size_t original_size = CGAL::halfedges_around_face(halfedge(f, pmesh), pmesh).size(); - - // Halfedge_around_facet_circulator - typedef typename CDT::Vertex_handle Tr_Vertex_handle; - halfedge_descriptor start = halfedge(f, pmesh); - halfedge_descriptor h = start; - Tr_Vertex_handle previous, first; - do - { - Tr_Vertex_handle vh = cdt.insert(get(_vpmap, target(h, pmesh))); - if (first == Tr_Vertex_handle()) { - first = vh; - } - vh->info() = h; - if(previous != Tr_Vertex_handle() && previous != vh) { - cdt.insert_constraint(previous, vh); - } - previous = vh; - h = next(h, pmesh); - - } while( h != start ); - cdt.insert_constraint(previous, first); - - // sets mark is_external - for(typename CDT::All_faces_iterator fit = cdt.all_faces_begin(), - end = cdt.all_faces_end(); - fit != end; ++fit) - { - fit->info().is_external = false; - } - std::queue face_queue; - face_queue.push(cdt.infinite_vertex()->face()); - while(! face_queue.empty() ) - { - typename CDT::Face_handle fh = face_queue.front(); - face_queue.pop(); - - if(fh->info().is_external) - continue; - - fh->info().is_external = true; - for(int i = 0; i <3; ++i) - { - if(!cdt.is_constrained(typename CDT::Edge(fh, i))) - { - face_queue.push(fh->neighbor(i)); - } - } - } - - if(cdt.dimension() != 2 || cdt.number_of_vertices() != original_size) - return out; - - for(typename CDT::Finite_edges_iterator eit = cdt.finite_edges_begin(), - end = cdt.finite_edges_end(); - eit != end; ++eit) - { - typename CDT::Face_handle fh = eit->first; - const int index = eit->second; - typename CDT::Face_handle opposite_fh = fh->neighbor(eit->second); - const int opposite_index = opposite_fh->index(fh); - - const Tr_Vertex_handle va = fh->vertex(cdt. cw(index)); - const Tr_Vertex_handle vb = fh->vertex(cdt.ccw(index)); - - if( ! (is_external(fh) && is_external(opposite_fh))//not both fh are external - && ! cdt.is_constrained(*eit) ) //and edge is not constrained - { - // strictly internal edge - halfedge_descriptor hnew = halfedge(add_edge(pmesh), pmesh), - hnewopp = opposite(hnew, pmesh); - - fh->info().e[index] = hnew; - opposite_fh->info().e[opposite_index] = hnewopp; - - set_target(hnew, target(va->info(), pmesh), pmesh); - set_target(hnewopp, target(vb->info(), pmesh), pmesh); - } - if( cdt.is_constrained(*eit) ) //edge is constrained - { - if(!is_external(fh)) { - fh->info().e[index] = va->info(); - } - if(!is_external(opposite_fh)) { - opposite_fh->info().e[opposite_index] = vb->info(); - } - } - } - for(typename CDT::Finite_faces_iterator fit = cdt.finite_faces_begin(), - end = cdt.finite_faces_end(); - fit != end; ++fit) - { - if(!is_external(fit)) - { - halfedge_descriptor h0 = fit->info().e[0]; - halfedge_descriptor h1 = fit->info().e[1]; - halfedge_descriptor h2 = fit->info().e[2]; - *out++=std::make_tuple(target(h0, pmesh), target(h1, pmesh), target(h2,pmesh)); - } - } - - return out; -} -#endif - - - /** * \ingroup PMP_meshing_grp * From 0ac812bd2f57e4efbea92c7cbaf0bc5579166dac Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sat, 19 Nov 2022 17:23:15 +0200 Subject: [PATCH 089/142] minor change, position shouldn't be optional that is, in area and mean measures, in gaussian, it is not needed --- .../Curvatures/interpolated_corrected_curvature_measures.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 6ed11404a257..f14904c6799a 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 @@ -111,7 +111,7 @@ namespace internal { template typename GT::FT interpolated_corrected_area_measure_face(const std::vector& u, - const std::vector& x = {}) + const std::vector& x) { const std::size_t n = x.size(); CGAL_precondition(u.size() == n); @@ -166,7 +166,7 @@ namespace internal { template typename GT::FT interpolated_corrected_mean_curvature_measure_face(const std::vector& u, - const std::vector& x = {}) + const std::vector& x) { const std::size_t n = x.size(); CGAL_precondition(u.size() == n); @@ -617,7 +617,7 @@ namespace internal { put(mu1_map, f, interpolated_corrected_mean_curvature_measure_face(u, x)); if (is_gaussian_curvature_selected) - put(mu2_map, f, interpolated_corrected_gaussian_curvature_measure_face(u, x)); + put(mu2_map, f, interpolated_corrected_gaussian_curvature_measure_face(u)); if (is_principal_curvatures_and_directions_selected) put(muXY_map, f, interpolated_corrected_anisotropic_measure_face(u, x)); From d5a2cf1f0555a015ea3d17c24624565cbb4aebcc Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sat, 19 Nov 2022 19:27:33 +0200 Subject: [PATCH 090/142] fixed an expansion bug when mesh has boundary and no input radius is specified --- .../Curvatures/interpolated_corrected_curvature_measures.h | 3 +++ 1 file changed, 3 insertions(+) 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 f14904c6799a..4a50a618e66f 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 @@ -632,6 +632,9 @@ namespace internal { Vertex_measures vertex_measures; for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { + if (f == boost::graph_traits::null_face()) + continue; + vertex_measures.area_measure += get(mu0_map, f); if (is_mean_curvature_selected) From 1fd56cdd1dfd5fa06184c1ea38fe581f29c02fdf Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sun, 20 Nov 2022 00:28:10 +0200 Subject: [PATCH 091/142] testing file for implemented functions --- .../Polygon_mesh_processing/CMakeLists.txt | 2 +- ...est_interopolated_corrected_curvatures.cpp | 148 --------------- ...test_interpolated_corrected_curvatures.cpp | 178 ++++++++++++++++++ 3 files changed, 179 insertions(+), 149 deletions(-) delete mode 100644 Polygon_mesh_processing/test/Polygon_mesh_processing/test_interopolated_corrected_curvatures.cpp create mode 100644 Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt index 808e6d3a05ef..c1aedddedf4e 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt @@ -69,7 +69,7 @@ create_single_source_cgal_program("self_intersection_polyhedron_test.cpp") create_single_source_cgal_program("self_intersection_surface_mesh_test.cpp") create_single_source_cgal_program("pmp_do_intersect_test.cpp") create_single_source_cgal_program("test_is_polygon_soup_a_polygon_mesh.cpp") -create_single_source_cgal_program("test_interopolated_corrected_curvatures.cpp") +create_single_source_cgal_program("test_interpolated_corrected_curvatures.cpp") create_single_source_cgal_program("test_stitching.cpp") create_single_source_cgal_program("remeshing_test.cpp") create_single_source_cgal_program("remeshing_with_isolated_constraints_test.cpp" ) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interopolated_corrected_curvatures.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interopolated_corrected_curvatures.cpp deleted file mode 100644 index b2dbcc0850bb..000000000000 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interopolated_corrected_curvatures.cpp +++ /dev/null @@ -1,148 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -namespace PMP = CGAL::Polygon_mesh_processing; - -typedef CGAL::Exact_predicates_inexact_constructions_kernel EpicKernel; -typedef CGAL::Surface_mesh SMesh; -typedef boost::graph_traits::face_descriptor face_descriptor; -typedef boost::graph_traits::edge_descriptor edge_descriptor; -typedef boost::graph_traits::vertex_descriptor vertex_descriptor; - -void test(std::string mesh_path, EpicKernel::FT rel_expansion_radius, EpicKernel::FT rel_noise_magnitude) { - SMesh pmesh; - const std::string filename = CGAL::data_file_path(mesh_path); - - if (!CGAL::IO::read_polygon_mesh(filename, pmesh)) - { - std::cerr << "Invalid input file." << std::endl; - } - - bool created = false; - - SMesh::Property_map mean_curvature_map, gaussian_curvature_map; - boost::tie(mean_curvature_map, created) = pmesh.add_property_map("v:mean_curvature_map", 0); - assert(created); - - boost::tie(gaussian_curvature_map, created) = pmesh.add_property_map("v:gaussian_curvature_map", 0); - assert(created); - - // getting the max and min edge lengthes - const auto edge_range = CGAL::edges(pmesh); - - const auto edge_length_comparator = [&, pmesh](auto l, auto r) { - return PMP::edge_length(l, pmesh) < PMP::edge_length(r, pmesh); - }; - - const edge_descriptor longest_edge = *std::max_element(edge_range.begin(), edge_range.end(), edge_length_comparator); - const EpicKernel::FT max_edge_length = PMP::edge_length(longest_edge, pmesh); - - const edge_descriptor shortest_edge = *std::min_element(edge_range.begin(), edge_range.end(), edge_length_comparator); - const EpicKernel::FT min_edge_length = PMP::edge_length(shortest_edge, pmesh); - - - if (rel_noise_magnitude > 0) - { - if (!CGAL::is_triangle_mesh(pmesh)) - return; - - SMesh::Property_map vnm; - boost::tie(vnm, created) = pmesh.add_property_map("v:vnm", { 0 , 0 , 0 }); - assert(created); - - CGAL::Polygon_mesh_processing::compute_vertex_normals(pmesh, vnm); - - PMP::random_perturbation(pmesh, rel_noise_magnitude * min_edge_length, CGAL::parameters::random_seed(0)); - PMP::interpolated_corrected_mean_curvature( - pmesh, - mean_curvature_map, - CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length).vertex_normal_map(vnm) - ); - PMP::interpolated_corrected_gaussian_curvature( - pmesh, - gaussian_curvature_map, - CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length).vertex_normal_map(vnm) - ); - } - else { - PMP::interpolated_corrected_mean_curvature( - pmesh, - mean_curvature_map, - CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length) - ); - PMP::interpolated_corrected_gaussian_curvature( - pmesh, - gaussian_curvature_map, - CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length) - ); - - } - - - - //PMP::interpolated_corrected_mean_curvature( - // pmesh, - // mean_curvature_map, - // CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length) - //); - //PMP::interpolated_corrected_gaussian_curvature( - // pmesh, - // gaussian_curvature_map, - // CGAL::parameters::ball_radius(rel_expansion_radius * max_edge_length) - //); - - - const EpicKernel::FT max_mean_curvature = *std::max_element(mean_curvature_map.begin(), mean_curvature_map.end()); - const EpicKernel::FT min_mean_curvature = *std::min_element(mean_curvature_map.begin(), mean_curvature_map.end()); - const EpicKernel::FT max_gaussian_curvature = *std::max_element(gaussian_curvature_map.begin(), gaussian_curvature_map.end()); - const EpicKernel::FT min_gaussian_curvature = *std::min_element(gaussian_curvature_map.begin(), gaussian_curvature_map.end()); - - std::cout << "# " << mesh_path << ":\n" - << "expansion radius ratio to max length / expansion radius = " << rel_expansion_radius << " / " << rel_expansion_radius * max_edge_length << ",\n" - << "max perturbation ratio to minlength / max perturbation = " << rel_noise_magnitude << " / " << rel_noise_magnitude * min_edge_length << "\n" - << "mean curvature: min = " << min_mean_curvature << " <-> " << max_mean_curvature << " = max" << "\n" - << "gaussian curvature: min = " << min_gaussian_curvature << " <-> " << max_gaussian_curvature << " = max" << "\n\n\n"; - - -} - -int main() -{ - const std::vector mesh_pathes_to_test = { - "meshes/icc_test/Sphere Quads + Tris.obj", - "meshes/icc_test/Sphere Quads + Tris 100352.obj", - "meshes/icc_test/Sphere Tris Ico.obj", - "meshes/icc_test/Sphere Tris Tet.obj", - "meshes/icc_test/Sphere Tris Oct.obj", - "meshes/icc_test/Sphere Quads.obj", - "meshes/icc_test/Sphere Quads Remesh.obj", - "meshes/icc_test/Sphere Ngons + Quads + Tris.obj", - "meshes/icc_test/Cube with fillet Quads.obj", - "meshes/cylinder.off", - "meshes/icc_test/Lantern Tris.obj", - "meshes/icc_test/Lantern Quads.obj" - }; - - const std::vector rel_expansion_radii = { 0, 0.1, 0.5, 1 }; - const std::vector rel_noise_magnitudes = { 0, 0.5, 0.9 }; - - for (auto mesh_path : mesh_pathes_to_test) { - for (EpicKernel::FT rel_expansion_radius : rel_expansion_radii) - for (EpicKernel::FT rel_noise_magnitude : rel_noise_magnitudes) - { - test(mesh_path, rel_expansion_radius, rel_noise_magnitude); - } - - std::cout << "_________________________________________________________________________________\n\n"; - } - -} diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp new file mode 100644 index 000000000000..a4f43470332e --- /dev/null +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp @@ -0,0 +1,178 @@ +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#define ABS_ERROR 1e-6 + +namespace PMP = CGAL::Polygon_mesh_processing; + +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic_kernel; +typedef CGAL::Surface_mesh SMesh; +typedef CGAL::Polyhedron_3 Polyhedron; + +struct Average_test_info { + Epic_kernel::FT expansion_radius = -1; + Epic_kernel::FT mean_curvature_avg; + Epic_kernel::FT gaussian_curvature_avg; + Epic_kernel::FT principal_curvature_avg; + Epic_kernel::FT tolerance = 0.9; + + Average_test_info( + Epic_kernel::FT mean_curvature_avg, + Epic_kernel::FT gaussian_curvature_avg, + Epic_kernel::FT principal_curvature_avg, + Epic_kernel::FT expansion_radius = -1, + Epic_kernel::FT tolerance = 0.9 + ): + expansion_radius(expansion_radius), + mean_curvature_avg(mean_curvature_avg), + gaussian_curvature_avg(gaussian_curvature_avg), + principal_curvature_avg(principal_curvature_avg), + tolerance(tolerance) + { + } + +}; + +bool passes_comparison(Epic_kernel::FT result, Epic_kernel::FT expected, Epic_kernel::FT tolerance) +{ + if (abs(expected) < ABS_ERROR && abs(result) < ABS_ERROR) + return true; // expected 0, got 0 + else if (abs(expected) < ABS_ERROR) + return false; // expected 0, got non-0 + + return std::min(result, expected) / std::max(result, expected) > tolerance; +} + +template +void test_average_curvatures(std::string mesh_path, Average_test_info test_info){ + PolygonMesh pmesh; + const std::string filename = CGAL::data_file_path(mesh_path); + + if (!CGAL::IO::read_polygon_mesh(filename, pmesh) || faces(pmesh).size() == 0) + { + std::cerr << "Invalid input file." << std::endl; + } + + typedef boost::graph_traits::vertex_descriptor vertex_descriptor; + + boost::property_map>::type + mean_curvature_map = get(CGAL::dynamic_vertex_property_t(), pmesh), + gaussian_curvature_map = get(CGAL::dynamic_vertex_property_t(), pmesh); + boost::property_map>>::type + principal_curvatures_and_directions_map = get(CGAL::dynamic_vertex_property_t>(), pmesh); + + // test_info.expansion_radius -> test if no radius is provided by user. + if (test_info.expansion_radius < 0) { + PMP::interpolated_corrected_mean_curvature(pmesh, mean_curvature_map); + PMP::interpolated_corrected_gaussian_curvature(pmesh, gaussian_curvature_map); + PMP::interpolated_corrected_principal_curvatures_and_directions(pmesh, principal_curvatures_and_directions_map); + } + else { + PMP::interpolated_corrected_mean_curvature( + pmesh, + mean_curvature_map, + CGAL::parameters::ball_radius(test_info.expansion_radius) + ); + + PMP::interpolated_corrected_gaussian_curvature( + pmesh, + gaussian_curvature_map, + CGAL::parameters::ball_radius(test_info.expansion_radius) + ); + + PMP::interpolated_corrected_principal_curvatures_and_directions( + pmesh, + principal_curvatures_and_directions_map, + CGAL::parameters::ball_radius(test_info.expansion_radius) + ); + } + + Epic_kernel::FT mean_curvature_avg = 0, gaussian_curvature_avg = 0, principal_curvature_avg = 0; + + for (vertex_descriptor v : vertices(pmesh)) + { + mean_curvature_avg += get(mean_curvature_map, v); + gaussian_curvature_avg += get(gaussian_curvature_map, v); + principal_curvature_avg += get(principal_curvatures_and_directions_map, v).min_curvature + + get(principal_curvatures_and_directions_map, v).max_curvature; + } + + mean_curvature_avg /= vertices(pmesh).size(); + gaussian_curvature_avg /= vertices(pmesh).size(); + principal_curvature_avg /= vertices(pmesh).size() * 2; + + // are average curvatures equal to expected? + assert(passes_comparison(mean_curvature_avg, test_info.mean_curvature_avg, test_info.tolerance)); + assert(passes_comparison(gaussian_curvature_avg, test_info.gaussian_curvature_avg, test_info.tolerance)); + assert(passes_comparison(principal_curvature_avg, test_info.principal_curvature_avg, test_info.tolerance)); + + PMP::interpolated_corrected_curvatures( + pmesh, + CGAL::parameters::ball_radius(test_info.expansion_radius) + .vertex_mean_curvature_map(mean_curvature_map) + .vertex_gaussian_curvature_map(gaussian_curvature_map) + .vertex_principal_curvatures_and_directions_map(principal_curvatures_and_directions_map) + ); + + // are average curvatures computed from interpolated_corrected_curvatures() equal to average curvatures each computed on its own? + Epic_kernel::FT new_mean_curvature_avg = 0, new_gaussian_curvature_avg = 0, new_principal_curvature_avg = 0; + + for (vertex_descriptor v : vertices(pmesh)) + { + new_mean_curvature_avg += get(mean_curvature_map, v); + new_gaussian_curvature_avg += get(gaussian_curvature_map, v); + new_principal_curvature_avg += get(principal_curvatures_and_directions_map, v).min_curvature + + get(principal_curvatures_and_directions_map, v).max_curvature; + } + + new_mean_curvature_avg /= vertices(pmesh).size(); + new_gaussian_curvature_avg /= vertices(pmesh).size(); + new_principal_curvature_avg /= vertices(pmesh).size() * 2; + + assert(passes_comparison(mean_curvature_avg, new_mean_curvature_avg, 0.99)); + assert(passes_comparison(gaussian_curvature_avg, new_gaussian_curvature_avg, 0.99)); + assert(passes_comparison(principal_curvature_avg, new_principal_curvature_avg, 0.99)); +} + +int main() +{ + // testing on a simple sphere(r = 0.5), on both Polyhedron & SurfaceMesh: + // Expected: Mean Curvature = 2, Gaussian Curvature = 4, Principal Curvatures = 2 & 2 so 2 on avg. + test_average_curvatures("meshes/sphere.off", Average_test_info(2,4,2)); + test_average_curvatures("meshes/sphere.off", Average_test_info(2, 4, 2)); + + // Same mesh but with specified expansion radii of 0 and 0.25 (half radius of sphere) + test_average_curvatures("meshes/sphere.off", Average_test_info(2, 4, 2, 0)); + test_average_curvatures("meshes/sphere.off", Average_test_info(2, 4, 2, 0.25)); + + // testing on a simple sphere(r = 10), on both Polyhedron & SurfaceMesh: + // Expected: Mean Curvature = 0.1, Gaussian Curvature = 0.01, Principal Curvatures = 0.1 & 0.1 so 0.1 on avg. + test_average_curvatures("meshes/sphere966.off", Average_test_info(0.1, 0.01, 0.1)); + test_average_curvatures("meshes/sphere966.off", Average_test_info(0.1, 0.01, 0.1)); + + // Same mesh but with specified expansion radii of 0 and 5 (half radius of sphere) + test_average_curvatures("meshes/sphere966.off", Average_test_info(0.1, 0.01, 0.1, 0)); + test_average_curvatures("meshes/sphere966.off", Average_test_info(0.1, 0.01, 0.1, 5)); + + // testing on a simple half cylinder(r = 1), on both Polyhedron & SurfaceMesh: + // Expected: Mean Curvature = 0.5, Gaussian Curvature = 0, Principal Curvatures = 0 & 1 so 0.5 on avg. + test_average_curvatures("meshes/cylinder.off", Average_test_info(0.5, 0, 0.5)); + test_average_curvatures("meshes/cylinder.off", Average_test_info(0.5, 0, 0.5)); + + // Same mesh but with specified expansion radii of 0 and 0.5 (half radius of cylinder) + test_average_curvatures("meshes/cylinder.off", Average_test_info(0.5, 0, 0.5, 0)); + test_average_curvatures("meshes/cylinder.off", Average_test_info(0.5, 0, 0.5, 0.5)); + + + +} From 2af64657636b1fadbacee3dac9e6b2108e1ffedf Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sun, 20 Nov 2022 00:39:14 +0200 Subject: [PATCH 092/142] trailing spaces --- .../test_interpolated_corrected_curvatures.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp index a4f43470332e..163c9b8d334d 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp @@ -32,13 +32,13 @@ struct Average_test_info { Epic_kernel::FT principal_curvature_avg, Epic_kernel::FT expansion_radius = -1, Epic_kernel::FT tolerance = 0.9 - ): + ): expansion_radius(expansion_radius), mean_curvature_avg(mean_curvature_avg), gaussian_curvature_avg(gaussian_curvature_avg), principal_curvature_avg(principal_curvature_avg), tolerance(tolerance) - { + { } }; From f6855fef22c428a701719578097f4051ce8525e1 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Tue, 3 Jan 2023 12:13:26 +0200 Subject: [PATCH 093/142] single vertex computation implemented single vertex curvature computation compared against the whole mesh computation on both cases of no radius and with radius on some vertices still need to add tests, documentation and an example file --- ...nterpolated_corrected_curvature_measures.h | 1374 ++++++++++------- .../internal/parameters_interface.h | 3 + 2 files changed, 830 insertions(+), 547 deletions(-) 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 4a50a618e66f..94aaff9b8b52 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 @@ -79,675 +79,911 @@ struct Principal_curvatures_and_directions { namespace internal { - template - typename GT::FT average_edge_length(const PolygonMesh& pmesh) { - const std::size_t n = edges(pmesh).size(); - if (n == 0) - return 0; - - typename GT::FT avg_edge_length = 0; - for (auto e : edges(pmesh)) - avg_edge_length += edge_length(e, pmesh); - - avg_edge_length /= n; - return avg_edge_length; - } +template +typename GT::FT average_edge_length(const PolygonMesh& pmesh) { + const std::size_t n = edges(pmesh).size(); + if (n == 0) + return 0; + + typename GT::FT avg_edge_length = 0; + for (auto e : edges(pmesh)) + avg_edge_length += edge_length(e, pmesh); + + avg_edge_length /= n; + return avg_edge_length; +} - enum Curvature_measure_index { - MU0_AREA_MEASURE, ///< corrected area density - MU1_MEAN_CURVATURE_MEASURE, ///< corrected mean curvature density - MU2_GAUSSIAN_CURVATURE_MEASURE ///< corrected gaussian curvature density - }; - - template - struct Vertex_measures { - typename GT::FT area_measure = 0; - typename GT::FT mean_curvature_measure = 0; - typename GT::FT gaussian_curvature_measure = 0; - std::array anisotropic_measure = { 0, 0, 0, - 0, 0, 0, - 0, 0, 0 }; - }; - - template - typename GT::FT interpolated_corrected_area_measure_face(const std::vector& u, - const std::vector& x) +enum Curvature_measure_index { + MU0_AREA_MEASURE, ///< corrected area density + MU1_MEAN_CURVATURE_MEASURE, ///< corrected mean curvature density + MU2_GAUSSIAN_CURVATURE_MEASURE ///< corrected gaussian curvature density +}; + +template +struct Vertex_measures { + typename GT::FT area_measure = 0; + typename GT::FT mean_curvature_measure = 0; + typename GT::FT gaussian_curvature_measure = 0; + std::array anisotropic_measure = { 0, 0, 0, + 0, 0, 0, + 0, 0, 0 }; +}; + +template +typename GT::FT interpolated_corrected_area_measure_face(const std::vector& u, + const std::vector& x) +{ + const std::size_t n = x.size(); + CGAL_precondition(u.size() == n); + CGAL_precondition(n >= 3); + + typename GT::Construct_cross_product_vector_3 cross_product; + + // Triangle: use triangle formula + if (n == 3) + { + const typename GT::Vector_3 um = (u[0] + u[1] + u[2]) / 3.0; + return 0.5 * um * cross_product(x[1] - x[0], x[2] - x[0]); + } + // Quad: use bilinear interpolation formula + else if (n == 4) { - const std::size_t n = x.size(); - CGAL_precondition(u.size() == n); - CGAL_precondition(n >= 3); + // for the formulas below, values of verices 2 & 3 are swapped (compared to paper) to correct order. + // the indices in paper vs in here are: 00 = 0, 10 = 1, 11 = 2, 01 = 3 + return (1.0 / 36.0) * ( + (4 * u[0] + 2 * u[1] + 2 * u[3] + u[2]) * cross_product(x[1] - x[0], x[3] - x[0]) + + (2 * u[0] + 4 * u[1] + u[3] + 2 * u[2]) * cross_product(x[1] - x[0], x[2] - x[1]) + + (2 * u[0] + u[1] + 4 * u[3] + 2 * u[2]) * cross_product(x[2] - x[3], x[3] - x[0]) + + (u[0] + 2 * u[1] + 2 * u[3] + 4 * u[2]) * cross_product(x[2] - x[3], x[2] - x[1]) + ); + } + // N-gon: split into n triangles by polygon center and use triangle formula for each + else + { + typename GT::FT mu0 = 0; - typename GT::Construct_cross_product_vector_3 cross_product; + // getting center of points + typename GT::Vector_3 xc = + std::accumulate(x.begin(), x.end(), typename GT::Vector_3(0, 0, 0)); + xc /= n; - // Triangle: use triangle formula - if (n == 3) - { - const typename GT::Vector_3 um = (u[0] + u[1] + u[2]) / 3.0; - return 0.5 * um * cross_product(x[1] - x[0], x[2] - x[0]); - } - // Quad: use bilinear interpolation formula - else if (n == 4) + // getting unit average normal of points + typename GT::Vector_3 uc = + std::accumulate(u.begin(), u.end(), typename GT::Vector_3(0, 0, 0)); + uc /= sqrt(uc * uc); + + // summing each triangle's measure after triangulation by barycenter split. + for (std::size_t i = 0; i < n; i++) { - // for the formulas below, values of verices 2 & 3 are swapped (compared to paper) to correct order. - // the indices in paper vs in here are: 00 = 0, 10 = 1, 11 = 2, 01 = 3 - return (1.0 / 36.0) * ( - (4 * u[0] + 2 * u[1] + 2 * u[3] + u[2]) * cross_product(x[1] - x[0], x[3] - x[0]) - + (2 * u[0] + 4 * u[1] + u[3] + 2 * u[2]) * cross_product(x[1] - x[0], x[2] - x[1]) - + (2 * u[0] + u[1] + 4 * u[3] + 2 * u[2]) * cross_product(x[2] - x[3], x[3] - x[0]) - + (u[0] + 2 * u[1] + 2 * u[3] + 4 * u[2]) * cross_product(x[2] - x[3], x[2] - x[1]) - ); + mu0 += interpolated_corrected_area_measure_face( + std::vector {u[i], u[(i + 1) % n], uc}, + std::vector {x[i], x[(i + 1) % n], xc} + ); } - // N-gon: split into n triangles by polygon center and use triangle formula for each - else - { - typename GT::FT mu0 = 0; + return mu0; + } +} - // getting center of points - typename GT::Vector_3 xc = - std::accumulate(x.begin(), x.end(), typename GT::Vector_3(0, 0, 0)); - xc /= n; +template +typename GT::FT interpolated_corrected_mean_curvature_measure_face(const std::vector& u, + const std::vector& x) +{ + const std::size_t n = x.size(); + CGAL_precondition(u.size() == n); + CGAL_precondition(n >= 3); - // getting unit average normal of points - typename GT::Vector_3 uc = - std::accumulate(u.begin(), u.end(), typename GT::Vector_3(0, 0, 0)); - uc /= sqrt(uc * uc); + typename GT::Construct_cross_product_vector_3 cross_product; - // summing each triangle's measure after triangulation by barycenter split. - for (std::size_t i = 0; i < n; i++) - { - mu0 += interpolated_corrected_area_measure_face( - std::vector {u[i], u[(i + 1) % n], uc}, - std::vector {x[i], x[(i + 1) % n], xc} - ); - } - return mu0; - } - } + // Triangle: use triangle formula + if (n == 3) + { + const typename GT::Vector_3 um = (u[0] + u[1] + u[2]) / 3.0; - template - typename GT::FT interpolated_corrected_mean_curvature_measure_face(const std::vector& u, - const std::vector& x) + return 0.5 * um * (cross_product(u[2] - u[1], x[0]) + + cross_product(u[0] - u[2], x[1]) + + cross_product(u[1] - u[0], x[2])); + } + // Quad: use bilinear interpolation formula + else if (n == 4) { - const std::size_t n = x.size(); - CGAL_precondition(u.size() == n); - CGAL_precondition(n >= 3); + // for the formulas below, values of verices 2 & 3 are swapped (compared to paper) to correct order. + // the indices in paper vs in here are: 00 = 0, 10 = 1, 11 = 2, 01 = 3 + + const typename GT::Vector_3 u02 = u[2] - u[0]; + const typename GT::Vector_3 u13 = u[3] - u[1]; + const typename GT::Vector_3 x0_cross = cross_product(u13, x[0]); + const typename GT::Vector_3 x1_cross = -cross_product(u02, x[1]); + const typename GT::Vector_3 x3_cross = cross_product(u02, x[3]); + const typename GT::Vector_3 x2_cross = -cross_product(u13, x[2]); + + return (1.0 / 12.0) * ( + u[0] * (2 * x0_cross - cross_product((u[3] + u[2]), x[1]) + cross_product((u[1] + u[2]), x[3]) + x2_cross) + + u[1] * (cross_product((u[3] + u[2]), x[0]) + 2 * x1_cross + x3_cross - cross_product((u[0] + u[3]), x[2])) + + u[3] * (-cross_product((u[1] + u[2]), x[0]) + x1_cross + 2 * x3_cross + cross_product((u[0] + u[1]), x[2])) + + u[2] * (x0_cross + cross_product((u[0] + u[3]), x[1]) - cross_product((u[0] + u[1]), x[3]) + 2 * x2_cross) + ); + } + // N-gon: split into n triangles by polygon center and use triangle formula for each + else + { + typename GT::FT mu1 = 0; - typename GT::Construct_cross_product_vector_3 cross_product; + // getting center of points + typename GT::Vector_3 xc = + std::accumulate(x.begin(), x.end(), typename GT::Vector_3(0, 0, 0)); + xc /= n; - // Triangle: use triangle formula - if (n == 3) - { - const typename GT::Vector_3 um = (u[0] + u[1] + u[2]) / 3.0; + // getting unit average normal of points + typename GT::Vector_3 uc = + std::accumulate(u.begin(), u.end(), typename GT::Vector_3(0, 0, 0)); + uc /= sqrt(uc * uc); - return 0.5 * um * (cross_product(u[2] - u[1], x[0]) - + cross_product(u[0] - u[2], x[1]) - + cross_product(u[1] - u[0], x[2])); - } - // Quad: use bilinear interpolation formula - else if (n == 4) + // summing each triangle's measure after triangulation by barycenter split. + for (std::size_t i = 0; i < n; i++) { - // for the formulas below, values of verices 2 & 3 are swapped (compared to paper) to correct order. - // the indices in paper vs in here are: 00 = 0, 10 = 1, 11 = 2, 01 = 3 - - const typename GT::Vector_3 u02 = u[2] - u[0]; - const typename GT::Vector_3 u13 = u[3] - u[1]; - const typename GT::Vector_3 x0_cross = cross_product(u13, x[0]); - const typename GT::Vector_3 x1_cross = -cross_product(u02, x[1]); - const typename GT::Vector_3 x3_cross = cross_product(u02, x[3]); - const typename GT::Vector_3 x2_cross = -cross_product(u13, x[2]); - - return (1.0 / 12.0) * ( - u[0] * (2 * x0_cross - cross_product((u[3] + u[2]), x[1]) + cross_product((u[1] + u[2]), x[3]) + x2_cross) - + u[1] * (cross_product((u[3] + u[2]), x[0]) + 2 * x1_cross + x3_cross - cross_product((u[0] + u[3]), x[2])) - + u[3] * (-cross_product((u[1] + u[2]), x[0]) + x1_cross + 2 * x3_cross + cross_product((u[0] + u[1]), x[2])) - + u[2] * (x0_cross + cross_product((u[0] + u[3]), x[1]) - cross_product((u[0] + u[1]), x[3]) + 2 * x2_cross) - ); + mu1 += interpolated_corrected_mean_curvature_measure_face( + std::vector {u[i], u[(i + 1) % n], uc}, + std::vector {x[i], x[(i + 1) % n], xc} + ); } - // N-gon: split into n triangles by polygon center and use triangle formula for each - else - { - typename GT::FT mu1 = 0; + return mu1; + } +} - // getting center of points - typename GT::Vector_3 xc = - std::accumulate(x.begin(), x.end(), typename GT::Vector_3(0, 0, 0)); - xc /= n; +template +typename GT::FT interpolated_corrected_gaussian_curvature_measure_face(const std::vector& u, + const std::vector& x = {}) +{ + const std::size_t n = u.size(); + CGAL_precondition(n >= 3); - // getting unit average normal of points - typename GT::Vector_3 uc = - std::accumulate(u.begin(), u.end(), typename GT::Vector_3(0, 0, 0)); - uc /= sqrt(uc * uc); + typename GT::Construct_cross_product_vector_3 cross_product; - // summing each triangle's measure after triangulation by barycenter split. - for (std::size_t i = 0; i < n; i++) - { - mu1 += interpolated_corrected_mean_curvature_measure_face( - std::vector {u[i], u[(i + 1) % n], uc}, - std::vector {x[i], x[(i + 1) % n], xc} - ); - } - return mu1; - } + // Triangle: use triangle formula + if (n == 3) + { + return 0.5 * u[0] * cross_product(u[1], u[2]); } - - template - typename GT::FT interpolated_corrected_gaussian_curvature_measure_face(const std::vector& u, - const std::vector& x = {}) + // Quad: use bilinear interpolation formula + else if (n == 4) + { + // for the formulas below, values of verices 2 & 3 are swapped (compared to paper) to correct order. + // the indices in paper vs in here are: 00 = 0, 10 = 1, 11 = 2, 01 = 3 + return (1.0 / 36.0) * ( + (4 * u[0] + 2 * u[1] + 2 * u[3] + u[2]) * cross_product(u[1] - u[0], u[3] - u[0]) + + (2 * u[0] + 4 * u[1] + u[3] + 2 * u[2]) * cross_product(u[1] - u[0], u[2] - u[1]) + + (2 * u[0] + u[1] + 4 * u[3] + 2 * u[2]) * cross_product(u[2] - u[3], u[3] - u[0]) + + (u[0] + 2 * u[1] + 2 * u[3] + 4 * u[2]) * cross_product(u[2] - u[3], u[2] - u[1]) + ); + } + // N-gon: split into n triangles by polygon center and use triangle formula for each + else { - const std::size_t n = u.size(); - CGAL_precondition(n >= 3); + typename GT::FT mu2 = 0; - typename GT::Construct_cross_product_vector_3 cross_product; + // getting unit average normal of points + typename GT::Vector_3 uc = + std::accumulate(u.begin(), u.end(), typename GT::Vector_3(0, 0, 0)); + uc /= sqrt(uc * uc); - // Triangle: use triangle formula - if (n == 3) + // summing each triangle's measure after triangulation by barycenter split. + for (std::size_t i = 0; i < n; i++) { - return 0.5 * u[0] * cross_product(u[1], u[2]); + mu2 += interpolated_corrected_gaussian_curvature_measure_face( + std::vector {u[i], u[(i + 1) % n], uc} + ); } - // Quad: use bilinear interpolation formula - else if (n == 4) + return mu2; + } +} + +template +std::array interpolated_corrected_anisotropic_measure_face(const std::vector& u, + const std::vector& x) +{ + const std::size_t n = x.size(); + CGAL_precondition(u.size() == n); + CGAL_precondition(n >= 3); + + typename GT::Construct_cross_product_vector_3 cross_product; + std::array muXY{ 0 }; + + // Triangle: use triangle formula + if (n == 3) + { + const typename GT::Vector_3 u01 = u[1] - u[0]; + const typename GT::Vector_3 u02 = u[2] - u[0]; + const typename GT::Vector_3 x01 = x[1] - x[0]; + const typename GT::Vector_3 x02 = x[2] - x[0]; + const typename GT::Vector_3 um = (u[0] + u[1] + u[2]) / 3.0; + + for (std::size_t ix = 0; ix < 3; ix++) { - // for the formulas below, values of verices 2 & 3 are swapped (compared to paper) to correct order. - // the indices in paper vs in here are: 00 = 0, 10 = 1, 11 = 2, 01 = 3 - return (1.0 / 36.0) * ( - (4 * u[0] + 2 * u[1] + 2 * u[3] + u[2]) * cross_product(u[1] - u[0], u[3] - u[0]) - + (2 * u[0] + 4 * u[1] + u[3] + 2 * u[2]) * cross_product(u[1] - u[0], u[2] - u[1]) - + (2 * u[0] + u[1] + 4 * u[3] + 2 * u[2]) * cross_product(u[2] - u[3], u[3] - u[0]) - + (u[0] + 2 * u[1] + 2 * u[3] + 4 * u[2]) * cross_product(u[2] - u[3], u[2] - u[1]) - ); + typename GT::Vector_3 X; + if (ix == 0) + X = typename GT::Vector_3(1, 0, 0); + if (ix == 1) + X = typename GT::Vector_3(0, 1, 0); + if (ix == 2) + X = typename GT::Vector_3(0, 0, 1); + + for (std::size_t iy = 0; iy < 3; iy++) + muXY[ix * 3 + iy] = 0.5 * um * (cross_product(u02[iy] * X, x01) - cross_product(u01[iy] * X, x02)); } - // N-gon: split into n triangles by polygon center and use triangle formula for each - else + } + // Quad: use bilinear interpolation formula + else if (n == 4) + { + // for the formulas below, values of verices 2 & 3 are swapped (compared to paper) to correct order. + // the indices in paper vs in here are: 00 = 0, 10 = 1, 11 = 2, 01 = 3 + for (std::size_t ix = 0; ix < 3; ix++) { - typename GT::FT mu2 = 0; + typename GT::Vector_3 X; + if (ix == 0) + X = typename GT::Vector_3(1, 0, 0); + if (ix == 1) + X = typename GT::Vector_3(0, 1, 0); + if (ix == 2) + X = typename GT::Vector_3(0, 0, 1); + + const typename GT::Vector_3 u0xX = cross_product(u[0], X); + const typename GT::Vector_3 u1xX = cross_product(u[1], X); + const typename GT::Vector_3 u2xX = cross_product(u[2], X); + const typename GT::Vector_3 u3xX = cross_product(u[3], X); - // getting unit average normal of points - typename GT::Vector_3 uc = - std::accumulate(u.begin(), u.end(), typename GT::Vector_3(0, 0, 0)); - uc /= sqrt(uc * uc); - - // summing each triangle's measure after triangulation by barycenter split. - for (std::size_t i = 0; i < n; i++) - { - mu2 += interpolated_corrected_gaussian_curvature_measure_face( - std::vector {u[i], u[(i + 1) % n], uc} - ); - } - return mu2; + for (std::size_t iy = 0; iy < 3; iy++) + muXY[ix * 3 + iy] = (1.0 / 72.0) * ( + + u[0][iy] * (u0xX * (-x[0] - 11 * x[1] + 13 * x[3] - x[2]) + + u1xX * (-5 * x[0] - 7 * x[1] + 11 * x[3] + x[2]) + + u3xX * (x[0] - 7 * x[1] + 11 * x[3] - 5 * x[2]) + + u2xX * (-x[0] - 5 * x[1] + 7 * x[3] - x[2]) + ) + + u[1][iy] * (u0xX * (13 * x[0] - x[1] - 7 * x[3] - 5 * x[2]) + + u1xX * (17 * x[0] - 5 * x[1] - 5 * x[3] - 7 * x[2]) + + u3xX * (5 * x[0] + x[1] + x[3] - 7 * x[2]) + + u2xX * (7 * x[0] - x[1] + 5 * x[3] - 11 * x[2]) + ) + + u[2][iy] * (u0xX * (-11 * x[0] + 5 * x[1] - x[3] + 7 * x[2]) + + u1xX * (-7 * x[0] + x[1] + x[3] + 5 * x[2]) + + u3xX * (-7 * x[0] - 5 * x[1] - 5 * x[3] + 17 * x[2]) + + u2xX * (-5 * x[0] - 7 * x[1] - x[3] + 13 * x[2]) + ) + + u[3][iy] * (u0xX * (-x[0] + 7 * x[1] - 5 * x[3] - x[2]) + + u1xX * (-5 * x[0] + 11 * x[1] - 7 * x[3] + x[2]) + + u3xX * (x[0] + 11 * x[1] - 7 * x[3] - 5 * x[2]) + + u2xX * (-x[0] + 13 * x[1] - 11 * x[3] - x[2]) + ) + + ); } } - - template - std::array interpolated_corrected_anisotropic_measure_face(const std::vector& u, - const std::vector& x) + // N-gon: split into n triangles by polygon center and use triangle formula for each + else { - const std::size_t n = x.size(); - CGAL_precondition(u.size() == n); - CGAL_precondition(n >= 3); + // getting center of points + typename GT::Vector_3 xc = + std::accumulate(x.begin(), x.end(), typename GT::Vector_3(0, 0, 0)); + xc /= n; - typename GT::Construct_cross_product_vector_3 cross_product; - std::array muXY{ 0 }; + // getting unit average normal of points + typename GT::Vector_3 uc = + std::accumulate(u.begin(), u.end(), typename GT::Vector_3(0, 0, 0)); + uc /= sqrt(uc * uc); - // Triangle: use triangle formula - if (n == 3) + // summing each triangle's measure after triangulation by barycenter split. + for (std::size_t i = 0; i < n; i++) { - const typename GT::Vector_3 u01 = u[1] - u[0]; - const typename GT::Vector_3 u02 = u[2] - u[0]; - const typename GT::Vector_3 x01 = x[1] - x[0]; - const typename GT::Vector_3 x02 = x[2] - x[0]; - const typename GT::Vector_3 um = (u[0] + u[1] + u[2]) / 3.0; + std::array muXY_curr_triangle = + interpolated_corrected_anisotropic_measure_face( + std::vector {u[i], u[(i + 1) % n], uc}, + std::vector {x[i], x[(i + 1) % n], xc} + ); for (std::size_t ix = 0; ix < 3; ix++) - { - typename GT::Vector_3 X; - if (ix == 0) - X = typename GT::Vector_3(1, 0, 0); - if (ix == 1) - X = typename GT::Vector_3(0, 1, 0); - if (ix == 2) - X = typename GT::Vector_3(0, 0, 1); - for (std::size_t iy = 0; iy < 3; iy++) - muXY[ix * 3 + iy] = 0.5 * um * (cross_product(u02[iy] * X, x01) - cross_product(u01[iy] * X, x02)); - } + muXY[ix * 3 + iy] += muXY_curr_triangle[ix * 3 + iy]; } - // Quad: use bilinear interpolation formula - else if (n == 4) + } + return muXY; +} + +//template +//typename GT::FT triangle_in_ball_ratio(const typename GT::Vector_3 x1, +// const typename GT::Vector_3 x2, +// const typename GT::Vector_3 x3, +// const typename GT::FT r, +// const typename GT::Vector_3 c, +// const std::size_t res = 3) +//{ +// const typename GT::FT R = r * r; +// const typename GT::FT acc = 1.0 / res; +// std::size_t samples_in = 0; +// for (GT::FT alpha = acc / 3; alpha < 1; alpha += acc) +// for (GT::FT beta = acc / 3; beta < 1 - alpha; beta += acc) +// { +// if ((alpha * x1 + beta * x2 + (1 - alpha - beta) * x3 - c).squared_length() < R) +// samples_in++; +// } +// return samples_in / (typename GT::FT)(res * (res + 1) / 2); +//} + +template +typename GT::FT face_in_ball_ratio(const std::vector& x, + const typename GT::FT r, + const typename GT::Vector_3 c) +{ + const std::size_t n = x.size(); + + // getting center of points + typename GT::Vector_3 xm = + std::accumulate(x.begin(), x.end(), typename GT::Vector_3(0, 0, 0)); + xm /= n; + + typename GT::FT d_min = (xm - c).squared_length(); + typename GT::FT d_max = d_min; + + for (const typename GT::Vector_3 xi : x) + { + const typename GT::FT d_sq = (xi - c).squared_length(); + d_max = (std::max)(d_sq, d_max); + d_min = (std::min)(d_sq, d_min); + } + + if (d_max <= r * r) return 1.0; + else if (r * r <= d_min) return 0.0; + + d_max = sqrt(d_max); + d_min = sqrt(d_min); + + return (r - d_min) / (d_max - d_min); +} + +template +Principal_curvatures_and_directions principal_curvatures_and_directions_from_anisotropic_measures( + const std::array anisotropic_measure, + const typename GT::FT v_mu0, + const typename GT::Vector_3 u_GT +) +{ + Eigen::Matrix v_muXY = Eigen::Matrix::Zero(); + + for (std::size_t ix = 0; ix < 3; ix++) + for (std::size_t iy = 0; iy < 3; iy++) + v_muXY(ix, iy) = anisotropic_measure[ix * 3 + iy]; + + Eigen::Matrix u(u_GT.x(), u_GT.y(), u_GT.z()); + const typename GT::FT K = 1000 * v_mu0; + + v_muXY = 0.5 * (v_muXY + v_muXY.transpose()) + K * u * u.transpose(); + + Eigen::SelfAdjointEigenSolver> eigensolver; + + eigensolver.computeDirect(v_muXY); + + if (eigensolver.info() != Eigen::Success) + return Principal_curvatures_and_directions(); + + const Eigen::Matrix eig_vals = eigensolver.eigenvalues(); + const Eigen::Matrix eig_vecs = eigensolver.eigenvectors(); + + const typename GT::Vector_3 min_eig_vec(eig_vecs(0, 1), eig_vecs(1, 1), eig_vecs(2, 1)); + const typename GT::Vector_3 max_eig_vec(eig_vecs(0, 0), eig_vecs(1, 0), eig_vecs(2, 0)); + + return Principal_curvatures_and_directions( + (v_mu0 != 0.0) ? -eig_vals[1] / v_mu0 : 0.0, + (v_mu0 != 0.0) ? -eig_vals[0] / v_mu0 : 0.0, + min_eig_vec, + max_eig_vec + ); +} + +template +typename Vertex_measures interpolated_corrected_measures_one_vertex_no_radius( + const PolygonMesh pmesh, + const typename boost::graph_traits::vertex_descriptor v, + const bool is_mean_curvature_selected, + const bool is_gaussian_curvature_selected, + const bool is_principal_curvatures_and_directions_selected, + const VPM vpm, + const VNM vnm +) +{ + typedef typename boost::graph_traits::face_descriptor Face_descriptor; + typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; + typedef typename GT::Point_3 Point_3; + typedef typename GT::Vector_3 Vector_3; + typedef typename GT::FT FT; + + std::queue bfs_queue; + std::unordered_set bfs_visited; + + typename Vertex_measures vertex_measures; + + std::vector x; + std::vector u; + + for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { + if (f != boost::graph_traits::null_face()) { - // for the formulas below, values of verices 2 & 3 are swapped (compared to paper) to correct order. - // the indices in paper vs in here are: 00 = 0, 10 = 1, 11 = 2, 01 = 3 - for (std::size_t ix = 0; ix < 3; ix++) + for (Vertex_descriptor vi : vertices_around_face(halfedge(f, pmesh), pmesh)) { - typename GT::Vector_3 X; - if (ix == 0) - X = typename GT::Vector_3(1, 0, 0); - if (ix == 1) - X = typename GT::Vector_3(0, 1, 0); - if (ix == 2) - X = typename GT::Vector_3(0, 0, 1); - - const typename GT::Vector_3 u0xX = cross_product(u[0], X); - const typename GT::Vector_3 u1xX = cross_product(u[1], X); - const typename GT::Vector_3 u2xX = cross_product(u[2], X); - const typename GT::Vector_3 u3xX = cross_product(u[3], X); - - for (std::size_t iy = 0; iy < 3; iy++) - muXY[ix * 3 + iy] = (1.0 / 72.0) * ( - - u[0][iy] * (u0xX * (-x[0] - 11 * x[1] + 13 * x[3] - x[2]) - + u1xX * (-5 * x[0] - 7 * x[1] + 11 * x[3] + x[2]) - + u3xX * (x[0] - 7 * x[1] + 11 * x[3] - 5 * x[2]) - + u2xX * (-x[0] - 5 * x[1] + 7 * x[3] - x[2]) - ) - + u[1][iy] * (u0xX * (13 * x[0] - x[1] - 7 * x[3] - 5 * x[2]) - + u1xX * (17 * x[0] - 5 * x[1] - 5 * x[3] - 7 * x[2]) - + u3xX * (5 * x[0] + x[1] + x[3] - 7 * x[2]) - + u2xX * (7 * x[0] - x[1] + 5 * x[3] - 11 * x[2]) - ) - + u[2][iy] * (u0xX * (-11 * x[0] + 5 * x[1] - x[3] + 7 * x[2]) - + u1xX * (-7 * x[0] + x[1] + x[3] + 5 * x[2]) - + u3xX * (-7 * x[0] - 5 * x[1] - 5 * x[3] + 17 * x[2]) - + u2xX * (-5 * x[0] - 7 * x[1] - x[3] + 13 * x[2]) - ) - + u[3][iy] * (u0xX * (-x[0] + 7 * x[1] - 5 * x[3] - x[2]) - + u1xX * (-5 * x[0] + 11 * x[1] - 7 * x[3] + x[2]) - + u3xX * (x[0] + 11 * x[1] - 7 * x[3] - 5 * x[2]) - + u2xX * (-x[0] + 13 * x[1] - 11 * x[3] - x[2]) - ) - - ); + Point_3 pi = get(vpm, vi); + Vector_3 ui = get(vnm, vi); + x.push_back(Vector_3(pi.x(), pi.y(), pi.z())); + u.push_back(ui); } - } - // N-gon: split into n triangles by polygon center and use triangle formula for each - else - { - // getting center of points - typename GT::Vector_3 xc = - std::accumulate(x.begin(), x.end(), typename GT::Vector_3(0, 0, 0)); - xc /= n; - - // getting unit average normal of points - typename GT::Vector_3 uc = - std::accumulate(u.begin(), u.end(), typename GT::Vector_3(0, 0, 0)); - uc /= sqrt(uc * uc); - - // summing each triangle's measure after triangulation by barycenter split. - for (std::size_t i = 0; i < n; i++) + + vertex_measures.area_measure += interpolated_corrected_area_measure_face(u, x); + + if (is_mean_curvature_selected) + vertex_measures.mean_curvature_measure += interpolated_corrected_mean_curvature_measure_face(u, x); + + if (is_gaussian_curvature_selected) + vertex_measures.gaussian_curvature_measure += interpolated_corrected_gaussian_curvature_measure_face(u, x); + + if (is_principal_curvatures_and_directions_selected) { - std::array muXY_curr_triangle = - interpolated_corrected_anisotropic_measure_face( - std::vector {u[i], u[(i + 1) % n], uc}, - std::vector {x[i], x[(i + 1) % n], xc} - ); - - for (std::size_t ix = 0; ix < 3; ix++) - for (std::size_t iy = 0; iy < 3; iy++) - muXY[ix * 3 + iy] += muXY_curr_triangle[ix * 3 + iy]; + const std::array face_anisotropic_measure = interpolated_corrected_anisotropic_measure_face(u, x); + for (std::size_t i = 0; i < 3 * 3; i++) + vertex_measures.anisotropic_measure[i] += face_anisotropic_measure[i]; } } - return muXY; + + x.clear(); + u.clear(); } + return vertex_measures; +} - //template - //typename GT::FT triangle_in_ball_ratio(const typename GT::Vector_3 x1, - // const typename GT::Vector_3 x2, - // const typename GT::Vector_3 x3, - // const typename GT::FT r, - // const typename GT::Vector_3 c, - // const std::size_t res = 3) - //{ - // const typename GT::FT R = r * r; - // const typename GT::FT acc = 1.0 / res; - // std::size_t samples_in = 0; - // for (GT::FT alpha = acc / 3; alpha < 1; alpha += acc) - // for (GT::FT beta = acc / 3; beta < 1 - alpha; beta += acc) - // { - // if ((alpha * x1 + beta * x2 + (1 - alpha - beta) * x3 - c).squared_length() < R) - // samples_in++; - // } - // return samples_in / (typename GT::FT)(res * (res + 1) / 2); - //} - - template - typename GT::FT face_in_ball_ratio(const std::vector& x, - const typename GT::FT r, - const typename GT::Vector_3 c) - { - const std::size_t n = x.size(); - // getting center of points - typename GT::Vector_3 xm = - std::accumulate(x.begin(), x.end(), typename GT::Vector_3(0, 0, 0)); - xm /= n; +template +typename Vertex_measures interpolated_corrected_measures_one_vertex( + const PolygonMesh pmesh, + const typename boost::graph_traits::vertex_descriptor v, + const typename GT::FT radius, + const bool is_mean_curvature_selected, + const bool is_gaussian_curvature_selected, + const bool is_principal_curvatures_and_directions_selected, + const VPM vpm, + const VNM vnm +) +{ + typedef typename boost::graph_traits::face_descriptor Face_descriptor; + typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; + typedef typename GT::Point_3 Point_3; + typedef typename GT::Vector_3 Vector_3; + typedef typename GT::FT FT; + + std::queue bfs_queue; + std::unordered_set bfs_visited; - typename GT::FT d_min = (xm - c).squared_length(); - typename GT::FT d_max = d_min; + typename Vertex_measures vertex_measures; - for (const typename GT::Vector_3 xi : x) + typename Point_3 vp = get(vpm, v); + typename Vector_3 c = Vector_3(vp.x(), vp.y(), vp.z()); + + for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { + if (f != boost::graph_traits::null_face()) { - const typename GT::FT d_sq = (xi - c).squared_length(); - d_max = (std::max)(d_sq, d_max); - d_min = (std::min)(d_sq, d_min); + bfs_queue.push(f); + bfs_visited.insert(f); } + } + std::vector x; + std::vector u; + while (!bfs_queue.empty()) { + Face_descriptor fi = bfs_queue.front(); + bfs_queue.pop(); - if (d_max <= r * r) return 1.0; - else if (r * r <= d_min) return 0.0; - - d_max = sqrt(d_max); - d_min = sqrt(d_min); + // looping over vertices in face to get point coordinates - return (r - d_min) / (d_max - d_min); - } + for (Vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh)) + { + Point_3 pi = get(vpm, vi); + Vector_3 ui = get(vnm, vi); + x.push_back(Vector_3(pi.x(), pi.y(), pi.z())); + u.push_back(ui); + } - template - Principal_curvatures_and_directions principal_curvatures_and_directions_from_anisotropic_measures( - const std::array anisotropic_measure, - const typename GT::FT v_mu0, - const typename GT::Vector_3 u_GT - ) - { - Eigen::Matrix v_muXY = Eigen::Matrix::Zero(); + const FT f_ratio = face_in_ball_ratio(x, radius, c); - for (std::size_t ix = 0; ix < 3; ix++) - for (std::size_t iy = 0; iy < 3; iy++) - v_muXY(ix, iy) = anisotropic_measure[ix * 3 + iy]; + if (f_ratio != 0.0) + { + vertex_measures.area_measure += f_ratio * interpolated_corrected_area_measure_face(u, x); - Eigen::Matrix u(u_GT.x(), u_GT.y(), u_GT.z()); - const typename GT::FT K = 1000 * v_mu0; + if (is_mean_curvature_selected) + vertex_measures.mean_curvature_measure += f_ratio * interpolated_corrected_mean_curvature_measure_face(u, x); - v_muXY = 0.5 * (v_muXY + v_muXY.transpose()) + K * u * u.transpose(); + if (is_gaussian_curvature_selected) + vertex_measures.gaussian_curvature_measure += f_ratio * interpolated_corrected_gaussian_curvature_measure_face(u, x); - Eigen::SelfAdjointEigenSolver> eigensolver; + if (is_principal_curvatures_and_directions_selected) + { + const std::array face_anisotropic_measure = interpolated_corrected_anisotropic_measure_face(u, x); + for (std::size_t i = 0; i < 3 * 3; i++) + vertex_measures.anisotropic_measure[i] += f_ratio * face_anisotropic_measure[i]; + } - eigensolver.computeDirect(v_muXY); + for (Face_descriptor fj : faces_around_face(halfedge(fi, pmesh), pmesh)) + { + if (bfs_visited.find(fj) == bfs_visited.end() && fj != boost::graph_traits::null_face()) + { + bfs_queue.push(fj); + bfs_visited.insert(fj); + } + } + } - if (eigensolver.info() != Eigen::Success) - return Principal_curvatures_and_directions(); + x.clear(); + u.clear(); + } + return vertex_measures; +} - const Eigen::Matrix eig_vals = eigensolver.eigenvalues(); - const Eigen::Matrix eig_vecs = eigensolver.eigenvectors(); +template + void interpolated_corrected_curvatures_one_vertex( + const PolygonMesh pmesh, + const typename boost::graph_traits::vertex_descriptor v, + NamedParameters& np = parameters::default_values() + ) +{ + typedef typename GetGeomTraits::type GT; + typedef typename GetVertexPointMap::const_type Vertex_position_map; + + typedef dynamic_vertex_property_t Vector_map_tag; + typedef typename boost::property_map::const_type Default_vector_map; + typedef typename internal_np::Lookup_named_param_def::type Vertex_normal_map; + + using parameters::choose_parameter; + using parameters::get_parameter; + using parameters::is_default_parameter; + + Vertex_position_map vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), + get_const_property_map(CGAL::vertex_point, pmesh)); + + Vertex_normal_map 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); + + typename GT::FT radius = choose_parameter(get_parameter(np, internal_np::ball_radius), -1); + if (radius == 0) + radius = average_edge_length(pmesh) * EXPANDING_RADIUS_EPSILON; + else + radius = radius; + + typename GT::FT* vertex_mean_curvature = choose_parameter(get_parameter(np, internal_np::vertex_mean_curvature), nullptr); + typename GT::FT* vertex_gaussian_curvature = choose_parameter(get_parameter(np, internal_np::vertex_gaussian_curvature), nullptr); + typename Principal_curvatures_and_directions* vertex_principal_curvatures_and_directions = choose_parameter(get_parameter(np, internal_np::vertex_principal_curvatures_and_directions), nullptr); + + const bool is_mean_curvature_selected = (vertex_mean_curvature != nullptr); + const bool is_gaussian_curvature_selected = (vertex_gaussian_curvature != nullptr); + const bool is_principal_curvatures_and_directions_selected = (vertex_principal_curvatures_and_directions != nullptr); + + std::cout << is_mean_curvature_selected << is_gaussian_curvature_selected << is_principal_curvatures_and_directions_selected << std::endl; + + Vertex_measures vertex_measures; + + if (radius < 0) + vertex_measures = interpolated_corrected_measures_one_vertex_no_radius( + pmesh, + v, + is_mean_curvature_selected, + is_gaussian_curvature_selected, + is_principal_curvatures_and_directions_selected, + vpm, + vnm + ); + else + vertex_measures = interpolated_corrected_measures_one_vertex( + pmesh, + v, + radius, + is_mean_curvature_selected, + is_gaussian_curvature_selected, + is_principal_curvatures_and_directions_selected, + vpm, + vnm + ); + + + if (is_mean_curvature_selected) { + *vertex_mean_curvature = vertex_measures.area_measure != 0 ? + 0.5 * vertex_measures.mean_curvature_measure / vertex_measures.area_measure : 0; + } - const typename GT::Vector_3 min_eig_vec(eig_vecs(0, 1), eig_vecs(1, 1), eig_vecs(2, 1)); - const typename GT::Vector_3 max_eig_vec(eig_vecs(0, 0), eig_vecs(1, 0), eig_vecs(2, 0)); + if (is_gaussian_curvature_selected) { + *vertex_gaussian_curvature = vertex_measures.area_measure != 0 ? + vertex_measures.gaussian_curvature_measure / vertex_measures.area_measure : 0; + } - return Principal_curvatures_and_directions( - (v_mu0 != 0.0) ? -eig_vals[1] / v_mu0 : 0.0, - (v_mu0 != 0.0) ? -eig_vals[0] / v_mu0 : 0.0, - min_eig_vec, - max_eig_vec + if (is_principal_curvatures_and_directions_selected) { + const GT::Vector_3 v_normal = get(vnm, v); + const Principal_curvatures_and_directions principal_curvatures_and_directions = principal_curvatures_and_directions_from_anisotropic_measures( + vertex_measures.anisotropic_measure, + vertex_measures.area_measure, + v_normal ); + *vertex_principal_curvatures_and_directions = principal_curvatures_and_directions; } +} - template - class Interpolated_corrected_curvatures_computer - { - typedef typename GetGeomTraits::type GT; - - typedef typename GT::FT FT; - typedef typename GT::Point_3 Point_3; - typedef typename GT::Vector_3 Vector_3; - - typedef typename boost::graph_traits::halfedge_descriptor Halfedge_descriptor; - typedef typename boost::graph_traits::edge_descriptor Edge_descriptor; - typedef typename boost::graph_traits::face_descriptor Face_descriptor; - typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; - - typedef typename GetVertexPointMap::const_type Vertex_position_map; - - typedef dynamic_vertex_property_t Vector_map_tag; - typedef typename boost::property_map::const_type Default_vector_map; - typedef typename internal_np::Lookup_named_param_def::type Vertex_normal_map; - - typedef Constant_property_map Default_scalar_map; - typedef typename internal_np::Lookup_named_param_def::type Vertex_mean_curvature_map; - - typedef typename internal_np::Lookup_named_param_def::type Vertex_gaussian_curvature_map; - - typedef Constant_property_map> Default_principal_map; - typedef typename internal_np::Lookup_named_param_def::type Vertex_principal_curvatures_and_directions_map; - - typedef typename boost::property_map>::const_type Face_scalar_measure_map; - typedef typename boost::property_map>>::const_type Face_anisotropic_measure_map; - - private: - const PolygonMesh& pmesh; - Vertex_position_map vpm; - Vertex_normal_map vnm; - FT ball_radius; - - bool is_mean_curvature_selected; - bool is_gaussian_curvature_selected; - bool is_principal_curvatures_and_directions_selected; - - Vertex_mean_curvature_map mean_curvature_map; - Vertex_gaussian_curvature_map gaussian_curvature_map; - Vertex_principal_curvatures_and_directions_map principal_curvatures_and_directions_map; - - Face_scalar_measure_map mu0_map, mu1_map, mu2_map; - Face_anisotropic_measure_map muXY_map; - - void set_property_maps() { - mu0_map = get(CGAL::dynamic_face_property_t(), pmesh); - mu1_map = get(CGAL::dynamic_face_property_t(), pmesh); - mu2_map = get(CGAL::dynamic_face_property_t(), pmesh); - muXY_map = get(CGAL::dynamic_face_property_t>(), pmesh); - } +template +class Interpolated_corrected_curvatures_computer +{ + typedef typename GetGeomTraits::type GT; + + typedef typename GT::FT FT; + typedef typename GT::Point_3 Point_3; + typedef typename GT::Vector_3 Vector_3; + + typedef typename boost::graph_traits::halfedge_descriptor Halfedge_descriptor; + typedef typename boost::graph_traits::edge_descriptor Edge_descriptor; + typedef typename boost::graph_traits::face_descriptor Face_descriptor; + typedef typename boost::graph_traits::vertex_descriptor Vertex_descriptor; + + typedef typename GetVertexPointMap::const_type Vertex_position_map; + + typedef dynamic_vertex_property_t Vector_map_tag; + typedef typename boost::property_map::const_type Default_vector_map; + typedef typename internal_np::Lookup_named_param_def::type Vertex_normal_map; + + typedef Constant_property_map Default_scalar_map; + typedef typename internal_np::Lookup_named_param_def::type Vertex_mean_curvature_map; + + typedef typename internal_np::Lookup_named_param_def::type Vertex_gaussian_curvature_map; + + typedef Constant_property_map> Default_principal_map; + typedef typename internal_np::Lookup_named_param_def::type Vertex_principal_curvatures_and_directions_map; + + typedef typename boost::property_map>::const_type Face_scalar_measure_map; + typedef typename boost::property_map>>::const_type Face_anisotropic_measure_map; + +private: + const PolygonMesh& pmesh; + Vertex_position_map vpm; + Vertex_normal_map vnm; + FT ball_radius; + + bool is_mean_curvature_selected; + bool is_gaussian_curvature_selected; + bool is_principal_curvatures_and_directions_selected; + + Vertex_mean_curvature_map mean_curvature_map; + Vertex_gaussian_curvature_map gaussian_curvature_map; + Vertex_principal_curvatures_and_directions_map principal_curvatures_and_directions_map; + + Face_scalar_measure_map mu0_map, mu1_map, mu2_map; + Face_anisotropic_measure_map muXY_map; + + void set_property_maps() { + mu0_map = get(CGAL::dynamic_face_property_t(), pmesh); + mu1_map = get(CGAL::dynamic_face_property_t(), pmesh); + mu2_map = get(CGAL::dynamic_face_property_t(), pmesh); + muXY_map = get(CGAL::dynamic_face_property_t>(), pmesh); - void set_named_params(const NamedParameters& np) - { - using parameters::choose_parameter; - using parameters::get_parameter; - using parameters::is_default_parameter; + } - vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), - get_const_property_map(CGAL::vertex_point, pmesh)); + void set_named_params(const NamedParameters& np) + { + using parameters::choose_parameter; + using parameters::get_parameter; + using parameters::is_default_parameter; - vnm = choose_parameter(get_parameter(np, internal_np::vertex_normal_map), - get(Vector_map_tag(), pmesh)); + vpm = choose_parameter(get_parameter(np, CGAL::vertex_point), + get_const_property_map(CGAL::vertex_point, pmesh)); - if (is_default_parameter::value) - compute_vertex_normals(pmesh, vnm, np); + vnm = choose_parameter(get_parameter(np, internal_np::vertex_normal_map), + get(Vector_map_tag(), pmesh)); - const FT radius = choose_parameter(get_parameter(np, internal_np::ball_radius), -1); + if (is_default_parameter::value) + compute_vertex_normals(pmesh, vnm, np); - is_mean_curvature_selected = !is_default_parameter::value; - is_gaussian_curvature_selected = !is_default_parameter::value; - is_principal_curvatures_and_directions_selected = !is_default_parameter::value; + const FT radius = choose_parameter(get_parameter(np, internal_np::ball_radius), -1); - mean_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_mean_curvature_map), Default_scalar_map()); - gaussian_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_gaussian_curvature_map), Default_scalar_map()); - principal_curvatures_and_directions_map = choose_parameter(get_parameter(np, internal_np::vertex_principal_curvatures_and_directions_map), Default_principal_map()); + is_mean_curvature_selected = !is_default_parameter::value; + is_gaussian_curvature_selected = !is_default_parameter::value; + is_principal_curvatures_and_directions_selected = !is_default_parameter::value; - set_ball_radius(radius); - } + mean_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_mean_curvature_map), Default_scalar_map()); + gaussian_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_gaussian_curvature_map), Default_scalar_map()); + principal_curvatures_and_directions_map = choose_parameter(get_parameter(np, internal_np::vertex_principal_curvatures_and_directions_map), Default_principal_map()); - void set_ball_radius(const FT radius) { - if (radius == 0) - ball_radius = average_edge_length(pmesh) * EXPANDING_RADIUS_EPSILON; - else - ball_radius = radius; - } + set_ball_radius(radius); + } - public: + void set_ball_radius(const FT radius) { + if (radius == 0) + ball_radius = average_edge_length(pmesh) * EXPANDING_RADIUS_EPSILON; + else + ball_radius = radius; + } - Interpolated_corrected_curvatures_computer(const PolygonMesh& pmesh, - const NamedParameters& np = parameters::default_values() - ) : - pmesh(pmesh) - { - set_named_params(np); +public: - if (is_mean_curvature_selected || is_gaussian_curvature_selected || is_principal_curvatures_and_directions_selected) - { - set_property_maps(); + Interpolated_corrected_curvatures_computer(const PolygonMesh& pmesh, + const NamedParameters& np = parameters::default_values() + ) : + pmesh(pmesh) + { + set_named_params(np); - compute_selected_curvatures(); - } + if (is_mean_curvature_selected || is_gaussian_curvature_selected || is_principal_curvatures_and_directions_selected) + { + set_property_maps(); + + compute_selected_curvatures(); } + } - private: +private: - void interpolated_corrected_selected_measures_all_faces() - { - std::vector x; - std::vector u; + void interpolated_corrected_selected_measures_all_faces() + { + std::vector x; + std::vector u; - for (Face_descriptor f : faces(pmesh)) + for (Face_descriptor f : faces(pmesh)) + { + for (Vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) { - for (Vertex_descriptor v : vertices_around_face(halfedge(f, pmesh), pmesh)) - { - Point_3 p = get(vpm, v); - x.push_back(Vector_3(p.x(), p.y(), p.z())); - u.push_back(get(vnm, v)); - } - put(mu0_map, f, interpolated_corrected_area_measure_face(u, x)); + Point_3 p = get(vpm, v); + x.push_back(Vector_3(p.x(), p.y(), p.z())); + u.push_back(get(vnm, v)); + } + put(mu0_map, f, interpolated_corrected_area_measure_face(u, x)); - if (is_mean_curvature_selected) - put(mu1_map, f, interpolated_corrected_mean_curvature_measure_face(u, x)); + if (is_mean_curvature_selected) + put(mu1_map, f, interpolated_corrected_mean_curvature_measure_face(u, x)); - if (is_gaussian_curvature_selected) - put(mu2_map, f, interpolated_corrected_gaussian_curvature_measure_face(u)); + if (is_gaussian_curvature_selected) + put(mu2_map, f, interpolated_corrected_gaussian_curvature_measure_face(u)); - if (is_principal_curvatures_and_directions_selected) - put(muXY_map, f, interpolated_corrected_anisotropic_measure_face(u, x)); + if (is_principal_curvatures_and_directions_selected) + put(muXY_map, f, interpolated_corrected_anisotropic_measure_face(u, x)); - x.clear(); - u.clear(); - } + x.clear(); + u.clear(); } + } - Vertex_measures expand_interpolated_corrected_measure_vertex_no_radius(Vertex_descriptor v) - { - Vertex_measures vertex_measures; + Vertex_measures expand_interpolated_corrected_measure_vertex_no_radius(Vertex_descriptor v) + { + Vertex_measures vertex_measures; - for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { - if (f == boost::graph_traits::null_face()) - continue; + for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { + if (f == boost::graph_traits::null_face()) + continue; - vertex_measures.area_measure += get(mu0_map, f); + vertex_measures.area_measure += get(mu0_map, f); - if (is_mean_curvature_selected) - vertex_measures.mean_curvature_measure += get(mu1_map, f); + if (is_mean_curvature_selected) + vertex_measures.mean_curvature_measure += get(mu1_map, f); - if (is_gaussian_curvature_selected) - vertex_measures.gaussian_curvature_measure += get(mu2_map, f); + if (is_gaussian_curvature_selected) + vertex_measures.gaussian_curvature_measure += get(mu2_map, f); - if (is_principal_curvatures_and_directions_selected) - { - const std::array face_anisotropic_measure = get(muXY_map, f); - for (std::size_t i = 0; i < 3 * 3; i++) - vertex_measures.anisotropic_measure[i] += face_anisotropic_measure[i]; - } + if (is_principal_curvatures_and_directions_selected) + { + const std::array face_anisotropic_measure = get(muXY_map, f); + for (std::size_t i = 0; i < 3 * 3; i++) + vertex_measures.anisotropic_measure[i] += face_anisotropic_measure[i]; } - - return vertex_measures; } - Vertex_measures expand_interpolated_corrected_measure_vertex(Vertex_descriptor v) - { - std::queue bfs_queue; - std::unordered_set bfs_visited; + return vertex_measures; + } - Point_3 vp = get(vpm, v); - Vector_3 c = Vector_3(vp.x(), vp.y(), vp.z()); + Vertex_measures expand_interpolated_corrected_measure_vertex(Vertex_descriptor v) + { + std::queue bfs_queue; + std::unordered_set bfs_visited; - Vertex_measures vertex_measures; + Point_3 vp = get(vpm, v); + Vector_3 c = Vector_3(vp.x(), vp.y(), vp.z()); - for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { - if (f != boost::graph_traits::null_face()) - { - bfs_queue.push(f); - bfs_visited.insert(f); - } + Vertex_measures vertex_measures; + + for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { + if (f != boost::graph_traits::null_face()) + { + bfs_queue.push(f); + bfs_visited.insert(f); } - while (!bfs_queue.empty()) { - Face_descriptor fi = bfs_queue.front(); - bfs_queue.pop(); + } + while (!bfs_queue.empty()) { + Face_descriptor fi = bfs_queue.front(); + bfs_queue.pop(); - // looping over vertices in face to get point coordinates - std::vector x; - for (Vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh)) - { - Point_3 pi = get(vpm, vi); - x.push_back(Vector_3(pi.x(), pi.y(), pi.z())); - } + // looping over vertices in face to get point coordinates + std::vector x; + for (Vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh)) + { + Point_3 pi = get(vpm, vi); + x.push_back(Vector_3(pi.x(), pi.y(), pi.z())); + } - const FT f_ratio = face_in_ball_ratio(x, ball_radius, c); + const FT f_ratio = face_in_ball_ratio(x, ball_radius, c); - if (f_ratio != 0.0) - { - vertex_measures.area_measure += f_ratio * get(mu0_map, fi); + if (f_ratio != 0.0) + { + vertex_measures.area_measure += f_ratio * get(mu0_map, fi); - if (is_mean_curvature_selected) - vertex_measures.mean_curvature_measure += f_ratio * get(mu1_map, fi); + if (is_mean_curvature_selected) + vertex_measures.mean_curvature_measure += f_ratio * get(mu1_map, fi); - if (is_gaussian_curvature_selected) - vertex_measures.gaussian_curvature_measure += f_ratio * get(mu2_map, fi); + if (is_gaussian_curvature_selected) + vertex_measures.gaussian_curvature_measure += f_ratio * get(mu2_map, fi); - if (is_principal_curvatures_and_directions_selected) - { - const std::array face_anisotropic_measure = get(muXY_map, fi); - for (std::size_t i = 0; i < 3 * 3; i++) - vertex_measures.anisotropic_measure[i] += f_ratio * face_anisotropic_measure[i]; - } + if (is_principal_curvatures_and_directions_selected) + { + const std::array face_anisotropic_measure = get(muXY_map, fi); + for (std::size_t i = 0; i < 3 * 3; i++) + vertex_measures.anisotropic_measure[i] += f_ratio * face_anisotropic_measure[i]; + } - for (Face_descriptor fj : faces_around_face(halfedge(fi, pmesh), pmesh)) + for (Face_descriptor fj : faces_around_face(halfedge(fi, pmesh), pmesh)) + { + if (bfs_visited.find(fj) == bfs_visited.end() && fj != boost::graph_traits::null_face()) { - if (bfs_visited.find(fj) == bfs_visited.end() && fj != boost::graph_traits::null_face()) - { - bfs_queue.push(fj); - bfs_visited.insert(fj); - } + bfs_queue.push(fj); + bfs_visited.insert(fj); } } } - return vertex_measures; } + return vertex_measures; + } - void compute_selected_curvatures() { - interpolated_corrected_selected_measures_all_faces(); + void compute_selected_curvatures() { + interpolated_corrected_selected_measures_all_faces(); - for (Vertex_descriptor v : vertices(pmesh)) - { - Vertex_measures vertex_measures = (ball_radius < 0) ? - expand_interpolated_corrected_measure_vertex_no_radius(v) : - expand_interpolated_corrected_measure_vertex(v); - - if (is_mean_curvature_selected) { - vertex_measures.area_measure != 0 ? - put(mean_curvature_map, v, 0.5 * vertex_measures.mean_curvature_measure / vertex_measures.area_measure) : - put(mean_curvature_map, v, 0); - } + for (Vertex_descriptor v : vertices(pmesh)) + { + Vertex_measures vertex_measures = (ball_radius < 0) ? + expand_interpolated_corrected_measure_vertex_no_radius(v) : + expand_interpolated_corrected_measure_vertex(v); + + if (is_mean_curvature_selected) { + vertex_measures.area_measure != 0 ? + put(mean_curvature_map, v, 0.5 * vertex_measures.mean_curvature_measure / vertex_measures.area_measure) : + put(mean_curvature_map, v, 0); + } - if (is_gaussian_curvature_selected) { - vertex_measures.area_measure != 0 ? - put(gaussian_curvature_map, v, vertex_measures.gaussian_curvature_measure / vertex_measures.area_measure) : - put(gaussian_curvature_map, v, 0); - } + if (is_gaussian_curvature_selected) { + vertex_measures.area_measure != 0 ? + put(gaussian_curvature_map, v, vertex_measures.gaussian_curvature_measure / vertex_measures.area_measure) : + put(gaussian_curvature_map, v, 0); + } - if (is_principal_curvatures_and_directions_selected) { - const Vector_3 v_normal = get(vnm, v); - const Principal_curvatures_and_directions principal_curvatures_and_directions = principal_curvatures_and_directions_from_anisotropic_measures( - vertex_measures.anisotropic_measure, - vertex_measures.area_measure, - v_normal - ); - put(principal_curvatures_and_directions_map, v, principal_curvatures_and_directions); - } + if (is_principal_curvatures_and_directions_selected) { + const Vector_3 v_normal = get(vnm, v); + const Principal_curvatures_and_directions principal_curvatures_and_directions = principal_curvatures_and_directions_from_anisotropic_measures( + vertex_measures.anisotropic_measure, + vertex_measures.area_measure, + v_normal + ); + put(principal_curvatures_and_directions_map, v, principal_curvatures_and_directions); } } - }; + } +}; } // namespace internal @@ -1030,6 +1266,50 @@ template(pmesh, np); } +template + typename GT::FT interpolated_corrected_mean_curvature_at_vertex(const PolygonMesh& pmesh, + typename boost::graph_traits::vertex_descriptor v, + const NamedParameters& np = parameters::default_values()) +{ + // use interpolated_corrected_curvatures_at_vertex to compute mean curvature + typename GT::FT* mean_curvature = new typename GT::FT(); + interpolated_corrected_curvatures_at_vertex(pmesh, v, np.vertex_mean_curvature(mean_curvature)); + return *mean_curvature; +} + +template + typename GT::FT interpolated_corrected_gaussian_curvature_at_vertex(const PolygonMesh& pmesh, + typename boost::graph_traits::vertex_descriptor v, + const NamedParameters& np = parameters::default_values()) +{ + // use interpolated_corrected_curvatures_at_vertex to compute gaussian curvature + typename GT::FT* gc = new typename GT::FT(); + interpolated_corrected_curvatures_at_vertex(pmesh, v, np.vertex_gaussian_curvature(gc)); + return *gc; +} + +template + Principal_curvatures_and_directions interpolated_corrected_principal_curvatures_and_directions_at_vertex(const PolygonMesh& pmesh, + typename boost::graph_traits::vertex_descriptor v, + const NamedParameters& np = parameters::default_values()) +{ + // use interpolated_corrected_curvatures_at_vertex to compute principal curvatures + Principal_curvatures_and_directions* pcd = new Principal_curvatures_and_directions(); + interpolated_corrected_curvatures_at_vertex(pmesh, v, np.vertex_principal_curvatures_and_directions(pcd)); + return *pcd; +} + +template + void interpolated_corrected_curvatures_at_vertex(const PolygonMesh& pmesh, + typename boost::graph_traits::vertex_descriptor v, + const NamedParameters& np = parameters::default_values()) +{ + internal::interpolated_corrected_curvatures_one_vertex(pmesh, v, np); +} } // namespace Polygon_mesh_processing } // namespace CGAL diff --git a/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h index 21b8227e86c9..0d5469775614 100644 --- a/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h +++ b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h @@ -90,6 +90,9 @@ CGAL_add_named_parameter(nb_points_per_distance_unit_t, nb_points_per_distance_u CGAL_add_named_parameter(vertex_mean_curvature_map_t, vertex_mean_curvature_map, vertex_mean_curvature_map) CGAL_add_named_parameter(vertex_gaussian_curvature_map_t, vertex_gaussian_curvature_map, vertex_gaussian_curvature_map) CGAL_add_named_parameter(vertex_principal_curvatures_and_directions_map_t, vertex_principal_curvatures_and_directions_map, vertex_principal_curvatures_and_directions_map) +CGAL_add_named_parameter(vertex_mean_curvature_t, vertex_mean_curvature, vertex_mean_curvature) +CGAL_add_named_parameter(vertex_gaussian_curvature_t, vertex_gaussian_curvature, vertex_gaussian_curvature) +CGAL_add_named_parameter(vertex_principal_curvatures_and_directions_t, vertex_principal_curvatures_and_directions, vertex_principal_curvatures_and_directions) CGAL_add_named_parameter(ball_radius_t, ball_radius, ball_radius) CGAL_add_named_parameter(outward_orientation_t, outward_orientation, outward_orientation) CGAL_add_named_parameter(overlap_test_t, overlap_test, do_overlap_test_of_bounded_sides) From 73bde6daa0c57675f5eccd157fab07f6b0370d55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 20 Jan 2023 16:02:25 +0100 Subject: [PATCH 094/142] Eigen is needed --- .../test/Polygon_mesh_processing/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt index c1aedddedf4e..c446a7395dee 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt @@ -1,4 +1,4 @@ -# Created by the script cgal_create_CMakeLists +0# Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. cmake_minimum_required(VERSION 3.1...3.23) @@ -44,6 +44,8 @@ if(TARGET CGAL::Eigen3_support) target_link_libraries(test_shape_smoothing PUBLIC CGAL::Eigen3_support) create_single_source_cgal_program("delaunay_remeshing_test.cpp") target_link_libraries(delaunay_remeshing_test PUBLIC CGAL::Eigen3_support) + create_single_source_cgal_program("test_interpolated_corrected_curvatures.cpp") + target_link_libraries(test_interpolated_corrected_curvatures PUBLIC CGAL::Eigen3_support) endif() find_package(OpenMesh QUIET) @@ -69,7 +71,6 @@ create_single_source_cgal_program("self_intersection_polyhedron_test.cpp") create_single_source_cgal_program("self_intersection_surface_mesh_test.cpp") create_single_source_cgal_program("pmp_do_intersect_test.cpp") create_single_source_cgal_program("test_is_polygon_soup_a_polygon_mesh.cpp") -create_single_source_cgal_program("test_interpolated_corrected_curvatures.cpp") create_single_source_cgal_program("test_stitching.cpp") create_single_source_cgal_program("remeshing_test.cpp") create_single_source_cgal_program("remeshing_with_isolated_constraints_test.cpp" ) From 8af5c620fafb7c6771357f91f05fb9000f748a90 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 23 Jan 2023 13:49:34 +0200 Subject: [PATCH 095/142] reference documentation + minor fix + added documentation for the at_vertext curvature functions - removed dynamically allocated pointers for storing the curvature on vertex --- .../PackageDescription.txt | 4 + ...nterpolated_corrected_curvature_measures.h | 761 ++++++++++++------ 2 files changed, 504 insertions(+), 261 deletions(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt index f62b2816cf7f..f6696dc1ba8c 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt @@ -205,6 +205,10 @@ The page \ref bgl_namedparameters "Named Parameters" describes their usage. - `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature_at_vertex()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature_at_vertex()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions_at_vertex()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures_at_vertex()` - `CGAL::Polygon_mesh_processing::Principal_curvatures_and_directions` \cgalCRPSection{Normal Computation Functions} 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 94aaff9b8b52..cdd25aefc0e5 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 @@ -36,11 +36,11 @@ namespace CGAL { namespace Polygon_mesh_processing { /** -* \ingroup PMP_corrected_curvatures_grp -* -* \brief a struct for storing principal curvatures and directions. -* -* @tparam GT is the geometric traits class. + * \ingroup PMP_corrected_curvatures_grp + * + * \brief a struct for storing principal curvatures and directions. + * + * @tparam GT is the geometric traits class. */ template struct Principal_curvatures_and_directions { @@ -665,11 +665,11 @@ template vertex_measures; if (radius < 0) + { + std::cout << -1; vertex_measures = interpolated_corrected_measures_one_vertex_no_radius( pmesh, v, @@ -679,18 +679,21 @@ template( - pmesh, - v, - radius, - is_mean_curvature_selected, - is_gaussian_curvature_selected, - is_principal_curvatures_and_directions_selected, - vpm, - vnm - ); - + pmesh, + v, + radius, + is_mean_curvature_selected, + is_gaussian_curvature_selected, + is_principal_curvatures_and_directions_selected, + vpm, + vnm + ); + } if (is_mean_curvature_selected) { *vertex_mean_curvature = vertex_measures.area_measure != 0 ? @@ -988,58 +991,58 @@ class Interpolated_corrected_curvatures_computer } // namespace internal /** -* \ingroup PMP_corrected_curvatures_grp -* -* Computes the interpolated corrected mean curvature across the mesh -* and stores it in a vertex property map `vcm`. -* -* @tparam PolygonMesh a model of `FaceListGraph`. -* @tparam VertexCurvatureMap model of `WritablePropertyMap` with -* `boost::graph_traits::%Vertex_descriptor` as key type and `GT::FT` as value type. -* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". -* -* @param pmesh the polygon mesh. -* @param vcm the vertex property map in which the computed mean curvatures are stored. -* @param np an optional sequence of \ref bgl_namedparameters "Named Parameters". -* -* \cgalNamedParamsBegin -* -* \cgalParamNBegin{vertex_point_map} -* \cgalParamDescription{a property map associating points to the vertices of `pmesh`} -* \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, pmesh)`} -* \cgalParamExtra{If this parameter is omitted, an internal property map for -* `CGAL::vertex_point_t` must be available in `PolygonMesh`.} -* \cgalParamNEnd -* -* \cgalParamNBegin{vertex_normal_map} -* \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} -* \cgalParamType{a class model of `ReadablePropertyMap` with -* `boost::graph_traits::%Vertex_descriptor` -* as key type and `%Vector_3` as value type} -* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} -* \cgalParamExtra{If this parameter is omitted, vertex normals will be -* computed using compute_vertex_normals()} -* \cgalParamNEnd -* -* \cgalParamNBegin{ball_radius} -* \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures -* by summing measures of faces inside a ball of this radius centered at the -* vertex expanded from. The summed face measures are weighted by their -* inclusion ratio inside this ball} -* \cgalParamType{`GT::FT`} -* \cgalParamDefault{`-1`} -* \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of -* measures on faces around the vertex} -* \cgalParamNEnd -* -* \cgalNamedParamsEnd -* -* @see `interpolated_corrected_gaussian_curvature()` -* @see `interpolated_corrected_principal_curvatures_and_directions()` -* @see `interpolated_corrected_curvatures()` + * \ingroup PMP_corrected_curvatures_grp + * + * Computes the interpolated corrected mean curvature across the mesh + * and stores it in a vertex property map `vcm`. + * + * @tparam PolygonMesh a model of `FaceListGraph`. + * @tparam VertexCurvatureMap model of `WritablePropertyMap` with + * `boost::graph_traits::%Vertex_descriptor` as key type and `GT::FT` as value type. + * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". + * + * @param pmesh the polygon mesh. + * @param vcm the vertex property map in which the computed mean curvatures are stored. + * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters". + * + * \cgalNamedParamsBegin + * + * \cgalParamNBegin{vertex_point_map} + * \cgalParamDescription{a property map associating points to the vertices of `pmesh`} + * \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, pmesh)`} + * \cgalParamExtra{If this parameter is omitted, an internal property map for + * `CGAL::vertex_point_t` must be available in `PolygonMesh`.} + * \cgalParamNEnd + * + * \cgalParamNBegin{vertex_normal_map} + * \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} + * \cgalParamType{a class model of `ReadablePropertyMap` with + * `boost::graph_traits::%Vertex_descriptor` + * as key type and `%Vector_3` as value type} + * \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} + * \cgalParamExtra{If this parameter is omitted, vertex normals will be + * computed using compute_vertex_normals()} + * \cgalParamNEnd + * + * \cgalParamNBegin{ball_radius} + * \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures + * by summing measures of faces inside a ball of this radius centered at the + * vertex expanded from. The summed face measures are weighted by their + * inclusion ratio inside this ball} + * \cgalParamType{`GT::FT`} + * \cgalParamDefault{`-1`} + * \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of + * measures on faces around the vertex} + * \cgalParamNEnd + * + * \cgalNamedParamsEnd + * + * @see `interpolated_corrected_gaussian_curvature()` + * @see `interpolated_corrected_principal_curvatures_and_directions()` + * @see `interpolated_corrected_curvatures()` */ template::%Vertex_descriptor` as key type and `GT::FT` as value type. -* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". -* -* @param pmesh the polygon mesh. -* @param vcm the vertex property map in which the computed gaussian curvatures are stored. -* @param np an optional sequence of \ref bgl_namedparameters "Named Parameters". -* -* \cgalNamedParamsBegin -* -* \cgalParamNBegin{vertex_point_map} -* \cgalParamDescription{a property map associating points to the vertices of `pmesh`} -* \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, pmesh)`} -* \cgalParamExtra{If this parameter is omitted, an internal property map for -* `CGAL::vertex_point_t` must be available in `PolygonMesh`.} -* \cgalParamNEnd -* -* \cgalParamNBegin{vertex_normal_map} -* \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} -* \cgalParamType{a class model of `ReadablePropertyMap` with -* `boost::graph_traits::%Vertex_descriptor` -* as key type and `%Vector_3` as value type} -* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} -* \cgalParamExtra{If this parameter is omitted, vertex normals will be -* computed using compute_vertex_normals()} -* \cgalParamNEnd -* -* \cgalParamNBegin{ball_radius} -* \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures -* by summing measures of faces inside a ball of this radius centered at the -* vertex expanded from. The summed face measures are weighted by their -* inclusion ratio inside this ball} -* \cgalParamType{`GT::FT`} -* \cgalParamDefault{`-1`} -* \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of -* measures on faces around the vertex} -* \cgalParamNEnd -* -* \cgalNamedParamsEnd -* -* @see `interpolated_corrected_mean_curvature()` -* @see `interpolated_corrected_principal_curvatures_and_directions()` -* @see `interpolated_corrected_curvatures()` + * \ingroup PMP_corrected_curvatures_grp + * + * Computes the interpolated corrected gaussian curvature across the mesh + * and stores it in a vertex property map `vcm`. + * + * @tparam PolygonMesh a model of `FaceListGraph`. + * @tparam VertexCurvatureMap model of `WritablePropertyMap` with + * `boost::graph_traits::%Vertex_descriptor` as key type and `GT::FT` as value type. + * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". + * + * @param pmesh the polygon mesh. + * @param vcm the vertex property map in which the computed gaussian curvatures are stored. + * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters". + * + * \cgalNamedParamsBegin + * + * \cgalParamNBegin{vertex_point_map} + * \cgalParamDescription{a property map associating points to the vertices of `pmesh`} + * \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, pmesh)`} + * \cgalParamExtra{If this parameter is omitted, an internal property map for + * `CGAL::vertex_point_t` must be available in `PolygonMesh`.} + * \cgalParamNEnd + * + * \cgalParamNBegin{vertex_normal_map} + * \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} + * \cgalParamType{a class model of `ReadablePropertyMap` with + * `boost::graph_traits::%Vertex_descriptor` + * as key type and `%Vector_3` as value type} + * \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} + * \cgalParamExtra{If this parameter is omitted, vertex normals will be + * computed using compute_vertex_normals()} + * \cgalParamNEnd + * + * \cgalParamNBegin{ball_radius} + * \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures + * by summing measures of faces inside a ball of this radius centered at the + * vertex expanded from. The summed face measures are weighted by their + * inclusion ratio inside this ball} + * \cgalParamType{`GT::FT`} + * \cgalParamDefault{`-1`} + * \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of + * measures on faces around the vertex} + * \cgalParamNEnd + * + * \cgalNamedParamsEnd + * + * @see `interpolated_corrected_mean_curvature()` + * @see `interpolated_corrected_principal_curvatures_and_directions()` + * @see `interpolated_corrected_curvatures()` */ template @@ -1115,59 +1118,59 @@ template::%Vertex_descriptor` as key type and -* `std::tuple, Eigen::Vector>` as value type. -* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". -* -* @param pmesh the polygon mesh. -* @param vcm the vertex property map in which the computed principal curvatures are stored. -* @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 `pmesh`} -* \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, pmesh)`} -* \cgalParamExtra{If this parameter is omitted, an internal property map for -* `CGAL::vertex_point_t` must be available in `PolygonMesh`.} -* \cgalParamNEnd -* -* \cgalParamNBegin{vertex_normal_map} -* \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} -* \cgalParamType{a class model of `ReadablePropertyMap` with -* `boost::graph_traits::%Vertex_descriptor` -* as key type and `%Vector_3` as value type} -* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} -* \cgalParamExtra{If this parameter is omitted, vertex normals will be -* computed using compute_vertex_normals()} -* \cgalParamNEnd -* -* \cgalParamNBegin{ball_radius} -* \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures -* by summing measures of faces inside a ball of this radius centered at the -* vertex expanded from. The summed face measures are weighted by their -* inclusion ratio inside this ball} -* \cgalParamType{`GT::FT`} -* \cgalParamDefault{`-1`} -* \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of -* measures on faces around the vertex} -* \cgalParamNEnd -* -* \cgalNamedParamsEnd -* -* @see `interpolated_corrected_mean_curvature()` -* @see `interpolated_corrected_gaussian_curvature()` -* @see `interpolated_corrected_curvatures()` + * \ingroup PMP_corrected_curvatures_grp + * + * Computes the interpolated corrected principal curvatures across the mesh + * and stores it in a vertex property map `vcm`. + * + * @tparam PolygonMesh a model of `FaceListGraph`. + * @tparam VertexCurvatureMap model of `WritablePropertyMap` with + * `boost::graph_traits::%Vertex_descriptor` as key type and + * `%Principal_curvatures_and_directions` as value type. + * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". + * + * @param pmesh the polygon mesh. + * @param vcm the vertex property map in which the computed principal curvatures are stored. + * @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 `pmesh`} + * \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, pmesh)`} + * \cgalParamExtra{If this parameter is omitted, an internal property map for + * `CGAL::vertex_point_t` must be available in `PolygonMesh`.} + * \cgalParamNEnd + * + * \cgalParamNBegin{vertex_normal_map} + * \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} + * \cgalParamType{a class model of `ReadablePropertyMap` with + * `boost::graph_traits::%Vertex_descriptor` + * as key type and `%Vector_3` as value type} + * \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} + * \cgalParamExtra{If this parameter is omitted, vertex normals will be + * computed using compute_vertex_normals()} + * \cgalParamNEnd + * + * \cgalParamNBegin{ball_radius} + * \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures + * by summing measures of faces inside a ball of this radius centered at the + * vertex expanded from. The summed face measures are weighted by their + * inclusion ratio inside this ball} + * \cgalParamType{`GT::FT`} + * \cgalParamDefault{`-1`} + * \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of + * measures on faces around the vertex} + * \cgalParamNEnd + * + * \cgalNamedParamsEnd + * + * @see `interpolated_corrected_mean_curvature()` + * @see `interpolated_corrected_gaussian_curvature()` + * @see `interpolated_corrected_curvatures()` */ template @@ -1179,84 +1182,84 @@ template::%Vertex_descriptor` -* as key type and `%Point_3` as value type} -* \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`} -* \cgalParamExtra{If this parameter is omitted, an internal property map for -* `CGAL::vertex_point_t` must be available in `PolygonMesh`.} -* \cgalParamNEnd -* -* \cgalParamNBegin{vertex_normal_map} -* \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} -* \cgalParamType{a class model of `ReadablePropertyMap` with -* `boost::graph_traits::%Vertex_descriptor` -* as key type and `%Vector_3` as value type} -* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} -* \cgalParamExtra{If this parameter is omitted, vertex normals will be -* computed using compute_vertex_normals()} -* \cgalParamNEnd -* -* \cgalParamNBegin{vertex_mean_curvature_map} -* \cgalParamDescription{a property map associating mean curvatures to the vertices of `pmesh`} -* \cgalParamType{a class model of `WritablePropertyMap` with -* `boost::graph_traits::%Vertex_descriptor` -* as key type and `%FT` as value type} -* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} -* \cgalParamExtra{If this parameter is omitted, mean curvatures won't be computed} -* \cgalParamNEnd -* -* \cgalParamNBegin{vertex_gaussian_curvature_map} -* \cgalParamDescription{a property map associating mean curvatures to the vertices of `pmesh`} -* \cgalParamType{a class model of `WritablePropertyMap` with -* `boost::graph_traits::%Vertex_descriptor` -* as key type and `%FT` as value type} -* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} -* \cgalParamExtra{If this parameter is omitted, gaussian curvatures won't be computed} -* \cgalParamNEnd -* -* -* \cgalParamNBegin{vertex_principal_curvatures_and_directions_map} -* \cgalParamDescription{a property map associating mean curvatures to the vertices of `pmesh`} -* \cgalParamType{a class model of `WritablePropertyMap` with -* `boost::graph_traits::%Vertex_descriptor` -* as key type and `%Principal_curvatures_and_directions` as value type} -* \cgalParamDefault{`get(dynamic_vertex_property_t>(), pmesh)`} -* \cgalParamExtra{If this parameter is omitted, mean principal won't be computed} -* \cgalParamNEnd -* -* \cgalParamNBegin{ball_radius} -* \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures -* by summing measures of faces inside a ball of this radius centered at the -* vertex expanded from. The summed face measures are weighted by their -* inclusion ratio inside this ball.} -* \cgalParamType{`GT::FT`} -* \cgalParamDefault{`-1`} -* \cgalParamExtra{If this parameter is omitted (`-1`), the epansion is then just a sum of -* measures on faces around the vertex} -* \cgalParamNEnd -* -* \cgalNamedParamsEnd -* -* @see `interpolated_corrected_mean_curvature()` -* @see `interpolated_corrected_gaussian_curvature()` -* @see `interpolated_corrected_principal_curvatures_and_directions()` + * \ingroup PMP_corrected_curvatures_grp + * + * Computes the interpolated corrected curvatures across the mesh, based on the provided property maps. + * By providing mean, gaussian and/or principal curvature property maps as named parameters, the user + * can choose which curvatures to compute. + * + * @tparam PolygonMesh a model of `FaceListGraph`. + * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". + * + * @param pmesh the polygon 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 `pmesh`} + * \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, pmesh)`} + * \cgalParamExtra{If this parameter is omitted, an internal property map for + * `CGAL::vertex_point_t` must be available in `PolygonMesh`.} + * \cgalParamNEnd + * + * \cgalParamNBegin{vertex_normal_map} + * \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} + * \cgalParamType{a class model of `ReadablePropertyMap` with + * `boost::graph_traits::%Vertex_descriptor` + * as key type and `%Vector_3` as value type} + * \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} + * \cgalParamExtra{If this parameter is omitted, vertex normals will be + * computed using compute_vertex_normals()} + * \cgalParamNEnd + * + * \cgalParamNBegin{vertex_mean_curvature_map} + * \cgalParamDescription{a property map associating mean curvatures to the vertices of `pmesh`} + * \cgalParamType{a class model of `WritablePropertyMap` with + * `boost::graph_traits::%Vertex_descriptor` + * as key type and `%FT` as value type} + * \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} + * \cgalParamExtra{If this parameter is omitted, mean curvatures won't be computed} + * \cgalParamNEnd + * + * \cgalParamNBegin{vertex_gaussian_curvature_map} + * \cgalParamDescription{a property map associating mean curvatures to the vertices of `pmesh`} + * \cgalParamType{a class model of `WritablePropertyMap` with + * `boost::graph_traits::%Vertex_descriptor` + * as key type and `%FT` as value type} + * \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} + * \cgalParamExtra{If this parameter is omitted, gaussian curvatures won't be computed} + * \cgalParamNEnd + * + * + * \cgalParamNBegin{vertex_principal_curvatures_and_directions_map} + * \cgalParamDescription{a property map associating mean curvatures to the vertices of `pmesh`} + * \cgalParamType{a class model of `WritablePropertyMap` with + * `boost::graph_traits::%Vertex_descriptor` + * as key type and `%Principal_curvatures_and_directions` as value type} + * \cgalParamDefault{`get(dynamic_vertex_property_t>(), pmesh)`} + * \cgalParamExtra{If this parameter is omitted, mean principal won't be computed} + * \cgalParamNEnd + * + * \cgalParamNBegin{ball_radius} + * \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures + * by summing measures of faces inside a ball of this radius centered at the + * vertex expanded from. The summed face measures are weighted by their + * inclusion ratio inside this ball.} + * \cgalParamType{`GT::FT`} + * \cgalParamDefault{`-1`} + * \cgalParamExtra{If this parameter is omitted (`-1`), the epansion is then just a sum of + * measures on faces around the vertex} + * \cgalParamNEnd + * + * \cgalNamedParamsEnd + * + * @see `interpolated_corrected_mean_curvature()` + * @see `interpolated_corrected_gaussian_curvature()` + * @see `interpolated_corrected_principal_curvatures_and_directions()` */ template @@ -1266,6 +1269,60 @@ template(pmesh, np); } +/** + * \ingroup PMP_corrected_curvatures_grp + * computes the interpolated corrected mean curvature at a vertex of a triangle mesh. + * + * @tparam GT a geometric traits class that provides the nested type `FT`, + * @tparam PolygonMesh a model of `FaceListGraph` + * @tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" + * + * @param pmesh the polygon mesh + * @param v the vertex of `pmesh` to compute the mean curvature at + * @param np optional sequence of \ref pmp_namedparameters "Named Parameters" among the ones listed below + * + * \cgalNamedParamsBegin + * \cgalParamNBegin{vertex_point_map} + * \cgalParamDescription{a property map associating points to the vertices of `pmesh`} + * \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, pmesh)`} + * \cgalParamExtra{If this parameter is omitted, an internal property map for + * `CGAL::vertex_point_t` must be available in `PolygonMesh`.} + * \cgalParamNEnd + * + * \cgalParamNBegin{vertex_normal_map} + * \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} + * \cgalParamType{a class model of `ReadablePropertyMap` with + * `boost::graph_traits::%Vertex_descriptor` + * as key type and `%Vector_3` as value type} + * \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} + * \cgalParamExtra{If this parameter is omitted, vertex normals will be + * computed using compute_vertex_normals()} + * \cgalParamNEnd + * + * \cgalParamNBegin{ball_radius} + * \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures + * by summing measures of faces inside a ball of this radius centered at the + * vertex expanded from. The summed face measures are weighted by their + * inclusion ratio inside this ball} + * \cgalParamType{`GT::FT`} + * \cgalParamDefault{`-1`} + * \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of + * measures on faces around the vertex} + * \cgalParamNEnd + * + * \cgalNamedParamsEnd + * + * @return the interpolated corrected mean curvature at the vertex `v` + * + * @see `interpolated_corrected_mean_curvature()` + * @see `interpolated_corrected_gaussian_curvature_at_vertex()` + * @see `interpolated_corrected_principal_curvatures_and_directions_at_vertex()` + * @see `interpolated_corrected_curvatures_at_vertex()` +*/ + template typename GT::FT interpolated_corrected_mean_curvature_at_vertex(const PolygonMesh& pmesh, @@ -1273,11 +1330,65 @@ template::%Vertex_descriptor` + * as key type and `%Point_3` as value type} + * \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`} + * \cgalParamExtra{If this parameter is omitted, an internal property map for + * `CGAL::vertex_point_t` must be available in `PolygonMesh`.} + * \cgalParamNEnd + * + * \cgalParamNBegin{vertex_normal_map} + * \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} + * \cgalParamType{a class model of `ReadablePropertyMap` with + * `boost::graph_traits::%Vertex_descriptor` + * as key type and `%Vector_3` as value type} + * \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} + * \cgalParamExtra{If this parameter is omitted, vertex normals will be + * computed using compute_vertex_normals()} + * \cgalParamNEnd + * + * \cgalParamNBegin{ball_radius} + * \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures + * by summing measures of faces inside a ball of this radius centered at the + * vertex expanded from. The summed face measures are weighted by their + * inclusion ratio inside this ball} + * \cgalParamType{`GT::FT`} + * \cgalParamDefault{`-1`} + * \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of + * measures on faces around the vertex} + * \cgalParamNEnd + * + * \cgalNamedParamsEnd + * + * @return the interpolated corrected Gaussian curvature at the vertex `v` + * + * @see `interpolated_corrected_gaussian_curvature()` + * @see `interpolated_corrected_mean_curvature_at_vertex()` + * @see `interpolated_corrected_principal_curvatures_and_directions_at_vertex()` + * @see `interpolated_corrected_curvatures_at_vertex()` +*/ + template typename GT::FT interpolated_corrected_gaussian_curvature_at_vertex(const PolygonMesh& pmesh, @@ -1285,11 +1396,64 @@ template::%Vertex_descriptor` + * as key type and `%Point_3` as value type} + * \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`} + * \cgalParamExtra{If this parameter is omitted, an internal property map for + * `CGAL::vertex_point_t` must be available in `PolygonMesh`.} + * \cgalParamNEnd + * + * \cgalParamNBegin{vertex_normal_map} + * \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} + * \cgalParamType{a class model of `ReadablePropertyMap` with + * `boost::graph_traits::%Vertex_descriptor` + * as key type and `%Vector_3` as value type} + * \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} + * \cgalParamExtra{If this parameter is omitted, vertex normals will be + * computed using compute_vertex_normals()} + * \cgalParamNEnd + * + * \cgalParamNBegin{ball_radius} + * \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures + * by summing measures of faces inside a ball of this radius centered at the + * vertex expanded from. The summed face measures are weighted by their + * inclusion ratio inside this ball} + * \cgalParamType{`GT::FT`} + * \cgalParamDefault{`-1`} + * \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of + * measures on faces around the vertex} + * \cgalParamNEnd + * \cgalNamedParamsEnd + * + * @return the interpolated corrected principal curvatures and directions at the vertex `v` + * + * @see `interpolated_corrected_principal_curvatures_and_directions()` + * @see `interpolated_corrected_mean_curvature_at_vertex()` + * @see `interpolated_corrected_gaussian_curvature_at_vertex()` + * @see `interpolated_corrected_curvatures_at_vertex()` +*/ + template Principal_curvatures_and_directions interpolated_corrected_principal_curvatures_and_directions_at_vertex(const PolygonMesh& pmesh, @@ -1297,11 +1461,86 @@ template* pcd = new Principal_curvatures_and_directions(); - interpolated_corrected_curvatures_at_vertex(pmesh, v, np.vertex_principal_curvatures_and_directions(pcd)); - return *pcd; + Principal_curvatures_and_directions pcd; + interpolated_corrected_curvatures_at_vertex(pmesh, v, np.vertex_principal_curvatures_and_directions(&pcd)); + return pcd; } +/** + * \ingroup PMP_corrected_curvatures_grp + * Computes the interpolated corrected curvatures at a certain vertex, based on the provided pointers. + * By providing mean, gaussian and/or principal curvature pointers as named parameters, the user + * can choose which curvatures to compute. + * The pointers are used to store the computed curvatures. + * The user is responsible for the memory management of the pointers. + * + * @tparam PolygonMesh a model of `FaceListGraph` + * @tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" + * + * @param pmesh the polygon mesh + * @param v the vertex of `pmesh` to compute the curvatures at + * @param np optional sequence of \ref pmp_namedparameters "Named Parameters" among the ones listed below + * + * \cgalNamedParamsBegin + * \cgalParamNBegin{vertex_point_map} + * \cgalParamDescription{a property map associating points to the vertices of `pmesh`} + * \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, pmesh)`} + * \cgalParamExtra{If this parameter is omitted, an internal property map for + * `CGAL::vertex_point_t` must be available in `PolygonMesh`.} + * \cgalParamNEnd + * + * \cgalParamNBegin{vertex_normal_map} + * \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} + * \cgalParamType{a class model of `ReadablePropertyMap` with + * `boost::graph_traits::%Vertex_descriptor` + * as key type and `%Vector_3` as value type} + * \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} + * \cgalParamExtra{If this parameter is omitted, vertex normals will be + * computed using compute_vertex_normals()} + * \cgalParamNEnd + * + * \cgalParamNBegin{vertex_mean_curvature} + * \cgalParamDescription{a pointer to a scalar value to store the mean curvature at the vertex `v`} + * \cgalParamType{`GT::FT*`} + * \cgalParamDefault{`nullptr`} + * \cgalParamExtra{If this parameter is omitted, mean curvature won't be computed} + * \cgalParamNEnd + * + * \cgalParamNBegin{vertex_gaussian_curvature} + * \cgalParamDescription{a pointer to a scalar value to store the gaussian curvature at the vertex `v`} + * \cgalParamType{`GT::FT*`} + * \cgalParamDefault{`nullptr`} + * \cgalParamExtra{If this parameter is omitted, gaussian curvature won't be computed} + * \cgalParamNEnd + * + * \cgalParamNBegin{vertex_principal_curvatures_and_directions} + * \cgalParamDescription{a pointer to a Principal_curvatures_and_directions object to store the principal curvatures and directions at the vertex `v`} + * \cgalParamType{`Principal_curvatures_and_directions*`} + * \cgalParamDefault{`nullptr`} + * \cgalParamExtra{If this parameter is omitted, principal curvatures and directions won't be computed} + * \cgalParamNEnd + * + * \cgalParamNBegin{ball_radius} + * \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures + * by summing measures of faces inside a ball of this radius centered at the + * vertex expanded from. The summed face measures are weighted by their + * inclusion ratio inside this ball.} + * \cgalParamType{`GT::FT`} + * \cgalParamDefault{`-1`} + * \cgalParamExtra{If this parameter is omitted (`-1`), the epansion is then just a sum of + * measures on faces around the vertex} + * \cgalParamNEnd + * + * \cgalNamedParamsEnd + * + * @see `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures()` + * @see `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature_at_vertex()` + * @see `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature_at_vertex()` + * @see `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions_at_vertex()` +*/ template void interpolated_corrected_curvatures_at_vertex(const PolygonMesh& pmesh, From 483e8b8e509ee4420ba0861ab70dd5a50133f7b0 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Tue, 24 Jan 2023 08:44:09 +0200 Subject: [PATCH 096/142] User manual + add example file for 1 vertex curvature --- .../Polygon_mesh_processing.txt | 16 ++++- .../Polygon_mesh_processing/CMakeLists.txt | 2 + ...corrected_curvatures_at_vertex_example.cpp | 60 +++++++++++++++++++ ...erpolated_corrected_curvatures_example.cpp | 2 + ...nterpolated_corrected_curvature_measures.h | 2 - 5 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_at_vertex_example.cpp diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index 1d7184561a80..49f912ee5ca7 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -889,7 +889,7 @@ correct vertex normals are provided. The implementation is generic in terms of mesh data structure. It can be used on Surface_mesh, Polyhedron_3 and other polygonal mesh structures based on the Face Graph Model. -These computations are performed using : +These computations are performed using (on all vertices of mesh): - `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions()` @@ -898,6 +898,13 @@ These computations are performed using : Where it is recommended to use the last function for computing multiple curvatures (example: mean and gaussian) as the implementation performs the shared computations only once, making it more efficient. +Similarly, we can use the following example functions to compute the curvatures on a specific vertex: +- `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature_at_vertex()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature_at_vertex()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions_at_vertex()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures_at_vertex()` + + \cgalFigureRef{icc_diff_radius} shows how the mean curvature changes depending on the ball_radius named parameter which can be set to a value > 0 to get a smoother distribution of values and "diffuse" the extreme values of curvatures across the mesh. @@ -934,6 +941,13 @@ not provide storage for the curvatures. \cgalExample{Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp} +\subsection ICCExamplePH Interpolated Corrected Curvature on a Vertex Example + +The following example illustrates how to +compute the curvatures on a specific vertex + +\cgalExample{Polygon_mesh_processing/interpolated_corrected_curvatures_at_vertex_example.cpp} + **************************************** \section PMPSlicer Slicer diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt index ab084384835b..5e840c38a508 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt @@ -109,6 +109,8 @@ if(TARGET CGAL::Eigen3_support) target_link_libraries(interpolated_corrected_curvatures_example PUBLIC CGAL::Eigen3_support) create_single_source_cgal_program("interpolated_corrected_curvatures_polyhedron_example.cpp") target_link_libraries(interpolated_corrected_curvatures_polyhedron_example PUBLIC CGAL::Eigen3_support) + create_single_source_cgal_program("interpolated_corrected_curvatures_at_vertex_example.cpp") + target_link_libraries(interpolated_corrected_curvatures_at_vertex_example PUBLIC CGAL::Eigen3_support) endif() diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_at_vertex_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_at_vertex_example.cpp new file mode 100644 index 000000000000..6ed061db93b8 --- /dev/null +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_at_vertex_example.cpp @@ -0,0 +1,60 @@ +#include +#include +#include +#include + +#include + +#include + +namespace PMP = CGAL::Polygon_mesh_processing; + +typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic_kernel; +typedef Epic_kernel::FT FT; +typedef CGAL::Surface_mesh Surface_Mesh; +typedef boost::graph_traits::face_descriptor face_descriptor; +typedef boost::graph_traits::vertex_descriptor vertex_descriptor; + +int main(int argc, char* argv[]) +{ + // instantiating and reading mesh + Surface_Mesh smesh; + const std::string filename = (argc > 1) ? + argv[1] : + CGAL::data_file_path("meshes/small_bunny.obj"); + + if (!CGAL::IO::read_polygon_mesh(filename, smesh)) + { + std::cerr << "Invalid input file." << std::endl; + return EXIT_FAILURE; + } + + // loop over vertices and use vertex_descriptor to compute a curvature on one vertex + for (vertex_descriptor v : vertices(smesh)) + { + FT h = PMP::interpolated_corrected_mean_curvature_at_vertex(smesh, v); + FT g = PMP::interpolated_corrected_gaussian_curvature_at_vertex(smesh, v); + PMP::Principal_curvatures_and_directions p = + PMP::interpolated_corrected_principal_curvatures_and_directions_at_vertex(smesh, v); + + // we can also specify a ball radius for expansion and a user defined vertex normals map using + // named parameters. Refer to interpolated_corrected_curvatures_example.cpp to see example usage. + + // Can also use interpolated_corrected_curvatures_at_vertex() to compute multiple curvatures + // on the vertex at the same time. This is more efficient than computing each one separately. + // The following commented lines show this (all mentioned named parameters work on it as well) + // we specify which curvatures we want to compute by passing pointers as named parameters + // as shown. These pointers are used for storing the result as well. in this example we + // selected mean and gaussian curvatures + // PMP::interpolated_corrected_curvatures_at_vertex( + // smesh, + // v, + // CGAL::parameters::vertex_mean_curvature(&h) + // .vertex_gaussian_curvature(&g) + // ); + + std::cout << v.idx() << ": HC = " << h + << ", GC = " << g << "\n" + << ", PC = [ " << p.min_curvature << " , " << p.max_curvature << " ]\n"; + } +} diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp index 33d34cd34f13..91266f594135 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp @@ -47,6 +47,8 @@ int main(int argc, char* argv[]) assert(created); // user can call these fucntions to compute a specfic curvature type on each vertex. + // (Note: if no ball radius is specified, the measure expansion of each vertex happens by + // summing measures on faces adjacent to each vertex.) PMP::interpolated_corrected_mean_curvature( smesh, mean_curvature_map 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 cdd25aefc0e5..847bac1f5c06 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 @@ -669,7 +669,6 @@ template( pmesh, v, @@ -682,7 +681,6 @@ template( pmesh, v, From a7cd6a275ecabaad05c802b4593e1f7235e25e65 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Tue, 24 Jan 2023 09:00:24 +0200 Subject: [PATCH 097/142] trailling whitespaces --- ...olated_corrected_curvatures_at_vertex_example.cpp | 12 ++++++------ .../interpolated_corrected_curvatures_example.cpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_at_vertex_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_at_vertex_example.cpp index 6ed061db93b8..009c5881f262 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_at_vertex_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_at_vertex_example.cpp @@ -17,7 +17,7 @@ typedef boost::graph_traits::vertex_descriptor vertex_descriptor; int main(int argc, char* argv[]) { - // instantiating and reading mesh + // instantiating and reading mesh Surface_Mesh smesh; const std::string filename = (argc > 1) ? argv[1] : @@ -34,21 +34,21 @@ int main(int argc, char* argv[]) { FT h = PMP::interpolated_corrected_mean_curvature_at_vertex(smesh, v); FT g = PMP::interpolated_corrected_gaussian_curvature_at_vertex(smesh, v); - PMP::Principal_curvatures_and_directions p = + PMP::Principal_curvatures_and_directions p = PMP::interpolated_corrected_principal_curvatures_and_directions_at_vertex(smesh, v); - // we can also specify a ball radius for expansion and a user defined vertex normals map using + // we can also specify a ball radius for expansion and a user defined vertex normals map using // named parameters. Refer to interpolated_corrected_curvatures_example.cpp to see example usage. // Can also use interpolated_corrected_curvatures_at_vertex() to compute multiple curvatures // on the vertex at the same time. This is more efficient than computing each one separately. // The following commented lines show this (all mentioned named parameters work on it as well) - // we specify which curvatures we want to compute by passing pointers as named parameters - // as shown. These pointers are used for storing the result as well. in this example we + // we specify which curvatures we want to compute by passing pointers as named parameters + // as shown. These pointers are used for storing the result as well. in this example we // selected mean and gaussian curvatures // PMP::interpolated_corrected_curvatures_at_vertex( // smesh, - // v, + // v, // CGAL::parameters::vertex_mean_curvature(&h) // .vertex_gaussian_curvature(&g) // ); diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp index 91266f594135..511288702336 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp @@ -47,7 +47,7 @@ int main(int argc, char* argv[]) assert(created); // user can call these fucntions to compute a specfic curvature type on each vertex. - // (Note: if no ball radius is specified, the measure expansion of each vertex happens by + // (Note: if no ball radius is specified, the measure expansion of each vertex happens by // summing measures on faces adjacent to each vertex.) PMP::interpolated_corrected_mean_curvature( smesh, From fc943a4c317588c51b7e64da23dd84c4fef9672a Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Tue, 24 Jan 2023 09:18:05 +0200 Subject: [PATCH 098/142] minor doc fixes --- .../Polygon_mesh_processing/Polygon_mesh_processing.txt | 8 ++++---- .../doc/Polygon_mesh_processing/examples.txt | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index 49f912ee5ca7..426e9e3b54a6 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -898,7 +898,7 @@ These computations are performed using (on all vertices of mesh): Where it is recommended to use the last function for computing multiple curvatures (example: mean and gaussian) as the implementation performs the shared computations only once, making it more efficient. -Similarly, we can use the following example functions to compute the curvatures on a specific vertex: +Similarly, we can use the following functions to compute curvatures on a specific vertex: - `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature_at_vertex()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature_at_vertex()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions_at_vertex()` @@ -924,7 +924,7 @@ Property maps are an API introduced in the boost library that allows associating values to keys. In the following examples, for each property map, we associate a curvature value to each vertex. -\subsection ICCExampleSM Interpolated Corrected Curvature on a Surface Mesh Example +\subsection ICCExampleSM Interpolated Corrected Curvatures on a Surface Mesh Example The following example illustrates how to compute the curvatures on vertices @@ -932,7 +932,7 @@ and store them in property maps provided by the class `Surface_mesh`. \cgalExample{Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp} -\subsection ICCExamplePH Interpolated Corrected Curvature on a Polyhedron Example +\subsection ICCExamplePH Interpolated Corrected Curvatures on a Polyhedron Example The following example illustrates how to compute the curvatures on vertices @@ -941,7 +941,7 @@ not provide storage for the curvatures. \cgalExample{Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp} -\subsection ICCExamplePH Interpolated Corrected Curvature on a Vertex Example +\subsection ICCExampleSV Interpolated Corrected Curvatures on a Vertex Example The following example illustrates how to compute the curvatures on a specific vertex diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt index 0588d1c76e14..58af6e391b56 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt @@ -21,6 +21,7 @@ \example Polygon_mesh_processing/isotropic_remeshing_example.cpp \example Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp \example Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp +\example Polygon_mesh_processing/interpolated_corrected_gaussian_curvature_at_vertex.cpp \example Polygon_mesh_processing/delaunay_remeshing_example.cpp \example Polygon_mesh_processing/compute_normals_example_Polyhedron.cpp \example Polygon_mesh_processing/hausdorff_distance_remeshing_example.cpp From ca4e412e0e1d98c605ef6cc16eb448a43f66158f Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Tue, 24 Jan 2023 09:35:20 +0200 Subject: [PATCH 099/142] minor fix --- .../test/Polygon_mesh_processing/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt index c446a7395dee..8608e203c6eb 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt @@ -1,4 +1,4 @@ -0# Created by the script cgal_create_CMakeLists +# Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. cmake_minimum_required(VERSION 3.1...3.23) From da3db9a40674ac30071ec9e579412e1c2ba9a8a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 24 Jan 2023 09:58:35 +0100 Subject: [PATCH 100/142] typo --- .../test/Polygon_mesh_processing/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt index c446a7395dee..8608e203c6eb 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/CMakeLists.txt @@ -1,4 +1,4 @@ -0# Created by the script cgal_create_CMakeLists +# Created by the script cgal_create_CMakeLists # This is the CMake script for compiling a set of CGAL applications. cmake_minimum_required(VERSION 3.1...3.23) From 50ba18725ca32ab402357f13409bcee7f1e9fd79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 24 Jan 2023 11:10:29 +0100 Subject: [PATCH 101/142] fix typename usage --- ...nterpolated_corrected_curvature_measures.h | 26 +++++++++---------- ...test_interpolated_corrected_curvatures.cpp | 6 ++--- 2 files changed, 16 insertions(+), 16 deletions(-) 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 94aaff9b8b52..94520cf403dd 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 @@ -479,7 +479,7 @@ Principal_curvatures_and_directions principal_curvatures_and_directions_from } template -typename Vertex_measures interpolated_corrected_measures_one_vertex_no_radius( +Vertex_measures interpolated_corrected_measures_one_vertex_no_radius( const PolygonMesh pmesh, const typename boost::graph_traits::vertex_descriptor v, const bool is_mean_curvature_selected, @@ -498,7 +498,7 @@ typename Vertex_measures interpolated_corrected_measures_one_vertex_no_radiu std::queue bfs_queue; std::unordered_set bfs_visited; - typename Vertex_measures vertex_measures; + Vertex_measures vertex_measures; std::vector x; std::vector u; @@ -538,7 +538,7 @@ typename Vertex_measures interpolated_corrected_measures_one_vertex_no_radiu template -typename Vertex_measures interpolated_corrected_measures_one_vertex( +Vertex_measures interpolated_corrected_measures_one_vertex( const PolygonMesh pmesh, const typename boost::graph_traits::vertex_descriptor v, const typename GT::FT radius, @@ -558,10 +558,10 @@ typename Vertex_measures interpolated_corrected_measures_one_vertex( std::queue bfs_queue; std::unordered_set bfs_visited; - typename Vertex_measures vertex_measures; + Vertex_measures vertex_measures; - typename Point_3 vp = get(vpm, v); - typename Vector_3 c = Vector_3(vp.x(), vp.y(), vp.z()); + Point_3 vp = get(vpm, v); + Vector_3 c = Vector_3(vp.x(), vp.y(), vp.z()); for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { if (f != boost::graph_traits::null_face()) @@ -626,13 +626,13 @@ template::vertex_descriptor v, - NamedParameters& np = parameters::default_values() + const NamedParameters& np = parameters::default_values() ) { typedef typename GetGeomTraits::type GT; typedef typename GetVertexPointMap::const_type Vertex_position_map; - typedef dynamic_vertex_property_t Vector_map_tag; + typedef dynamic_vertex_property_t Vector_map_tag; typedef typename boost::property_map::const_type Default_vector_map; typedef typename internal_np::Lookup_named_param_def* vertex_principal_curvatures_and_directions = choose_parameter(get_parameter(np, internal_np::vertex_principal_curvatures_and_directions), nullptr); + Principal_curvatures_and_directions* vertex_principal_curvatures_and_directions = choose_parameter(get_parameter(np, internal_np::vertex_principal_curvatures_and_directions), nullptr); const bool is_mean_curvature_selected = (vertex_mean_curvature != nullptr); const bool is_gaussian_curvature_selected = (vertex_gaussian_curvature != nullptr); @@ -703,7 +703,7 @@ template principal_curvatures_and_directions = principal_curvatures_and_directions_from_anisotropic_measures( vertex_measures.anisotropic_measure, vertex_measures.area_measure, @@ -1046,7 +1046,7 @@ template void interpolated_corrected_mean_curvature(const PolygonMesh& pmesh, VertexCurvatureMap& vcm, - NamedParameters& np = parameters::default_values()) + const NamedParameters& np = parameters::default_values()) { interpolated_corrected_curvatures(pmesh, np.vertex_mean_curvature_map(vcm)); } @@ -1109,7 +1109,7 @@ template void interpolated_corrected_gaussian_curvature(const PolygonMesh& pmesh, VertexCurvatureMap& vcm, - NamedParameters& np = parameters::default_values()) + const NamedParameters& np = parameters::default_values()) { interpolated_corrected_curvatures(pmesh, np.vertex_gaussian_curvature_map(vcm)); } @@ -1173,7 +1173,7 @@ template void interpolated_corrected_principal_curvatures_and_directions(const PolygonMesh& pmesh, VertexCurvatureMap& vcm, - NamedParameters& np = parameters::default_values()) + const NamedParameters& np = parameters::default_values()) { interpolated_corrected_curvatures(pmesh, np.vertex_principal_curvatures_and_directions_map(vcm)); } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp index 163c9b8d334d..7f8aa1f7d691 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp @@ -63,12 +63,12 @@ void test_average_curvatures(std::string mesh_path, Average_test_info test_info) std::cerr << "Invalid input file." << std::endl; } - typedef boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; - boost::property_map>::type + typename boost::property_map>::type mean_curvature_map = get(CGAL::dynamic_vertex_property_t(), pmesh), gaussian_curvature_map = get(CGAL::dynamic_vertex_property_t(), pmesh); - boost::property_map>>::type + typename boost::property_map>>::type principal_curvatures_and_directions_map = get(CGAL::dynamic_vertex_property_t>(), pmesh); // test_info.expansion_radius -> test if no radius is provided by user. From 69610f6958dc51f31ede8a0e75c32e4f4c9a5c84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 24 Jan 2023 11:15:04 +0100 Subject: [PATCH 102/142] move function --- ...nterpolated_corrected_curvature_measures.h | 128 +++++++++--------- 1 file changed, 64 insertions(+), 64 deletions(-) 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 94520cf403dd..821436dc05f6 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 @@ -990,17 +990,15 @@ class Interpolated_corrected_curvatures_computer /** * \ingroup PMP_corrected_curvatures_grp * -* Computes the interpolated corrected mean curvature across the mesh -* and stores it in a vertex property map `vcm`. +* Computes the interpolated corrected curvatures across the mesh, based on the provided property maps. +* By providing mean, gaussian and/or principal curvature property maps as named parameters, the user +* can choose which curvatures to compute. * * @tparam PolygonMesh a model of `FaceListGraph`. -* @tparam VertexCurvatureMap model of `WritablePropertyMap` with -* `boost::graph_traits::%Vertex_descriptor` as key type and `GT::FT` as value type. * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". * * @param pmesh the polygon mesh. -* @param vcm the vertex property map in which the computed mean curvatures are stored. -* @param np an optional sequence of \ref bgl_namedparameters "Named Parameters". +* @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below * * \cgalNamedParamsBegin * @@ -1024,37 +1022,63 @@ class Interpolated_corrected_curvatures_computer * computed using compute_vertex_normals()} * \cgalParamNEnd * +* \cgalParamNBegin{vertex_mean_curvature_map} +* \cgalParamDescription{a property map associating mean curvatures to the vertices of `pmesh`} +* \cgalParamType{a class model of `WritablePropertyMap` with +* `boost::graph_traits::%Vertex_descriptor` +* as key type and `%FT` as value type} +* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} +* \cgalParamExtra{If this parameter is omitted, mean curvatures won't be computed} +* \cgalParamNEnd +* +* \cgalParamNBegin{vertex_gaussian_curvature_map} +* \cgalParamDescription{a property map associating mean curvatures to the vertices of `pmesh`} +* \cgalParamType{a class model of `WritablePropertyMap` with +* `boost::graph_traits::%Vertex_descriptor` +* as key type and `%FT` as value type} +* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} +* \cgalParamExtra{If this parameter is omitted, gaussian curvatures won't be computed} +* \cgalParamNEnd +* +* +* \cgalParamNBegin{vertex_principal_curvatures_and_directions_map} +* \cgalParamDescription{a property map associating mean curvatures to the vertices of `pmesh`} +* \cgalParamType{a class model of `WritablePropertyMap` with +* `boost::graph_traits::%Vertex_descriptor` +* as key type and `%Principal_curvatures_and_directions` as value type} +* \cgalParamDefault{`get(dynamic_vertex_property_t>(), pmesh)`} +* \cgalParamExtra{If this parameter is omitted, mean principal won't be computed} +* \cgalParamNEnd +* * \cgalParamNBegin{ball_radius} * \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures * by summing measures of faces inside a ball of this radius centered at the * vertex expanded from. The summed face measures are weighted by their -* inclusion ratio inside this ball} +* inclusion ratio inside this ball.} * \cgalParamType{`GT::FT`} * \cgalParamDefault{`-1`} -* \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of +* \cgalParamExtra{If this parameter is omitted (`-1`), the epansion is then just a sum of * measures on faces around the vertex} * \cgalParamNEnd * * \cgalNamedParamsEnd * +* @see `interpolated_corrected_mean_curvature()` * @see `interpolated_corrected_gaussian_curvature()` * @see `interpolated_corrected_principal_curvatures_and_directions()` -* @see `interpolated_corrected_curvatures()` */ - -template - void interpolated_corrected_mean_curvature(const PolygonMesh& pmesh, - VertexCurvatureMap& vcm, + void interpolated_corrected_curvatures(const PolygonMesh& pmesh, const NamedParameters& np = parameters::default_values()) { - interpolated_corrected_curvatures(pmesh, np.vertex_mean_curvature_map(vcm)); + internal::Interpolated_corrected_curvatures_computer(pmesh, np); } /** * \ingroup PMP_corrected_curvatures_grp * -* Computes the interpolated corrected gaussian curvature across the mesh +* Computes the interpolated corrected mean curvature across the mesh * and stores it in a vertex property map `vcm`. * * @tparam PolygonMesh a model of `FaceListGraph`. @@ -1063,7 +1087,7 @@ template - void interpolated_corrected_gaussian_curvature(const PolygonMesh& pmesh, + void interpolated_corrected_mean_curvature(const PolygonMesh& pmesh, VertexCurvatureMap& vcm, const NamedParameters& np = parameters::default_values()) { - interpolated_corrected_curvatures(pmesh, np.vertex_gaussian_curvature_map(vcm)); + interpolated_corrected_curvatures(pmesh, np.vertex_mean_curvature_map(vcm)); } /** * \ingroup PMP_corrected_curvatures_grp * -* Computes the interpolated corrected principal curvatures across the mesh +* Computes the interpolated corrected gaussian curvature across the mesh * and stores it in a vertex property map `vcm`. * * @tparam PolygonMesh a model of `FaceListGraph`. * @tparam VertexCurvatureMap model of `WritablePropertyMap` with -* `boost::graph_traits::%Vertex_descriptor` as key type and -* `std::tuple, Eigen::Vector>` as value type. +* `boost::graph_traits::%Vertex_descriptor` as key type and `GT::FT` as value type. * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". * * @param pmesh the polygon mesh. -* @param vcm the vertex property map in which the computed principal curvatures are stored. -* @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below +* @param vcm the vertex property map in which the computed gaussian curvatures are stored. +* @param np an optional sequence of \ref bgl_namedparameters "Named Parameters". * * \cgalNamedParamsBegin * @@ -1166,29 +1190,32 @@ template - void interpolated_corrected_principal_curvatures_and_directions(const PolygonMesh& pmesh, + void interpolated_corrected_gaussian_curvature(const PolygonMesh& pmesh, VertexCurvatureMap& vcm, const NamedParameters& np = parameters::default_values()) { - interpolated_corrected_curvatures(pmesh, np.vertex_principal_curvatures_and_directions_map(vcm)); + interpolated_corrected_curvatures(pmesh, np.vertex_gaussian_curvature_map(vcm)); } /** * \ingroup PMP_corrected_curvatures_grp * -* Computes the interpolated corrected curvatures across the mesh, based on the provided property maps. -* By providing mean, gaussian and/or principal curvature property maps as named parameters, the user -* can choose which curvatures to compute. +* Computes the interpolated corrected principal curvatures across the mesh +* and stores it in a vertex property map `vcm`. * * @tparam PolygonMesh a model of `FaceListGraph`. +* @tparam VertexCurvatureMap model of `WritablePropertyMap` with +* `boost::graph_traits::%Vertex_descriptor` as key type and +* `std::tuple, Eigen::Vector>` as value type. * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". * * @param pmesh the polygon mesh. +* @param vcm the vertex property map in which the computed principal curvatures are stored. * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below * * \cgalNamedParamsBegin @@ -1213,42 +1240,14 @@ template::%Vertex_descriptor` -* as key type and `%FT` as value type} -* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} -* \cgalParamExtra{If this parameter is omitted, mean curvatures won't be computed} -* \cgalParamNEnd -* -* \cgalParamNBegin{vertex_gaussian_curvature_map} -* \cgalParamDescription{a property map associating mean curvatures to the vertices of `pmesh`} -* \cgalParamType{a class model of `WritablePropertyMap` with -* `boost::graph_traits::%Vertex_descriptor` -* as key type and `%FT` as value type} -* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} -* \cgalParamExtra{If this parameter is omitted, gaussian curvatures won't be computed} -* \cgalParamNEnd -* -* -* \cgalParamNBegin{vertex_principal_curvatures_and_directions_map} -* \cgalParamDescription{a property map associating mean curvatures to the vertices of `pmesh`} -* \cgalParamType{a class model of `WritablePropertyMap` with -* `boost::graph_traits::%Vertex_descriptor` -* as key type and `%Principal_curvatures_and_directions` as value type} -* \cgalParamDefault{`get(dynamic_vertex_property_t>(), pmesh)`} -* \cgalParamExtra{If this parameter is omitted, mean principal won't be computed} -* \cgalParamNEnd -* * \cgalParamNBegin{ball_radius} * \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures * by summing measures of faces inside a ball of this radius centered at the * vertex expanded from. The summed face measures are weighted by their -* inclusion ratio inside this ball.} +* inclusion ratio inside this ball} * \cgalParamType{`GT::FT`} * \cgalParamDefault{`-1`} -* \cgalParamExtra{If this parameter is omitted (`-1`), the epansion is then just a sum of +* \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of * measures on faces around the vertex} * \cgalParamNEnd * @@ -1256,14 +1255,15 @@ template - void interpolated_corrected_curvatures(const PolygonMesh& pmesh, + void interpolated_corrected_principal_curvatures_and_directions(const PolygonMesh& pmesh, + VertexCurvatureMap& vcm, const NamedParameters& np = parameters::default_values()) { - internal::Interpolated_corrected_curvatures_computer(pmesh, np); + interpolated_corrected_curvatures(pmesh, np.vertex_principal_curvatures_and_directions_map(vcm)); } template Date: Tue, 24 Jan 2023 11:27:31 +0100 Subject: [PATCH 103/142] fix warning --- .../Interpolated_corrected_principal_curvatures_plugin.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp index 789ba4a06567..e5a01f7b3c3b 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp @@ -81,7 +81,7 @@ void compute(SMesh* sMesh, CGAL::parameters::ball_radius(0) ); - typename Epic_kernel::FT max_curvature_magnitude_on_mesh = 0; + double max_curvature_magnitude_on_mesh = 0; for (Vertex_descriptor v : vertices(*sMesh)) { const PMP::Principal_curvatures_and_directions pc = principal_curvatures_and_directions_map[v]; @@ -99,11 +99,9 @@ void compute(SMesh* sMesh, // compute min edge len around central vertex // to scale the ribbons used to display the directions - typedef EPICK::FT FT; - const std::size_t n = CGAL::edges(*sMesh).size(); - Epic_kernel::FT avg_edge_length = 0; + double avg_edge_length = 0; if (n > 0) { for (auto e : CGAL::edges(*sMesh)) avg_edge_length += PMP::edge_length(e, *sMesh); From 999b475e4ca5142589b239fb8418a7ff78254c56 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Tue, 24 Jan 2023 14:08:02 +0200 Subject: [PATCH 104/142] tests (incomplete) + minor typename fix still not passing single vertex on polyhedron due to a problem with vertex normal map --- ...nterpolated_corrected_curvature_measures.h | 10 ++-- ...test_interpolated_corrected_curvatures.cpp | 58 ++++++++++++++++--- 2 files changed, 55 insertions(+), 13 deletions(-) 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 847bac1f5c06..4cf352e32e48 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 @@ -399,8 +399,8 @@ std::array interpolated_corrected_anisotropic_measure_fa // const typename GT::FT R = r * r; // const typename GT::FT acc = 1.0 / res; // std::size_t samples_in = 0; -// for (GT::FT alpha = acc / 3; alpha < 1; alpha += acc) -// for (GT::FT beta = acc / 3; beta < 1 - alpha; beta += acc) +// for (typename GT::FT alpha = acc / 3; alpha < 1; alpha += acc) +// for (typename GT::FT beta = acc / 3; beta < 1 - alpha; beta += acc) // { // if ((alpha * x1 + beta * x2 + (1 - alpha - beta) * x3 - c).squared_length() < R) // samples_in++; @@ -632,7 +632,7 @@ template::type GT; typedef typename GetVertexPointMap::const_type Vertex_position_map; - typedef dynamic_vertex_property_t Vector_map_tag; + typedef dynamic_vertex_property_t Vector_map_tag; typedef typename boost::property_map::const_type Default_vector_map; typedef typename internal_np::Lookup_named_param_def(pmesh) * EXPANDING_RADIUS_EPSILON; - else - radius = radius; typename GT::FT* vertex_mean_curvature = choose_parameter(get_parameter(np, internal_np::vertex_mean_curvature), nullptr); typename GT::FT* vertex_gaussian_curvature = choose_parameter(get_parameter(np, internal_np::vertex_gaussian_curvature), nullptr); @@ -704,7 +702,7 @@ template principal_curvatures_and_directions = principal_curvatures_and_directions_from_anisotropic_measures( vertex_measures.anisotropic_measure, vertex_measures.area_measure, diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp index 163c9b8d334d..a6fa6f712680 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp @@ -54,7 +54,11 @@ bool passes_comparison(Epic_kernel::FT result, Epic_kernel::FT expected, Epic_ke } template -void test_average_curvatures(std::string mesh_path, Average_test_info test_info){ +void test_average_curvatures(std::string mesh_path, + Average_test_info test_info, + bool compare_single_vertex = false +){ + PolygonMesh pmesh; const std::string filename = CGAL::data_file_path(mesh_path); @@ -116,6 +120,7 @@ void test_average_curvatures(std::string mesh_path, Average_test_info test_info) assert(passes_comparison(gaussian_curvature_avg, test_info.gaussian_curvature_avg, test_info.tolerance)); assert(passes_comparison(principal_curvature_avg, test_info.principal_curvature_avg, test_info.tolerance)); + // computing curvatures together from interpolated_corrected_curvatures() PMP::interpolated_corrected_curvatures( pmesh, CGAL::parameters::ball_radius(test_info.expansion_radius) @@ -124,7 +129,6 @@ void test_average_curvatures(std::string mesh_path, Average_test_info test_info) .vertex_principal_curvatures_and_directions_map(principal_curvatures_and_directions_map) ); - // are average curvatures computed from interpolated_corrected_curvatures() equal to average curvatures each computed on its own? Epic_kernel::FT new_mean_curvature_avg = 0, new_gaussian_curvature_avg = 0, new_principal_curvature_avg = 0; for (vertex_descriptor v : vertices(pmesh)) @@ -138,22 +142,62 @@ void test_average_curvatures(std::string mesh_path, Average_test_info test_info) new_mean_curvature_avg /= vertices(pmesh).size(); new_gaussian_curvature_avg /= vertices(pmesh).size(); new_principal_curvature_avg /= vertices(pmesh).size() * 2; - + + // are average curvatures computed from interpolated_corrected_curvatures() + // equal to average curvatures each computed on its own? assert(passes_comparison(mean_curvature_avg, new_mean_curvature_avg, 0.99)); assert(passes_comparison(gaussian_curvature_avg, new_gaussian_curvature_avg, 0.99)); assert(passes_comparison(principal_curvature_avg, new_principal_curvature_avg, 0.99)); + + if (compare_single_vertex) + { + // computing curvatures together from interpolated_corrected_curvatures() + + Epic_kernel::FT single_vertex_mean_curvature_avg = 0, + single_vertex_gaussian_curvature_avg = 0, + single_vertex_principal_curvature_avg = 0; + + Epic_kernel::FT h, g; + PMP::Principal_curvatures_and_directions p; + + for (vertex_descriptor v : vertices(pmesh)) + { + PMP::interpolated_corrected_curvatures_at_vertex( + pmesh, + v, + CGAL::parameters::vertex_gaussian_curvature(&g) + .vertex_mean_curvature(&h) + .vertex_principal_curvatures_and_directions(&p) + ); + + single_vertex_mean_curvature_avg += h; + single_vertex_gaussian_curvature_avg += g; + single_vertex_principal_curvature_avg += p.min_curvature + p.max_curvature; + } + + single_vertex_mean_curvature_avg /= vertices(pmesh).size(); + single_vertex_gaussian_curvature_avg /= vertices(pmesh).size(); + single_vertex_principal_curvature_avg /= vertices(pmesh).size() * 2; + + assert(passes_comparison(mean_curvature_avg, single_vertex_mean_curvature_avg, 0.99)); + assert(passes_comparison(gaussian_curvature_avg, single_vertex_gaussian_curvature_avg, 0.99)); + assert(passes_comparison(principal_curvature_avg, single_vertex_principal_curvature_avg, 0.99)); + } + } int main() { // testing on a simple sphere(r = 0.5), on both Polyhedron & SurfaceMesh: + // For this mesh, ina addition to the whole mesh functions, we also compare against the single vertex + // curvature functions to make sure the produce the same results // Expected: Mean Curvature = 2, Gaussian Curvature = 4, Principal Curvatures = 2 & 2 so 2 on avg. - test_average_curvatures("meshes/sphere.off", Average_test_info(2,4,2)); - test_average_curvatures("meshes/sphere.off", Average_test_info(2, 4, 2)); + test_average_curvatures("meshes/sphere.off", Average_test_info(2,4,2), true); + test_average_curvatures("meshes/sphere.off", Average_test_info(2, 4, 2), true); // Same mesh but with specified expansion radii of 0 and 0.25 (half radius of sphere) - test_average_curvatures("meshes/sphere.off", Average_test_info(2, 4, 2, 0)); - test_average_curvatures("meshes/sphere.off", Average_test_info(2, 4, 2, 0.25)); + test_average_curvatures("meshes/sphere.off", Average_test_info(2, 4, 2, 0), true); + test_average_curvatures("meshes/sphere.off", Average_test_info(2, 4, 2, 0.25), true); // testing on a simple sphere(r = 10), on both Polyhedron & SurfaceMesh: // Expected: Mean Curvature = 0.1, Gaussian Curvature = 0.01, Principal Curvatures = 0.1 & 0.1 so 0.1 on avg. From 7303c7401e476d85784715ab3c28e05a8ca3eb8a Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Tue, 24 Jan 2023 14:42:39 +0200 Subject: [PATCH 105/142] move function + minor func doc fix --- ...nterpolated_corrected_curvature_measures.h | 155 +++++++++--------- 1 file changed, 78 insertions(+), 77 deletions(-) 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 078fcaeb48e3..2ae9a6856e38 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 @@ -1210,7 +1210,7 @@ template::%Vertex_descriptor` as key type and -* `std::tuple, Eigen::Vector>` as value type. +* `%Principal_curvatures_and_directions` as value type. * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". * * @param pmesh the polygon mesh. @@ -1265,16 +1265,20 @@ template*`} + * \cgalParamDefault{`nullptr`} + * \cgalParamExtra{If this parameter is omitted, principal curvatures and directions won't be computed} + * \cgalParamNEnd + * * \cgalParamNBegin{ball_radius} * \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures * by summing measures of faces inside a ball of this radius centered at the * vertex expanded from. The summed face measures are weighted by their - * inclusion ratio inside this ball} + * inclusion ratio inside this ball.} * \cgalParamType{`GT::FT`} * \cgalParamDefault{`-1`} - * \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of + * \cgalParamExtra{If this parameter is omitted (`-1`), the epansion is then just a sum of * measures on faces around the vertex} * \cgalParamNEnd * * \cgalNamedParamsEnd * - * @return the interpolated corrected mean curvature at the vertex `v` - * - * @see `interpolated_corrected_mean_curvature()` - * @see `interpolated_corrected_gaussian_curvature_at_vertex()` - * @see `interpolated_corrected_principal_curvatures_and_directions_at_vertex()` - * @see `interpolated_corrected_curvatures_at_vertex()` + * @see `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures()` + * @see `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature_at_vertex()` + * @see `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature_at_vertex()` + * @see `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions_at_vertex()` */ - -template - typename GT::FT interpolated_corrected_mean_curvature_at_vertex(const PolygonMesh& pmesh, + void interpolated_corrected_curvatures_at_vertex(const PolygonMesh& pmesh, typename boost::graph_traits::vertex_descriptor v, const NamedParameters& np = parameters::default_values()) { - // use interpolated_corrected_curvatures_at_vertex to compute mean curvature - typename GT::FT mean_curvature; - interpolated_corrected_curvatures_at_vertex(pmesh, v, np.vertex_mean_curvature(&mean_curvature)); - return mean_curvature; + internal::interpolated_corrected_curvatures_one_vertex(pmesh, v, np); } /** * \ingroup PMP_corrected_curvatures_grp - * computes the interpolated corrected Gaussian curvature at a vertex of a triangle mesh. + * computes the interpolated corrected mean curvature at a vertex of a triangle mesh. * * @tparam GT a geometric traits class that provides the nested type `FT`, * @tparam PolygonMesh a model of `FaceListGraph` * @tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" * * @param pmesh the polygon mesh - * @param v the vertex of `pmesh` to compute the Gaussian curvature at + * @param v the vertex of `pmesh` to compute the mean curvature at * @param np optional sequence of \ref pmp_namedparameters "Named Parameters" among the ones listed below * * \cgalNamedParamsBegin @@ -1377,36 +1396,36 @@ template - typename GT::FT interpolated_corrected_gaussian_curvature_at_vertex(const PolygonMesh& pmesh, + typename GT::FT interpolated_corrected_mean_curvature_at_vertex(const PolygonMesh& pmesh, typename boost::graph_traits::vertex_descriptor v, const NamedParameters& np = parameters::default_values()) { - // use interpolated_corrected_curvatures_at_vertex to compute gaussian curvature - typename GT::FT gc; - interpolated_corrected_curvatures_at_vertex(pmesh, v, np.vertex_gaussian_curvature(&gc)); - return gc; + // use interpolated_corrected_curvatures_at_vertex to compute mean curvature + typename GT::FT mean_curvature; + interpolated_corrected_curvatures_at_vertex(pmesh, v, np.vertex_mean_curvature(&mean_curvature)); + return mean_curvature; } /** * \ingroup PMP_corrected_curvatures_grp - * computes the interpolated corrected principal curvatures and directions at a vertex of a triangle mesh. + * computes the interpolated corrected Gaussian curvature at a vertex of a triangle mesh. * - * @tparam GT the geometric traits class, + * @tparam GT a geometric traits class that provides the nested type `FT`, * @tparam PolygonMesh a model of `FaceListGraph` * @tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" * * @param pmesh the polygon mesh - * @param v the vertex of `pmesh` to compute the principal curvatures and directions at + * @param v the vertex of `pmesh` to compute the Gaussian curvature at * @param np optional sequence of \ref pmp_namedparameters "Named Parameters" among the ones listed below * * \cgalNamedParamsBegin @@ -1440,41 +1459,39 @@ template - Principal_curvatures_and_directions interpolated_corrected_principal_curvatures_and_directions_at_vertex(const PolygonMesh& pmesh, + typename GT::FT interpolated_corrected_gaussian_curvature_at_vertex(const PolygonMesh& pmesh, typename boost::graph_traits::vertex_descriptor v, const NamedParameters& np = parameters::default_values()) { - // use interpolated_corrected_curvatures_at_vertex to compute principal curvatures - Principal_curvatures_and_directions pcd; - interpolated_corrected_curvatures_at_vertex(pmesh, v, np.vertex_principal_curvatures_and_directions(&pcd)); - return pcd; + // use interpolated_corrected_curvatures_at_vertex to compute gaussian curvature + typename GT::FT gc; + interpolated_corrected_curvatures_at_vertex(pmesh, v, np.vertex_gaussian_curvature(&gc)); + return gc; } /** * \ingroup PMP_corrected_curvatures_grp - * Computes the interpolated corrected curvatures at a certain vertex, based on the provided pointers. - * By providing mean, gaussian and/or principal curvature pointers as named parameters, the user - * can choose which curvatures to compute. - * The pointers are used to store the computed curvatures. - * The user is responsible for the memory management of the pointers. + * computes the interpolated corrected principal curvatures and directions at a vertex of a triangle mesh. * + * @tparam GT the geometric traits class, * @tparam PolygonMesh a model of `FaceListGraph` * @tparam NamedParameters a sequence of \ref pmp_namedparameters "Named Parameters" * * @param pmesh the polygon mesh - * @param v the vertex of `pmesh` to compute the curvatures at + * @param v the vertex of `pmesh` to compute the principal curvatures and directions at * @param np optional sequence of \ref pmp_namedparameters "Named Parameters" among the ones listed below * * \cgalNamedParamsBegin @@ -1498,52 +1515,36 @@ template*`} - * \cgalParamDefault{`nullptr`} - * \cgalParamExtra{If this parameter is omitted, principal curvatures and directions won't be computed} - * \cgalParamNEnd - * * \cgalParamNBegin{ball_radius} * \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures * by summing measures of faces inside a ball of this radius centered at the * vertex expanded from. The summed face measures are weighted by their - * inclusion ratio inside this ball.} + * inclusion ratio inside this ball} * \cgalParamType{`GT::FT`} * \cgalParamDefault{`-1`} - * \cgalParamExtra{If this parameter is omitted (`-1`), the epansion is then just a sum of + * \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of * measures on faces around the vertex} * \cgalParamNEnd - * * \cgalNamedParamsEnd * - * @see `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures()` - * @see `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature_at_vertex()` - * @see `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature_at_vertex()` - * @see `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions_at_vertex()` + * @return the interpolated corrected principal curvatures and directions at the vertex `v` + * + * @see `interpolated_corrected_principal_curvatures_and_directions()` + * @see `interpolated_corrected_mean_curvature_at_vertex()` + * @see `interpolated_corrected_gaussian_curvature_at_vertex()` + * @see `interpolated_corrected_curvatures_at_vertex()` */ -template - void interpolated_corrected_curvatures_at_vertex(const PolygonMesh& pmesh, + Principal_curvatures_and_directions interpolated_corrected_principal_curvatures_and_directions_at_vertex(const PolygonMesh& pmesh, typename boost::graph_traits::vertex_descriptor v, const NamedParameters& np = parameters::default_values()) { - internal::interpolated_corrected_curvatures_one_vertex(pmesh, v, np); + // use interpolated_corrected_curvatures_at_vertex to compute principal curvatures + Principal_curvatures_and_directions pcd; + interpolated_corrected_curvatures_at_vertex(pmesh, v, np.vertex_principal_curvatures_and_directions(&pcd)); + return pcd; } } // namespace Polygon_mesh_processing From f9c21faf02f7296a6285909dffa9c3758599e564 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Tue, 24 Jan 2023 15:11:58 +0200 Subject: [PATCH 106/142] trailling white spaces --- .../test_interpolated_corrected_curvatures.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp index cd71fbb20f34..367d3c7045d1 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp @@ -54,7 +54,7 @@ bool passes_comparison(Epic_kernel::FT result, Epic_kernel::FT expected, Epic_ke } template -void test_average_curvatures(std::string mesh_path, +void test_average_curvatures(std::string mesh_path, Average_test_info test_info, bool compare_single_vertex = false ){ @@ -142,8 +142,8 @@ void test_average_curvatures(std::string mesh_path, new_mean_curvature_avg /= vertices(pmesh).size(); new_gaussian_curvature_avg /= vertices(pmesh).size(); new_principal_curvature_avg /= vertices(pmesh).size() * 2; - - // are average curvatures computed from interpolated_corrected_curvatures() + + // are average curvatures computed from interpolated_corrected_curvatures() // equal to average curvatures each computed on its own? assert(passes_comparison(mean_curvature_avg, new_mean_curvature_avg, 0.99)); assert(passes_comparison(gaussian_curvature_avg, new_gaussian_curvature_avg, 0.99)); @@ -156,15 +156,15 @@ void test_average_curvatures(std::string mesh_path, Epic_kernel::FT single_vertex_mean_curvature_avg = 0, single_vertex_gaussian_curvature_avg = 0, single_vertex_principal_curvature_avg = 0; - + Epic_kernel::FT h, g; PMP::Principal_curvatures_and_directions p; - + for (vertex_descriptor v : vertices(pmesh)) { PMP::interpolated_corrected_curvatures_at_vertex( pmesh, - v, + v, CGAL::parameters::vertex_gaussian_curvature(&g) .vertex_mean_curvature(&h) .vertex_principal_curvatures_and_directions(&p) @@ -189,8 +189,8 @@ void test_average_curvatures(std::string mesh_path, int main() { // testing on a simple sphere(r = 0.5), on both Polyhedron & SurfaceMesh: - // For this mesh, ina addition to the whole mesh functions, we also compare against the single vertex - // curvature functions to make sure the produce the same results + // For this mesh, ina addition to the whole mesh functions, we also compare against the single vertex + // curvature functions to make sure the produce the same results // Expected: Mean Curvature = 2, Gaussian Curvature = 4, Principal Curvatures = 2 & 2 so 2 on avg. test_average_curvatures("meshes/sphere.off", Average_test_info(2,4,2), true); test_average_curvatures("meshes/sphere.off", Average_test_info(2, 4, 2), true); From 92e22644357462fd3b13af386d4795284999639e Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Tue, 24 Jan 2023 17:58:03 +0200 Subject: [PATCH 107/142] Update test_interpolated_corrected_curvatures.cpp --- .../test_interpolated_corrected_curvatures.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp index 367d3c7045d1..12ab2bff3872 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp @@ -168,6 +168,7 @@ void test_average_curvatures(std::string mesh_path, CGAL::parameters::vertex_gaussian_curvature(&g) .vertex_mean_curvature(&h) .vertex_principal_curvatures_and_directions(&p) + .ball_radius(test_info.expansion_radius) ); single_vertex_mean_curvature_avg += h; From 6f2f912c4d03e5a418d37c2f9b1de7c0d4de4a5a Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Tue, 24 Jan 2023 18:41:25 +0200 Subject: [PATCH 108/142] minor fix --- .../Curvatures/interpolated_corrected_curvature_measures.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 2ae9a6856e38..32287848fb31 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 @@ -480,7 +480,7 @@ Principal_curvatures_and_directions principal_curvatures_and_directions_from template Vertex_measures interpolated_corrected_measures_one_vertex_no_radius( - const PolygonMesh pmesh, + const PolygonMesh& pmesh, const typename boost::graph_traits::vertex_descriptor v, const bool is_mean_curvature_selected, const bool is_gaussian_curvature_selected, @@ -539,7 +539,7 @@ Vertex_measures interpolated_corrected_measures_one_vertex_no_radius( template Vertex_measures interpolated_corrected_measures_one_vertex( - const PolygonMesh pmesh, + const PolygonMesh& pmesh, const typename boost::graph_traits::vertex_descriptor v, const typename GT::FT radius, const bool is_mean_curvature_selected, @@ -624,7 +624,7 @@ Vertex_measures interpolated_corrected_measures_one_vertex( template void interpolated_corrected_curvatures_one_vertex( - const PolygonMesh pmesh, + const PolygonMesh& pmesh, const typename boost::graph_traits::vertex_descriptor v, const NamedParameters& np = parameters::default_values() ) From 1294548acc0444ec23145fe29d3e428baa515f8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 24 Jan 2023 17:58:27 +0100 Subject: [PATCH 109/142] avoid macro substitution --- .../test_interpolated_corrected_curvatures.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp index 12ab2bff3872..2aa963fea52b 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp @@ -50,7 +50,7 @@ bool passes_comparison(Epic_kernel::FT result, Epic_kernel::FT expected, Epic_ke else if (abs(expected) < ABS_ERROR) return false; // expected 0, got non-0 - return std::min(result, expected) / std::max(result, expected) > tolerance; + return (std::min)(result, expected) / (std::max)(result, expected) > tolerance; } template From 00cf0970e56f8eafdbb74afe728e8b7e8bcf3c3e Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Thu, 26 Jan 2023 12:04:51 +0200 Subject: [PATCH 110/142] changed the mesh file used in examples --- ...corrected_curvatures_at_vertex_example.cpp | 3 +- ...erpolated_corrected_curvatures_example.cpp | 3 +- ...orrected_curvatures_polyhedron_example.cpp | 35 ++++++++++--------- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_at_vertex_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_at_vertex_example.cpp index 009c5881f262..046f9101d1e6 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_at_vertex_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_at_vertex_example.cpp @@ -12,7 +12,6 @@ namespace PMP = CGAL::Polygon_mesh_processing; typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic_kernel; typedef Epic_kernel::FT FT; typedef CGAL::Surface_mesh Surface_Mesh; -typedef boost::graph_traits::face_descriptor face_descriptor; typedef boost::graph_traits::vertex_descriptor vertex_descriptor; int main(int argc, char* argv[]) @@ -21,7 +20,7 @@ int main(int argc, char* argv[]) Surface_Mesh smesh; const std::string filename = (argc > 1) ? argv[1] : - CGAL::data_file_path("meshes/small_bunny.obj"); + CGAL::data_file_path("meshes/sphere.off"); if (!CGAL::IO::read_polygon_mesh(filename, smesh)) { diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp index 511288702336..6a991bafdfb8 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp @@ -12,7 +12,6 @@ namespace PMP = CGAL::Polygon_mesh_processing; typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic_kernel; typedef CGAL::Surface_mesh Surface_Mesh; -typedef boost::graph_traits::face_descriptor face_descriptor; typedef boost::graph_traits::vertex_descriptor vertex_descriptor; int main(int argc, char* argv[]) @@ -20,7 +19,7 @@ int main(int argc, char* argv[]) Surface_Mesh smesh; const std::string filename = (argc > 1) ? argv[1] : - CGAL::data_file_path("meshes/small_bunny.obj"); + CGAL::data_file_path("meshes/sphere.off"); if (!CGAL::IO::read_polygon_mesh(filename, smesh)) { diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp index 6bbe49ce37e5..0d1ffcfa35d1 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp @@ -13,13 +13,14 @@ namespace PMP = CGAL::Polygon_mesh_processing; typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic_kernel; typedef CGAL::Polyhedron_3 Polyhedron; -typedef boost::graph_traits::face_descriptor face_descriptor; typedef boost::graph_traits::vertex_descriptor vertex_descriptor; -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { Polyhedron polyhedron; - const std::string filename = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/small_bunny.obj"); + const std::string filename = (argc > 1) ? + argv[1] : + CGAL::data_file_path("meshes/sphere.off"); if (!CGAL::IO::read_polygon_mesh(filename, polyhedron)) { @@ -28,22 +29,22 @@ int main(int argc, char *argv[]) } boost::property_map>::type - mean_curvature_map = get(CGAL::dynamic_vertex_property_t(), polyhedron), - gaussian_curvature_map = get(CGAL::dynamic_vertex_property_t(), polyhedron); + mean_curvature_map = get(CGAL::dynamic_vertex_property_t(), polyhedron), + gaussian_curvature_map = get(CGAL::dynamic_vertex_property_t(), polyhedron); boost::property_map>>::type - principal_curvatures_and_directions_map = get(CGAL::dynamic_vertex_property_t>(), polyhedron); + principal_curvatures_and_directions_map = get(CGAL::dynamic_vertex_property_t>(), polyhedron); PMP::interpolated_corrected_mean_curvature( - polyhedron, - mean_curvature_map); + polyhedron, + mean_curvature_map); PMP::interpolated_corrected_gaussian_curvature( - polyhedron, - gaussian_curvature_map); + polyhedron, + gaussian_curvature_map); PMP::interpolated_corrected_principal_curvatures_and_directions( - polyhedron, - principal_curvatures_and_directions_map); + polyhedron, + principal_curvatures_and_directions_map); // uncomment this to compute a curvature while specifying named parameters // Example: an expansion ball radius of 0.5 and a vertex normals map (does not have to depend on positions) @@ -59,17 +60,17 @@ int main(int argc, char *argv[]) // This function can be used to compute multiple curvature types by specifiying them as named parameters // This is more efficient than computing each one separately (shared computations). PMP::interpolated_corrected_curvatures( - polyhedron, - CGAL::parameters::vertex_mean_curvature_map(mean_curvature_map) - .vertex_principal_curvatures_and_directions_map(principal_curvatures_and_directions_map)); + polyhedron, + CGAL::parameters::vertex_mean_curvature_map(mean_curvature_map) + .vertex_principal_curvatures_and_directions_map(principal_curvatures_and_directions_map)); int i = 0; for (vertex_descriptor v : vertices(polyhedron)) { auto PC = get(principal_curvatures_and_directions_map, v); std::cout << i << ": HC = " << get(mean_curvature_map, v) - << ", GC = " << get(gaussian_curvature_map, v) << "\n" - << ", PC = [ " << PC.min_curvature << " , " << PC.max_curvature << " ]\n"; + << ", GC = " << get(gaussian_curvature_map, v) << "\n" + << ", PC = [ " << PC.min_curvature << " , " << PC.max_curvature << " ]\n"; i++; } } From 8d2043d0aab934e3d97cd2de8be8f112638fc94b Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sat, 28 Jan 2023 15:54:35 +0200 Subject: [PATCH 111/142] renaming mostly to pass the max path error --- .../PackageDescription.txt | 8 ++-- .../Polygon_mesh_processing.txt | 14 +++--- .../doc/Polygon_mesh_processing/examples.txt | 6 +-- .../Polygon_mesh_processing/CMakeLists.txt | 12 ++--- ...lated_corrected_curvatures_example_PH.cpp} | 0 ...lated_corrected_curvatures_example_SM.cpp} | 0 ...d_corrected_curvatures_vertex_example.cpp} | 12 ++--- ...nterpolated_corrected_curvature_measures.h | 44 +++++++++---------- ...test_interpolated_corrected_curvatures.cpp | 2 +- 9 files changed, 49 insertions(+), 49 deletions(-) rename Polygon_mesh_processing/examples/Polygon_mesh_processing/{interpolated_corrected_curvatures_polyhedron_example.cpp => interpolated_corrected_curvatures_example_PH.cpp} (100%) rename Polygon_mesh_processing/examples/Polygon_mesh_processing/{interpolated_corrected_curvatures_example.cpp => interpolated_corrected_curvatures_example_SM.cpp} (100%) rename Polygon_mesh_processing/examples/Polygon_mesh_processing/{interpolated_corrected_curvatures_at_vertex_example.cpp => interpolated_corrected_curvatures_vertex_example.cpp} (83%) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt index d5790ec725ee..52ae8934ddf2 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt @@ -212,10 +212,10 @@ The page \ref bgl_namedparameters "Named Parameters" describes their usage. - `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures()` -- `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature_at_vertex()` -- `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature_at_vertex()` -- `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions_at_vertex()` -- `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures_at_vertex()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature_one_vertex()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature_one_vertex()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions_one_vertex()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures_one_vertex()` - `CGAL::Polygon_mesh_processing::Principal_curvatures_and_directions` \cgalCRPSection{Normal Computation Functions} diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index fedebf4b8f8a..751db0992492 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -909,10 +909,10 @@ Where it is recommended to use the last function for computing multiple curvatur as the implementation performs the shared computations only once, making it more efficient. Similarly, we can use the following functions to compute curvatures on a specific vertex: -- `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature_at_vertex()` -- `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature_at_vertex()` -- `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions_at_vertex()` -- `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures_at_vertex()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature_one_vertex()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature_one_vertex()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions_one_vertex()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures_one_vertex()` \cgalFigureRef{icc_diff_radius} shows how the mean curvature changes depending on @@ -940,7 +940,7 @@ The following example illustrates how to compute the curvatures on vertices and store them in property maps provided by the class `Surface_mesh`. -\cgalExample{Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp} +\cgalExample{Polygon_mesh_processing/interpolated_corrected_curvatures_example_SM.cpp} \subsection ICCExamplePH Interpolated Corrected Curvatures on a Polyhedron Example @@ -949,14 +949,14 @@ compute the curvatures on vertices and store them in dynamic property maps as the class `Polyhedron_3` does not provide storage for the curvatures. -\cgalExample{Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp} +\cgalExample{Polygon_mesh_processing/interpolated_corrected_curvatures_example_PH.cpp} \subsection ICCExampleSV Interpolated Corrected Curvatures on a Vertex Example The following example illustrates how to compute the curvatures on a specific vertex -\cgalExample{Polygon_mesh_processing/interpolated_corrected_curvatures_at_vertex_example.cpp} +\cgalExample{Polygon_mesh_processing/interpolated_corrected_curvatures_vertex_example.cpp} **************************************** \section PMPSlicer Slicer diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt index 58af6e391b56..33e68eea8091 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt @@ -19,9 +19,9 @@ \example Polygon_mesh_processing/refine_fair_example.cpp \example Polygon_mesh_processing/mesh_slicer_example.cpp \example Polygon_mesh_processing/isotropic_remeshing_example.cpp -\example Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp -\example Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp -\example Polygon_mesh_processing/interpolated_corrected_gaussian_curvature_at_vertex.cpp +\example Polygon_mesh_processing/interpolated_corrected_curvatures_example_SM.cpp +\example Polygon_mesh_processing/interpolated_corrected_curvatures_example_PH.cpp +\example Polygon_mesh_processing/interpolated_corrected_curvatures_vertex_example.cpp \example Polygon_mesh_processing/delaunay_remeshing_example.cpp \example Polygon_mesh_processing/compute_normals_example_Polyhedron.cpp \example Polygon_mesh_processing/hausdorff_distance_remeshing_example.cpp diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt index 5e840c38a508..93e321e837c8 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt @@ -105,12 +105,12 @@ create_single_source_cgal_program("cc_compatible_orientations.cpp") if(TARGET CGAL::Eigen3_support) - create_single_source_cgal_program("interpolated_corrected_curvatures_example.cpp") - target_link_libraries(interpolated_corrected_curvatures_example PUBLIC CGAL::Eigen3_support) - create_single_source_cgal_program("interpolated_corrected_curvatures_polyhedron_example.cpp") - target_link_libraries(interpolated_corrected_curvatures_polyhedron_example PUBLIC CGAL::Eigen3_support) - create_single_source_cgal_program("interpolated_corrected_curvatures_at_vertex_example.cpp") - target_link_libraries(interpolated_corrected_curvatures_at_vertex_example PUBLIC CGAL::Eigen3_support) + create_single_source_cgal_program("interpolated_corrected_curvatures_example_SM.cpp") + target_link_libraries(interpolated_corrected_curvatures_example_SM PUBLIC CGAL::Eigen3_support) + create_single_source_cgal_program("interpolated_corrected_curvatures_example_PH.cpp") + target_link_libraries(interpolated_corrected_curvatures_example_PH PUBLIC CGAL::Eigen3_support) + create_single_source_cgal_program("interpolated_corrected_curvatures_vertex_example.cpp") + target_link_libraries(interpolated_corrected_curvatures_vertex_example PUBLIC CGAL::Eigen3_support) endif() diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example_PH.cpp similarity index 100% rename from Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_polyhedron_example.cpp rename to Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example_PH.cpp diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example_SM.cpp similarity index 100% rename from Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example.cpp rename to Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example_SM.cpp diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_at_vertex_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_vertex_example.cpp similarity index 83% rename from Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_at_vertex_example.cpp rename to Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_vertex_example.cpp index 046f9101d1e6..a897066facb6 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_at_vertex_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_vertex_example.cpp @@ -31,21 +31,21 @@ int main(int argc, char* argv[]) // loop over vertices and use vertex_descriptor to compute a curvature on one vertex for (vertex_descriptor v : vertices(smesh)) { - FT h = PMP::interpolated_corrected_mean_curvature_at_vertex(smesh, v); - FT g = PMP::interpolated_corrected_gaussian_curvature_at_vertex(smesh, v); + FT h = PMP::interpolated_corrected_mean_curvature_one_vertex(smesh, v); + FT g = PMP::interpolated_corrected_gaussian_curvature_one_vertex(smesh, v); PMP::Principal_curvatures_and_directions p = - PMP::interpolated_corrected_principal_curvatures_and_directions_at_vertex(smesh, v); + PMP::interpolated_corrected_principal_curvatures_and_directions_one_vertex(smesh, v); // we can also specify a ball radius for expansion and a user defined vertex normals map using - // named parameters. Refer to interpolated_corrected_curvatures_example.cpp to see example usage. + // named parameters. Refer to interpolated_corrected_curvatures_example_SM.cpp to see example usage. - // Can also use interpolated_corrected_curvatures_at_vertex() to compute multiple curvatures + // Can also use interpolated_corrected_curvatures_one_vertex() to compute multiple curvatures // on the vertex at the same time. This is more efficient than computing each one separately. // The following commented lines show this (all mentioned named parameters work on it as well) // we specify which curvatures we want to compute by passing pointers as named parameters // as shown. These pointers are used for storing the result as well. in this example we // selected mean and gaussian curvatures - // PMP::interpolated_corrected_curvatures_at_vertex( + // PMP::interpolated_corrected_curvatures_one_vertex( // smesh, // v, // CGAL::parameters::vertex_mean_curvature(&h) 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 32287848fb31..2142e57fd194 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 @@ -1337,13 +1337,13 @@ template - void interpolated_corrected_curvatures_at_vertex(const PolygonMesh& pmesh, + void interpolated_corrected_curvatures_one_vertex(const PolygonMesh& pmesh, typename boost::graph_traits::vertex_descriptor v, const NamedParameters& np = parameters::default_values()) { @@ -1399,20 +1399,20 @@ template - typename GT::FT interpolated_corrected_mean_curvature_at_vertex(const PolygonMesh& pmesh, + typename GT::FT interpolated_corrected_mean_curvature_one_vertex(const PolygonMesh& pmesh, typename boost::graph_traits::vertex_descriptor v, const NamedParameters& np = parameters::default_values()) { - // use interpolated_corrected_curvatures_at_vertex to compute mean curvature + // use interpolated_corrected_curvatures_one_vertex to compute mean curvature typename GT::FT mean_curvature; - interpolated_corrected_curvatures_at_vertex(pmesh, v, np.vertex_mean_curvature(&mean_curvature)); + interpolated_corrected_curvatures_one_vertex(pmesh, v, np.vertex_mean_curvature(&mean_curvature)); return mean_curvature; } @@ -1465,20 +1465,20 @@ template - typename GT::FT interpolated_corrected_gaussian_curvature_at_vertex(const PolygonMesh& pmesh, + typename GT::FT interpolated_corrected_gaussian_curvature_one_vertex(const PolygonMesh& pmesh, typename boost::graph_traits::vertex_descriptor v, const NamedParameters& np = parameters::default_values()) { - // use interpolated_corrected_curvatures_at_vertex to compute gaussian curvature + // use interpolated_corrected_curvatures_one_vertex to compute gaussian curvature typename GT::FT gc; - interpolated_corrected_curvatures_at_vertex(pmesh, v, np.vertex_gaussian_curvature(&gc)); + interpolated_corrected_curvatures_one_vertex(pmesh, v, np.vertex_gaussian_curvature(&gc)); return gc; } @@ -1530,20 +1530,20 @@ template - Principal_curvatures_and_directions interpolated_corrected_principal_curvatures_and_directions_at_vertex(const PolygonMesh& pmesh, + Principal_curvatures_and_directions interpolated_corrected_principal_curvatures_and_directions_one_vertex(const PolygonMesh& pmesh, typename boost::graph_traits::vertex_descriptor v, const NamedParameters& np = parameters::default_values()) { - // use interpolated_corrected_curvatures_at_vertex to compute principal curvatures + // use interpolated_corrected_curvatures_one_vertex to compute principal curvatures Principal_curvatures_and_directions pcd; - interpolated_corrected_curvatures_at_vertex(pmesh, v, np.vertex_principal_curvatures_and_directions(&pcd)); + interpolated_corrected_curvatures_one_vertex(pmesh, v, np.vertex_principal_curvatures_and_directions(&pcd)); return pcd; } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp index 2aa963fea52b..37fc6f050df4 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp @@ -162,7 +162,7 @@ void test_average_curvatures(std::string mesh_path, for (vertex_descriptor v : vertices(pmesh)) { - PMP::interpolated_corrected_curvatures_at_vertex( + PMP::interpolated_corrected_curvatures_one_vertex( pmesh, v, CGAL::parameters::vertex_gaussian_curvature(&g) From 4e669b79a73682b97aca64b9e04ef46edbf56143 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sun, 29 Jan 2023 06:26:16 +0200 Subject: [PATCH 112/142] conversion warnings --- ...interpolated_corrected_curvature_measures.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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 2142e57fd194..cfe3b79b6e19 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 @@ -89,7 +89,7 @@ typename GT::FT average_edge_length(const PolygonMesh& pmesh) { for (auto e : edges(pmesh)) avg_edge_length += edge_length(e, pmesh); - avg_edge_length /= n; + avg_edge_length /= static_cast(n); return avg_edge_length; } @@ -145,7 +145,7 @@ typename GT::FT interpolated_corrected_area_measure_face(const std::vector(n); // getting unit average normal of points typename GT::Vector_3 uc = @@ -211,7 +211,7 @@ typename GT::FT interpolated_corrected_mean_curvature_measure_face(const std::ve // getting center of points typename GT::Vector_3 xc = std::accumulate(x.begin(), x.end(), typename GT::Vector_3(0, 0, 0)); - xc /= n; + xc /= static_cast(n); // getting unit average normal of points typename GT::Vector_3 uc = @@ -297,7 +297,7 @@ std::array interpolated_corrected_anisotropic_measure_fa const typename GT::Vector_3 x02 = x[2] - x[0]; const typename GT::Vector_3 um = (u[0] + u[1] + u[2]) / 3.0; - for (std::size_t ix = 0; ix < 3; ix++) + for (unsigned int ix = 0; ix < 3; ix++) { typename GT::Vector_3 X; if (ix == 0) @@ -307,7 +307,7 @@ std::array interpolated_corrected_anisotropic_measure_fa if (ix == 2) X = typename GT::Vector_3(0, 0, 1); - for (std::size_t iy = 0; iy < 3; iy++) + for (unsigned int iy = 0; iy < 3; iy++) muXY[ix * 3 + iy] = 0.5 * um * (cross_product(u02[iy] * X, x01) - cross_product(u01[iy] * X, x02)); } } @@ -316,7 +316,7 @@ std::array interpolated_corrected_anisotropic_measure_fa { // for the formulas below, values of verices 2 & 3 are swapped (compared to paper) to correct order. // the indices in paper vs in here are: 00 = 0, 10 = 1, 11 = 2, 01 = 3 - for (std::size_t ix = 0; ix < 3; ix++) + for (unsigned int ix = 0; ix < 3; ix++) { typename GT::Vector_3 X; if (ix == 0) @@ -331,7 +331,7 @@ std::array interpolated_corrected_anisotropic_measure_fa const typename GT::Vector_3 u2xX = cross_product(u[2], X); const typename GT::Vector_3 u3xX = cross_product(u[3], X); - for (std::size_t iy = 0; iy < 3; iy++) + for (unsigned int iy = 0; iy < 3; iy++) muXY[ix * 3 + iy] = (1.0 / 72.0) * ( u[0][iy] * (u0xX * (-x[0] - 11 * x[1] + 13 * x[3] - x[2]) @@ -364,7 +364,7 @@ std::array interpolated_corrected_anisotropic_measure_fa // getting center of points typename GT::Vector_3 xc = std::accumulate(x.begin(), x.end(), typename GT::Vector_3(0, 0, 0)); - xc /= n; + xc /= static_cast(n); // getting unit average normal of points typename GT::Vector_3 uc = @@ -418,7 +418,7 @@ typename GT::FT face_in_ball_ratio(const std::vector& x, // getting center of points typename GT::Vector_3 xm = std::accumulate(x.begin(), x.end(), typename GT::Vector_3(0, 0, 0)); - xm /= n; + xm /= static_cast(n); typename GT::FT d_min = (xm - c).squared_length(); typename GT::FT d_max = d_min; From 2ccabc92899980c65ce17ff9e165905af3d2e6c0 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sun, 29 Jan 2023 09:39:39 +0200 Subject: [PATCH 113/142] renaming files --- ....h => interpolated_corrected_curvatures.h} | 20 +++++++++---------- .../include/CGAL/license/gpl_package_list.txt | 2 +- ...olated_corrected_curvatures_example_PH.cpp | 2 +- ...olated_corrected_curvatures_example_SM.cpp | 2 +- ...ed_corrected_curvatures_vertex_example.cpp | 2 +- ....h => interpolated_corrected_curvatures.h} | 8 ++++---- ...test_interpolated_corrected_curvatures.cpp | 2 +- .../Display/Display_property_plugin.cpp | 2 +- ..._corrected_principal_curvatures_plugin.cpp | 2 +- 9 files changed, 21 insertions(+), 21 deletions(-) rename Installation/include/CGAL/license/Polygon_mesh_processing/{interpolated_corrected_curvature_measures.h => interpolated_corrected_curvatures.h} (83%) rename Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/{Curvatures/interpolated_corrected_curvature_measures.h => interpolated_corrected_curvatures.h} (99%) 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_curvatures.h similarity index 83% rename from Installation/include/CGAL/license/Polygon_mesh_processing/interpolated_corrected_curvature_measures.h rename to Installation/include/CGAL/license/Polygon_mesh_processing/interpolated_corrected_curvatures.h index 15e2a79af8a9..e484daaf5eae 100644 --- a/Installation/include/CGAL/license/Polygon_mesh_processing/interpolated_corrected_curvature_measures.h +++ b/Installation/include/CGAL/license/Polygon_mesh_processing/interpolated_corrected_curvatures.h @@ -11,15 +11,15 @@ // // 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 +#ifndef CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURES_H +#define CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURES_H #include #include -#ifdef CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURE_MEASURES_COMMERCIAL_LICENSE +#ifdef CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURES_COMMERCIAL_LICENSE -# if CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURE_MEASURES_COMMERCIAL_LICENSE < CGAL_RELEASE_DATE +# if CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURES_COMMERCIAL_LICENSE < CGAL_RELEASE_DATE # if defined(CGAL_LICENSE_WARNING) @@ -33,22 +33,22 @@ 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 +# endif // CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURES_COMMERCIAL_LICENSE < CGAL_RELEASE_DATE -#else // no CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURE_MEASURES_COMMERCIAL_LICENSE +#else // no CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURES_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." + CGAL_pragma_warning("\nThe macro CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURES_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.\ +# error "The macro CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURES_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 // no CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURES_COMMERCIAL_LICENSE -#endif // CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURE_MEASURES_H +#endif // CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURES_H diff --git a/Installation/include/CGAL/license/gpl_package_list.txt b/Installation/include/CGAL/license/gpl_package_list.txt index c6ac0b619df0..14d68b5d9a6a 100644 --- a/Installation/include/CGAL/license/gpl_package_list.txt +++ b/Installation/include/CGAL/license/gpl_package_list.txt @@ -51,7 +51,7 @@ Polygon_mesh_processing/connected_components Polygon Mesh Processing - Connected Polygon_mesh_processing/corefinement Polygon Mesh Processing - Corefinement Polygon_mesh_processing/core Polygon Mesh Processing - Core Polygon_mesh_processing/distance Polygon Mesh Processing - Distance -Polygon_mesh_processing/Curvatures/interpolated_corrected_curvature_measures Polygon Mesh Processing - Interpolated Corrected Curvatures +Polygon_mesh_processing/interpolated_corrected_curvatures Polygon Mesh Processing - Interpolated Corrected Curvatures Polygon_mesh_processing/measure Polygon Mesh Processing - Geometric Measure Polygon_mesh_processing/meshing_hole_filling Polygon Mesh Processing - Meshing and Hole Filling Polygon_mesh_processing/orientation Polygon Mesh Processing - Orientation diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example_PH.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example_PH.cpp index 0d1ffcfa35d1..3cf675c53ca4 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example_PH.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example_PH.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example_SM.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example_SM.cpp index 6a991bafdfb8..d92ec7b8096d 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example_SM.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example_SM.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_vertex_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_vertex_example.cpp index a897066facb6..beb2eda31c04 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_vertex_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_vertex_example.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include 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/interpolated_corrected_curvatures.h similarity index 99% rename from Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/Curvatures/interpolated_corrected_curvature_measures.h rename to Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h index cfe3b79b6e19..7f0bbc8197ce 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/interpolated_corrected_curvatures.h @@ -11,10 +11,10 @@ // Author(s) : Hossam Saeed // -#ifndef CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURE_MEASURES_H -#define CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURE_MEASURES_H +#ifndef CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURES_H +#define CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURES_H -#include +#include #include #include @@ -1550,4 +1550,4 @@ template -#include +#include #include #include #include diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index 67a2061fc5e8..f515c7c12e08 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include "Scene_points_with_normal_item.h" diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp index e5a01f7b3c3b..8bb6a229967b 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Interpolated_corrected_principal_curvatures_plugin.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include using namespace CGAL::Three; class Polyhedron_demo_interpolated_corrected_principal_curvatures_and_directions_plugin : From eef0f5fd80cf703486b1f72b862898f45c266d00 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Tue, 31 Jan 2023 11:23:46 +0200 Subject: [PATCH 114/142] removed unused parameter --- .../interpolated_corrected_curvatures.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h index 7f0bbc8197ce..a71fdf164449 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h @@ -27,7 +27,6 @@ #include #include #include -#include #define EXPANDING_RADIUS_EPSILON 1e-6 @@ -231,8 +230,7 @@ typename GT::FT interpolated_corrected_mean_curvature_measure_face(const std::ve } template -typename GT::FT interpolated_corrected_gaussian_curvature_measure_face(const std::vector& u, - const std::vector& x = {}) +typename GT::FT interpolated_corrected_gaussian_curvature_measure_face(const std::vector& u) { const std::size_t n = u.size(); CGAL_precondition(n >= 3); From 4f4eeea292f09dc7e7a84c55787346f2ec51a607 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Tue, 31 Jan 2023 11:55:15 +0200 Subject: [PATCH 115/142] removing _example suffix (renaming) --- .../Polygon_mesh_processing.txt | 6 +++--- .../doc/Polygon_mesh_processing/examples.txt | 6 +++--- .../examples/Polygon_mesh_processing/CMakeLists.txt | 12 ++++++------ ....cpp => interpolated_corrected_curvatures_PH.cpp} | 0 ....cpp => interpolated_corrected_curvatures_SM.cpp} | 0 ... => interpolated_corrected_curvatures_vertex.cpp} | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) rename Polygon_mesh_processing/examples/Polygon_mesh_processing/{interpolated_corrected_curvatures_example_PH.cpp => interpolated_corrected_curvatures_PH.cpp} (100%) rename Polygon_mesh_processing/examples/Polygon_mesh_processing/{interpolated_corrected_curvatures_example_SM.cpp => interpolated_corrected_curvatures_SM.cpp} (100%) rename Polygon_mesh_processing/examples/Polygon_mesh_processing/{interpolated_corrected_curvatures_vertex_example.cpp => interpolated_corrected_curvatures_vertex.cpp} (98%) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index 751db0992492..1da140d96791 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -940,7 +940,7 @@ The following example illustrates how to compute the curvatures on vertices and store them in property maps provided by the class `Surface_mesh`. -\cgalExample{Polygon_mesh_processing/interpolated_corrected_curvatures_example_SM.cpp} +\cgalExample{Polygon_mesh_processing/interpolated_corrected_curvatures_SM.cpp} \subsection ICCExamplePH Interpolated Corrected Curvatures on a Polyhedron Example @@ -949,14 +949,14 @@ compute the curvatures on vertices and store them in dynamic property maps as the class `Polyhedron_3` does not provide storage for the curvatures. -\cgalExample{Polygon_mesh_processing/interpolated_corrected_curvatures_example_PH.cpp} +\cgalExample{Polygon_mesh_processing/interpolated_corrected_curvatures_PH.cpp} \subsection ICCExampleSV Interpolated Corrected Curvatures on a Vertex Example The following example illustrates how to compute the curvatures on a specific vertex -\cgalExample{Polygon_mesh_processing/interpolated_corrected_curvatures_vertex_example.cpp} +\cgalExample{Polygon_mesh_processing/interpolated_corrected_curvatures_vertex.cpp} **************************************** \section PMPSlicer Slicer diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt index 33e68eea8091..3a5620d82424 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/examples.txt @@ -19,9 +19,9 @@ \example Polygon_mesh_processing/refine_fair_example.cpp \example Polygon_mesh_processing/mesh_slicer_example.cpp \example Polygon_mesh_processing/isotropic_remeshing_example.cpp -\example Polygon_mesh_processing/interpolated_corrected_curvatures_example_SM.cpp -\example Polygon_mesh_processing/interpolated_corrected_curvatures_example_PH.cpp -\example Polygon_mesh_processing/interpolated_corrected_curvatures_vertex_example.cpp +\example Polygon_mesh_processing/interpolated_corrected_curvatures_SM.cpp +\example Polygon_mesh_processing/interpolated_corrected_curvatures_PH.cpp +\example Polygon_mesh_processing/interpolated_corrected_curvatures_vertex.cpp \example Polygon_mesh_processing/delaunay_remeshing_example.cpp \example Polygon_mesh_processing/compute_normals_example_Polyhedron.cpp \example Polygon_mesh_processing/hausdorff_distance_remeshing_example.cpp diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt index 93e321e837c8..19a3aaf5313d 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt @@ -105,12 +105,12 @@ create_single_source_cgal_program("cc_compatible_orientations.cpp") if(TARGET CGAL::Eigen3_support) - create_single_source_cgal_program("interpolated_corrected_curvatures_example_SM.cpp") - target_link_libraries(interpolated_corrected_curvatures_example_SM PUBLIC CGAL::Eigen3_support) - create_single_source_cgal_program("interpolated_corrected_curvatures_example_PH.cpp") - target_link_libraries(interpolated_corrected_curvatures_example_PH PUBLIC CGAL::Eigen3_support) - create_single_source_cgal_program("interpolated_corrected_curvatures_vertex_example.cpp") - target_link_libraries(interpolated_corrected_curvatures_vertex_example PUBLIC CGAL::Eigen3_support) + create_single_source_cgal_program("interpolated_corrected_curvatures_SM.cpp") + target_link_libraries(interpolated_corrected_curvatures_SM PUBLIC CGAL::Eigen3_support) + create_single_source_cgal_program("interpolated_corrected_curvatures_PH.cpp") + target_link_libraries(interpolated_corrected_curvatures_PH PUBLIC CGAL::Eigen3_support) + create_single_source_cgal_program("interpolated_corrected_curvatures_vertex.cpp") + target_link_libraries(interpolated_corrected_curvatures_vertex PUBLIC CGAL::Eigen3_support) endif() diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example_PH.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_PH.cpp similarity index 100% rename from Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example_PH.cpp rename to Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_PH.cpp diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example_SM.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_SM.cpp similarity index 100% rename from Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_example_SM.cpp rename to Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_SM.cpp diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_vertex_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_vertex.cpp similarity index 98% rename from Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_vertex_example.cpp rename to Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_vertex.cpp index beb2eda31c04..47fbcfd68711 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_vertex_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_vertex.cpp @@ -37,7 +37,7 @@ int main(int argc, char* argv[]) PMP::interpolated_corrected_principal_curvatures_and_directions_one_vertex(smesh, v); // we can also specify a ball radius for expansion and a user defined vertex normals map using - // named parameters. Refer to interpolated_corrected_curvatures_example_SM.cpp to see example usage. + // named parameters. Refer to interpolated_corrected_curvatures_SM.cpp to see example usage. // Can also use interpolated_corrected_curvatures_one_vertex() to compute multiple curvatures // on the vertex at the same time. This is more efficient than computing each one separately. From bd5d9df950ea845efa3b6bdf926a1b548c8c4ffd Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Tue, 31 Jan 2023 11:57:00 +0200 Subject: [PATCH 116/142] fix some functions were passing x to interpolated_corrected_gaussian_curvature_measure_face() when it was not needed (and causes a compilation error for 1 vertex) --- .../interpolated_corrected_curvatures.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h index a71fdf164449..3c7c647e8a6b 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h @@ -518,7 +518,7 @@ Vertex_measures interpolated_corrected_measures_one_vertex_no_radius( vertex_measures.mean_curvature_measure += interpolated_corrected_mean_curvature_measure_face(u, x); if (is_gaussian_curvature_selected) - vertex_measures.gaussian_curvature_measure += interpolated_corrected_gaussian_curvature_measure_face(u, x); + vertex_measures.gaussian_curvature_measure += interpolated_corrected_gaussian_curvature_measure_face(u); if (is_principal_curvatures_and_directions_selected) { @@ -594,7 +594,7 @@ Vertex_measures interpolated_corrected_measures_one_vertex( vertex_measures.mean_curvature_measure += f_ratio * interpolated_corrected_mean_curvature_measure_face(u, x); if (is_gaussian_curvature_selected) - vertex_measures.gaussian_curvature_measure += f_ratio * interpolated_corrected_gaussian_curvature_measure_face(u, x); + vertex_measures.gaussian_curvature_measure += f_ratio * interpolated_corrected_gaussian_curvature_measure_face(u); if (is_principal_curvatures_and_directions_selected) { From 6a7e7d267ebf9be9eedd306ce311b7c0d5c7dc2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 31 Jan 2023 11:56:48 +0100 Subject: [PATCH 117/142] fix link --- .../interpolated_corrected_curvatures.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h index 3c7c647e8a6b..88110842b67d 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h @@ -1273,11 +1273,11 @@ template Date: Tue, 31 Jan 2023 12:06:10 +0100 Subject: [PATCH 118/142] remove unused variable --- .../demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index f515c7c12e08..c4c7d6a3c916 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -839,7 +839,7 @@ private Q_SLOTS: } - double outMin = 0, outMax = 5 * maxEdgeLength, base = 1.2; + double outMax = 5 * maxEdgeLength, base = 1.2; expand_radius = (pow(base, val) - 1) * outMax / (pow(base, sliderMax) - 1); dock_widget->expandingRadiusLabel->setText(tr("Expanding Radius : %1").arg(expand_radius)); From e71fcd899a44a07a53d65fbdf976d6224141fd0c Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Thu, 2 Feb 2023 02:15:34 +0200 Subject: [PATCH 119/142] removed unused enum --- .../interpolated_corrected_curvatures.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h index 88110842b67d..7adc37f0b4a2 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h @@ -92,12 +92,6 @@ typename GT::FT average_edge_length(const PolygonMesh& pmesh) { return avg_edge_length; } -enum Curvature_measure_index { - MU0_AREA_MEASURE, ///< corrected area density - MU1_MEAN_CURVATURE_MEASURE, ///< corrected mean curvature density - MU2_GAUSSIAN_CURVATURE_MEASURE ///< corrected gaussian curvature density -}; - template struct Vertex_measures { typename GT::FT area_measure = 0; From fcbc89b50314db6f17508bcc8a63046c18c910fc Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Thu, 2 Feb 2023 12:07:20 +0200 Subject: [PATCH 120/142] added comments for clarity --- .../interpolated_corrected_curvatures.h | 63 +++++++++++++++---- 1 file changed, 52 insertions(+), 11 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h index 7adc37f0b4a2..952a7e749ecf 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h @@ -118,7 +118,7 @@ typename GT::FT interpolated_corrected_area_measure_face(const std::vector interpolated_corrected_anisotropic_measure_fa muXY[ix * 3 + iy] = 0.5 * um * (cross_product(u02[iy] * X, x01) - cross_product(u01[iy] * X, x02)); } } - // Quad: use bilinear interpolation formula + // Quad: use the bilinear interpolation formula else if (n == 4) { // for the formulas below, values of verices 2 & 3 are swapped (compared to paper) to correct order. @@ -412,6 +412,7 @@ typename GT::FT face_in_ball_ratio(const std::vector& x, std::accumulate(x.begin(), x.end(), typename GT::Vector_3(0, 0, 0)); xm /= static_cast(n); + // computing squared distance of furthest and closest point to ball center typename GT::FT d_min = (xm - c).squared_length(); typename GT::FT d_max = d_min; @@ -422,12 +423,14 @@ typename GT::FT face_in_ball_ratio(const std::vector& x, d_min = (std::min)(d_sq, d_min); } + // if the furthest point is inside ball, return 1 if (d_max <= r * r) return 1.0; + // if the closest point is outside ball, return 0 else if (r * r <= d_min) return 0.0; + // else, approximate inclusion ratio of the triangle: d_max = sqrt(d_max); d_min = sqrt(d_min); - return (r - d_min) / (d_max - d_min); } @@ -438,17 +441,22 @@ Principal_curvatures_and_directions principal_curvatures_and_directions_from const typename GT::Vector_3 u_GT ) { + // putting anisotropic measure in matrix form Eigen::Matrix v_muXY = Eigen::Matrix::Zero(); for (std::size_t ix = 0; ix < 3; ix++) for (std::size_t iy = 0; iy < 3; iy++) v_muXY(ix, iy) = anisotropic_measure[ix * 3 + iy]; + // constant factor K to force the principal direction eigenvectors to be tangential to the surface Eigen::Matrix u(u_GT.x(), u_GT.y(), u_GT.z()); const typename GT::FT K = 1000 * v_mu0; + // symmetrizing and adding the constant term v_muXY = 0.5 * (v_muXY + v_muXY.transpose()) + K * u * u.transpose(); + + // computing eigenvalues and eigenvectors Eigen::SelfAdjointEigenSolver> eigensolver; eigensolver.computeDirect(v_muXY); @@ -462,6 +470,7 @@ Principal_curvatures_and_directions principal_curvatures_and_directions_from const typename GT::Vector_3 min_eig_vec(eig_vecs(0, 1), eig_vecs(1, 1), eig_vecs(2, 1)); const typename GT::Vector_3 max_eig_vec(eig_vecs(0, 0), eig_vecs(1, 0), eig_vecs(2, 0)); + // returning principal curvatures and directions (with the correct sign) return Principal_curvatures_and_directions( (v_mu0 != 0.0) ? -eig_vals[1] / v_mu0 : 0.0, (v_mu0 != 0.0) ? -eig_vals[0] / v_mu0 : 0.0, @@ -470,6 +479,7 @@ Principal_curvatures_and_directions principal_curvatures_and_directions_from ); } +// measures are computed for faces only if they are adjacent to the vertex template Vertex_measures interpolated_corrected_measures_one_vertex_no_radius( const PolygonMesh& pmesh, @@ -495,9 +505,11 @@ Vertex_measures interpolated_corrected_measures_one_vertex_no_radius( std::vector x; std::vector u; + // compute for each face around the vertex (except the null (boundary) face) for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { if (f != boost::graph_traits::null_face()) { + // looping over vertices in face to get point coordinates and normal vectors for (Vertex_descriptor vi : vertices_around_face(halfedge(f, pmesh), pmesh)) { Point_3 pi = get(vpm, vi); @@ -506,6 +518,7 @@ Vertex_measures interpolated_corrected_measures_one_vertex_no_radius( u.push_back(ui); } + // compute measures for selected curvatures (area is always computed) vertex_measures.area_measure += interpolated_corrected_area_measure_face(u, x); if (is_mean_curvature_selected) @@ -528,7 +541,7 @@ Vertex_measures interpolated_corrected_measures_one_vertex_no_radius( return vertex_measures; } - +// measures are computed for faces only if they are in the ball of radius 'radius' centered at the vertex template Vertex_measures interpolated_corrected_measures_one_vertex( const PolygonMesh& pmesh, @@ -547,6 +560,7 @@ Vertex_measures interpolated_corrected_measures_one_vertex( typedef typename GT::Vector_3 Vector_3; typedef typename GT::FT FT; + // the ball expansion is done using a BFS traversal from the vertex std::queue bfs_queue; std::unordered_set bfs_visited; @@ -568,8 +582,7 @@ Vertex_measures interpolated_corrected_measures_one_vertex( Face_descriptor fi = bfs_queue.front(); bfs_queue.pop(); - // looping over vertices in face to get point coordinates - + // looping over vertices in face to get point coordinates and normal vectors for (Vertex_descriptor vi : vertices_around_face(halfedge(fi, pmesh), pmesh)) { Point_3 pi = get(vpm, vi); @@ -578,8 +591,11 @@ Vertex_measures interpolated_corrected_measures_one_vertex( u.push_back(ui); } + // approximate inclusion ratio of the face in the ball const FT f_ratio = face_in_ball_ratio(x, radius, c); + // if it is not 0 (not completely outside), compute measures for selected curvatures (area is always computed) + // and add neighboring faces to the bfs queue if (f_ratio != 0.0) { vertex_measures.area_measure += f_ratio * interpolated_corrected_area_measure_face(u, x); @@ -613,6 +629,7 @@ Vertex_measures interpolated_corrected_measures_one_vertex( return vertex_measures; } +// computes selected curvatures for one specific vertex template void interpolated_corrected_curvatures_one_vertex( @@ -640,23 +657,29 @@ template::value) compute_vertex_normals(pmesh, vnm, np); + // if no radius is given, we pass -1 which will make the expansion be only on the incident faces instead of a ball typename GT::FT radius = choose_parameter(get_parameter(np, internal_np::ball_radius), -1); + // if the radius is 0, we use a small epsilon to expand the ball (scaled with the average edge length) if (radius == 0) radius = average_edge_length(pmesh) * EXPANDING_RADIUS_EPSILON; + // get parameters (pointers) for curvatures typename GT::FT* vertex_mean_curvature = choose_parameter(get_parameter(np, internal_np::vertex_mean_curvature), nullptr); typename GT::FT* vertex_gaussian_curvature = choose_parameter(get_parameter(np, internal_np::vertex_gaussian_curvature), nullptr); Principal_curvatures_and_directions* vertex_principal_curvatures_and_directions = choose_parameter(get_parameter(np, internal_np::vertex_principal_curvatures_and_directions), nullptr); + // determine which curvatures are selected (by checking if the pointers are not null) const bool is_mean_curvature_selected = (vertex_mean_curvature != nullptr); const bool is_gaussian_curvature_selected = (vertex_gaussian_curvature != nullptr); const bool is_principal_curvatures_and_directions_selected = (vertex_principal_curvatures_and_directions != nullptr); Vertex_measures vertex_measures; + // if the radius is negative, we do not expand the ball (only the incident faces) if (radius < 0) { vertex_measures = interpolated_corrected_measures_one_vertex_no_radius( @@ -683,6 +706,7 @@ template principal_curvatures_and_directions = principal_curvatures_and_directions_from_anisotropic_measures( vertex_measures.anisotropic_measure, @@ -783,11 +808,14 @@ class Interpolated_corrected_curvatures_computer vnm = choose_parameter(get_parameter(np, internal_np::vertex_normal_map), get(Vector_map_tag(), pmesh)); + // if no normal map is given, compute normals if (is_default_parameter::value) compute_vertex_normals(pmesh, vnm, np); + // if no radius is given, we pass -1 which will make the expansion be only on the incident faces instead of a ball const FT radius = choose_parameter(get_parameter(np, internal_np::ball_radius), -1); + // check which curvature maps are provided by the user (determines which curvatures are computed) is_mean_curvature_selected = !is_default_parameter::value; is_gaussian_curvature_selected = !is_default_parameter::value; is_principal_curvatures_and_directions_selected = !is_default_parameter::value; @@ -800,6 +828,7 @@ class Interpolated_corrected_curvatures_computer } void set_ball_radius(const FT radius) { + // if given radius is 0, we use a small epsilon to expand the ball (scaled by the average edge length) if (radius == 0) ball_radius = average_edge_length(pmesh) * EXPANDING_RADIUS_EPSILON; else @@ -825,6 +854,8 @@ class Interpolated_corrected_curvatures_computer private: + // Computes the (selected) interpolated corrected measures for all faces + // and stores them in the property maps void interpolated_corrected_selected_measures_all_faces() { std::vector x; @@ -854,14 +885,17 @@ class Interpolated_corrected_curvatures_computer } } + // expand the measures of the faces incident to v Vertex_measures expand_interpolated_corrected_measure_vertex_no_radius(Vertex_descriptor v) { Vertex_measures vertex_measures; + // add the measures of the faces incident to v (excluding the null (boundary) face) for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { if (f == boost::graph_traits::null_face()) continue; + // only add the measures for the selected curvatures (area measure is always added) vertex_measures.area_measure += get(mu0_map, f); if (is_mean_curvature_selected) @@ -881,8 +915,10 @@ class Interpolated_corrected_curvatures_computer return vertex_measures; } + // expand the measures of the faces inside the ball of radius r around v Vertex_measures expand_interpolated_corrected_measure_vertex(Vertex_descriptor v) { + // the ball expansion is done using a BFS traversal from the vertex std::queue bfs_queue; std::unordered_set bfs_visited; @@ -891,6 +927,7 @@ class Interpolated_corrected_curvatures_computer Vertex_measures vertex_measures; + // add the measures of the faces incident to v (excluding the null (boundary) face) for (Face_descriptor f : faces_around_target(halfedge(v, pmesh), pmesh)) { if (f != boost::graph_traits::null_face()) { @@ -910,8 +947,11 @@ class Interpolated_corrected_curvatures_computer x.push_back(Vector_3(pi.x(), pi.y(), pi.z())); } + // compute the inclusion ratio of the face in the ball const FT f_ratio = face_in_ball_ratio(x, ball_radius, c); + // if the face is inside the ball, add the measures + // only add the measures for the selected curvatures (area measure is always added) if (f_ratio != 0.0) { vertex_measures.area_measure += f_ratio * get(mu0_map, fi); @@ -947,10 +987,13 @@ class Interpolated_corrected_curvatures_computer for (Vertex_descriptor v : vertices(pmesh)) { + // expand the computed measures (on faces) to the vertices Vertex_measures vertex_measures = (ball_radius < 0) ? expand_interpolated_corrected_measure_vertex_no_radius(v) : expand_interpolated_corrected_measure_vertex(v); + // compute the selected curvatures from the expanded measures and store them in the property maps + // if the area measure is zero, the curvature is set to zero if (is_mean_curvature_selected) { vertex_measures.area_measure != 0 ? put(mean_curvature_map, v, 0.5 * vertex_measures.mean_curvature_measure / vertex_measures.area_measure) : @@ -964,6 +1007,7 @@ class Interpolated_corrected_curvatures_computer } if (is_principal_curvatures_and_directions_selected) { + // compute the principal curvatures and directions from the anisotropic measure const Vector_3 v_normal = get(vnm, v); const Principal_curvatures_and_directions principal_curvatures_and_directions = principal_curvatures_and_directions_from_anisotropic_measures( vertex_measures.anisotropic_measure, @@ -1402,7 +1446,6 @@ template::vertex_descriptor v, const NamedParameters& np = parameters::default_values()) { - // use interpolated_corrected_curvatures_one_vertex to compute mean curvature typename GT::FT mean_curvature; interpolated_corrected_curvatures_one_vertex(pmesh, v, np.vertex_mean_curvature(&mean_curvature)); return mean_curvature; @@ -1468,7 +1511,6 @@ template::vertex_descriptor v, const NamedParameters& np = parameters::default_values()) { - // use interpolated_corrected_curvatures_one_vertex to compute gaussian curvature typename GT::FT gc; interpolated_corrected_curvatures_one_vertex(pmesh, v, np.vertex_gaussian_curvature(&gc)); return gc; @@ -1533,7 +1575,6 @@ template::vertex_descriptor v, const NamedParameters& np = parameters::default_values()) { - // use interpolated_corrected_curvatures_one_vertex to compute principal curvatures Principal_curvatures_and_directions pcd; interpolated_corrected_curvatures_one_vertex(pmesh, v, np.vertex_principal_curvatures_and_directions(&pcd)); return pcd; From ec4312695a5136411b53ae572f9445fd7e385983 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Thu, 2 Feb 2023 12:23:50 +0200 Subject: [PATCH 121/142] remove unused var + minor change --- .../interpolated_corrected_curvatures.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h index 952a7e749ecf..b298f8cf495f 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h @@ -497,9 +497,6 @@ Vertex_measures interpolated_corrected_measures_one_vertex_no_radius( typedef typename GT::Vector_3 Vector_3; typedef typename GT::FT FT; - std::queue bfs_queue; - std::unordered_set bfs_visited; - Vertex_measures vertex_measures; std::vector x; @@ -814,6 +811,7 @@ class Interpolated_corrected_curvatures_computer // if no radius is given, we pass -1 which will make the expansion be only on the incident faces instead of a ball const FT radius = choose_parameter(get_parameter(np, internal_np::ball_radius), -1); + set_ball_radius(radius); // check which curvature maps are provided by the user (determines which curvatures are computed) is_mean_curvature_selected = !is_default_parameter::value; @@ -823,8 +821,6 @@ class Interpolated_corrected_curvatures_computer mean_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_mean_curvature_map), Default_scalar_map()); gaussian_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_gaussian_curvature_map), Default_scalar_map()); principal_curvatures_and_directions_map = choose_parameter(get_parameter(np, internal_np::vertex_principal_curvatures_and_directions_map), Default_principal_map()); - - set_ball_radius(radius); } void set_ball_radius(const FT radius) { From 19fd037731d50f20e703c6dddc9997441bad9d06 Mon Sep 17 00:00:00 2001 From: David Coeurjolly Date: Mon, 20 Feb 2023 11:20:07 +0100 Subject: [PATCH 122/142] Minor API doc edits --- .../interpolated_corrected_curvatures.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h index b298f8cf495f..ea01b0fe4c34 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h @@ -1022,8 +1022,8 @@ class Interpolated_corrected_curvatures_computer * \ingroup PMP_corrected_curvatures_grp * * Computes the interpolated corrected curvatures across the mesh, based on the provided property maps. -* By providing mean, gaussian and/or principal curvature property maps as named parameters, the user -* can choose which curvatures to compute. +* By providing mean, gaussian and/or principal curvature and direction property maps as named parameters, the user +* can choose which quantites to compute. * * @tparam PolygonMesh a model of `FaceListGraph`. * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". @@ -1039,7 +1039,7 @@ class Interpolated_corrected_curvatures_computer * `boost::graph_traits::%Vertex_descriptor` * as key type and `%Point_3` as value type} * \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`} -* \cgalParamExtra{If this parameter is omitted, an internal property map for +* \cgalParamExtra{If this parameter is omitted, an internal property map forBy * `CGAL::vertex_point_t` must be available in `PolygonMesh`.} * \cgalParamNEnd * @@ -1301,9 +1301,10 @@ template Date: Wed, 22 Mar 2023 18:13:27 +0100 Subject: [PATCH 123/142] first pass on the API --- .../Polygon_mesh_processing.txt | 2 +- ...terpolated_corrected_curvatures_vertex.cpp | 7 +- .../interpolated_corrected_curvatures.h | 695 ++++++++++-------- 3 files changed, 386 insertions(+), 318 deletions(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index 1da140d96791..2eb85a80bfbb 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -1166,7 +1166,7 @@ is covered by a set of prisms, where each prism is an offset for an input triang That is, the implementation in \cgal does not use indirect predicates. The interpolated corrected curvatures were implemented during GSoC 2022. This was implemented by Hossam Saeed and under -supervision of Sebastien Loriot, Jaques-Olivier Lachaud and David Coeurjolly. The implementation is based on \cgalCite{lachaud2020}. +supervision of David Coeurjolly, Jaques-Olivier Lachaud, and Sébastien Loriot. The implementation is based on \cgalCite{lachaud2020}. DGtal's implementation was also used as a reference during the project. diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_vertex.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_vertex.cpp index 47fbcfd68711..e5845a1b3a5a 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_vertex.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_vertex.cpp @@ -10,7 +10,6 @@ namespace PMP = CGAL::Polygon_mesh_processing; typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic_kernel; -typedef Epic_kernel::FT FT; typedef CGAL::Surface_mesh Surface_Mesh; typedef boost::graph_traits::vertex_descriptor vertex_descriptor; @@ -31,10 +30,10 @@ int main(int argc, char* argv[]) // loop over vertices and use vertex_descriptor to compute a curvature on one vertex for (vertex_descriptor v : vertices(smesh)) { - FT h = PMP::interpolated_corrected_mean_curvature_one_vertex(smesh, v); - FT g = PMP::interpolated_corrected_gaussian_curvature_one_vertex(smesh, v); + double h = PMP::interpolated_corrected_mean_curvature_one_vertex(smesh, v); + double g = PMP::interpolated_corrected_gaussian_curvature_one_vertex(smesh, v); PMP::Principal_curvatures_and_directions p = - PMP::interpolated_corrected_principal_curvatures_and_directions_one_vertex(smesh, v); + PMP::interpolated_corrected_principal_curvatures_and_directions_one_vertex(smesh, v); // we can also specify a ball radius for expansion and a user defined vertex normals map using // named parameters. Refer to interpolated_corrected_curvatures_SM.cpp to see example usage. diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h index ea01b0fe4c34..24c1d12a59e3 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h @@ -28,8 +28,6 @@ #include #include -#define EXPANDING_RADIUS_EPSILON 1e-6 - namespace CGAL { namespace Polygon_mesh_processing { @@ -39,7 +37,7 @@ namespace Polygon_mesh_processing { * * \brief a struct for storing principal curvatures and directions. * - * @tparam GT is the geometric traits class. + * @tparam GT is the geometric traits class, model of `Kernel`. */ template struct Principal_curvatures_and_directions { @@ -662,7 +660,7 @@ template(pmesh) * EXPANDING_RADIUS_EPSILON; + radius = average_edge_length(pmesh) * 1e-6; // get parameters (pointers) for curvatures typename GT::FT* vertex_mean_curvature = choose_parameter(get_parameter(np, internal_np::vertex_mean_curvature), nullptr); @@ -826,7 +824,7 @@ class Interpolated_corrected_curvatures_computer void set_ball_radius(const FT radius) { // if given radius is 0, we use a small epsilon to expand the ball (scaled by the average edge length) if (radius == 0) - ball_radius = average_edge_length(pmesh) * EXPANDING_RADIUS_EPSILON; + ball_radius = average_edge_length(pmesh) * 1e-6; else ball_radius = radius; } @@ -1021,7 +1019,7 @@ class Interpolated_corrected_curvatures_computer /** * \ingroup PMP_corrected_curvatures_grp * -* Computes the interpolated corrected curvatures across the mesh, based on the provided property maps. +* computes the interpolated corrected curvatures across the mesh `pmesh`. * By providing mean, gaussian and/or principal curvature and direction property maps as named parameters, the user * can choose which quantites to compute. * @@ -1029,66 +1027,70 @@ class Interpolated_corrected_curvatures_computer * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". * * @param pmesh the polygon mesh. -* @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. +* `GT` stands for the type of the object provided to the named parameter `geom_traits()`. * * \cgalNamedParamsBegin * * \cgalParamNBegin{vertex_point_map} * \cgalParamDescription{a property map associating points to the vertices of `pmesh`} * \cgalParamType{a class model of `ReadablePropertyMap` with -* `boost::graph_traits::%Vertex_descriptor` -* as key type and `%Point_3` as value type} +* `boost::graph_traits::%vertex_descriptor` +* as key type and `GT::Point_3` as value type} * \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`} -* \cgalParamExtra{If this parameter is omitted, an internal property map forBy +* \cgalParamExtra{If this parameter is omitted, an internal property map for * `CGAL::vertex_point_t` must be available in `PolygonMesh`.} * \cgalParamNEnd * * \cgalParamNBegin{vertex_normal_map} * \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} * \cgalParamType{a class model of `ReadablePropertyMap` with -* `boost::graph_traits::%Vertex_descriptor` -* as key type and `%Vector_3` as value type} +* `boost::graph_traits::%vertex_descriptor` +* as key type and `GT::Vector_3` as value type} * \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} * \cgalParamExtra{If this parameter is omitted, vertex normals will be -* computed using compute_vertex_normals()} +* computed using `compute_vertex_normals()`} +* \cgalParamNEnd +* +* \cgalParamNBegin{geom_traits} +* \cgalParamDescription{an instance of a geometric traits class} +* \cgalParamType{a class model of `Kernel`} +* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`} +* \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.} * \cgalParamNEnd * * \cgalParamNBegin{vertex_mean_curvature_map} * \cgalParamDescription{a property map associating mean curvatures to the vertices of `pmesh`} * \cgalParamType{a class model of `WritablePropertyMap` with -* `boost::graph_traits::%Vertex_descriptor` -* as key type and `%FT` as value type} -* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} +* `boost::graph_traits::%vertex_descriptor` +* as key type and `GT::FT` as value type} * \cgalParamExtra{If this parameter is omitted, mean curvatures won't be computed} * \cgalParamNEnd * * \cgalParamNBegin{vertex_gaussian_curvature_map} * \cgalParamDescription{a property map associating mean curvatures to the vertices of `pmesh`} * \cgalParamType{a class model of `WritablePropertyMap` with -* `boost::graph_traits::%Vertex_descriptor` -* as key type and `%FT` as value type} -* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} +* `boost::graph_traits::%vertex_descriptor` +* as key type and `GT::FT` as value type} * \cgalParamExtra{If this parameter is omitted, gaussian curvatures won't be computed} * \cgalParamNEnd * -* * \cgalParamNBegin{vertex_principal_curvatures_and_directions_map} * \cgalParamDescription{a property map associating mean curvatures to the vertices of `pmesh`} * \cgalParamType{a class model of `WritablePropertyMap` with -* `boost::graph_traits::%Vertex_descriptor` -* as key type and `%Principal_curvatures_and_directions` as value type} -* \cgalParamDefault{`get(dynamic_vertex_property_t>(), pmesh)`} +* `boost::graph_traits::%vertex_descriptor` +* as key type and `Principal_curvatures_and_directions` as value type} * \cgalParamExtra{If this parameter is omitted, mean principal won't be computed} * \cgalParamNEnd * * \cgalParamNBegin{ball_radius} -* \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures +* \cgalParamDescription{a strictly positive scalar value specifying the radius used for expanding curvature measures * by summing measures of faces inside a ball of this radius centered at the * vertex expanded from. The summed face measures are weighted by their * inclusion ratio inside this ball.} * \cgalParamType{`GT::FT`} * \cgalParamDefault{`-1`} -* \cgalParamExtra{If this parameter is omitted (`-1`), the epansion is then just a sum of +* \cgalParamExtra{If this parameter is omitted (`-1`), the expansion is then just a sum of * measures on faces around the vertex} * \cgalParamNEnd * @@ -1099,9 +1101,9 @@ class Interpolated_corrected_curvatures_computer * @see `interpolated_corrected_principal_curvatures_and_directions()` */ template - void interpolated_corrected_curvatures(const PolygonMesh& pmesh, - const NamedParameters& np = parameters::default_values()) + typename NamedParameters = parameters::Default_named_parameters> +void interpolated_corrected_curvatures(const PolygonMesh& pmesh, + const NamedParameters& np = parameters::default_values()) { internal::Interpolated_corrected_curvatures_computer(pmesh, np); } @@ -1109,25 +1111,25 @@ template::%Vertex_descriptor` as key type and `GT::FT` as value type. +* @tparam VertexCurvatureMap a model of `WritablePropertyMap` with +* `boost::graph_traits::%vertex_descriptor` as key type and `GT::FT` as value type. * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". * * @param pmesh the polygon mesh. * @param vcm the vertex property map in which the computed mean curvatures are stored. * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters". +* `GT` stands for the type of the object provided to the named parameter `geom_traits()`. * * \cgalNamedParamsBegin * * \cgalParamNBegin{vertex_point_map} * \cgalParamDescription{a property map associating points to the vertices of `pmesh`} * \cgalParamType{a class model of `ReadablePropertyMap` with -* `boost::graph_traits::%Vertex_descriptor` -* as key type and `%Point_3` as value type} +* `boost::graph_traits::%vertex_descriptor` +* as key type and `GT::Point_3` as value type} * \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`} * \cgalParamExtra{If this parameter is omitted, an internal property map for * `CGAL::vertex_point_t` must be available in `PolygonMesh`.} @@ -1136,11 +1138,18 @@ template::%Vertex_descriptor` -* as key type and `%Vector_3` as value type} +* `boost::graph_traits::%vertex_descriptor` +* as key type and `GT::Vector_3` as value type} * \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} * \cgalParamExtra{If this parameter is omitted, vertex normals will be -* computed using compute_vertex_normals()} +* computed using `compute_vertex_normals()`} +* \cgalParamNEnd +* +* \cgalParamNBegin{geom_traits} +* \cgalParamDescription{an instance of a geometric traits class} +* \cgalParamType{a class model of `Kernel`} +* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`} +* \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.} * \cgalParamNEnd * * \cgalParamNBegin{ball_radius} @@ -1162,10 +1171,10 @@ template - void interpolated_corrected_mean_curvature(const PolygonMesh& pmesh, - VertexCurvatureMap& vcm, - const NamedParameters& np = parameters::default_values()) + typename NamedParameters = parameters::Default_named_parameters> +void interpolated_corrected_mean_curvature(const PolygonMesh& pmesh, + VertexCurvatureMap vcm, + const NamedParameters& np = parameters::default_values()) { interpolated_corrected_curvatures(pmesh, np.vertex_mean_curvature_map(vcm)); } @@ -1173,24 +1182,24 @@ template::%Vertex_descriptor` as key type and `GT::FT` as value type. +* @tparam VertexCurvatureMap a model of `WritablePropertyMap` with +* `boost::graph_traits::%vertex_descriptor` as key type and `GT::FT` as value type. * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". * * @param pmesh the polygon mesh. * @param vcm the vertex property map in which the computed gaussian curvatures are stored. * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters". +* `GT` stands for the type of the object provided to the named parameter `geom_traits()`. * * \cgalNamedParamsBegin * * \cgalParamNBegin{vertex_point_map} * \cgalParamDescription{a property map associating points to the vertices of `pmesh`} * \cgalParamType{a class model of `ReadablePropertyMap` with -* `boost::graph_traits::%Vertex_descriptor` +* `boost::graph_traits::%vertex_descriptor` * as key type and `%Point_3` as value type} * \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`} * \cgalParamExtra{If this parameter is omitted, an internal property map for @@ -1199,12 +1208,19 @@ template::%Vertex_descriptor` +* \cgalParamType{a class model of `GT::ReadablePropertyMap` with +* `boost::graph_traits::%vertex_descriptor` * as key type and `%Vector_3` as value type} * \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} * \cgalParamExtra{If this parameter is omitted, vertex normals will be -* computed using compute_vertex_normals()} +* computed using `compute_vertex_normals()`} +* \cgalParamNEnd +* +* \cgalParamNBegin{geom_traits} +* \cgalParamDescription{an instance of a geometric traits class} +* \cgalParamType{a class model of `Kernel`} +* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`} +* \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.} * \cgalParamNEnd * * \cgalParamNBegin{ball_radius} @@ -1225,10 +1241,10 @@ template - void interpolated_corrected_gaussian_curvature(const PolygonMesh& pmesh, - VertexCurvatureMap& vcm, - const NamedParameters& np = parameters::default_values()) + typename NamedParameters = parameters::Default_named_parameters> +void interpolated_corrected_gaussian_curvature(const PolygonMesh& pmesh, + VertexCurvatureMap vcm, + const NamedParameters& np = parameters::default_values()) { interpolated_corrected_curvatures(pmesh, np.vertex_gaussian_curvature_map(vcm)); } @@ -1236,26 +1252,26 @@ template::%Vertex_descriptor` as key type and -* `%Principal_curvatures_and_directions` as value type. +* @tparam VertexCurvatureMap a model of `WritablePropertyMap` with +* `boost::graph_traits::%vertex_descriptor` as key type and +* `Principal_curvatures_and_directions` as value type. * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". * * @param pmesh the polygon mesh. * @param vcm the vertex property map in which the computed principal curvatures are stored. * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below +* `GT` stands for the type of the object provided to the named parameter `geom_traits()`. * * \cgalNamedParamsBegin * * \cgalParamNBegin{vertex_point_map} * \cgalParamDescription{a property map associating points to the vertices of `pmesh`} * \cgalParamType{a class model of `ReadablePropertyMap` with -* `boost::graph_traits::%Vertex_descriptor` -* as key type and `%Point_3` as value type} +* `boost::graph_traits::%vertex_descriptor` +* as key type and `GT::Point_3` as value type} * \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`} * \cgalParamExtra{If this parameter is omitted, an internal property map for * `CGAL::vertex_point_t` must be available in `PolygonMesh`.} @@ -1264,11 +1280,18 @@ template::%Vertex_descriptor` -* as key type and `%Vector_3` as value type} +* `boost::graph_traits::%vertex_descriptor` +* as key type and `GT::Vector_3` as value type} * \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} * \cgalParamExtra{If this parameter is omitted, vertex normals will be -* computed using compute_vertex_normals()} +* computed using `compute_vertex_normals()`} +* \cgalParamNEnd +* +* \cgalParamNBegin{geom_traits} +* \cgalParamDescription{an instance of a geometric traits class} +* \cgalParamType{a class model of `Kernel`} +* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`} +* \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.} * \cgalParamNEnd * * \cgalParamNBegin{ball_radius} @@ -1289,289 +1312,335 @@ template - void interpolated_corrected_principal_curvatures_and_directions(const PolygonMesh& pmesh, - VertexCurvatureMap& vcm, - const NamedParameters& np = parameters::default_values()) +typename NamedParameters = parameters::Default_named_parameters> +void interpolated_corrected_principal_curvatures_and_directions(const PolygonMesh& pmesh, + VertexCurvatureMap vcm, + const NamedParameters& np = parameters::default_values()) { interpolated_corrected_curvatures(pmesh, np.vertex_principal_curvatures_and_directions_map(vcm)); } /** - * \ingroup PMP_corrected_curvatures_grp - * Computes the interpolated corrected curvatures at a certain vertex, based on the provided pointers. - * By providing mean, gaussian and/or principal curvature and direction property maps as named parameters, the user - * can choose which quantites to compute. - * - * The pointers are used to store the computed quantities. - * The user is responsible for the memory management of the pointers. - * - * @tparam PolygonMesh a model of `FaceListGraph` - * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" - * - * @param pmesh the polygon mesh - * @param v the vertex of `pmesh` to compute the curvatures at - * @param np 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 `pmesh`} - * \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, pmesh)`} - * \cgalParamExtra{If this parameter is omitted, an internal property map for - * `CGAL::vertex_point_t` must be available in `PolygonMesh`.} - * \cgalParamNEnd - * - * \cgalParamNBegin{vertex_normal_map} - * \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} - * \cgalParamType{a class model of `ReadablePropertyMap` with - * `boost::graph_traits::%Vertex_descriptor` - * as key type and `%Vector_3` as value type} - * \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} - * \cgalParamExtra{If this parameter is omitted, vertex normals will be - * computed using compute_vertex_normals()} - * \cgalParamNEnd - * - * \cgalParamNBegin{vertex_mean_curvature} - * \cgalParamDescription{a pointer to a scalar value to store the mean curvature at the vertex `v`} - * \cgalParamType{`GT::FT*`} - * \cgalParamDefault{`nullptr`} - * \cgalParamExtra{If this parameter is omitted, mean curvature won't be computed} - * \cgalParamNEnd - * - * \cgalParamNBegin{vertex_gaussian_curvature} - * \cgalParamDescription{a pointer to a scalar value to store the gaussian curvature at the vertex `v`} - * \cgalParamType{`GT::FT*`} - * \cgalParamDefault{`nullptr`} - * \cgalParamExtra{If this parameter is omitted, gaussian curvature won't be computed} - * \cgalParamNEnd - * - * \cgalParamNBegin{vertex_principal_curvatures_and_directions} - * \cgalParamDescription{a pointer to a Principal_curvatures_and_directions object to store the principal curvatures and directions at the vertex `v`} - * \cgalParamType{`Principal_curvatures_and_directions*`} - * \cgalParamDefault{`nullptr`} - * \cgalParamExtra{If this parameter is omitted, principal curvatures and directions won't be computed} - * \cgalParamNEnd - * - * \cgalParamNBegin{ball_radius} - * \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures - * by summing measures of faces inside a ball of this radius centered at the - * vertex expanded from. The summed face measures are weighted by their - * inclusion ratio inside this ball.} - * \cgalParamType{`GT::FT`} - * \cgalParamDefault{`-1`} - * \cgalParamExtra{If this parameter is omitted (`-1`), the epansion is then just a sum of - * measures on faces around the vertex} - * \cgalParamNEnd - * - * \cgalNamedParamsEnd - * - * @see `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures()` - * @see `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature_one_vertex()` - * @see `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature_one_vertex()` - * @see `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions_one_vertex()` +* \ingroup PMP_corrected_curvatures_grp +* computes the interpolated corrected curvatures at a certain vertex, based on the provided pointers. +* By providing mean, gaussian and/or principal curvature and direction property maps as named parameters, the user +* can choose which quantites to compute. +* +* The pointers are used to store the computed quantities. +* The user is responsible for the memory management of the pointers. +* +* @tparam PolygonMesh a model of `FaceListGraph` +* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" +* +* @param pmesh the polygon mesh +* @param v the vertex of `pmesh` to compute the curvatures at +* @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below +* `GT` stands for the type of the object provided to the named parameter `geom_traits()`. +* +* \cgalNamedParamsBegin +* \cgalParamNBegin{vertex_point_map} +* \cgalParamDescription{a property map associating points to the vertices of `pmesh`} +* \cgalParamType{a class model of `ReadablePropertyMap` with +* `boost::graph_traits::%vertex_descriptor` +* as key type and `GT::Point_3` as value type} +* \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`} +* \cgalParamExtra{If this parameter is omitted, an internal property map for +* `CGAL::vertex_point_t` must be available in `PolygonMesh`.} +* \cgalParamNEnd +* +* \cgalParamNBegin{vertex_normal_map} +* \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} +* \cgalParamType{a class model of `ReadablePropertyMap` with +* `boost::graph_traits::%vertex_descriptor` +* as key type and `GT::Vector_3` as value type} +* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} +* \cgalParamExtra{If this parameter is omitted, vertex normals will be +* computed using `compute_vertex_normals()`} +* \cgalParamNEnd +* +* +* \cgalParamNBegin{geom_traits} +* \cgalParamDescription{an instance of a geometric traits class} +* \cgalParamType{a class model of `Kernel`} +* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`} +* \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.} +* \cgalParamNEnd +* +* \cgalParamNBegin{vertex_mean_curvature} +* \cgalParamDescription{a pointer to a scalar value to store the mean curvature at the vertex `v`} +* \cgalParamType{`GT::FT*`} +* \cgalParamDefault{`nullptr`} +* \cgalParamExtra{If this parameter is omitted, mean curvature won't be computed} +* \cgalParamNEnd +* +* \cgalParamNBegin{vertex_gaussian_curvature} +* \cgalParamDescription{a pointer to a scalar value to store the gaussian curvature at the vertex `v`} +* \cgalParamType{`GT::FT*`} +* \cgalParamDefault{`nullptr`} +* \cgalParamExtra{If this parameter is omitted, gaussian curvature won't be computed} +* \cgalParamNEnd +* +* \cgalParamNBegin{vertex_principal_curvatures_and_directions} +* \cgalParamDescription{a pointer to a Principal_curvatures_and_directions object to store the principal curvatures and directions at the vertex `v`} +* \cgalParamType{`Principal_curvatures_and_directions*`} +* \cgalParamDefault{`nullptr`} +* \cgalParamExtra{If this parameter is omitted, principal curvatures and directions won't be computed} +* \cgalParamNEnd +* +* \cgalParamNBegin{ball_radius} +* \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures +* by summing measures of faces inside a ball of this radius centered at the +* vertex expanded from. The summed face measures are weighted by their +* inclusion ratio inside this ball.} +* \cgalParamType{`GT::FT`} +* \cgalParamDefault{`-1`} +* \cgalParamExtra{If this parameter is omitted (`-1`), the epansion is then just a sum of +* measures on faces around the vertex} +* \cgalParamNEnd +* +* \cgalNamedParamsEnd +* +* @see `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures()` +* @see `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature_one_vertex()` +* @see `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature_one_vertex()` +* @see `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions_one_vertex()` */ template - void interpolated_corrected_curvatures_one_vertex(const PolygonMesh& pmesh, - typename boost::graph_traits::vertex_descriptor v, - const NamedParameters& np = parameters::default_values()) + typename NamedParameters = parameters::Default_named_parameters> +void interpolated_corrected_curvatures_one_vertex(const PolygonMesh& pmesh, + typename boost::graph_traits::vertex_descriptor v, + const NamedParameters& np = parameters::default_values()) { internal::interpolated_corrected_curvatures_one_vertex(pmesh, v, np); } /** - * \ingroup PMP_corrected_curvatures_grp - * computes the interpolated corrected mean curvature at a vertex of a triangle mesh. - * - * @tparam GT a geometric traits class that provides the nested type `FT`, - * @tparam PolygonMesh a model of `FaceListGraph` - * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" - * - * @param pmesh the polygon mesh - * @param v the vertex of `pmesh` to compute the mean curvature at - * @param np 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 `pmesh`} - * \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, pmesh)`} - * \cgalParamExtra{If this parameter is omitted, an internal property map for - * `CGAL::vertex_point_t` must be available in `PolygonMesh`.} - * \cgalParamNEnd - * - * \cgalParamNBegin{vertex_normal_map} - * \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} - * \cgalParamType{a class model of `ReadablePropertyMap` with - * `boost::graph_traits::%Vertex_descriptor` - * as key type and `%Vector_3` as value type} - * \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} - * \cgalParamExtra{If this parameter is omitted, vertex normals will be - * computed using compute_vertex_normals()} - * \cgalParamNEnd - * - * \cgalParamNBegin{ball_radius} - * \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures - * by summing measures of faces inside a ball of this radius centered at the - * vertex expanded from. The summed face measures are weighted by their - * inclusion ratio inside this ball} - * \cgalParamType{`GT::FT`} - * \cgalParamDefault{`-1`} - * \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of - * measures on faces around the vertex} - * \cgalParamNEnd - * - * \cgalNamedParamsEnd - * - * @return the interpolated corrected mean curvature at the vertex `v` - * - * @see `interpolated_corrected_mean_curvature()` - * @see `interpolated_corrected_gaussian_curvature_one_vertex()` - * @see `interpolated_corrected_principal_curvatures_and_directions_one_vertex()` - * @see `interpolated_corrected_curvatures_one_vertex()` +* \ingroup PMP_corrected_curvatures_grp +* computes the interpolated corrected mean curvature at a vertex of a triangle mesh. +* +* @tparam PolygonMesh a model of `FaceListGraph` +* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" +* +* @param pmesh the polygon mesh +* @param v the vertex of `pmesh` to compute the mean curvature at +* @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below +* `GT` stands for the type of the object provided to the named parameter `geom_traits()`. +* +* \cgalNamedParamsBegin +* \cgalParamNBegin{vertex_point_map} +* \cgalParamDescription{a property map associating points to the vertices of `pmesh`} +* \cgalParamType{a class model of `ReadablePropertyMap` with +* `boost::graph_traits::%vertex_descriptor` +* as key type and `GT::Point_3` as value type} +* \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`} +* \cgalParamExtra{If this parameter is omitted, an internal property map for +* `CGAL::vertex_point_t` must be available in `PolygonMesh`.} +* \cgalParamNEnd +* +* \cgalParamNBegin{vertex_normal_map} +* \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} +* \cgalParamType{a class model of `ReadablePropertyMap` with +* `boost::graph_traits::%vertex_descriptor` +* as key type and `GT::Vector_3` as value type} +* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} +* \cgalParamExtra{If this parameter is omitted, vertex normals will be +* computed using `compute_vertex_normals()`} +* \cgalParamNEnd +* +* \cgalParamNBegin{geom_traits} +* \cgalParamDescription{an instance of a geometric traits class} +* \cgalParamType{a class model of `Kernel`} +* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`} +* \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.} +* \cgalParamNEnd +* +* \cgalParamNBegin{ball_radius} +* \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures +* by summing measures of faces inside a ball of this radius centered at the +* vertex expanded from. The summed face measures are weighted by their +* inclusion ratio inside this ball} +* \cgalParamType{`GT::FT`} +* \cgalParamDefault{`-1`} +* \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of +* measures on faces around the vertex} +* \cgalParamNEnd +* +* \cgalNamedParamsEnd +* +* @return the interpolated corrected mean curvature at the vertex `v` +* +* @see `interpolated_corrected_mean_curvature()` +* @see `interpolated_corrected_gaussian_curvature_one_vertex()` +* @see `interpolated_corrected_principal_curvatures_and_directions_one_vertex()` +* @see `interpolated_corrected_curvatures_one_vertex()` */ -template - typename GT::FT interpolated_corrected_mean_curvature_one_vertex(const PolygonMesh& pmesh, - typename boost::graph_traits::vertex_descriptor v, - const NamedParameters& np = parameters::default_values()) +template +#ifdef DOXYGEN_RUNNING +typename GT::FT +#else +typename GetGeomTraits::type::FT +#endif +interpolated_corrected_mean_curvature_one_vertex(const PolygonMesh& pmesh, + typename boost::graph_traits::vertex_descriptor v, + const NamedParameters& np = parameters::default_values()) { - typename GT::FT mean_curvature; + typename GetGeomTraits::type::FT mean_curvature; interpolated_corrected_curvatures_one_vertex(pmesh, v, np.vertex_mean_curvature(&mean_curvature)); return mean_curvature; } /** - * \ingroup PMP_corrected_curvatures_grp - * computes the interpolated corrected Gaussian curvature at a vertex of a triangle mesh. - * - * @tparam GT a geometric traits class that provides the nested type `FT`, - * @tparam PolygonMesh a model of `FaceListGraph` - * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" - * - * @param pmesh the polygon mesh - * @param v the vertex of `pmesh` to compute the Gaussian curvature at - * @param np 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 `pmesh`} - * \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, pmesh)`} - * \cgalParamExtra{If this parameter is omitted, an internal property map for - * `CGAL::vertex_point_t` must be available in `PolygonMesh`.} - * \cgalParamNEnd - * - * \cgalParamNBegin{vertex_normal_map} - * \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} - * \cgalParamType{a class model of `ReadablePropertyMap` with - * `boost::graph_traits::%Vertex_descriptor` - * as key type and `%Vector_3` as value type} - * \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} - * \cgalParamExtra{If this parameter is omitted, vertex normals will be - * computed using compute_vertex_normals()} - * \cgalParamNEnd - * - * \cgalParamNBegin{ball_radius} - * \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures - * by summing measures of faces inside a ball of this radius centered at the - * vertex expanded from. The summed face measures are weighted by their - * inclusion ratio inside this ball} - * \cgalParamType{`GT::FT`} - * \cgalParamDefault{`-1`} - * \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of - * measures on faces around the vertex} - * \cgalParamNEnd - * - * \cgalNamedParamsEnd - * - * @return the interpolated corrected Gaussian curvature at the vertex `v` - * - * @see `interpolated_corrected_gaussian_curvature()` - * @see `interpolated_corrected_mean_curvature_one_vertex()` - * @see `interpolated_corrected_principal_curvatures_and_directions_one_vertex()` - * @see `interpolated_corrected_curvatures_one_vertex()` +* \ingroup PMP_corrected_curvatures_grp +* computes the interpolated corrected Gaussian curvature at a vertex of a triangle mesh. +* +* @tparam PolygonMesh a model of `FaceListGraph` +* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" +* +* @param pmesh the polygon mesh +* @param v the vertex of `pmesh` to compute the Gaussian curvature at +* @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below +* `GT` stands for the type of the object provided to the named parameter `geom_traits()`. +* +* \cgalNamedParamsBegin +* \cgalParamNBegin{vertex_point_map} +* \cgalParamDescription{a property map associating points to the vertices of `pmesh`} +* \cgalParamType{a class model of `ReadablePropertyMap` with +* `boost::graph_traits::%vertex_descriptor` +* as key type and `GT::Point_3` as value type} +* \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`} +* \cgalParamExtra{If this parameter is omitted, an internal property map for +* `CGAL::vertex_point_t` must be available in `PolygonMesh`.} +* \cgalParamNEnd +* +* \cgalParamNBegin{vertex_normal_map} +* \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} +* \cgalParamType{a class model of `ReadablePropertyMap` with +* `boost::graph_traits::%vertex_descriptor` +* as key type and `GT::Vector_3` as value type} +* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} +* \cgalParamExtra{If this parameter is omitted, vertex normals will be +* computed using `compute_vertex_normals()`} +* \cgalParamNEnd +* +* \cgalParamNBegin{geom_traits} +* \cgalParamDescription{an instance of a geometric traits class} +* \cgalParamType{a class model of `Kernel`} +* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`} +* \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.} +* \cgalParamNEnd +* +* \cgalParamNBegin{ball_radius} +* \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures +* by summing measures of faces inside a ball of this radius centered at the +* vertex expanded from. The summed face measures are weighted by their +* inclusion ratio inside this ball} +* \cgalParamType{`GT::FT`} +* \cgalParamDefault{`-1`} +* \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of +* measures on faces around the vertex} +* \cgalParamNEnd +* +* \cgalNamedParamsEnd +* +* @return the interpolated corrected Gaussian curvature at the vertex `v` +* +* @see `interpolated_corrected_gaussian_curvature()` +* @see `interpolated_corrected_mean_curvature_one_vertex()` +* @see `interpolated_corrected_principal_curvatures_and_directions_one_vertex()` +* @see `interpolated_corrected_curvatures_one_vertex()` */ -template - typename GT::FT interpolated_corrected_gaussian_curvature_one_vertex(const PolygonMesh& pmesh, - typename boost::graph_traits::vertex_descriptor v, - const NamedParameters& np = parameters::default_values()) +#ifdef DOXYGEN_RUNNING +typename GT::FT +#else +typename GetGeomTraits::type::FT +#endif +interpolated_corrected_gaussian_curvature_one_vertex(const PolygonMesh& pmesh, + typename boost::graph_traits::vertex_descriptor v, + const NamedParameters& np = parameters::default_values()) { - typename GT::FT gc; + typename GetGeomTraits::type::FT gc; interpolated_corrected_curvatures_one_vertex(pmesh, v, np.vertex_gaussian_curvature(&gc)); return gc; } /** - * \ingroup PMP_corrected_curvatures_grp - * computes the interpolated corrected principal curvatures and directions at a vertex of a triangle mesh. - * - * @tparam GT the geometric traits class, - * @tparam PolygonMesh a model of `FaceListGraph` - * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" - * - * @param pmesh the polygon mesh - * @param v the vertex of `pmesh` to compute the principal curvatures and directions at - * @param np 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 `pmesh`} - * \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, pmesh)`} - * \cgalParamExtra{If this parameter is omitted, an internal property map for - * `CGAL::vertex_point_t` must be available in `PolygonMesh`.} - * \cgalParamNEnd - * - * \cgalParamNBegin{vertex_normal_map} - * \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} - * \cgalParamType{a class model of `ReadablePropertyMap` with - * `boost::graph_traits::%Vertex_descriptor` - * as key type and `%Vector_3` as value type} - * \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} - * \cgalParamExtra{If this parameter is omitted, vertex normals will be - * computed using compute_vertex_normals()} - * \cgalParamNEnd - * - * \cgalParamNBegin{ball_radius} - * \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures - * by summing measures of faces inside a ball of this radius centered at the - * vertex expanded from. The summed face measures are weighted by their - * inclusion ratio inside this ball} - * \cgalParamType{`GT::FT`} - * \cgalParamDefault{`-1`} - * \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of - * measures on faces around the vertex} - * \cgalParamNEnd - * \cgalNamedParamsEnd - * - * @return the interpolated corrected principal curvatures and directions at the vertex `v` - * - * @see `interpolated_corrected_principal_curvatures_and_directions()` - * @see `interpolated_corrected_mean_curvature_one_vertex()` - * @see `interpolated_corrected_gaussian_curvature_one_vertex()` - * @see `interpolated_corrected_curvatures_one_vertex()` +* \ingroup PMP_corrected_curvatures_grp +* computes the interpolated corrected principal curvatures and directions at a vertex of a triangle mesh. +* +* @tparam PolygonMesh a model of `FaceListGraph` +* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" +* +* @param pmesh the polygon mesh +* @param v the vertex of `pmesh` to compute the principal curvatures and directions at +* @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below +* `GT` stands for the type of the object provided to the named parameter `geom_traits()`. +* +* \cgalNamedParamsBegin +* \cgalParamNBegin{vertex_point_map} +* \cgalParamDescription{a property map associating points to the vertices of `pmesh`} +* \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, pmesh)`} +* \cgalParamExtra{If this parameter is omitted, an internal property map for +* `CGAL::vertex_point_t` must be available in `PolygonMesh`.} +* \cgalParamNEnd +* +* \cgalParamNBegin{vertex_normal_map} +* \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`} +* \cgalParamType{a class model of `ReadablePropertyMap` with +* `boost::graph_traits::%vertex_descriptor` +* as key type and `%Vector_3` as value type} +* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} +* \cgalParamExtra{If this parameter is omitted, vertex normals will be +* computed using `compute_vertex_normals()`} +* \cgalParamNEnd +* +* \cgalParamNBegin{geom_traits} +* \cgalParamDescription{an instance of a geometric traits class} +* \cgalParamType{a class model of `Kernel`} +* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`} +* \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.} +* \cgalParamNEnd +* +* \cgalParamNBegin{ball_radius} +* \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures +* by summing measures of faces inside a ball of this radius centered at the +* vertex expanded from. The summed face measures are weighted by their +* inclusion ratio inside this ball} +* \cgalParamType{`GT::FT`} +* \cgalParamDefault{`-1`} +* \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of +* measures on faces around the vertex} +* \cgalParamNEnd +* \cgalNamedParamsEnd +* +* @return the interpolated corrected principal curvatures and directions at the vertex `v` +* +* @see `interpolated_corrected_principal_curvatures_and_directions()` +* @see `interpolated_corrected_mean_curvature_one_vertex()` +* @see `interpolated_corrected_gaussian_curvature_one_vertex()` +* @see `interpolated_corrected_curvatures_one_vertex()` */ -template - Principal_curvatures_and_directions interpolated_corrected_principal_curvatures_and_directions_one_vertex(const PolygonMesh& pmesh, - typename boost::graph_traits::vertex_descriptor v, - const NamedParameters& np = parameters::default_values()) +template +#ifdef DOXYGEN_RUNNING +Principal_curvatures_and_directions +#else +Principal_curvatures_and_directions::type> +#endif +interpolated_corrected_principal_curvatures_and_directions_one_vertex(const PolygonMesh& pmesh, + typename boost::graph_traits::vertex_descriptor v, + const NamedParameters& np = parameters::default_values()) { + using GT=typename GetGeomTraits::type; Principal_curvatures_and_directions pcd; interpolated_corrected_curvatures_one_vertex(pmesh, v, np.vertex_principal_curvatures_and_directions(&pcd)); return pcd; From 5ef5d67920724435a903a932866b9525260125a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 22 Mar 2023 18:40:44 +0100 Subject: [PATCH 124/142] do not use pointers --- .../interpolated_corrected_curvatures.h | 75 +++++++++---------- ...test_interpolated_corrected_curvatures.cpp | 6 +- 2 files changed, 39 insertions(+), 42 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h index 24c1d12a59e3..cc898d2fc943 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h @@ -624,6 +624,16 @@ Vertex_measures interpolated_corrected_measures_one_vertex( return vertex_measures; } +template +void set_value(const T& value, std::reference_wrapper rw) +{ + rw.get()=value; +} + +template +void set_value(const T&, internal_np::Param_not_found) +{} + // computes selected curvatures for one specific vertex template @@ -662,15 +672,10 @@ template(pmesh) * 1e-6; - // get parameters (pointers) for curvatures - typename GT::FT* vertex_mean_curvature = choose_parameter(get_parameter(np, internal_np::vertex_mean_curvature), nullptr); - typename GT::FT* vertex_gaussian_curvature = choose_parameter(get_parameter(np, internal_np::vertex_gaussian_curvature), nullptr); - Principal_curvatures_and_directions* vertex_principal_curvatures_and_directions = choose_parameter(get_parameter(np, internal_np::vertex_principal_curvatures_and_directions), nullptr); - - // determine which curvatures are selected (by checking if the pointers are not null) - const bool is_mean_curvature_selected = (vertex_mean_curvature != nullptr); - const bool is_gaussian_curvature_selected = (vertex_gaussian_curvature != nullptr); - const bool is_principal_curvatures_and_directions_selected = (vertex_principal_curvatures_and_directions != nullptr); + // determine which curvatures are selected + const bool is_mean_curvature_selected = !is_default_parameter::value; + const bool is_gaussian_curvature_selected = !is_default_parameter::value; + const bool is_principal_curvatures_and_directions_selected = !is_default_parameter::value; Vertex_measures vertex_measures; @@ -703,13 +708,13 @@ template principal_curvatures_and_directions = principal_curvatures_and_directions_from_anisotropic_measures( vertex_measures.anisotropic_measure, vertex_measures.area_measure, - v_normal - ); - *vertex_principal_curvatures_and_directions = principal_curvatures_and_directions; + v_normal); + set_value(principal_curvatures_and_directions, get_parameter(np, internal_np::vertex_principal_curvatures_and_directions)); } } @@ -1064,7 +1068,7 @@ class Interpolated_corrected_curvatures_computer * \cgalParamType{a class model of `WritablePropertyMap` with * `boost::graph_traits::%vertex_descriptor` * as key type and `GT::FT` as value type} -* \cgalParamExtra{If this parameter is omitted, mean curvatures won't be computed} +* \cgalParamExtra{If this parameter is omitted, mean curvatures will not be computed} * \cgalParamNEnd * * \cgalParamNBegin{vertex_gaussian_curvature_map} @@ -1072,7 +1076,7 @@ class Interpolated_corrected_curvatures_computer * \cgalParamType{a class model of `WritablePropertyMap` with * `boost::graph_traits::%vertex_descriptor` * as key type and `GT::FT` as value type} -* \cgalParamExtra{If this parameter is omitted, gaussian curvatures won't be computed} +* \cgalParamExtra{If this parameter is omitted, gaussian curvatures will not be computed} * \cgalParamNEnd * * \cgalParamNBegin{vertex_principal_curvatures_and_directions_map} @@ -1080,7 +1084,7 @@ class Interpolated_corrected_curvatures_computer * \cgalParamType{a class model of `WritablePropertyMap` with * `boost::graph_traits::%vertex_descriptor` * as key type and `Principal_curvatures_and_directions` as value type} -* \cgalParamExtra{If this parameter is omitted, mean principal won't be computed} +* \cgalParamExtra{If this parameter is omitted, mean principal will not be computed} * \cgalParamNEnd * * \cgalParamNBegin{ball_radius} @@ -1323,13 +1327,10 @@ void interpolated_corrected_principal_curvatures_and_directions(const PolygonMes /** * \ingroup PMP_corrected_curvatures_grp -* computes the interpolated corrected curvatures at a certain vertex, based on the provided pointers. +* computes the interpolated corrected curvatures at a vertex `v`. * By providing mean, gaussian and/or principal curvature and direction property maps as named parameters, the user * can choose which quantites to compute. * -* The pointers are used to store the computed quantities. -* The user is responsible for the memory management of the pointers. -* * @tparam PolygonMesh a model of `FaceListGraph` * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" * @@ -1359,7 +1360,6 @@ void interpolated_corrected_principal_curvatures_and_directions(const PolygonMes * computed using `compute_vertex_normals()`} * \cgalParamNEnd * -* * \cgalParamNBegin{geom_traits} * \cgalParamDescription{an instance of a geometric traits class} * \cgalParamType{a class model of `Kernel`} @@ -1368,24 +1368,21 @@ void interpolated_corrected_principal_curvatures_and_directions(const PolygonMes * \cgalParamNEnd * * \cgalParamNBegin{vertex_mean_curvature} -* \cgalParamDescription{a pointer to a scalar value to store the mean curvature at the vertex `v`} -* \cgalParamType{`GT::FT*`} -* \cgalParamDefault{`nullptr`} -* \cgalParamExtra{If this parameter is omitted, mean curvature won't be computed} +* \cgalParamDescription{a reference to a scalar value to store the mean curvature at the vertex `v`} +* \cgalParamType{`std::reference_wrapper`} +* \cgalParamExtra{If this parameter is omitted, mean curvature will not be computed} * \cgalParamNEnd * * \cgalParamNBegin{vertex_gaussian_curvature} -* \cgalParamDescription{a pointer to a scalar value to store the gaussian curvature at the vertex `v`} -* \cgalParamType{`GT::FT*`} -* \cgalParamDefault{`nullptr`} -* \cgalParamExtra{If this parameter is omitted, gaussian curvature won't be computed} +* \cgalParamDescription{a reference to a scalar value to store the gaussian curvature at the vertex `v`} +* \cgalParamType{`std::reference_wrapper`} +* \cgalParamExtra{If this parameter is omitted, gaussian curvature will not be computed} * \cgalParamNEnd * * \cgalParamNBegin{vertex_principal_curvatures_and_directions} -* \cgalParamDescription{a pointer to a Principal_curvatures_and_directions object to store the principal curvatures and directions at the vertex `v`} -* \cgalParamType{`Principal_curvatures_and_directions*`} -* \cgalParamDefault{`nullptr`} -* \cgalParamExtra{If this parameter is omitted, principal curvatures and directions won't be computed} +* \cgalParamDescription{a reference to an`Principal_curvatures_and_directions` object to store the principal curvatures and directions at the vertex `v`} +* \cgalParamType{`std::reference_wrapper>`} +* \cgalParamExtra{If this parameter is omitted, principal curvatures and directions will not be computed} * \cgalParamNEnd * * \cgalParamNBegin{ball_radius} @@ -1488,7 +1485,7 @@ interpolated_corrected_mean_curvature_one_vertex(const PolygonMesh& pmesh, const NamedParameters& np = parameters::default_values()) { typename GetGeomTraits::type::FT mean_curvature; - interpolated_corrected_curvatures_one_vertex(pmesh, v, np.vertex_mean_curvature(&mean_curvature)); + interpolated_corrected_curvatures_one_vertex(pmesh, v, np.vertex_mean_curvature(std::ref(mean_curvature))); return mean_curvature; } @@ -1565,7 +1562,7 @@ interpolated_corrected_gaussian_curvature_one_vertex(const PolygonMesh& pmesh, const NamedParameters& np = parameters::default_values()) { typename GetGeomTraits::type::FT gc; - interpolated_corrected_curvatures_one_vertex(pmesh, v, np.vertex_gaussian_curvature(&gc)); + interpolated_corrected_curvatures_one_vertex(pmesh, v, np.vertex_gaussian_curvature(std::ref(gc))); return gc; } @@ -1642,7 +1639,7 @@ interpolated_corrected_principal_curvatures_and_directions_one_vertex(const Poly { using GT=typename GetGeomTraits::type; Principal_curvatures_and_directions pcd; - interpolated_corrected_curvatures_one_vertex(pmesh, v, np.vertex_principal_curvatures_and_directions(&pcd)); + interpolated_corrected_curvatures_one_vertex(pmesh, v, np.vertex_principal_curvatures_and_directions(std::ref(pcd))); return pcd; } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp index c8d3894720cc..bd0594652206 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp @@ -165,9 +165,9 @@ void test_average_curvatures(std::string mesh_path, PMP::interpolated_corrected_curvatures_one_vertex( pmesh, v, - CGAL::parameters::vertex_gaussian_curvature(&g) - .vertex_mean_curvature(&h) - .vertex_principal_curvatures_and_directions(&p) + CGAL::parameters::vertex_gaussian_curvature(std::ref(g)) + .vertex_mean_curvature(std::ref(h)) + .vertex_principal_curvatures_and_directions(std::ref(p)) .ball_radius(test_info.expansion_radius) ); From 7f4597720eed4bc4c9c215668f99e02495357826 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 22 Mar 2023 18:44:11 +0100 Subject: [PATCH 125/142] the mesh does not need to be triangulated --- .../interpolated_corrected_curvatures.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h index cc898d2fc943..94a8533ca42b 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h @@ -1414,7 +1414,7 @@ void interpolated_corrected_curvatures_one_vertex(const PolygonMesh& pmesh, /** * \ingroup PMP_corrected_curvatures_grp -* computes the interpolated corrected mean curvature at a vertex of a triangle mesh. +* computes the interpolated corrected mean curvature at vertex `v` of mesh `pmesh`. * * @tparam PolygonMesh a model of `FaceListGraph` * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" @@ -1491,7 +1491,7 @@ interpolated_corrected_mean_curvature_one_vertex(const PolygonMesh& pmesh, /** * \ingroup PMP_corrected_curvatures_grp -* computes the interpolated corrected Gaussian curvature at a vertex of a triangle mesh. +* computes the interpolated corrected Gaussian curvature at vertex `v` of mesh `pmesh`. * * @tparam PolygonMesh a model of `FaceListGraph` * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" @@ -1568,7 +1568,7 @@ interpolated_corrected_gaussian_curvature_one_vertex(const PolygonMesh& pmesh, /** * \ingroup PMP_corrected_curvatures_grp -* computes the interpolated corrected principal curvatures and directions at a vertex of a triangle mesh. +* computes the interpolated corrected principal curvatures and directions at vertex `v` of mesh `pmesh`. * * @tparam PolygonMesh a model of `FaceListGraph` * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" From 661513b16ee05509e00d0975213e928c75443dd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 22 Mar 2023 19:12:28 +0100 Subject: [PATCH 126/142] gaussian -> Gaussian --- .../PackageDescription.txt | 4 +- .../Polygon_mesh_processing.txt | 4 +- .../interpolated_corrected_curvatures_PH.cpp | 2 +- .../interpolated_corrected_curvatures_SM.cpp | 2 +- ...terpolated_corrected_curvatures_vertex.cpp | 4 +- .../interpolated_corrected_curvatures.h | 76 +++++++++---------- ...test_interpolated_corrected_curvatures.cpp | 24 +++--- .../Display/Display_property_plugin.cpp | 10 +-- .../internal/parameters_interface.h | 4 +- 9 files changed, 65 insertions(+), 65 deletions(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt index 9cb257338a72..9c8b5d6f2948 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt @@ -209,11 +209,11 @@ The page \ref bgl_namedparameters "Named Parameters" describes their usage. \cgalCRPSection{Corrected Curvatures} - `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature()` -- `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_Gaussian_curvature()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature_one_vertex()` -- `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature_one_vertex()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_Gaussian_curvature_one_vertex()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions_one_vertex()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures_one_vertex()` - `CGAL::Polygon_mesh_processing::Principal_curvatures_and_directions` diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index 2eb85a80bfbb..65c236e99fc3 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -901,7 +901,7 @@ Polyhedron_3 and other polygonal mesh structures based on the Face Graph Model. These computations are performed using (on all vertices of mesh): - `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature()` -- `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_Gaussian_curvature()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures()` @@ -910,7 +910,7 @@ as the implementation performs the shared computations only once, making it more Similarly, we can use the following functions to compute curvatures on a specific vertex: - `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature_one_vertex()` -- `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature_one_vertex()` +- `CGAL::Polygon_mesh_processing::interpolated_corrected_Gaussian_curvature_one_vertex()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions_one_vertex()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures_one_vertex()` diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_PH.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_PH.cpp index 3cf675c53ca4..0e3923dc67b8 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_PH.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_PH.cpp @@ -38,7 +38,7 @@ int main(int argc, char* argv[]) polyhedron, mean_curvature_map); - PMP::interpolated_corrected_gaussian_curvature( + PMP::interpolated_corrected_Gaussian_curvature( polyhedron, gaussian_curvature_map); diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_SM.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_SM.cpp index d92ec7b8096d..811146dd6412 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_SM.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_SM.cpp @@ -53,7 +53,7 @@ int main(int argc, char* argv[]) mean_curvature_map ); - PMP::interpolated_corrected_gaussian_curvature( + PMP::interpolated_corrected_Gaussian_curvature( smesh, gaussian_curvature_map ); diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_vertex.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_vertex.cpp index e5845a1b3a5a..c0722b25675a 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_vertex.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_vertex.cpp @@ -31,7 +31,7 @@ int main(int argc, char* argv[]) for (vertex_descriptor v : vertices(smesh)) { double h = PMP::interpolated_corrected_mean_curvature_one_vertex(smesh, v); - double g = PMP::interpolated_corrected_gaussian_curvature_one_vertex(smesh, v); + double g = PMP::interpolated_corrected_Gaussian_curvature_one_vertex(smesh, v); PMP::Principal_curvatures_and_directions p = PMP::interpolated_corrected_principal_curvatures_and_directions_one_vertex(smesh, v); @@ -48,7 +48,7 @@ int main(int argc, char* argv[]) // smesh, // v, // CGAL::parameters::vertex_mean_curvature(&h) - // .vertex_gaussian_curvature(&g) + // .vertex_Gaussian_curvature(&g) // ); std::cout << v.idx() << ": HC = " << h diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h index 94a8533ca42b..bffd2657e96c 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h @@ -222,7 +222,7 @@ typename GT::FT interpolated_corrected_mean_curvature_measure_face(const std::ve } template -typename GT::FT interpolated_corrected_gaussian_curvature_measure_face(const std::vector& u) +typename GT::FT interpolated_corrected_Gaussian_curvature_measure_face(const std::vector& u) { const std::size_t n = u.size(); CGAL_precondition(n >= 3); @@ -259,7 +259,7 @@ typename GT::FT interpolated_corrected_gaussian_curvature_measure_face(const std // summing each triangle's measure after triangulation by barycenter split. for (std::size_t i = 0; i < n; i++) { - mu2 += interpolated_corrected_gaussian_curvature_measure_face( + mu2 += interpolated_corrected_Gaussian_curvature_measure_face( std::vector {u[i], u[(i + 1) % n], uc} ); } @@ -483,7 +483,7 @@ Vertex_measures interpolated_corrected_measures_one_vertex_no_radius( const PolygonMesh& pmesh, const typename boost::graph_traits::vertex_descriptor v, const bool is_mean_curvature_selected, - const bool is_gaussian_curvature_selected, + const bool is_Gaussian_curvature_selected, const bool is_principal_curvatures_and_directions_selected, const VPM vpm, const VNM vnm @@ -519,8 +519,8 @@ Vertex_measures interpolated_corrected_measures_one_vertex_no_radius( if (is_mean_curvature_selected) vertex_measures.mean_curvature_measure += interpolated_corrected_mean_curvature_measure_face(u, x); - if (is_gaussian_curvature_selected) - vertex_measures.gaussian_curvature_measure += interpolated_corrected_gaussian_curvature_measure_face(u); + if (is_Gaussian_curvature_selected) + vertex_measures.gaussian_curvature_measure += interpolated_corrected_Gaussian_curvature_measure_face(u); if (is_principal_curvatures_and_directions_selected) { @@ -543,7 +543,7 @@ Vertex_measures interpolated_corrected_measures_one_vertex( const typename boost::graph_traits::vertex_descriptor v, const typename GT::FT radius, const bool is_mean_curvature_selected, - const bool is_gaussian_curvature_selected, + const bool is_Gaussian_curvature_selected, const bool is_principal_curvatures_and_directions_selected, const VPM vpm, const VNM vnm @@ -598,8 +598,8 @@ Vertex_measures interpolated_corrected_measures_one_vertex( if (is_mean_curvature_selected) vertex_measures.mean_curvature_measure += f_ratio * interpolated_corrected_mean_curvature_measure_face(u, x); - if (is_gaussian_curvature_selected) - vertex_measures.gaussian_curvature_measure += f_ratio * interpolated_corrected_gaussian_curvature_measure_face(u); + if (is_Gaussian_curvature_selected) + vertex_measures.gaussian_curvature_measure += f_ratio * interpolated_corrected_Gaussian_curvature_measure_face(u); if (is_principal_curvatures_and_directions_selected) { @@ -674,7 +674,7 @@ template::value; - const bool is_gaussian_curvature_selected = !is_default_parameter::value; + const bool is_Gaussian_curvature_selected = !is_default_parameter::value; const bool is_principal_curvatures_and_directions_selected = !is_default_parameter::value; Vertex_measures vertex_measures; @@ -686,7 +686,7 @@ template::type Vertex_mean_curvature_map; - typedef typename internal_np::Lookup_named_param_def::type Vertex_gaussian_curvature_map; + Default_scalar_map>::type Vertex_Gaussian_curvature_map; typedef Constant_property_map> Default_principal_map; typedef typename internal_np::Lookup_named_param_def::value; - is_gaussian_curvature_selected = !is_default_parameter::value; + is_Gaussian_curvature_selected = !is_default_parameter::value; is_principal_curvatures_and_directions_selected = !is_default_parameter::value; mean_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_mean_curvature_map), Default_scalar_map()); - gaussian_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_gaussian_curvature_map), Default_scalar_map()); + gaussian_curvature_map = choose_parameter(get_parameter(np, internal_np::vertex_Gaussian_curvature_map), Default_scalar_map()); principal_curvatures_and_directions_map = choose_parameter(get_parameter(np, internal_np::vertex_principal_curvatures_and_directions_map), Default_principal_map()); } @@ -842,7 +842,7 @@ class Interpolated_corrected_curvatures_computer { set_named_params(np); - if (is_mean_curvature_selected || is_gaussian_curvature_selected || is_principal_curvatures_and_directions_selected) + if (is_mean_curvature_selected || is_Gaussian_curvature_selected || is_principal_curvatures_and_directions_selected) { set_property_maps(); @@ -872,8 +872,8 @@ class Interpolated_corrected_curvatures_computer if (is_mean_curvature_selected) put(mu1_map, f, interpolated_corrected_mean_curvature_measure_face(u, x)); - if (is_gaussian_curvature_selected) - put(mu2_map, f, interpolated_corrected_gaussian_curvature_measure_face(u)); + if (is_Gaussian_curvature_selected) + put(mu2_map, f, interpolated_corrected_Gaussian_curvature_measure_face(u)); if (is_principal_curvatures_and_directions_selected) put(muXY_map, f, interpolated_corrected_anisotropic_measure_face(u, x)); @@ -899,7 +899,7 @@ class Interpolated_corrected_curvatures_computer if (is_mean_curvature_selected) vertex_measures.mean_curvature_measure += get(mu1_map, f); - if (is_gaussian_curvature_selected) + if (is_Gaussian_curvature_selected) vertex_measures.gaussian_curvature_measure += get(mu2_map, f); if (is_principal_curvatures_and_directions_selected) @@ -957,7 +957,7 @@ class Interpolated_corrected_curvatures_computer if (is_mean_curvature_selected) vertex_measures.mean_curvature_measure += f_ratio * get(mu1_map, fi); - if (is_gaussian_curvature_selected) + if (is_Gaussian_curvature_selected) vertex_measures.gaussian_curvature_measure += f_ratio * get(mu2_map, fi); if (is_principal_curvatures_and_directions_selected) @@ -998,7 +998,7 @@ class Interpolated_corrected_curvatures_computer put(mean_curvature_map, v, 0); } - if (is_gaussian_curvature_selected) { + if (is_Gaussian_curvature_selected) { vertex_measures.area_measure != 0 ? put(gaussian_curvature_map, v, vertex_measures.gaussian_curvature_measure / vertex_measures.area_measure) : put(gaussian_curvature_map, v, 0); @@ -1071,7 +1071,7 @@ class Interpolated_corrected_curvatures_computer * \cgalParamExtra{If this parameter is omitted, mean curvatures will not be computed} * \cgalParamNEnd * -* \cgalParamNBegin{vertex_gaussian_curvature_map} +* \cgalParamNBegin{vertex_Gaussian_curvature_map} * \cgalParamDescription{a property map associating mean curvatures to the vertices of `pmesh`} * \cgalParamType{a class model of `WritablePropertyMap` with * `boost::graph_traits::%vertex_descriptor` @@ -1101,7 +1101,7 @@ class Interpolated_corrected_curvatures_computer * \cgalNamedParamsEnd * * @see `interpolated_corrected_mean_curvature()` -* @see `interpolated_corrected_gaussian_curvature()` +* @see `interpolated_corrected_Gaussian_curvature()` * @see `interpolated_corrected_principal_curvatures_and_directions()` */ template -void interpolated_corrected_gaussian_curvature(const PolygonMesh& pmesh, +void interpolated_corrected_Gaussian_curvature(const PolygonMesh& pmesh, VertexCurvatureMap vcm, const NamedParameters& np = parameters::default_values()) { - interpolated_corrected_curvatures(pmesh, np.vertex_gaussian_curvature_map(vcm)); + interpolated_corrected_curvatures(pmesh, np.vertex_Gaussian_curvature_map(vcm)); } /** @@ -1312,7 +1312,7 @@ void interpolated_corrected_gaussian_curvature(const PolygonMesh& pmesh, * \cgalNamedParamsEnd * * @see `interpolated_corrected_mean_curvature()` -* @see `interpolated_corrected_gaussian_curvature()` +* @see `interpolated_corrected_Gaussian_curvature()` * @see `interpolated_corrected_curvatures()` */ template`} * \cgalParamExtra{If this parameter is omitted, gaussian curvature will not be computed} @@ -1400,7 +1400,7 @@ void interpolated_corrected_principal_curvatures_and_directions(const PolygonMes * * @see `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures()` * @see `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature_one_vertex()` -* @see `CGAL::Polygon_mesh_processing::interpolated_corrected_gaussian_curvature_one_vertex()` +* @see `CGAL::Polygon_mesh_processing::interpolated_corrected_Gaussian_curvature_one_vertex()` * @see `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions_one_vertex()` */ template::type::FT #endif -interpolated_corrected_gaussian_curvature_one_vertex(const PolygonMesh& pmesh, +interpolated_corrected_Gaussian_curvature_one_vertex(const PolygonMesh& pmesh, typename boost::graph_traits::vertex_descriptor v, const NamedParameters& np = parameters::default_values()) { typename GetGeomTraits::type::FT gc; - interpolated_corrected_curvatures_one_vertex(pmesh, v, np.vertex_gaussian_curvature(std::ref(gc))); + interpolated_corrected_curvatures_one_vertex(pmesh, v, np.vertex_Gaussian_curvature(std::ref(gc))); return gc; } @@ -1622,7 +1622,7 @@ interpolated_corrected_gaussian_curvature_one_vertex(const PolygonMesh& pmesh, * * @see `interpolated_corrected_principal_curvatures_and_directions()` * @see `interpolated_corrected_mean_curvature_one_vertex()` -* @see `interpolated_corrected_gaussian_curvature_one_vertex()` +* @see `interpolated_corrected_Gaussian_curvature_one_vertex()` * @see `interpolated_corrected_curvatures_one_vertex()` */ diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp index bd0594652206..c0772ce989bc 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp @@ -78,7 +78,7 @@ void test_average_curvatures(std::string mesh_path, // test_info.expansion_radius -> test if no radius is provided by user. if (test_info.expansion_radius < 0) { PMP::interpolated_corrected_mean_curvature(pmesh, mean_curvature_map); - PMP::interpolated_corrected_gaussian_curvature(pmesh, gaussian_curvature_map); + PMP::interpolated_corrected_Gaussian_curvature(pmesh, gaussian_curvature_map); PMP::interpolated_corrected_principal_curvatures_and_directions(pmesh, principal_curvatures_and_directions_map); } else { @@ -88,7 +88,7 @@ void test_average_curvatures(std::string mesh_path, CGAL::parameters::ball_radius(test_info.expansion_radius) ); - PMP::interpolated_corrected_gaussian_curvature( + PMP::interpolated_corrected_Gaussian_curvature( pmesh, gaussian_curvature_map, CGAL::parameters::ball_radius(test_info.expansion_radius) @@ -125,28 +125,28 @@ void test_average_curvatures(std::string mesh_path, pmesh, CGAL::parameters::ball_radius(test_info.expansion_radius) .vertex_mean_curvature_map(mean_curvature_map) - .vertex_gaussian_curvature_map(gaussian_curvature_map) + .vertex_Gaussian_curvature_map(gaussian_curvature_map) .vertex_principal_curvatures_and_directions_map(principal_curvatures_and_directions_map) ); - Epic_kernel::FT new_mean_curvature_avg = 0, new_gaussian_curvature_avg = 0, new_principal_curvature_avg = 0; + Epic_kernel::FT new_mean_curvature_avg = 0, new_Gaussian_curvature_avg = 0, new_principal_curvature_avg = 0; for (vertex_descriptor v : vertices(pmesh)) { new_mean_curvature_avg += get(mean_curvature_map, v); - new_gaussian_curvature_avg += get(gaussian_curvature_map, v); + new_Gaussian_curvature_avg += get(gaussian_curvature_map, v); new_principal_curvature_avg += get(principal_curvatures_and_directions_map, v).min_curvature + get(principal_curvatures_and_directions_map, v).max_curvature; } new_mean_curvature_avg /= vertices(pmesh).size(); - new_gaussian_curvature_avg /= vertices(pmesh).size(); + new_Gaussian_curvature_avg /= vertices(pmesh).size(); new_principal_curvature_avg /= vertices(pmesh).size() * 2; // are average curvatures computed from interpolated_corrected_curvatures() // equal to average curvatures each computed on its own? assert(passes_comparison(mean_curvature_avg, new_mean_curvature_avg, 0.99)); - assert(passes_comparison(gaussian_curvature_avg, new_gaussian_curvature_avg, 0.99)); + assert(passes_comparison(gaussian_curvature_avg, new_Gaussian_curvature_avg, 0.99)); assert(passes_comparison(principal_curvature_avg, new_principal_curvature_avg, 0.99)); if (compare_single_vertex) @@ -154,7 +154,7 @@ void test_average_curvatures(std::string mesh_path, // computing curvatures together from interpolated_corrected_curvatures() Epic_kernel::FT single_vertex_mean_curvature_avg = 0, - single_vertex_gaussian_curvature_avg = 0, + single_vertex_Gaussian_curvature_avg = 0, single_vertex_principal_curvature_avg = 0; Epic_kernel::FT h, g; @@ -165,23 +165,23 @@ void test_average_curvatures(std::string mesh_path, PMP::interpolated_corrected_curvatures_one_vertex( pmesh, v, - CGAL::parameters::vertex_gaussian_curvature(std::ref(g)) + CGAL::parameters::vertex_Gaussian_curvature(std::ref(g)) .vertex_mean_curvature(std::ref(h)) .vertex_principal_curvatures_and_directions(std::ref(p)) .ball_radius(test_info.expansion_radius) ); single_vertex_mean_curvature_avg += h; - single_vertex_gaussian_curvature_avg += g; + single_vertex_Gaussian_curvature_avg += g; single_vertex_principal_curvature_avg += p.min_curvature + p.max_curvature; } single_vertex_mean_curvature_avg /= vertices(pmesh).size(); - single_vertex_gaussian_curvature_avg /= vertices(pmesh).size(); + single_vertex_Gaussian_curvature_avg /= vertices(pmesh).size(); single_vertex_principal_curvature_avg /= vertices(pmesh).size() * 2; assert(passes_comparison(mean_curvature_avg, single_vertex_mean_curvature_avg, 0.99)); - assert(passes_comparison(gaussian_curvature_avg, single_vertex_gaussian_curvature_avg, 0.99)); + assert(passes_comparison(gaussian_curvature_avg, single_vertex_Gaussian_curvature_avg, 0.99)); assert(passes_comparison(principal_curvature_avg, single_vertex_principal_curvature_avg, 0.99)); } diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index c4c7d6a3c916..050487c9fec2 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -662,7 +662,7 @@ private Q_SLOTS: if (does_exist) sm_item->face_graph()->remove_property_map(pmap); std::tie(pmap, does_exist) = - sm_item->face_graph()->property_map("v:interpolated_corrected_gaussian_curvature"); + sm_item->face_graph()->property_map("v:interpolated_corrected_Gaussian_curvature"); if (does_exist) sm_item->face_graph()->remove_property_map(pmap); }); @@ -748,7 +748,7 @@ private Q_SLOTS: smesh.remove_property_map(mean_curvature); } SMesh::Property_map gaussian_curvature; - std::tie(gaussian_curvature, found) = smesh.property_map("v:interpolated_corrected_gaussian_curvature"); + std::tie(gaussian_curvature, found) = smesh.property_map("v:interpolated_corrected_Gaussian_curvature"); if (found) { smesh.remove_property_map(gaussian_curvature); @@ -851,7 +851,7 @@ private Q_SLOTS: if (mu_index != MEAN_CURVATURE && mu_index != GAUSSIAN_CURVATURE) return; std::string tied_string = (mu_index == MEAN_CURVATURE)? - "v:interpolated_corrected_mean_curvature": "v:interpolated_corrected_gaussian_curvature"; + "v:interpolated_corrected_mean_curvature": "v:interpolated_corrected_Gaussian_curvature"; SMesh& smesh = *item->face_graph(); const auto vnm = smesh.property_map("v:normal_before_perturbation").first; @@ -868,13 +868,13 @@ private Q_SLOTS: if (mu_index == MEAN_CURVATURE) PMP::interpolated_corrected_mean_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expand_radius).vertex_normal_map(vnm)); else - PMP::interpolated_corrected_gaussian_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expand_radius).vertex_normal_map(vnm)); + PMP::interpolated_corrected_Gaussian_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expand_radius).vertex_normal_map(vnm)); } else { if (mu_index == MEAN_CURVATURE) PMP::interpolated_corrected_mean_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expand_radius)); else - PMP::interpolated_corrected_gaussian_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expand_radius)); + PMP::interpolated_corrected_Gaussian_curvature(smesh, mu_i_map, CGAL::parameters::ball_radius(expand_radius)); } double res_min = ARBITRARY_DBL_MAX, res_max = -ARBITRARY_DBL_MAX; diff --git a/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h index 4990dca1ba15..30272955bb00 100644 --- a/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h +++ b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h @@ -91,10 +91,10 @@ CGAL_add_named_parameter(number_of_points_on_edges_t, number_of_points_on_edges, CGAL_add_named_parameter(nb_points_per_area_unit_t, nb_points_per_area_unit, number_of_points_per_area_unit) CGAL_add_named_parameter(nb_points_per_distance_unit_t, nb_points_per_distance_unit, number_of_points_per_distance_unit) CGAL_add_named_parameter(vertex_mean_curvature_map_t, vertex_mean_curvature_map, vertex_mean_curvature_map) -CGAL_add_named_parameter(vertex_gaussian_curvature_map_t, vertex_gaussian_curvature_map, vertex_gaussian_curvature_map) +CGAL_add_named_parameter(vertex_Gaussian_curvature_map_t, vertex_Gaussian_curvature_map, vertex_Gaussian_curvature_map) CGAL_add_named_parameter(vertex_principal_curvatures_and_directions_map_t, vertex_principal_curvatures_and_directions_map, vertex_principal_curvatures_and_directions_map) CGAL_add_named_parameter(vertex_mean_curvature_t, vertex_mean_curvature, vertex_mean_curvature) -CGAL_add_named_parameter(vertex_gaussian_curvature_t, vertex_gaussian_curvature, vertex_gaussian_curvature) +CGAL_add_named_parameter(vertex_Gaussian_curvature_t, vertex_Gaussian_curvature, vertex_Gaussian_curvature) CGAL_add_named_parameter(vertex_principal_curvatures_and_directions_t, vertex_principal_curvatures_and_directions, vertex_principal_curvatures_and_directions) CGAL_add_named_parameter(ball_radius_t, ball_radius, ball_radius) CGAL_add_named_parameter(outward_orientation_t, outward_orientation, outward_orientation) From 556218bf153dcfd7b82861445e0a77e135753c0f Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sat, 25 Mar 2023 11:57:22 +0200 Subject: [PATCH 127/142] gaussian -> Gaussian in docs and comments --- .../Polygon_mesh_processing.txt | 4 ++-- .../interpolated_corrected_curvatures_vertex.cpp | 2 +- .../interpolated_corrected_curvatures.h | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index 65c236e99fc3..e2bee6e295d8 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -890,7 +890,7 @@ not provide storage for the normals. \section PMPICC Computing Curvatures This package provides methods to compute curvatures on polygonal meshes based on Interpolated Corrected Curvatures -on Polyhedral Surfaces \cgalCite{lachaud2020}. This includes mean curvature, gaussian curvature, +on Polyhedral Surfaces \cgalCite{lachaud2020}. This includes mean curvature, Gaussian curvature, principal curvatures and directions. These can be computed on triangle meshes, quad meshes, and meshes with n-gon faces. The algorithms used prove to work well in general. Also, on meshes with noise on vertex positions, they give accurate results, on the condition that the @@ -905,7 +905,7 @@ These computations are performed using (on all vertices of mesh): - `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures()` -Where it is recommended to use the last function for computing multiple curvatures (example: mean and gaussian) +Where it is recommended to use the last function for computing multiple curvatures (example: mean and Gaussian) as the implementation performs the shared computations only once, making it more efficient. Similarly, we can use the following functions to compute curvatures on a specific vertex: diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_vertex.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_vertex.cpp index c0722b25675a..c6bef5faa740 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_vertex.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_vertex.cpp @@ -43,7 +43,7 @@ int main(int argc, char* argv[]) // The following commented lines show this (all mentioned named parameters work on it as well) // we specify which curvatures we want to compute by passing pointers as named parameters // as shown. These pointers are used for storing the result as well. in this example we - // selected mean and gaussian curvatures + // selected mean and Gaussian curvatures // PMP::interpolated_corrected_curvatures_one_vertex( // smesh, // v, diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h index bffd2657e96c..2324b0e9e88c 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h @@ -1024,7 +1024,7 @@ class Interpolated_corrected_curvatures_computer * \ingroup PMP_corrected_curvatures_grp * * computes the interpolated corrected curvatures across the mesh `pmesh`. -* By providing mean, gaussian and/or principal curvature and direction property maps as named parameters, the user +* By providing mean, Gaussian and/or principal curvature and direction property maps as named parameters, the user * can choose which quantites to compute. * * @tparam PolygonMesh a model of `FaceListGraph`. @@ -1076,7 +1076,7 @@ class Interpolated_corrected_curvatures_computer * \cgalParamType{a class model of `WritablePropertyMap` with * `boost::graph_traits::%vertex_descriptor` * as key type and `GT::FT` as value type} -* \cgalParamExtra{If this parameter is omitted, gaussian curvatures will not be computed} +* \cgalParamExtra{If this parameter is omitted, Gaussian curvatures will not be computed} * \cgalParamNEnd * * \cgalParamNBegin{vertex_principal_curvatures_and_directions_map} @@ -1186,7 +1186,7 @@ void interpolated_corrected_mean_curvature(const PolygonMesh& pmesh, /** * \ingroup PMP_corrected_curvatures_grp * -* computes the interpolated corrected gaussian curvature across the mesh `pmesh`. +* computes the interpolated corrected Gaussian curvature across the mesh `pmesh`. * * @tparam PolygonMesh a model of `FaceListGraph`. * @tparam VertexCurvatureMap a model of `WritablePropertyMap` with @@ -1194,7 +1194,7 @@ void interpolated_corrected_mean_curvature(const PolygonMesh& pmesh, * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". * * @param pmesh the polygon mesh. -* @param vcm the vertex property map in which the computed gaussian curvatures are stored. +* @param vcm the vertex property map in which the computed Gaussian curvatures are stored. * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters". * `GT` stands for the type of the object provided to the named parameter `geom_traits()`. * @@ -1328,7 +1328,7 @@ void interpolated_corrected_principal_curvatures_and_directions(const PolygonMes /** * \ingroup PMP_corrected_curvatures_grp * computes the interpolated corrected curvatures at a vertex `v`. -* By providing mean, gaussian and/or principal curvature and direction property maps as named parameters, the user +* By providing mean, Gaussian and/or principal curvature and direction property maps as named parameters, the user * can choose which quantites to compute. * * @tparam PolygonMesh a model of `FaceListGraph` @@ -1374,9 +1374,9 @@ void interpolated_corrected_principal_curvatures_and_directions(const PolygonMes * \cgalParamNEnd * * \cgalParamNBegin{vertex_Gaussian_curvature} -* \cgalParamDescription{a reference to a scalar value to store the gaussian curvature at the vertex `v`} +* \cgalParamDescription{a reference to a scalar value to store the Gaussian curvature at the vertex `v`} * \cgalParamType{`std::reference_wrapper`} -* \cgalParamExtra{If this parameter is omitted, gaussian curvature will not be computed} +* \cgalParamExtra{If this parameter is omitted, Gaussian curvature will not be computed} * \cgalParamNEnd * * \cgalParamNBegin{vertex_principal_curvatures_and_directions} From 2bc8b1b49565f9f033c40d30dd08d1f6192d99f5 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sat, 25 Mar 2023 13:29:15 +0200 Subject: [PATCH 128/142] user man doc improvements --- .../Polygon_mesh_processing.txt | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index e2bee6e295d8..49614be67c91 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -896,10 +896,10 @@ and meshes with n-gon faces. The algorithms used prove to work well in general. with noise on vertex positions, they give accurate results, on the condition that the correct vertex normals are provided. -The implementation is generic in terms of mesh data structure. It can be used on Surface_mesh, -Polyhedron_3 and other polygonal mesh structures based on the Face Graph Model. +The implementation is generic in terms of mesh data structure. It can be used on `Surface_mesh`, +`Polyhedron_3` and other polygonal mesh structures based on the concept `FaceGraph`. -These computations are performed using (on all vertices of mesh): +These computations are performed using (on all vertices of the mesh): - `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_Gaussian_curvature()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions()` @@ -916,29 +916,25 @@ Similarly, we can use the following functions to compute curvatures on a specifi \cgalFigureRef{icc_diff_radius} shows how the mean curvature changes depending on -the ball_radius named parameter which can be set to a value > 0 to get a smoother -distribution of values and "diffuse" the extreme values of curvatures across the mesh. +the named parameter `ball_radius`, which can be set to a value > 0 to get a smoother +distribution of values and "diffuses" the extreme values of curvatures across the mesh. \cgalFigureAnchor{icc_diff_radius}
- +
\cgalFigureCaptionBegin{icc_diff_radius} -The mean curvature distribution on a bear mesh with different values for the expanding ball radius +The mean curvature distribution on a bear mesh with different values for the ball radius parameter \cgalFigureCaptionEnd -Property maps are used to record the computed curvatures as shown in examples. - - -Property maps are an API introduced in the boost library that allows associating -values to keys. In the following examples, for each property map, we associate +\ref BGLPropertyMaps are used to record the computed curvatures as shown in examples. In the following examples, for each property map, we associate a curvature value to each vertex. \subsection ICCExampleSM Interpolated Corrected Curvatures on a Surface Mesh Example The following example illustrates how to compute the curvatures on vertices -and store them in property maps provided by the class `Surface_mesh`. +and store them in the property maps provided by the class `Surface_mesh`. \cgalExample{Polygon_mesh_processing/interpolated_corrected_curvatures_SM.cpp} From 49c12d9265f2b0c02fd816f82d82f5e9141c4504 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sat, 25 Mar 2023 13:44:36 +0200 Subject: [PATCH 129/142] ref doc fixes --- .../interpolated_corrected_curvatures.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h index 2324b0e9e88c..71a2ceaaa911 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h @@ -1072,7 +1072,7 @@ class Interpolated_corrected_curvatures_computer * \cgalParamNEnd * * \cgalParamNBegin{vertex_Gaussian_curvature_map} -* \cgalParamDescription{a property map associating mean curvatures to the vertices of `pmesh`} +* \cgalParamDescription{a property map associating Gaussian curvatures to the vertices of `pmesh`} * \cgalParamType{a class model of `WritablePropertyMap` with * `boost::graph_traits::%vertex_descriptor` * as key type and `GT::FT` as value type} @@ -1080,11 +1080,11 @@ class Interpolated_corrected_curvatures_computer * \cgalParamNEnd * * \cgalParamNBegin{vertex_principal_curvatures_and_directions_map} -* \cgalParamDescription{a property map associating mean curvatures to the vertices of `pmesh`} +* \cgalParamDescription{a property map associating principal curvatures and directions to the vertices of `pmesh`} * \cgalParamType{a class model of `WritablePropertyMap` with * `boost::graph_traits::%vertex_descriptor` * as key type and `Principal_curvatures_and_directions` as value type} -* \cgalParamExtra{If this parameter is omitted, mean principal will not be computed} +* \cgalParamExtra{If this parameter is omitted, principal curvatures and directions will not be computed} * \cgalParamNEnd * * \cgalParamNBegin{ball_radius} @@ -1256,7 +1256,7 @@ void interpolated_corrected_Gaussian_curvature(const PolygonMesh& pmesh, /** * \ingroup PMP_corrected_curvatures_grp * -* computes the interpolated corrected principal curvatures across the mesh `pmesh`. +* computes the interpolated corrected principal curvatures and directions across the mesh `pmesh`. * * @tparam PolygonMesh a model of `FaceListGraph`. * @tparam VertexCurvatureMap a model of `WritablePropertyMap` with @@ -1265,7 +1265,7 @@ void interpolated_corrected_Gaussian_curvature(const PolygonMesh& pmesh, * @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". * * @param pmesh the polygon mesh. -* @param vcm the vertex property map in which the computed principal curvatures are stored. +* @param vcm the vertex property map in which the computed principal curvatures and directions are stored. * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below * `GT` stands for the type of the object provided to the named parameter `geom_traits()`. * From 057b6fc2dd5011052b1049bbbfbc3728c3b875e8 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 27 Mar 2023 17:20:26 +0200 Subject: [PATCH 130/142] gaussian -> Gaussian in example files --- .../interpolated_corrected_curvatures_PH.cpp | 6 +++--- .../interpolated_corrected_curvatures_SM.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_PH.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_PH.cpp index 0e3923dc67b8..ecf40b840829 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_PH.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_PH.cpp @@ -30,7 +30,7 @@ int main(int argc, char* argv[]) boost::property_map>::type mean_curvature_map = get(CGAL::dynamic_vertex_property_t(), polyhedron), - gaussian_curvature_map = get(CGAL::dynamic_vertex_property_t(), polyhedron); + Gaussian_curvature_map = get(CGAL::dynamic_vertex_property_t(), polyhedron); boost::property_map>>::type principal_curvatures_and_directions_map = get(CGAL::dynamic_vertex_property_t>(), polyhedron); @@ -40,7 +40,7 @@ int main(int argc, char* argv[]) PMP::interpolated_corrected_Gaussian_curvature( polyhedron, - gaussian_curvature_map); + Gaussian_curvature_map); PMP::interpolated_corrected_principal_curvatures_and_directions( polyhedron, @@ -69,7 +69,7 @@ int main(int argc, char* argv[]) { auto PC = get(principal_curvatures_and_directions_map, v); std::cout << i << ": HC = " << get(mean_curvature_map, v) - << ", GC = " << get(gaussian_curvature_map, v) << "\n" + << ", GC = " << get(Gaussian_curvature_map, v) << "\n" << ", PC = [ " << PC.min_curvature << " , " << PC.max_curvature << " ]\n"; i++; } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_SM.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_SM.cpp index 811146dd6412..ab985e5068d0 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_SM.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_SM.cpp @@ -29,11 +29,11 @@ int main(int argc, char* argv[]) // creating and tying surface mesh property maps for curvatures (with defaults = 0) bool created = false; - Surface_Mesh::Property_map mean_curvature_map, gaussian_curvature_map; + Surface_Mesh::Property_map mean_curvature_map, Gaussian_curvature_map; boost::tie(mean_curvature_map, created) = smesh.add_property_map("v:mean_curvature_map", 0); assert(created); - boost::tie(gaussian_curvature_map, created) = smesh.add_property_map("v:gaussian_curvature_map", 0); + boost::tie(Gaussian_curvature_map, created) = smesh.add_property_map("v:Gaussian_curvature_map", 0); assert(created); // we use a tuple of 2 scalar values and 2 vectors for principal curvatures and directions @@ -55,7 +55,7 @@ int main(int argc, char* argv[]) PMP::interpolated_corrected_Gaussian_curvature( smesh, - gaussian_curvature_map + Gaussian_curvature_map ); PMP::interpolated_corrected_principal_curvatures_and_directions( @@ -91,7 +91,7 @@ int main(int argc, char* argv[]) { auto PC = principal_curvatures_and_directions_map[v]; std::cout << v.idx() << ": HC = " << mean_curvature_map[v] - << ", GC = " << gaussian_curvature_map[v] << "\n" + << ", GC = " << Gaussian_curvature_map[v] << "\n" << ", PC = [ " << PC.min_curvature << " , " << PC.max_curvature << " ]\n"; } } From 5aa995dbe7a24727d22bcbee6d3d2170b0d3274b Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 27 Mar 2023 17:45:16 +0200 Subject: [PATCH 131/142] missing dots in ref documentation --- .../interpolated_corrected_curvatures.h | 250 +++++++++--------- 1 file changed, 125 insertions(+), 125 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h index 71a2ceaaa911..a22761691b18 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h @@ -1037,54 +1037,54 @@ class Interpolated_corrected_curvatures_computer * \cgalNamedParamsBegin * * \cgalParamNBegin{vertex_point_map} -* \cgalParamDescription{a property map associating points to the vertices of `pmesh`} +* \cgalParamDescription{a property map associating points to the vertices of `pmesh`.} * \cgalParamType{a class model of `ReadablePropertyMap` with * `boost::graph_traits::%vertex_descriptor` -* as key type and `GT::Point_3` as value type} -* \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`} +* as key type and `GT::Point_3` as value type.} +* \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`.} * \cgalParamExtra{If this parameter is omitted, an internal property map for * `CGAL::vertex_point_t` must be available in `PolygonMesh`.} * \cgalParamNEnd * * \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::%vertex_descriptor` -* as key type and `GT::Vector_3` as value type} -* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} +* as key type and `GT::Vector_3` as value type.} +* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`.} * \cgalParamExtra{If this parameter is omitted, vertex normals will be -* computed using `compute_vertex_normals()`} +* computed using `compute_vertex_normals()`.} * \cgalParamNEnd * * \cgalParamNBegin{geom_traits} -* \cgalParamDescription{an instance of a geometric traits class} +* \cgalParamDescription{an instance of a geometric traits class.} * \cgalParamType{a class model of `Kernel`} -* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`} +* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`.} * \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.} * \cgalParamNEnd * * \cgalParamNBegin{vertex_mean_curvature_map} -* \cgalParamDescription{a property map associating mean curvatures to the vertices of `pmesh`} +* \cgalParamDescription{a property map associating mean curvatures to the vertices of `pmesh`.} * \cgalParamType{a class model of `WritablePropertyMap` with * `boost::graph_traits::%vertex_descriptor` * as key type and `GT::FT` as value type} -* \cgalParamExtra{If this parameter is omitted, mean curvatures will not be computed} +* \cgalParamExtra{If this parameter is omitted, mean curvatures will not be computed.} * \cgalParamNEnd * * \cgalParamNBegin{vertex_Gaussian_curvature_map} -* \cgalParamDescription{a property map associating Gaussian curvatures to the vertices of `pmesh`} +* \cgalParamDescription{a property map associating Gaussian curvatures to the vertices of `pmesh`.} * \cgalParamType{a class model of `WritablePropertyMap` with * `boost::graph_traits::%vertex_descriptor` -* as key type and `GT::FT` as value type} -* \cgalParamExtra{If this parameter is omitted, Gaussian curvatures will not be computed} +* as key type and `GT::FT` as value type.} +* \cgalParamExtra{If this parameter is omitted, Gaussian curvatures will not be computed.} * \cgalParamNEnd * * \cgalParamNBegin{vertex_principal_curvatures_and_directions_map} -* \cgalParamDescription{a property map associating principal curvatures and directions to the vertices of `pmesh`} +* \cgalParamDescription{a property map associating principal curvatures and directions to the vertices of `pmesh`.} * \cgalParamType{a class model of `WritablePropertyMap` with * `boost::graph_traits::%vertex_descriptor` -* as key type and `Principal_curvatures_and_directions` as value type} -* \cgalParamExtra{If this parameter is omitted, principal curvatures and directions will not be computed} +* as key type and `Principal_curvatures_and_directions` as value type.} +* \cgalParamExtra{If this parameter is omitted, principal curvatures and directions will not be computed.} * \cgalParamNEnd * * \cgalParamNBegin{ball_radius} @@ -1095,7 +1095,7 @@ class Interpolated_corrected_curvatures_computer * \cgalParamType{`GT::FT`} * \cgalParamDefault{`-1`} * \cgalParamExtra{If this parameter is omitted (`-1`), the expansion is then just a sum of -* measures on faces around the vertex} +* measures on faces around the vertex.} * \cgalParamNEnd * * \cgalNamedParamsEnd @@ -1130,29 +1130,29 @@ void interpolated_corrected_curvatures(const PolygonMesh& pmesh, * \cgalNamedParamsBegin * * \cgalParamNBegin{vertex_point_map} -* \cgalParamDescription{a property map associating points to the vertices of `pmesh`} +* \cgalParamDescription{a property map associating points to the vertices of `pmesh`.} * \cgalParamType{a class model of `ReadablePropertyMap` with * `boost::graph_traits::%vertex_descriptor` -* as key type and `GT::Point_3` as value type} -* \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`} +* as key type and `GT::Point_3` as value type.} +* \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`.} * \cgalParamExtra{If this parameter is omitted, an internal property map for * `CGAL::vertex_point_t` must be available in `PolygonMesh`.} * \cgalParamNEnd * * \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::%vertex_descriptor` -* as key type and `GT::Vector_3` as value type} -* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} +* as key type and `GT::Vector_3` as value type.} +* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`.} * \cgalParamExtra{If this parameter is omitted, vertex normals will be -* computed using `compute_vertex_normals()`} +* computed using `compute_vertex_normals()`.} * \cgalParamNEnd * * \cgalParamNBegin{geom_traits} -* \cgalParamDescription{an instance of a geometric traits class} +* \cgalParamDescription{an instance of a geometric traits class.} * \cgalParamType{a class model of `Kernel`} -* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`} +* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`.} * \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.} * \cgalParamNEnd * @@ -1160,11 +1160,11 @@ void interpolated_corrected_curvatures(const PolygonMesh& pmesh, * \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures * by summing measures of faces inside a ball of this radius centered at the * vertex expanded from. The summed face measures are weighted by their -* inclusion ratio inside this ball} +* inclusion ratio inside this ball.} * \cgalParamType{`GT::FT`} * \cgalParamDefault{`-1`} * \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of -* measures on faces around the vertex} +* measures on faces around the vertex.} * \cgalParamNEnd * * \cgalNamedParamsEnd @@ -1201,29 +1201,29 @@ void interpolated_corrected_mean_curvature(const PolygonMesh& pmesh, * \cgalNamedParamsBegin * * \cgalParamNBegin{vertex_point_map} -* \cgalParamDescription{a property map associating points to the vertices of `pmesh`} +* \cgalParamDescription{a property map associating points to the vertices of `pmesh`.} * \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, pmesh)`} +* as key type and `%Point_3` as value type.} +* \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`.} * \cgalParamExtra{If this parameter is omitted, an internal property map for * `CGAL::vertex_point_t` must be available in `PolygonMesh`.} * \cgalParamNEnd * * \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 `GT::ReadablePropertyMap` with * `boost::graph_traits::%vertex_descriptor` -* as key type and `%Vector_3` as value type} -* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} +* as key type and `%Vector_3` as value type.} +* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`.} * \cgalParamExtra{If this parameter is omitted, vertex normals will be -* computed using `compute_vertex_normals()`} +* computed using `compute_vertex_normals()`.} * \cgalParamNEnd * * \cgalParamNBegin{geom_traits} -* \cgalParamDescription{an instance of a geometric traits class} +* \cgalParamDescription{an instance of a geometric traits class.} * \cgalParamType{a class model of `Kernel`} -* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`} +* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`.} * \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.} * \cgalParamNEnd * @@ -1231,11 +1231,11 @@ void interpolated_corrected_mean_curvature(const PolygonMesh& pmesh, * \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures * by summing measures of faces inside a ball of this radius centered at the * vertex expanded from. The summed face measures are weighted by their -* inclusion ratio inside this ball} +* inclusion ratio inside this ball.} * \cgalParamType{`GT::FT`} * \cgalParamDefault{`-1`} * \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of -* measures on faces around the vertex} +* measures on faces around the vertex.} * \cgalParamNEnd * * \cgalNamedParamsEnd @@ -1272,29 +1272,29 @@ void interpolated_corrected_Gaussian_curvature(const PolygonMesh& pmesh, * \cgalNamedParamsBegin * * \cgalParamNBegin{vertex_point_map} -* \cgalParamDescription{a property map associating points to the vertices of `pmesh`} +* \cgalParamDescription{a property map associating points to the vertices of `pmesh`.} * \cgalParamType{a class model of `ReadablePropertyMap` with * `boost::graph_traits::%vertex_descriptor` -* as key type and `GT::Point_3` as value type} -* \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`} +* as key type and `GT::Point_3` as value type.} +* \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`.} * \cgalParamExtra{If this parameter is omitted, an internal property map for * `CGAL::vertex_point_t` must be available in `PolygonMesh`.} * \cgalParamNEnd * * \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::%vertex_descriptor` -* as key type and `GT::Vector_3` as value type} -* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} +* as key type and `GT::Vector_3` as value type.} +* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`.} * \cgalParamExtra{If this parameter is omitted, vertex normals will be -* computed using `compute_vertex_normals()`} +* computed using `compute_vertex_normals()`.} * \cgalParamNEnd * * \cgalParamNBegin{geom_traits} -* \cgalParamDescription{an instance of a geometric traits class} +* \cgalParamDescription{an instance of a geometric traits class.} * \cgalParamType{a class model of `Kernel`} -* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`} +* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`.} * \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.} * \cgalParamNEnd * @@ -1302,11 +1302,11 @@ void interpolated_corrected_Gaussian_curvature(const PolygonMesh& pmesh, * \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures * by summing measures of faces inside a ball of this radius centered at the * vertex expanded from. The summed face measures are weighted by their -* inclusion ratio inside this ball} +* inclusion ratio inside this ball.} * \cgalParamType{`GT::FT`} * \cgalParamDefault{`-1`} * \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of -* measures on faces around the vertex} +* measures on faces around the vertex.} * \cgalParamNEnd * * \cgalNamedParamsEnd @@ -1331,58 +1331,58 @@ void interpolated_corrected_principal_curvatures_and_directions(const PolygonMes * By providing mean, Gaussian and/or principal curvature and direction property maps as named parameters, the user * can choose which quantites to compute. * -* @tparam PolygonMesh a model of `FaceListGraph` -* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" +* @tparam PolygonMesh a model of `FaceListGraph`. +* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". * -* @param pmesh the polygon mesh -* @param v the vertex of `pmesh` to compute the curvatures at +* @param pmesh the polygon mesh. +* @param v the vertex of `pmesh` to compute the curvatures at. * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below * `GT` stands for the type of the object provided to the named parameter `geom_traits()`. * * \cgalNamedParamsBegin * \cgalParamNBegin{vertex_point_map} -* \cgalParamDescription{a property map associating points to the vertices of `pmesh`} +* \cgalParamDescription{a property map associating points to the vertices of `pmesh`.} * \cgalParamType{a class model of `ReadablePropertyMap` with * `boost::graph_traits::%vertex_descriptor` -* as key type and `GT::Point_3` as value type} -* \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`} +* as key type and `GT::Point_3` as value type.} +* \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`.} * \cgalParamExtra{If this parameter is omitted, an internal property map for * `CGAL::vertex_point_t` must be available in `PolygonMesh`.} * \cgalParamNEnd * * \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::%vertex_descriptor` -* as key type and `GT::Vector_3` as value type} -* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} +* as key type and `GT::Vector_3` as value type.} +* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`.} * \cgalParamExtra{If this parameter is omitted, vertex normals will be -* computed using `compute_vertex_normals()`} +* computed using `compute_vertex_normals()`.} * \cgalParamNEnd * * \cgalParamNBegin{geom_traits} -* \cgalParamDescription{an instance of a geometric traits class} +* \cgalParamDescription{an instance of a geometric traits class.} * \cgalParamType{a class model of `Kernel`} -* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`} +* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`.} * \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.} * \cgalParamNEnd * * \cgalParamNBegin{vertex_mean_curvature} -* \cgalParamDescription{a reference to a scalar value to store the mean curvature at the vertex `v`} -* \cgalParamType{`std::reference_wrapper`} -* \cgalParamExtra{If this parameter is omitted, mean curvature will not be computed} +* \cgalParamDescription{a reference to a scalar value to store the mean curvature at the vertex `v`.} +* \cgalParamType{`std::reference_wrapper`.} +* \cgalParamExtra{If this parameter is omitted, mean curvature will not be computed.} * \cgalParamNEnd * * \cgalParamNBegin{vertex_Gaussian_curvature} -* \cgalParamDescription{a reference to a scalar value to store the Gaussian curvature at the vertex `v`} -* \cgalParamType{`std::reference_wrapper`} -* \cgalParamExtra{If this parameter is omitted, Gaussian curvature will not be computed} +* \cgalParamDescription{a reference to a scalar value to store the Gaussian curvature at the vertex `v`.} +* \cgalParamType{`std::reference_wrapper`.} +* \cgalParamExtra{If this parameter is omitted, Gaussian curvature will not be computed.} * \cgalParamNEnd * * \cgalParamNBegin{vertex_principal_curvatures_and_directions} -* \cgalParamDescription{a reference to an`Principal_curvatures_and_directions` object to store the principal curvatures and directions at the vertex `v`} -* \cgalParamType{`std::reference_wrapper>`} -* \cgalParamExtra{If this parameter is omitted, principal curvatures and directions will not be computed} +* \cgalParamDescription{a reference to an`Principal_curvatures_and_directions` object to store the principal curvatures and directions at the vertex `v`.} +* \cgalParamType{`std::reference_wrapper>`.} +* \cgalParamExtra{If this parameter is omitted, principal curvatures and directions will not be computed.} * \cgalParamNEnd * * \cgalParamNBegin{ball_radius} @@ -1393,7 +1393,7 @@ void interpolated_corrected_principal_curvatures_and_directions(const PolygonMes * \cgalParamType{`GT::FT`} * \cgalParamDefault{`-1`} * \cgalParamExtra{If this parameter is omitted (`-1`), the epansion is then just a sum of -* measures on faces around the vertex} +* measures on faces around the vertex.} * \cgalParamNEnd * * \cgalNamedParamsEnd @@ -1416,39 +1416,39 @@ void interpolated_corrected_curvatures_one_vertex(const PolygonMesh& pmesh, * \ingroup PMP_corrected_curvatures_grp * computes the interpolated corrected mean curvature at vertex `v` of mesh `pmesh`. * -* @tparam PolygonMesh a model of `FaceListGraph` -* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" +* @tparam PolygonMesh a model of `FaceListGraph`. +* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". * -* @param pmesh the polygon mesh -* @param v the vertex of `pmesh` to compute the mean curvature at +* @param pmesh the polygon mesh. +* @param v the vertex of `pmesh` to compute the mean curvature at. * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below * `GT` stands for the type of the object provided to the named parameter `geom_traits()`. * * \cgalNamedParamsBegin * \cgalParamNBegin{vertex_point_map} -* \cgalParamDescription{a property map associating points to the vertices of `pmesh`} +* \cgalParamDescription{a property map associating points to the vertices of `pmesh`.} * \cgalParamType{a class model of `ReadablePropertyMap` with * `boost::graph_traits::%vertex_descriptor` -* as key type and `GT::Point_3` as value type} -* \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`} +* as key type and `GT::Point_3` as value type.} +* \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`.} * \cgalParamExtra{If this parameter is omitted, an internal property map for * `CGAL::vertex_point_t` must be available in `PolygonMesh`.} * \cgalParamNEnd * * \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::%vertex_descriptor` -* as key type and `GT::Vector_3` as value type} -* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} +* as key type and `GT::Vector_3` as value type.} +* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`.} * \cgalParamExtra{If this parameter is omitted, vertex normals will be -* computed using `compute_vertex_normals()`} +* computed using `compute_vertex_normals()`.} * \cgalParamNEnd * * \cgalParamNBegin{geom_traits} -* \cgalParamDescription{an instance of a geometric traits class} -* \cgalParamType{a class model of `Kernel`} -* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`} +* \cgalParamDescription{an instance of a geometric traits class.} +* \cgalParamType{a class model of `Kernel`.} +* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`.} * \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.} * \cgalParamNEnd * @@ -1456,16 +1456,16 @@ void interpolated_corrected_curvatures_one_vertex(const PolygonMesh& pmesh, * \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures * by summing measures of faces inside a ball of this radius centered at the * vertex expanded from. The summed face measures are weighted by their -* inclusion ratio inside this ball} +* inclusion ratio inside this ball.} * \cgalParamType{`GT::FT`} * \cgalParamDefault{`-1`} * \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of -* measures on faces around the vertex} +* measures on faces around the vertex.} * \cgalParamNEnd * * \cgalNamedParamsEnd * -* @return the interpolated corrected mean curvature at the vertex `v` +* @return the interpolated corrected mean curvature at the vertex `v`. * * @see `interpolated_corrected_mean_curvature()` * @see `interpolated_corrected_Gaussian_curvature_one_vertex()` @@ -1493,39 +1493,39 @@ interpolated_corrected_mean_curvature_one_vertex(const PolygonMesh& pmesh, * \ingroup PMP_corrected_curvatures_grp * computes the interpolated corrected Gaussian curvature at vertex `v` of mesh `pmesh`. * -* @tparam PolygonMesh a model of `FaceListGraph` -* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" +* @tparam PolygonMesh a model of `FaceListGraph`. +* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". * -* @param pmesh the polygon mesh -* @param v the vertex of `pmesh` to compute the Gaussian curvature at +* @param pmesh the polygon mesh. +* @param v the vertex of `pmesh` to compute the Gaussian curvature at. * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below * `GT` stands for the type of the object provided to the named parameter `geom_traits()`. * * \cgalNamedParamsBegin * \cgalParamNBegin{vertex_point_map} -* \cgalParamDescription{a property map associating points to the vertices of `pmesh`} +* \cgalParamDescription{a property map associating points to the vertices of `pmesh`.} * \cgalParamType{a class model of `ReadablePropertyMap` with * `boost::graph_traits::%vertex_descriptor` -* as key type and `GT::Point_3` as value type} -* \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`} +* as key type and `GT::Point_3` as value type.} +* \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`.} * \cgalParamExtra{If this parameter is omitted, an internal property map for * `CGAL::vertex_point_t` must be available in `PolygonMesh`.} * \cgalParamNEnd * * \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::%vertex_descriptor` -* as key type and `GT::Vector_3` as value type} -* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} +* as key type and `GT::Vector_3` as value type.} +* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`.} * \cgalParamExtra{If this parameter is omitted, vertex normals will be -* computed using `compute_vertex_normals()`} +* computed using `compute_vertex_normals()`.} * \cgalParamNEnd * * \cgalParamNBegin{geom_traits} -* \cgalParamDescription{an instance of a geometric traits class} -* \cgalParamType{a class model of `Kernel`} -* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`} +* \cgalParamDescription{an instance of a geometric traits class.} +* \cgalParamType{a class model of `Kernel`.} +* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`.} * \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.} * \cgalParamNEnd * @@ -1533,16 +1533,16 @@ interpolated_corrected_mean_curvature_one_vertex(const PolygonMesh& pmesh, * \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures * by summing measures of faces inside a ball of this radius centered at the * vertex expanded from. The summed face measures are weighted by their -* inclusion ratio inside this ball} +* inclusion ratio inside this ball.} * \cgalParamType{`GT::FT`} * \cgalParamDefault{`-1`} * \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of -* measures on faces around the vertex} +* measures on faces around the vertex.} * \cgalParamNEnd * * \cgalNamedParamsEnd * -* @return the interpolated corrected Gaussian curvature at the vertex `v` +* @return the interpolated corrected Gaussian curvature at the vertex `v`. * * @see `interpolated_corrected_Gaussian_curvature()` * @see `interpolated_corrected_mean_curvature_one_vertex()` @@ -1570,39 +1570,39 @@ interpolated_corrected_Gaussian_curvature_one_vertex(const PolygonMesh& pmesh, * \ingroup PMP_corrected_curvatures_grp * computes the interpolated corrected principal curvatures and directions at vertex `v` of mesh `pmesh`. * -* @tparam PolygonMesh a model of `FaceListGraph` -* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" +* @tparam PolygonMesh a model of `FaceListGraph`. +* @tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters". * -* @param pmesh the polygon mesh -* @param v the vertex of `pmesh` to compute the principal curvatures and directions at +* @param pmesh the polygon mesh. +* @param v the vertex of `pmesh` to compute the principal curvatures and directions at. * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below * `GT` stands for the type of the object provided to the named parameter `geom_traits()`. * * \cgalNamedParamsBegin * \cgalParamNBegin{vertex_point_map} -* \cgalParamDescription{a property map associating points to the vertices of `pmesh`} +* \cgalParamDescription{a property map associating points to the vertices of `pmesh`.} * \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, pmesh)`} +* as key type and `%Point_3` as value type.} +* \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`.} * \cgalParamExtra{If this parameter is omitted, an internal property map for * `CGAL::vertex_point_t` must be available in `PolygonMesh`.} * \cgalParamNEnd * * \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::%vertex_descriptor` -* as key type and `%Vector_3` as value type} -* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`} +* as key type and `%Vector_3` as value type.} +* \cgalParamDefault{`get(dynamic_vertex_property_t(), pmesh)`.} * \cgalParamExtra{If this parameter is omitted, vertex normals will be -* computed using `compute_vertex_normals()`} +* computed using `compute_vertex_normals()`.} * \cgalParamNEnd * * \cgalParamNBegin{geom_traits} -* \cgalParamDescription{an instance of a geometric traits class} -* \cgalParamType{a class model of `Kernel`} -* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`} +* \cgalParamDescription{an instance of a geometric traits class.} +* \cgalParamType{a class model of `Kernel`.} +* \cgalParamDefault{a \cgal Kernel deduced from the point type, using `CGAL::Kernel_traits`.} * \cgalParamExtra{The geometric traits class must be compatible with the vertex point type.} * \cgalParamNEnd * @@ -1610,15 +1610,15 @@ interpolated_corrected_Gaussian_curvature_one_vertex(const PolygonMesh& pmesh, * \cgalParamDescription{a scalar value specifying the radius used for expanding curvature measures * by summing measures of faces inside a ball of this radius centered at the * vertex expanded from. The summed face measures are weighted by their -* inclusion ratio inside this ball} +* inclusion ratio inside this ball.} * \cgalParamType{`GT::FT`} * \cgalParamDefault{`-1`} * \cgalParamExtra{If this parameter is omitted (`-1`), the expansion will just by a weightless sum of -* measures on faces around the vertex} +* measures on faces around the vertex.} * \cgalParamNEnd * \cgalNamedParamsEnd * -* @return the interpolated corrected principal curvatures and directions at the vertex `v` +* @return the interpolated corrected principal curvatures and directions at the vertex `v`. * * @see `interpolated_corrected_principal_curvatures_and_directions()` * @see `interpolated_corrected_mean_curvature_one_vertex()` From 2884d8b3cbdd14341d63142d4e96949e3a06be97 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 27 Mar 2023 18:06:06 +0200 Subject: [PATCH 132/142] using is_zero() & is_negative() for FT variables --- .../interpolated_corrected_curvatures.h | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h index a22761691b18..72f7b1b93d07 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h @@ -470,8 +470,8 @@ Principal_curvatures_and_directions principal_curvatures_and_directions_from // returning principal curvatures and directions (with the correct sign) return Principal_curvatures_and_directions( - (v_mu0 != 0.0) ? -eig_vals[1] / v_mu0 : 0.0, - (v_mu0 != 0.0) ? -eig_vals[0] / v_mu0 : 0.0, + (!is_zero(v_mu0)) ? -eig_vals[1] / v_mu0 : 0.0, + (!is_zero(v_mu0)) ? -eig_vals[0] / v_mu0 : 0.0, min_eig_vec, max_eig_vec ); @@ -591,7 +591,7 @@ Vertex_measures interpolated_corrected_measures_one_vertex( // if it is not 0 (not completely outside), compute measures for selected curvatures (area is always computed) // and add neighboring faces to the bfs queue - if (f_ratio != 0.0) + if (!is_zero(f_ratio)) { vertex_measures.area_measure += f_ratio * interpolated_corrected_area_measure_face(u, x); @@ -669,7 +669,7 @@ template(pmesh) * 1e-6; // determine which curvatures are selected @@ -680,7 +680,7 @@ template vertex_measures; // if the radius is negative, we do not expand the ball (only the incident faces) - if (radius < 0) + if (is_negative(radius)) { vertex_measures = interpolated_corrected_measures_one_vertex_no_radius( pmesh, @@ -708,12 +708,12 @@ template(pmesh) * 1e-6; else ball_radius = radius; @@ -950,7 +950,7 @@ class Interpolated_corrected_curvatures_computer // if the face is inside the ball, add the measures // only add the measures for the selected curvatures (area measure is always added) - if (f_ratio != 0.0) + if (!is_zero(f_ratio)) { vertex_measures.area_measure += f_ratio * get(mu0_map, fi); @@ -986,20 +986,20 @@ class Interpolated_corrected_curvatures_computer for (Vertex_descriptor v : vertices(pmesh)) { // expand the computed measures (on faces) to the vertices - Vertex_measures vertex_measures = (ball_radius < 0) ? + Vertex_measures vertex_measures = (is_negative(ball_radius)) ? expand_interpolated_corrected_measure_vertex_no_radius(v) : expand_interpolated_corrected_measure_vertex(v); // compute the selected curvatures from the expanded measures and store them in the property maps // if the area measure is zero, the curvature is set to zero if (is_mean_curvature_selected) { - vertex_measures.area_measure != 0 ? + !is_zero(vertex_measures.area_measure) ? put(mean_curvature_map, v, 0.5 * vertex_measures.mean_curvature_measure / vertex_measures.area_measure) : put(mean_curvature_map, v, 0); } if (is_Gaussian_curvature_selected) { - vertex_measures.area_measure != 0 ? + !is_zero(vertex_measures.area_measure) ? put(gaussian_curvature_map, v, vertex_measures.gaussian_curvature_measure / vertex_measures.area_measure) : put(gaussian_curvature_map, v, 0); } From 4279a734bfb71821609ee14ea5bf33bcc90831cf Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 27 Mar 2023 19:35:31 +0200 Subject: [PATCH 133/142] minor linting changing --- .../interpolated_corrected_curvatures_PH.cpp | 16 ++++------ .../interpolated_corrected_curvatures_SM.cpp | 31 +++++++++---------- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_PH.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_PH.cpp index ecf40b840829..0aa0c196d3f5 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_PH.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_PH.cpp @@ -31,20 +31,16 @@ int main(int argc, char* argv[]) boost::property_map>::type mean_curvature_map = get(CGAL::dynamic_vertex_property_t(), polyhedron), Gaussian_curvature_map = get(CGAL::dynamic_vertex_property_t(), polyhedron); + boost::property_map>>::type - principal_curvatures_and_directions_map = get(CGAL::dynamic_vertex_property_t>(), polyhedron); + principal_curvatures_and_directions_map = + get(CGAL::dynamic_vertex_property_t>(), polyhedron); - PMP::interpolated_corrected_mean_curvature( - polyhedron, - mean_curvature_map); + PMP::interpolated_corrected_mean_curvature(polyhedron, mean_curvature_map); - PMP::interpolated_corrected_Gaussian_curvature( - polyhedron, - Gaussian_curvature_map); + PMP::interpolated_corrected_Gaussian_curvature(polyhedron, Gaussian_curvature_map); - PMP::interpolated_corrected_principal_curvatures_and_directions( - polyhedron, - principal_curvatures_and_directions_map); + PMP::interpolated_corrected_principal_curvatures_and_directions(polyhedron, principal_curvatures_and_directions_map); // uncomment this to compute a curvature while specifying named parameters // Example: an expansion ball radius of 0.5 and a vertex normals map (does not have to depend on positions) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_SM.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_SM.cpp index ab985e5068d0..d75ab14f6984 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_SM.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_SM.cpp @@ -29,17 +29,23 @@ int main(int argc, char* argv[]) // creating and tying surface mesh property maps for curvatures (with defaults = 0) bool created = false; - Surface_Mesh::Property_map mean_curvature_map, Gaussian_curvature_map; - boost::tie(mean_curvature_map, created) = smesh.add_property_map("v:mean_curvature_map", 0); + Surface_Mesh::Property_map + mean_curvature_map, Gaussian_curvature_map; + + boost::tie(mean_curvature_map, created) = + smesh.add_property_map("v:mean_curvature_map", 0); assert(created); - boost::tie(Gaussian_curvature_map, created) = smesh.add_property_map("v:Gaussian_curvature_map", 0); + boost::tie(Gaussian_curvature_map, created) = + smesh.add_property_map("v:Gaussian_curvature_map", 0); assert(created); // we use a tuple of 2 scalar values and 2 vectors for principal curvatures and directions - Surface_Mesh::Property_map> principal_curvatures_and_directions_map; + Surface_Mesh::Property_map> + principal_curvatures_and_directions_map; - boost::tie(principal_curvatures_and_directions_map, created) = smesh.add_property_map> + boost::tie(principal_curvatures_and_directions_map, created) = + smesh.add_property_map> ("v:principal_curvatures_and_directions_map", { 0, 0, Epic_kernel::Vector_3(0,0,0), Epic_kernel::Vector_3(0,0,0) }); @@ -48,20 +54,11 @@ int main(int argc, char* argv[]) // user can call these fucntions to compute a specfic curvature type on each vertex. // (Note: if no ball radius is specified, the measure expansion of each vertex happens by // summing measures on faces adjacent to each vertex.) - PMP::interpolated_corrected_mean_curvature( - smesh, - mean_curvature_map - ); + PMP::interpolated_corrected_mean_curvature(smesh, mean_curvature_map); - PMP::interpolated_corrected_Gaussian_curvature( - smesh, - Gaussian_curvature_map - ); + PMP::interpolated_corrected_Gaussian_curvature(smesh, Gaussian_curvature_map); - PMP::interpolated_corrected_principal_curvatures_and_directions( - smesh, - principal_curvatures_and_directions_map - ); + PMP::interpolated_corrected_principal_curvatures_and_directions(smesh, principal_curvatures_and_directions_map); // uncomment this to compute a curvature while specifying named parameters // Example: an expansion ball radius of 0.5 and a vertex normals map (does not have to depend on positions) From 33c7f5c03aabadea45c0ed1078d38df38455efa2 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 27 Mar 2023 19:37:31 +0200 Subject: [PATCH 134/142] traillling spaces --- .../interpolated_corrected_curvatures_PH.cpp | 2 +- .../interpolated_corrected_curvatures_SM.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_PH.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_PH.cpp index 0aa0c196d3f5..c93de26f26cc 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_PH.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_PH.cpp @@ -33,7 +33,7 @@ int main(int argc, char* argv[]) Gaussian_curvature_map = get(CGAL::dynamic_vertex_property_t(), polyhedron); boost::property_map>>::type - principal_curvatures_and_directions_map = + principal_curvatures_and_directions_map = get(CGAL::dynamic_vertex_property_t>(), polyhedron); PMP::interpolated_corrected_mean_curvature(polyhedron, mean_curvature_map); diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_SM.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_SM.cpp index d75ab14f6984..dae2ec0716ec 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_SM.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/interpolated_corrected_curvatures_SM.cpp @@ -29,22 +29,22 @@ int main(int argc, char* argv[]) // creating and tying surface mesh property maps for curvatures (with defaults = 0) bool created = false; - Surface_Mesh::Property_map + Surface_Mesh::Property_map mean_curvature_map, Gaussian_curvature_map; - boost::tie(mean_curvature_map, created) = + boost::tie(mean_curvature_map, created) = smesh.add_property_map("v:mean_curvature_map", 0); assert(created); - boost::tie(Gaussian_curvature_map, created) = + boost::tie(Gaussian_curvature_map, created) = smesh.add_property_map("v:Gaussian_curvature_map", 0); assert(created); // we use a tuple of 2 scalar values and 2 vectors for principal curvatures and directions - Surface_Mesh::Property_map> + Surface_Mesh::Property_map> principal_curvatures_and_directions_map; - boost::tie(principal_curvatures_and_directions_map, created) = + boost::tie(principal_curvatures_and_directions_map, created) = smesh.add_property_map> ("v:principal_curvatures_and_directions_map", { 0, 0, Epic_kernel::Vector_3(0,0,0), From 796d7cc57d79a06454afac969a329d49a428f6b3 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Fri, 31 Mar 2023 01:55:26 +0200 Subject: [PATCH 135/142] handled scale dependency and add tests for it --- .../interpolated_corrected_curvatures.h | 22 ++++-- ...test_interpolated_corrected_curvatures.cpp | 68 ++++++++++++++----- 2 files changed, 66 insertions(+), 24 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h index 72f7b1b93d07..4b940f157e88 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h @@ -436,7 +436,8 @@ template Principal_curvatures_and_directions principal_curvatures_and_directions_from_anisotropic_measures( const std::array anisotropic_measure, const typename GT::FT v_mu0, - const typename GT::Vector_3 u_GT + const typename GT::Vector_3 u_GT, + const typename GT::FT avg_edge_length ) { // putting anisotropic measure in matrix form @@ -448,7 +449,7 @@ Principal_curvatures_and_directions principal_curvatures_and_directions_from // constant factor K to force the principal direction eigenvectors to be tangential to the surface Eigen::Matrix u(u_GT.x(), u_GT.y(), u_GT.z()); - const typename GT::FT K = 1000 * v_mu0; + const typename GT::FT K = 1000 * avg_edge_length * v_mu0; // symmetrizing and adding the constant term v_muXY = 0.5 * (v_muXY + v_muXY.transpose()) + K * u * u.transpose(); @@ -668,9 +669,13 @@ template(pmesh); + // if the radius is 0, we use a small epsilon to expand the ball (scaled with the average edge length) if (is_zero(radius)) - radius = average_edge_length(pmesh) * 1e-6; + radius = avg_edge_length * 1e-6; // determine which curvatures are selected const bool is_mean_curvature_selected = !is_default_parameter::value; @@ -723,7 +728,9 @@ template principal_curvatures_and_directions = principal_curvatures_and_directions_from_anisotropic_measures( vertex_measures.anisotropic_measure, vertex_measures.area_measure, - v_normal); + v_normal, + avg_edge_length + ); set_value(principal_curvatures_and_directions, get_parameter(np, internal_np::vertex_principal_curvatures_and_directions)); } } @@ -775,6 +782,7 @@ class Interpolated_corrected_curvatures_computer Vertex_position_map vpm; Vertex_normal_map vnm; FT ball_radius; + FT avg_edge_length; bool is_mean_curvature_selected; bool is_Gaussian_curvature_selected; @@ -813,6 +821,7 @@ class Interpolated_corrected_curvatures_computer // if no radius is given, we pass -1 which will make the expansion be only on the incident faces instead of a ball const FT radius = choose_parameter(get_parameter(np, internal_np::ball_radius), -1); + avg_edge_length = average_edge_length(pmesh); set_ball_radius(radius); // check which curvature maps are provided by the user (determines which curvatures are computed) @@ -828,7 +837,7 @@ class Interpolated_corrected_curvatures_computer void set_ball_radius(const FT radius) { // if given radius is 0, we use a small epsilon to expand the ball (scaled by the average edge length) if (is_zero(radius)) - ball_radius = average_edge_length(pmesh) * 1e-6; + ball_radius = avg_edge_length * 1e-6; else ball_radius = radius; } @@ -1010,7 +1019,8 @@ class Interpolated_corrected_curvatures_computer const Principal_curvatures_and_directions principal_curvatures_and_directions = principal_curvatures_and_directions_from_anisotropic_measures( vertex_measures.anisotropic_measure, vertex_measures.area_measure, - v_normal + v_normal, + avg_edge_length ); put(principal_curvatures_and_directions_map, v, principal_curvatures_and_directions); } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp index c0772ce989bc..2f1af8adb106 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp @@ -32,7 +32,7 @@ struct Average_test_info { Epic_kernel::FT principal_curvature_avg, Epic_kernel::FT expansion_radius = -1, Epic_kernel::FT tolerance = 0.9 - ): + ) : expansion_radius(expansion_radius), mean_curvature_avg(mean_curvature_avg), gaussian_curvature_avg(gaussian_curvature_avg), @@ -43,8 +43,7 @@ struct Average_test_info { }; -bool passes_comparison(Epic_kernel::FT result, Epic_kernel::FT expected, Epic_kernel::FT tolerance) -{ +bool passes_comparison(Epic_kernel::FT result, Epic_kernel::FT expected, Epic_kernel::FT tolerance) { if (abs(expected) < ABS_ERROR && abs(result) < ABS_ERROR) return true; // expected 0, got 0 else if (abs(expected) < ABS_ERROR) @@ -56,8 +55,10 @@ bool passes_comparison(Epic_kernel::FT result, Epic_kernel::FT expected, Epic_ke template void test_average_curvatures(std::string mesh_path, Average_test_info test_info, - bool compare_single_vertex = false -){ + bool compare_single_vertex = false, + int scale_factor_exponent = 0 +) { + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; PolygonMesh pmesh; const std::string filename = CGAL::data_file_path(mesh_path); @@ -67,14 +68,33 @@ void test_average_curvatures(std::string mesh_path, std::cerr << "Invalid input file." << std::endl; } - typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + // The following part is used to scale the given mesh and expected curvatures by a constant factor + // this is used to test the stability of the implementation across different scales + if (scale_factor_exponent) { + Epic_kernel::FT factor = pow(10, scale_factor_exponent); + + test_info.expansion_radius *= factor; + test_info.mean_curvature_avg /= factor; + test_info.gaussian_curvature_avg /= factor * factor; + test_info.principal_curvature_avg /= factor; + + auto vpm = get(CGAL::vertex_point, pmesh); + + for (vertex_descriptor vi : vertices(pmesh)) { + Epic_kernel::Point_3 pi = get(vpm, vi); + Epic_kernel::Point_3 pi_new(pi.x() * factor, pi.y() * factor, pi.z() * factor); + put(vpm, vi, pi_new); + } + } + typename boost::property_map>::type mean_curvature_map = get(CGAL::dynamic_vertex_property_t(), pmesh), gaussian_curvature_map = get(CGAL::dynamic_vertex_property_t(), pmesh); - typename boost::property_map>>::type - principal_curvatures_and_directions_map = get(CGAL::dynamic_vertex_property_t>(), pmesh); - + typename boost::property_map + >>::type + principal_curvatures_and_directions_map = + get(CGAL::dynamic_vertex_property_t>(), pmesh); // test_info.expansion_radius -> test if no radius is provided by user. if (test_info.expansion_radius < 0) { PMP::interpolated_corrected_mean_curvature(pmesh, mean_curvature_map); @@ -103,8 +123,7 @@ void test_average_curvatures(std::string mesh_path, Epic_kernel::FT mean_curvature_avg = 0, gaussian_curvature_avg = 0, principal_curvature_avg = 0; - for (vertex_descriptor v : vertices(pmesh)) - { + for (vertex_descriptor v : vertices(pmesh)) { mean_curvature_avg += get(mean_curvature_map, v); gaussian_curvature_avg += get(gaussian_curvature_map, v); principal_curvature_avg += get(principal_curvatures_and_directions_map, v).min_curvature @@ -131,8 +150,7 @@ void test_average_curvatures(std::string mesh_path, Epic_kernel::FT new_mean_curvature_avg = 0, new_Gaussian_curvature_avg = 0, new_principal_curvature_avg = 0; - for (vertex_descriptor v : vertices(pmesh)) - { + for (vertex_descriptor v : vertices(pmesh)) { new_mean_curvature_avg += get(mean_curvature_map, v); new_Gaussian_curvature_avg += get(gaussian_curvature_map, v); new_principal_curvature_avg += get(principal_curvatures_and_directions_map, v).min_curvature @@ -149,8 +167,7 @@ void test_average_curvatures(std::string mesh_path, assert(passes_comparison(gaussian_curvature_avg, new_Gaussian_curvature_avg, 0.99)); assert(passes_comparison(principal_curvature_avg, new_principal_curvature_avg, 0.99)); - if (compare_single_vertex) - { + if (compare_single_vertex) { // computing curvatures together from interpolated_corrected_curvatures() Epic_kernel::FT single_vertex_mean_curvature_avg = 0, @@ -160,8 +177,7 @@ void test_average_curvatures(std::string mesh_path, Epic_kernel::FT h, g; PMP::Principal_curvatures_and_directions p; - for (vertex_descriptor v : vertices(pmesh)) - { + for (vertex_descriptor v : vertices(pmesh)) { PMP::interpolated_corrected_curvatures_one_vertex( pmesh, v, @@ -193,7 +209,7 @@ int main() // For this mesh, ina addition to the whole mesh functions, we also compare against the single vertex // curvature functions to make sure the produce the same results // Expected: Mean Curvature = 2, Gaussian Curvature = 4, Principal Curvatures = 2 & 2 so 2 on avg. - test_average_curvatures("meshes/sphere.off", Average_test_info(2,4,2), true); + test_average_curvatures("meshes/sphere.off", Average_test_info(2, 4, 2), true); test_average_curvatures("meshes/sphere.off", Average_test_info(2, 4, 2), true); // Same mesh but with specified expansion radii of 0 and 0.25 (half radius of sphere) @@ -218,6 +234,22 @@ int main() test_average_curvatures("meshes/cylinder.off", Average_test_info(0.5, 0, 0.5, 0)); test_average_curvatures("meshes/cylinder.off", Average_test_info(0.5, 0, 0.5, 0.5)); + // Same tests as last one, but with a scaling on the mesh with different values to check for scale stability + test_average_curvatures("meshes/cylinder.off", Average_test_info(0.5, 0, 0.5, 0), false, -6); + test_average_curvatures("meshes/cylinder.off", Average_test_info(0.5, 0, 0.5, 0.5), false, -6); + + test_average_curvatures("meshes/cylinder.off", Average_test_info(0.5, 0, 0.5, 0), false, -3); + test_average_curvatures("meshes/cylinder.off", Average_test_info(0.5, 0, 0.5, 0.5), false, -3); + + test_average_curvatures("meshes/cylinder.off", Average_test_info(0.5, 0, 0.5, 0), false, -1); + test_average_curvatures("meshes/cylinder.off", Average_test_info(0.5, 0, 0.5, 0.5), false, -1); + + test_average_curvatures("meshes/cylinder.off", Average_test_info(0.5, 0, 0.5, 0), false, 1); + test_average_curvatures("meshes/cylinder.off", Average_test_info(0.5, 0, 0.5, 0.5), false, 1); + test_average_curvatures("meshes/cylinder.off", Average_test_info(0.5, 0, 0.5, 0), false, 3); + test_average_curvatures("meshes/cylinder.off", Average_test_info(0.5, 0, 0.5, 0.5), false, 3); + test_average_curvatures("meshes/cylinder.off", Average_test_info(0.5, 0, 0.5, 0), false, 6); + test_average_curvatures("meshes/cylinder.off", Average_test_info(0.5, 0, 0.5, 0.5), false, 6); } From cef23a90456ece3a592b33fcdf17317726759bb3 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sat, 8 Apr 2023 10:24:47 +0200 Subject: [PATCH 136/142] moving captions out of the figure --- .../doc/Polygon_mesh_processing/Polygon_mesh_processing.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index 49614be67c91..70f9cf00c0e7 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -921,10 +921,12 @@ distribution of values and "diffuses" the extreme values of curvatures across th \cgalFigureAnchor{icc_diff_radius}
- +
\cgalFigureCaptionBegin{icc_diff_radius} -The mean curvature distribution on a bear mesh with different values for the ball radius parameter +The mean curvature distribution on a bear mesh with different values for the ball +radius parameter. R = 0 (a), R = 0.025 (b), R = 0.05 (c), R = 0.16 (d). Note that +the max edge length is 0.031 and the size of bounding box of the mesh is 1 x 0.7 x 0.8. \cgalFigureCaptionEnd \ref BGLPropertyMaps are used to record the computed curvatures as shown in examples. In the following examples, for each property map, we associate From 8393933630960d1b23198aac9bc37b6ce38ea0f0 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Sat, 8 Apr 2023 10:27:13 +0200 Subject: [PATCH 137/142] minor grammer fixes --- .../Polygon_mesh_processing.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index 70f9cf00c0e7..987b88b0a217 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -905,8 +905,8 @@ These computations are performed using (on all vertices of the mesh): - `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures()` -Where it is recommended to use the last function for computing multiple curvatures (example: mean and Gaussian) -as the implementation performs the shared computations only once, making it more efficient. +Where it is recommended to use the last function for computing multiple curvatures (for example: mean and +Gaussian) as the implementation performs the shared computations only once, making it more efficient. Similarly, we can use the following functions to compute curvatures on a specific vertex: - `CGAL::Polygon_mesh_processing::interpolated_corrected_mean_curvature_one_vertex()` @@ -924,9 +924,9 @@ distribution of values and "diffuses" the extreme values of curvatures across th \cgalFigureCaptionBegin{icc_diff_radius} -The mean curvature distribution on a bear mesh with different values for the ball -radius parameter. R = 0 (a), R = 0.025 (b), R = 0.05 (c), R = 0.16 (d). Note that -the max edge length is 0.031 and the size of bounding box of the mesh is 1 x 0.7 x 0.8. +The mean curvature distribution on a bear mesh with different values for the ball radius +parameter. R = 0 (a), R = 0.025 (b), R = 0.05 (c), R = 0.16 (d). Note that the max +edge length is 0.031 and the size of the bounding box of the mesh is 1 x 0.7 x 0.8. \cgalFigureCaptionEnd \ref BGLPropertyMaps are used to record the computed curvatures as shown in examples. In the following examples, for each property map, we associate From f8a9862abfd91f33622830b9142e3137c57842b6 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 17 Apr 2023 15:14:37 +0200 Subject: [PATCH 138/142] incomplete update to user man doc --- .../Polygon_mesh_processing.txt | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index 987b88b0a217..b454706b9723 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -892,10 +892,16 @@ not provide storage for the normals. This package provides methods to compute curvatures on polygonal meshes based on Interpolated Corrected Curvatures on Polyhedral Surfaces \cgalCite{lachaud2020}. This includes mean curvature, Gaussian curvature, principal curvatures and directions. These can be computed on triangle meshes, quad meshes, -and meshes with n-gon faces. The algorithms used prove to work well in general. Also, on meshes +and meshes with n-gon faces (for n-gons, the centroid must be inside the n-gon face). +The algorithms used prove to work well in general. Also, on meshes with noise on vertex positions, they give accurate results, on the condition that the correct vertex normals are provided. +\subsection ICCBackground Brief Background + + +\subsection ICCAPI API + The implementation is generic in terms of mesh data structure. It can be used on `Surface_mesh`, `Polyhedron_3` and other polygonal mesh structures based on the concept `FaceGraph`. @@ -914,6 +920,9 @@ Similarly, we can use the following functions to compute curvatures on a specifi - `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions_one_vertex()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures_one_vertex()` +\subsection ICCResults Results + +**To be updated** \cgalFigureRef{icc_diff_radius} shows how the mean curvature changes depending on the named parameter `ball_radius`, which can be set to a value > 0 to get a smoother @@ -921,12 +930,12 @@ distribution of values and "diffuses" the extreme values of curvatures across th \cgalFigureAnchor{icc_diff_radius}
- +
\cgalFigureCaptionBegin{icc_diff_radius} -The mean curvature distribution on a bear mesh with different values for the ball radius -parameter. R = 0 (a), R = 0.025 (b), R = 0.05 (c), R = 0.16 (d). Note that the max -edge length is 0.031 and the size of the bounding box of the mesh is 1 x 0.7 x 0.8. +The mean curvature on a mesh with different values for the ball radius +parameter: (a) R = 0, (b) R = 0.025, (c) R = 0.05, (d) R = 0.16. Note that the max +edge length is 0.031 and the size of the bounding box of the mesh is 1 x .7 x .8. \cgalFigureCaptionEnd \ref BGLPropertyMaps are used to record the computed curvatures as shown in examples. In the following examples, for each property map, we associate From 261eac81e9847bdc2b313ac19ae7a00edeaa9405 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Tue, 18 Apr 2023 14:30:37 +0200 Subject: [PATCH 139/142] user manual - incomplete --- .../Polygon_mesh_processing.txt | 57 ++++++++++++++++--- 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index b454706b9723..ead5b5a8c80c 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -889,16 +889,57 @@ not provide storage for the normals. **************************************** \section PMPICC Computing Curvatures -This package provides methods to compute curvatures on polygonal meshes based on Interpolated Corrected Curvatures -on Polyhedral Surfaces \cgalCite{lachaud2020}. This includes mean curvature, Gaussian curvature, -principal curvatures and directions. These can be computed on triangle meshes, quad meshes, -and meshes with n-gon faces (for n-gons, the centroid must be inside the n-gon face). -The algorithms used prove to work well in general. Also, on meshes -with noise on vertex positions, they give accurate results, on the condition that the -correct vertex normals are provided. +This package provides methods to compute curvatures on polygonal meshes based on Interpolated +Corrected Curvatures on Polyhedral Surfaces \cgalCite{lachaud2020}. This includes mean curvature, +Gaussian curvature, principal curvatures and directions. These can be computed on triangle meshes, +quad meshes, and meshes with n-gon faces (for n-gons, the centroid must be inside the n-gon face). +The algorithms used prove to work well in general. Also, on meshes with noise on vertex positions, +they give accurate results, on the condition that the correct vertex normals are provided. \subsection ICCBackground Brief Background +Curvatures are quantities that describe the local geometry of a surface. They are important in many +geometry processing applications. since surfaces are 2-dimensional objects (embedded in 3D), they can bend +in 2 independent directions. These directions are called principal directions, and the amount of bending +in each direction is called the principal curvature: \f$ k_1 \f$ and \f$ k_2 \f$. Curvature is usually +expressed as scalar quantities like the mean curvature \f$ H \f$ and the Gaussian curvature \f$ K \f$ +which are defined in terms of the principal curvatures. + +The algorithms are based on the following paper \cgalCite{lachaud2020}. It introduces a new way to +compute curvatures on polygonal meshes. The main idea is based on decoupling the normal information from +the position information, which is useful for dealing with digital surfaces, or meshes with noise on +vertex positions. To compute the curvatures, we first compute interpolated curvature measures for each face +as described below. For a triangle \f$ \tau_{ijk} \f$, with vertices \a i, \a j, \a k: + +\f[ + \begin{align*} + \mu^{(0)}(\tau_{ijk}) = &\frac{1}{2} \langle \bar{\mathbf{u}} \mid (\mathbf{x}_j - \mathbf{x}_i) \times (\mathbf{x}_k - \mathbf{x}_i) \rangle, \\ + \mu^{(1)}(\tau_{ijk}) = &\frac{1}{2} \langle \bar{\mathbf{u}} \mid (\mathbf{u}_k - \mathbf{u}_j) \times \mathbf{x}_i + (\mathbf{u}_i - \mathbf{u}_k) \times \mathbf{x}_j + (\mathbf{u}_j - \mathbf{u}_i) \times \mathbf{x}_k \rangle, \\ + \mu^{(2)}(\tau_{ijk}) = &\frac{1}{2} \langle \mathbf{u}_i \mid \mathbf{u}_j \times \mathbf{u}_k \rangle, \\ + \mu^{\mathbf{X},\mathbf{Y}}(\tau_{ijk}) = & \frac{1}{2} \big\langle \bar{\mathbf{u}} \big| \langle \mathbf{Y} | \mathbf{u}_k -\mathbf{u}_i \rangle \mathbf{X} \times (\mathbf{x}_j - \mathbf{x}_i) \big\rangle + -\frac{1}{2} \big\langle \bar{\mathbf{u}} \big| \langle \mathbf{Y} | \mathbf{u}_j -\mathbf{u}_i \rangle \mathbf{X} \times (\mathbf{x}_k - \mathbf{x}_i) \big\rangle, + \end{align*} +\f] +where \f$ \langle \cdot \mid \cdot \rangle \f$ denotes the usual scalar product, +\f$ \bar{\mathbf{u}}=\frac{1}{3}( \mathbf{u}_i + \mathbf{u}_j + \mathbf{u}_k )\f$. + +The first measure \f$ \mu^{(0)} \f$ is the area measure of the triangle, and the second and third measures +\f$ \mu^{(1)} \f$ and \f$ \mu^{(2)} \f$ are the mean and Gaussian corrected curvature measures of the triangle. +The last measure \f$ \mu^{\mathbf{X},\mathbf{Y}} \f$ is the anisotropic corrected curvature measure of the triangle. +The anisotropic measure is later used to compute the principal curvatures and directions through an eigenvalue +solver. + +The interpolated curvature measures are then computed for each vertex \f$ v \f$ as the sum of +the curvature measures of the faces in a ball around \f$ v \f$ weighted by the inclusion ratio of the +triangle in the ball. if the ball radius is not specified, the sum is instead over the incident faces +of \f$ v \f$. + +To get the final curvature value for a vertex \f$ v \f$, the respective interpolated curvature measure +is divided by the interpolated area measure. + +\f[ +\mu^{(k)}( B ) = \sum_{\tau : \text{triangle} } \mu^{(k)}( \tau ) \frac{\mathrm{Area}( \tau \cap B )}{\mathrm{Area}(\tau)}. +\f] \subsection ICCAPI API @@ -920,7 +961,7 @@ Similarly, we can use the following functions to compute curvatures on a specifi - `CGAL::Polygon_mesh_processing::interpolated_corrected_principal_curvatures_and_directions_one_vertex()` - `CGAL::Polygon_mesh_processing::interpolated_corrected_curvatures_one_vertex()` -\subsection ICCResults Results +\subsection ICCResults Results & Performance **To be updated** From 585e79b67e5750a541d18e97487f9b23d07d5d00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 26 Apr 2023 13:06:19 +0200 Subject: [PATCH 140/142] add authors from the history section --- .../doc/Polygon_mesh_processing/PackageDescription.txt | 2 +- .../doc/Polygon_mesh_processing/Polygon_mesh_processing.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt index 9c8b5d6f2948..bf667377a96a 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/PackageDescription.txt @@ -79,7 +79,7 @@ \cgalPkgPicture{hole_filling_ico.png} \cgalPkgSummaryBegin -\cgalPkgAuthors{Sébastien Loriot, Mael Rouxel-Labbé, Jane Tournois, and Ilker %O. Yaz} +\cgalPkgAuthors{David Coeurjolly, Jaques-Olivier Lachaud, Konstantinos Katriopla, Sébastien Loriot, Mael Rouxel-Labbé, Hossam Saeed, Jane Tournois, and Ilker %O. Yaz} \cgalPkgDesc{This package provides a collection of methods and classes for polygon mesh processing, ranging from basic operations on simplices, to complex geometry processing algorithms such as Boolean operations, remeshing, repairing, collision and intersection detection, and more.} diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index ead5b5a8c80c..eac246d8ab47 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -4,7 +4,7 @@ namespace CGAL { \anchor Chapter_PolygonMeshProcessing \cgalAutoToc -\authors Sébastien Loriot, Mael Rouxel-Labbé, Jane Tournois, Ilker %O. Yaz +\authors David Coeurjolly, Jaques-Olivier Lachaud, Konstantinos Katriopla, Sébastien Loriot, Mael Rouxel-Labbé, Hossam Saeed, Jane Tournois, and Ilker %O. Yaz \image html neptun_head.jpg \image latex neptun_head.jpg From ae5d32ba2e425853d4cf822ffd64e19c1d45e7ad Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 1 May 2023 12:23:20 +0200 Subject: [PATCH 141/142] citing/referencing "corrected curvature measures" + refining the theo background --- Documentation/doc/biblio/geom.bib | 12 +++++++ .../Polygon_mesh_processing.txt | 33 ++++++++++--------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/Documentation/doc/biblio/geom.bib b/Documentation/doc/biblio/geom.bib index 7c9fec6e420d..f072116a2e27 100644 --- a/Documentation/doc/biblio/geom.bib +++ b/Documentation/doc/biblio/geom.bib @@ -152065,3 +152065,15 @@ @article{lachaud2020 month = jul, year = {2020} } + +@article{lachaud2022 + author = {Jacques-Olivier Lachaud and Pascal Romon and Boris Thibert}, + journal = {Discrete & Computational Geometry}, + title = {Corrected Curvature Measures}, + volume = {68}, + pages = {477-524}, + month = jul, + year = {2022}, + url = {https://doi.org/10.1007/s00454-022-00399-4} +} + diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index eac246d8ab47..354c622f0e99 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -898,18 +898,21 @@ they give accurate results, on the condition that the correct vertex normals are \subsection ICCBackground Brief Background -Curvatures are quantities that describe the local geometry of a surface. They are important in many -geometry processing applications. since surfaces are 2-dimensional objects (embedded in 3D), they can bend +Surface curvatures are quantities that describe the local geometry of a surface. They are important in many +geometry processing applications. As surfaces are 2-dimensional objects (embedded in 3D), they can bend in 2 independent directions. These directions are called principal directions, and the amount of bending -in each direction is called the principal curvature: \f$ k_1 \f$ and \f$ k_2 \f$. Curvature is usually -expressed as scalar quantities like the mean curvature \f$ H \f$ and the Gaussian curvature \f$ K \f$ -which are defined in terms of the principal curvatures. - -The algorithms are based on the following paper \cgalCite{lachaud2020}. It introduces a new way to -compute curvatures on polygonal meshes. The main idea is based on decoupling the normal information from -the position information, which is useful for dealing with digital surfaces, or meshes with noise on -vertex positions. To compute the curvatures, we first compute interpolated curvature measures for each face -as described below. For a triangle \f$ \tau_{ijk} \f$, with vertices \a i, \a j, \a k: +in each direction is called the principal curvature: \f$ k_1 \f$ and \f$ k_2 \f$ (denoting max and min +curvatures). Curvature is usually expressed as scalar quantities like the mean curvature \f$ H \f$ and +the Gaussian curvature \f$ K \f$ which are defined in terms of the principal curvatures. + +The algorithms are based on the two papers \cgalCite{lachaud2022} and \cgalCite{lachaud2020}. They +introduce a new way to compute curvatures on polygonal meshes. The main idea in \cgalCite{lachaud2022} is +based on decoupling the normal information from the position information, which is useful for dealing with +digital surfaces, or meshes with noise on vertex positions. \cgalCite{lachaud2020} introduces some +extensions to this framework. As it uses linear interpolation on the corrected normal vector field +to derive new closed form equations for the corrected curvature measures. These interpolated +curvature measures are the first step for computing the curvatures. For a triangle \f$ \tau_{ijk} \f$, +with vertices \a i, \a j, \a k: \f[ \begin{align*} @@ -923,10 +926,10 @@ as described below. For a triangle \f$ \tau_{ijk} \f$, with vertices \a i, \a j, where \f$ \langle \cdot \mid \cdot \rangle \f$ denotes the usual scalar product, \f$ \bar{\mathbf{u}}=\frac{1}{3}( \mathbf{u}_i + \mathbf{u}_j + \mathbf{u}_k )\f$. -The first measure \f$ \mu^{(0)} \f$ is the area measure of the triangle, and the second and third measures -\f$ \mu^{(1)} \f$ and \f$ \mu^{(2)} \f$ are the mean and Gaussian corrected curvature measures of the triangle. -The last measure \f$ \mu^{\mathbf{X},\mathbf{Y}} \f$ is the anisotropic corrected curvature measure of the triangle. -The anisotropic measure is later used to compute the principal curvatures and directions through an eigenvalue +The first measure \f$ \mu^{(0)} \f$ is the area measure of the triangle, and the measures \f$ \mu^{(1)} \f$ and +\f$ \mu^{(2)} \f$ are the mean and Gaussian corrected curvature measures of the triangle. The last measure +\f$ \mu^{\mathbf{X},\mathbf{Y}} \f$ is the anisotropic corrected curvature measure of the triangle. The +anisotropic measure is later used to compute the principal curvatures and directions through an eigenvalue solver. The interpolated curvature measures are then computed for each vertex \f$ v \f$ as the sum of From 83bf49bf3977565330e6316cd2640fc60c38cb46 Mon Sep 17 00:00:00 2001 From: hoskillua <47090776+hoskillua@users.noreply.github.com> Date: Mon, 1 May 2023 12:29:25 +0200 Subject: [PATCH 142/142] Computing curvatures mentioned in the outline section (1.3) --- .../doc/Polygon_mesh_processing/Polygon_mesh_processing.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index 354c622f0e99..6b6f979ba59f 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -49,6 +49,7 @@ mesh, which includes point location and self intersection tests. - \ref PMPCombinatorialRepair : repair of polygon meshes and polygon soups. - \ref PMPGeometricRepair : repair of the geometry of polygon meshes. - \ref PMPNormalComp : normal computation at vertices and on faces of a polygon mesh. +- \ref PMPICC : computing curvatures (mean, gaussian, principal) on a polygon mesh. - \ref PMPSlicer : functor able to compute the intersections of a polygon mesh with arbitrary planes (slicer). - \ref PMPConnectedComponents : methods to deal with connected components of a polygon mesh (extraction, marks, removal, ...).