From e012dad4c1f85892c9a7b164ebdf19bc80e5319d Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Tue, 29 Jun 2021 16:55:31 +0200 Subject: [PATCH 1/3] added a comment to internal functions --- Weights/include/CGAL/Weights/utils.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Weights/include/CGAL/Weights/utils.h b/Weights/include/CGAL/Weights/utils.h index ce3f6399f28..919b2fc2bf2 100644 --- a/Weights/include/CGAL/Weights/utils.h +++ b/Weights/include/CGAL/Weights/utils.h @@ -103,7 +103,13 @@ namespace Weights { const GeomTraits traits; return cotangent(p, q, r, traits); } + /// \endcond + /// \cond SKIP_IN_MANUAL + // These are free functions to be used when building weights from parts rather + // than using the predefined weight functions. In principle, they can be removed. + // They are here to have unified interface within the Weights package and its + // construction weight system. template typename GeomTraits::FT squared_distance( const CGAL::Point_2& p, From 80cd3411df9358727062f53755c49c5d84d83f57 Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Tue, 29 Jun 2021 16:58:41 +0200 Subject: [PATCH 2/3] better description of the analytic weight traits --- Weights/doc/Weights/Concepts/AnalyticWeightTraits_2.h | 5 ++--- Weights/doc/Weights/Concepts/AnalyticWeightTraits_3.h | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Weights/doc/Weights/Concepts/AnalyticWeightTraits_2.h b/Weights/doc/Weights/Concepts/AnalyticWeightTraits_2.h index 5536e4b5db8..4b882bd82d5 100644 --- a/Weights/doc/Weights/Concepts/AnalyticWeightTraits_2.h +++ b/Weights/doc/Weights/Concepts/AnalyticWeightTraits_2.h @@ -2,9 +2,8 @@ \ingroup PkgWeightsRefConcepts \cgalConcept -A concept that describes the set of requirements of the template parameter -`GeomTraits` used to parameterize several classes and functions -from the namespace `CGAL::Weights`. +A concept that describes the set of requirements of classes used in the computation +of analytic weights in 2D. \cgalHasModel - All models of `Kernel` diff --git a/Weights/doc/Weights/Concepts/AnalyticWeightTraits_3.h b/Weights/doc/Weights/Concepts/AnalyticWeightTraits_3.h index 7dbc4dfcaf0..3560a85f478 100644 --- a/Weights/doc/Weights/Concepts/AnalyticWeightTraits_3.h +++ b/Weights/doc/Weights/Concepts/AnalyticWeightTraits_3.h @@ -2,9 +2,8 @@ \ingroup PkgWeightsRefConcepts \cgalConcept -A concept that describes the set of requirements of the template parameter -`GeomTraits` used to parameterize several classes and functions -from the namespace `CGAL::Weights`. +A concept that describes the set of requirements of classes used in the computation +of analytic weights in 3D. \cgalHasModel - All models of `Kernel` From 686309a17d03540c01a3a2e175f4c25b2756e4a1 Mon Sep 17 00:00:00 2001 From: Dmitry Anisimov Date: Tue, 29 Jun 2021 17:03:52 +0200 Subject: [PATCH 3/3] using double numbers in examples --- Weights/examples/Weights/convergence.cpp | 8 ++++---- Weights/examples/Weights/coordinates_multiple_queries.cpp | 6 +++--- Weights/examples/Weights/coordinates_one_query.cpp | 4 ++-- Weights/examples/Weights/weighted_laplacian.cpp | 8 ++++---- Weights/examples/Weights/weights.cpp | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Weights/examples/Weights/convergence.cpp b/Weights/examples/Weights/convergence.cpp index 8bfe138813f..8cc85915531 100644 --- a/Weights/examples/Weights/convergence.cpp +++ b/Weights/examples/Weights/convergence.cpp @@ -18,8 +18,8 @@ int main() { // Choose a type of the weight: // e.g. 0 - Wachspress (WP) weight; 1 - mean value (MV); - const FT wp = FT(0); - const FT mv = FT(1); + const FT wp = 0.0; + const FT mv = 1.0; // Compute WP and MV weights. std::cout << "3D Wachspress (WP, q0): "; @@ -29,8 +29,8 @@ int main() { // Converge WP towards MV. std::cout << "Converge WP to MV on q0: " << std::endl; - const FT step = FT(1) / FT(10); - for (FT x = FT(0); x <= FT(1); x += step) { + const FT step = 0.1; + for (FT x = 0.0; x <= 1.0; x += step) { std::cout << "3D x: "; std::cout << CGAL::Weights::three_point_family_weight(p0, p1, p2, q0, x) << std::endl; } diff --git a/Weights/examples/Weights/coordinates_multiple_queries.cpp b/Weights/examples/Weights/coordinates_multiple_queries.cpp index 8f3f7c66f34..ec11863fd0b 100644 --- a/Weights/examples/Weights/coordinates_multiple_queries.cpp +++ b/Weights/examples/Weights/coordinates_multiple_queries.cpp @@ -24,7 +24,7 @@ int main() { // Generate a set of query points. std::vector queries; queries.reserve(num_queries); - Generator generator(FT(1)); + Generator generator(1.0); std::copy_n(generator, num_queries, std::back_inserter(queries)); assert(queries.size() == num_queries); @@ -51,11 +51,11 @@ int main() { // Normalize weights in order to get barycentric coordinates. for (std::size_t i = 0; i < weights.size(); i += polygon.size()) { - FT sum = FT(0); + FT sum = 0.0; for (std::size_t j = 0; j < polygon.size(); ++j) { sum += weights[i + j]; } - assert(sum != FT(0)); + assert(sum != 0.0); for (std::size_t j = 0; j < polygon.size(); ++j) { coordinates.push_back(weights[i + j] / sum); } diff --git a/Weights/examples/Weights/coordinates_one_query.cpp b/Weights/examples/Weights/coordinates_one_query.cpp index 08873af009a..00f4b9328ec 100644 --- a/Weights/examples/Weights/coordinates_one_query.cpp +++ b/Weights/examples/Weights/coordinates_one_query.cpp @@ -30,11 +30,11 @@ int main() { std::cout << std::endl; // Normalize weights in order to get barycentric coordinates. - FT sum = FT(0); + FT sum = 0.0; for (const FT weight : weights) { sum += weight; } - assert(sum != FT(0)); + assert(sum != 0.0); for (const FT weight : weights) { coordinates.push_back(weight / sum); } diff --git a/Weights/examples/Weights/weighted_laplacian.cpp b/Weights/examples/Weights/weighted_laplacian.cpp index 437d608edec..bd44f1fb0ea 100644 --- a/Weights/examples/Weights/weighted_laplacian.cpp +++ b/Weights/examples/Weights/weighted_laplacian.cpp @@ -49,13 +49,13 @@ FT get_w_ij(const Mesh& mesh, const HD he, const PointMap pmap) { const auto& p0 = get(pmap, v2); // neighbor jm const auto& p2 = get(pmap, v3); // neighbor jp - return CGAL::Weights::cotangent_weight(p0, p1, p2, q) / FT(2); + return CGAL::Weights::cotangent_weight(p0, p1, p2, q) / 2.0; } template FT get_w_i(const Mesh& mesh, const VD v_i, const PointMap pmap) { - FT A_i = FT(0); + FT A_i = 0.0; const auto v0 = v_i; const auto init = halfedge(v_i, mesh); for (const auto& he : halfedges_around_target(init, mesh)) { @@ -70,8 +70,8 @@ FT get_w_i(const Mesh& mesh, const VD v_i, const PointMap pmap) { const auto& r = get(pmap, v2); A_i += CGAL::Weights::mixed_voronoi_area(p, q, r); } - assert(A_i != FT(0)); - return FT(1) / (FT(2) * A_i); + assert(A_i != 0.0); + return 1.0 / (2.0 * A_i); } void set_laplacian_matrix(const Mesh& mesh, Matrix& L) { diff --git a/Weights/examples/Weights/weights.cpp b/Weights/examples/Weights/weights.cpp index cc1c968ed26..dc53da2355c 100644 --- a/Weights/examples/Weights/weights.cpp +++ b/Weights/examples/Weights/weights.cpp @@ -26,8 +26,8 @@ int main() { std::cout << CGAL::Weights::tangent_weight(t3, r3, p3, q3) << std::endl; std::cout << "2D/3D Shepard weight: "; - std::cout << CGAL::Weights::shepard_weight(r2, q2, FT(2)) << "/"; - std::cout << CGAL::Weights::shepard_weight(r3, q3, FT(2)) << std::endl; + std::cout << CGAL::Weights::shepard_weight(r2, q2, 2.0) << "/"; + std::cout << CGAL::Weights::shepard_weight(r3, q3, 2.0) << std::endl; std::cout << "2D/3D barycentric area: "; std::cout << CGAL::Weights::barycentric_area(p2, q2, r2) << "/";