mirror of https://github.com/CGAL/cgal
make sure Delaunay domain 2 is not included anywhere due to license issues, added description to the convenience header, typos, one more overload for HM
This commit is contained in:
parent
65c43db706
commit
983289304a
|
|
@ -74,7 +74,6 @@ coordinates from the Package \ref PkgInterpolation2.}
|
|||
- `mean_value_coordinates_2()`
|
||||
- `discrete_harmonic_weights_2()`
|
||||
- `discrete_harmonic_coordinates_2()`
|
||||
- `harmonic_coordinates_2()`
|
||||
- `boundary_coordinates_2()`
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/Barycentric_coordinates_2.h>
|
||||
#include <CGAL/Barycentric_coordinates_2/Delaunay_domain_2.h>
|
||||
#include <CGAL/Barycentric_coordinates_2/Harmonic_coordinates_2.h>
|
||||
|
||||
// Typedefs.
|
||||
using Kernel = CGAL::Simple_cartesian<double>;
|
||||
|
|
@ -34,12 +35,14 @@ int main() {
|
|||
Point_2(0.01, 0.10), Point_2(0.02, 0.07)
|
||||
};
|
||||
|
||||
// Construct a Delaunay domain.
|
||||
// Use seeds to mark the interior part of the polygon.
|
||||
std::list<Point_2> seeds;
|
||||
seeds.push_back(Point_2(0.1, 0.1));
|
||||
|
||||
// Construct a Delaunay domain.
|
||||
const double max_edge_length = 0.01;
|
||||
Domain domain(polygon);
|
||||
domain.create(0.01, seeds);
|
||||
domain.create(max_edge_length, seeds);
|
||||
|
||||
// Compute harmonic coordinates at the vertices of the domain.
|
||||
Harmonic_coordinates_2 harmonic_coordinates_2(polygon, domain);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,17 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Barycentric_coordinates_2.h>
|
||||
#include <CGAL/Barycentric_coordinates_2/Delaunay_domain_2.h>
|
||||
#include <CGAL/Barycentric_coordinates_2/Harmonic_coordinates_2.h>
|
||||
|
||||
// Typedefs.
|
||||
using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
|
||||
using FT = Kernel::FT;
|
||||
using Point_2 = Kernel::Point_2;
|
||||
using Point_range = std::vector<Point_2>;
|
||||
|
||||
using Domain =
|
||||
CGAL::Barycentric_coordinates::Delaunay_domain_2<Point_range, Kernel>;
|
||||
using Harmonic_coordinates_2 =
|
||||
CGAL::Barycentric_coordinates::Harmonic_coordinates_2<Point_range, Domain, Kernel>;
|
||||
|
||||
int main() {
|
||||
|
||||
|
|
@ -25,14 +32,20 @@ int main() {
|
|||
// Use seeds to mark the interior part of the source shape.
|
||||
const std::vector<Point_2> seeds = { Point_2(3, 5) };
|
||||
|
||||
// Construct a Delaunay domain.
|
||||
const FT max_edge_length = FT(1) / FT(3);
|
||||
Domain domain(source_shape);
|
||||
domain.create(max_edge_length, seeds);
|
||||
|
||||
// Use it to store coordinates.
|
||||
std::vector< std::vector<FT> > coordinates;
|
||||
coordinates.reserve(domain.number_of_vertices());
|
||||
|
||||
// Compute harmonic coordinates at the vertices of the
|
||||
// discretized interior domain of the source shape.
|
||||
const FT max_edge_length = FT(1) / FT(3);
|
||||
CGAL::Barycentric_coordinates::harmonic_coordinates_2(
|
||||
source_shape, seeds, std::back_inserter(coordinates), max_edge_length);
|
||||
Harmonic_coordinates_2 harmonic_coordinates_2(source_shape, domain);
|
||||
harmonic_coordinates_2.compute();
|
||||
harmonic_coordinates_2(std::back_inserter(coordinates));
|
||||
|
||||
// Deform the source domain into the target domain.
|
||||
// We output only the first 20 results.
|
||||
|
|
|
|||
|
|
@ -16,131 +16,22 @@
|
|||
|
||||
#include <CGAL/license/Barycentric_coordinates_2.h>
|
||||
|
||||
// Deprecated headers.
|
||||
// #include <CGAL/Barycentric_coordinates_2/Deprecated_headers_2.h>
|
||||
/**
|
||||
* \ingroup PkgBarycentricCoordinates2Ref
|
||||
* \file CGAL/Barycentric_coordinates_2.h
|
||||
* A convenience header that includes all free functions and classes for
|
||||
* 2D barycentric coordinates.
|
||||
*/
|
||||
|
||||
// Internal includes.
|
||||
#include <CGAL/Barycentric_coordinates_2/barycentric_enum_2.h>
|
||||
#include <CGAL/Barycentric_coordinates_2/segment_coordinates_2.h>
|
||||
#include <CGAL/Barycentric_coordinates_2/triangle_coordinates_2.h>
|
||||
#include <CGAL/Barycentric_coordinates_2/boundary_coordinates_2.h>
|
||||
|
||||
#include <CGAL/Barycentric_coordinates_2/Delaunay_domain_2.h>
|
||||
#include <CGAL/Barycentric_coordinates_2/Wachspress_coordinates_2.h>
|
||||
#include <CGAL/Barycentric_coordinates_2/Discrete_harmonic_coordinates_2.h>
|
||||
#include <CGAL/Barycentric_coordinates_2/Mean_value_coordinates_2.h>
|
||||
#include <CGAL/Barycentric_coordinates_2/Harmonic_coordinates_2.h>
|
||||
|
||||
namespace CGAL {
|
||||
namespace Barycentric_coordinates {
|
||||
|
||||
/*!
|
||||
\ingroup PkgBarycentricCoordinates2RefFunctions
|
||||
|
||||
\brief computes 2D harmonic coordinates.
|
||||
|
||||
This function first creates a triangulation of the polygon interior domain given
|
||||
the user specified `max_edge_length` parameter and several `seed` points. It then
|
||||
computes 2D harmonic coordinates at each vertex of this triangulation with respect
|
||||
to the `n` vertices of a simple `polygon`, that is one coordinate per polygon vertex.
|
||||
The coordinates are stored in a destination range beginning at `c_begin`, where each
|
||||
range element is a vector with `n` coordinates, and the size of range equals to the
|
||||
number of triangulation vertices.
|
||||
|
||||
Internally, the classes `Delaunay_domain_2` and `Harmonic_coordinates_2` are used.
|
||||
If one wants to evaluate harmonic coordinates at multiple query points, which are
|
||||
not the vertices of the created triangulation, one needs to refer to those classes.
|
||||
|
||||
\tparam PointRange
|
||||
a model of `ConstRange` whose iterator type is `RandomAccessIterator`
|
||||
and value type is `GeomTraits::Point_2`
|
||||
|
||||
\tparam OutIterator
|
||||
a model of `OutputIterator` that accepts elements of type `std::vector<GeomTraits::FT>`
|
||||
|
||||
\tparam GeomTraits
|
||||
a model of `BarycentricTraits_2`
|
||||
|
||||
\param polygon
|
||||
an instance of `PointRange` with 2D points, which form a simple polygon
|
||||
|
||||
\param seeds
|
||||
an instance of `PointRange`, which contains seed points indicating, which parts
|
||||
of the `polygon` should be partitioned and subdivided
|
||||
|
||||
\param c_begin
|
||||
the beginning of the destination range with the computed coordinates
|
||||
|
||||
\param traits
|
||||
a traits class with geometric objects, predicates, and constructions;
|
||||
this parameter can be omitted if the traits class can be deduced from the
|
||||
value type of the `PointRange`
|
||||
|
||||
\param max_edge_length
|
||||
an upper bound on the length of the longest edge; the default is `0.01`
|
||||
|
||||
\return an output iterator to the element in the destination range,
|
||||
one past the last vector of coordinates stored
|
||||
|
||||
\pre polygon.size() >= 3
|
||||
\pre polygon is simple
|
||||
*/
|
||||
template<
|
||||
typename PointRange,
|
||||
typename OutIterator,
|
||||
typename GeomTraits>
|
||||
OutIterator harmonic_coordinates_2(
|
||||
const PointRange& polygon,
|
||||
const PointRange& seeds,
|
||||
OutIterator c_begin,
|
||||
const GeomTraits& traits,
|
||||
const typename GeomTraits::FT max_edge_length =
|
||||
typename GeomTraits::FT(1) / typename GeomTraits::FT(100)) {
|
||||
|
||||
using Domain =
|
||||
Delaunay_domain_2<PointRange, GeomTraits>;
|
||||
using Harmonic_coordinates_2 =
|
||||
Harmonic_coordinates_2<PointRange, Domain, GeomTraits>;
|
||||
using FT = typename GeomTraits::FT;
|
||||
|
||||
Domain domain(polygon, traits);
|
||||
domain.create(max_edge_length, seeds);
|
||||
|
||||
Harmonic_coordinates_2 harmonic_coordinates_2(
|
||||
polygon, domain, traits);
|
||||
harmonic_coordinates_2.compute();
|
||||
|
||||
std::vector<FT> coordinates;
|
||||
coordinates.reserve(polygon.size());
|
||||
for (std::size_t k = 0; k < domain.number_of_vertices(); ++k) {
|
||||
coordinates.clear();
|
||||
harmonic_coordinates_2(k, std::back_inserter(coordinates));
|
||||
*(c_begin++) = coordinates;
|
||||
}
|
||||
return c_begin;
|
||||
}
|
||||
|
||||
/// \cond SKIP_IN_MANUAL
|
||||
template<
|
||||
typename PointRange,
|
||||
typename OutIterator>
|
||||
OutIterator harmonic_coordinates_2(
|
||||
const PointRange& polygon,
|
||||
const PointRange& seeds,
|
||||
OutIterator c_begin,
|
||||
const typename Kernel_traits<typename PointRange::value_type>::Kernel::FT
|
||||
max_edge_length =
|
||||
typename Kernel_traits<typename PointRange::value_type>::Kernel::FT(1) /
|
||||
typename Kernel_traits<typename PointRange::value_type>::Kernel::FT(100)) {
|
||||
|
||||
using GeomTraits = typename Kernel_traits<
|
||||
typename PointRange::value_type>::Kernel;
|
||||
const GeomTraits traits;
|
||||
return harmonic_coordinates_2(
|
||||
polygon, seeds, c_begin, traits, max_edge_length);
|
||||
}
|
||||
/// \endcond
|
||||
|
||||
} // namespace Barycentric_coordinates
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_BARYCENTRIC_COORDINATES_2_H
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
// Copyright (c) 2019 INRIA Sophia-Antipolis (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) : Dmitry Anisimov, David Bommes, Kai Hormann, Pierre Alliez
|
||||
//
|
||||
|
||||
#ifndef CGAL_BARYCENTRIC_DEPRECATED_HEADERS_2_H
|
||||
#define CGAL_BARYCENTRIC_DEPRECATED_HEADERS_2_H
|
||||
|
||||
#include <CGAL/license/Barycentric_coordinates_2.h>
|
||||
|
||||
#include <CGAL/Barycentric_coordinates_2/deprecated/barycentric_enum_2_deprecated.h>
|
||||
#include <CGAL/Barycentric_coordinates_2/deprecated/Segment_coordinates_2_deprecated.h>
|
||||
#include <CGAL/Barycentric_coordinates_2/deprecated/Triangle_coordinates_2_deprecated.h>
|
||||
|
||||
#include <CGAL/Barycentric_coordinates_2/deprecated/Wachspress_2_deprecated.h>
|
||||
#include <CGAL/Barycentric_coordinates_2/deprecated/Mean_value_2_deprecated.h>
|
||||
#include <CGAL/Barycentric_coordinates_2/deprecated/Discrete_harmonic_2_deprecated.h>
|
||||
#include <CGAL/Barycentric_coordinates_2/deprecated/Generalized_barycentric_coordinates_2_deprecated.h>
|
||||
|
||||
#endif // CGAL_BARYCENTRIC_DEPRECATED_HEADERS_2_H
|
||||
|
|
@ -169,8 +169,8 @@ namespace Barycentric_coordinates {
|
|||
/*!
|
||||
\brief computes 2D discrete harmonic coordinates.
|
||||
|
||||
This function fills `coordinates` with 2D discrete harmonic coordinates computed at the `query`
|
||||
point with respect to the vertices of the input polygon.
|
||||
This function fills `c_begin` with 2D discrete harmonic coordinates computed
|
||||
at the `query` point with respect to the vertices of the input polygon.
|
||||
|
||||
The number of returned coordinates equals to the number of polygon vertices.
|
||||
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ namespace Barycentric_coordinates {
|
|||
/*!
|
||||
\brief evaluates 2D harmonic coordinates.
|
||||
|
||||
This function fills `coordinates` with harmonic coordinates evaluated at the `query`
|
||||
This function fills `c_begin` with harmonic coordinates evaluated at the `query`
|
||||
point with respect to the vertices of the input polygon. Evaluation is performed
|
||||
by locating the finite element in the input domain that contains `query` and then
|
||||
linearly interpolating harmonic coordinates within this element.
|
||||
|
|
@ -252,9 +252,9 @@ namespace Barycentric_coordinates {
|
|||
}
|
||||
|
||||
/*!
|
||||
\brief returns 2D harmonic coordinates.
|
||||
\brief returns 2D harmonic coordinates at one domain vertex.
|
||||
|
||||
This function fills `coordinates` with harmonic coordinates computed at the
|
||||
This function fills `c_begin` with harmonic coordinates computed at the
|
||||
vertex of the input domain with the index `query_index`.
|
||||
|
||||
The number of returned coordinates equals to the number of polygon vertices.
|
||||
|
|
@ -310,6 +310,36 @@ namespace Barycentric_coordinates {
|
|||
return c_begin;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief returns 2D harmonic coordinates at all domain vertices.
|
||||
|
||||
This function fills `c_begin` with harmonic coordinates computed at
|
||||
the vertices of the input domain.
|
||||
|
||||
The number of returned coordinates equals to the number of input domain vertices.
|
||||
|
||||
\tparam OutIterator
|
||||
a model of `OutputIterator` that accepts values of type `std::vector<FT>`
|
||||
|
||||
\param c_begin
|
||||
the beginning of the destination range with the computed coordinates
|
||||
|
||||
\return an output iterator to the element in the destination range,
|
||||
one past the last coordinate set stored
|
||||
*/
|
||||
template<typename OutIterator>
|
||||
OutIterator operator()(OutIterator c_begin) {
|
||||
|
||||
std::vector<FT> coordinates;
|
||||
coordinates.reserve(m_polygon.size());
|
||||
for (std::size_t k = 0; k < m_domain.number_of_vertices(); ++k) {
|
||||
coordinates.clear();
|
||||
operator()(k, std::back_inserter(coordinates));
|
||||
*(c_begin++) = coordinates;
|
||||
}
|
||||
return c_begin;
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Computation
|
||||
|
|
|
|||
|
|
@ -178,8 +178,8 @@ namespace Barycentric_coordinates {
|
|||
/*!
|
||||
\brief computes 2D mean value coordinates.
|
||||
|
||||
This function fills `coordinates` with 2D mean value coordinates computed at the `query`
|
||||
point with respect to the vertices of the input polygon.
|
||||
This function fills `c_begin` with 2D mean value coordinates computed
|
||||
at the `query` point with respect to the vertices of the input polygon.
|
||||
|
||||
The number of returned coordinates equals to the number of polygon vertices.
|
||||
|
||||
|
|
|
|||
|
|
@ -167,8 +167,8 @@ namespace Barycentric_coordinates {
|
|||
/*!
|
||||
\brief computes 2D Wachspress coordinates.
|
||||
|
||||
This function fills `coordinates` with 2D Wachspress coordinates computed at the `query`
|
||||
point with respect to the vertices of the input polygon.
|
||||
This function fills `c_begin` with 2D Wachspress coordinates computed
|
||||
at the `query` point with respect to the vertices of the input polygon.
|
||||
|
||||
The number of returned coordinates equals to the number of polygon vertices.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Barycentric_coordinates_2/Delaunay_domain_2.h>
|
||||
#include <CGAL/Barycentric_coordinates_2.h>
|
||||
|
||||
using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <CGAL/Projection_traits_xz_3.h>
|
||||
#include <CGAL/Projection_traits_yz_3.h>
|
||||
#include <CGAL/Barycentric_coordinates_2.h>
|
||||
#include <CGAL/Barycentric_coordinates_2/Delaunay_domain_2.h>
|
||||
|
||||
using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
|
||||
using FT = typename Kernel::FT;
|
||||
|
|
|
|||
Loading…
Reference in New Issue