Merge branch 'gsoc2022' of https://github.com/hoskillua/cgal into gsoc2022

This commit is contained in:
hoskillua 2022-07-27 15:44:57 +02:00
commit 1a1cfb409e
2 changed files with 50 additions and 36 deletions

View File

@ -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

View File

@ -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
@ -46,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()`
@ -56,30 +69,31 @@ template<typename GT>
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)
{
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;
}
@ -89,8 +103,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.
@ -106,7 +120,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()`
@ -125,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;
@ -180,7 +194,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()`
@ -218,7 +232,7 @@ typename GT::FT interpolated_corrected_measure_face(const std::vector<typename G
xm /= n;
// getting unit average normal of points
typename GT::Vector_3 um =
typename GT::Vector_3 um =
std::accumulate(u.begin(), u.end(), typename GT::Vector_3(0, 0, 0));
um /= sqrt(um * um);
@ -245,14 +259,14 @@ typename GT::FT interpolated_corrected_measure_face(const std::vector<typename G
*
* @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
* @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
* \cgalParamType{a class model of `ReadablePropertyMap` with
* `boost::graph_traits<PolygonMesh>::%vertex_descriptor`
* as key type and `%Point_3` as value type}
* \cgalParamDefault{`boost::get(CGAL::vertex_point, pmesh)`}
@ -262,7 +276,7 @@ typename GT::FT interpolated_corrected_measure_face(const std::vector<typename G
*
* \cgalParamNBegin{vertex_normal_map}
* \cgalParamDescription{a property map associating normal vectors to the vertices of `pmesh`}
* \cgalParamType{a class model of `ReadablePropertyMap` with
* \cgalParamType{a class model of `ReadablePropertyMap` with
* `boost::graph_traits<PolygonMesh>::%vertex_descriptor`
* as key type and `%Vector_3` as value type}
* \cgalParamDefault{`get(dynamic_vertex_property_t<GT::Vector_3>(), pmesh)`}
@ -393,7 +407,7 @@ template<typename PolygonMesh, typename FaceMeasureMap, typename VertexCurvature
typedef typename boost::graph_traits<PolygonMesh>::face_descriptor face_descriptor;
typedef typename boost::graph_traits<PolygonMesh>::vertex_descriptor vertex_descriptor;
const typename GetGeomTraits<PolygonMesh, NamedParameters>::type::FT
const typename GetGeomTraits<PolygonMesh, NamedParameters>::type::FT
r = choose_parameter(get_parameter(np, internal_np::ball_radius), 0.01);
if (r < 0.000001)