template<class Traits, class PointPMap = boost::typed_identity_property_map <typename Traits::Point_2>, class MassPMap = boost::static_property_map <typename Traits::FT>>
class CGAL::Optimal_transportation_reconstruction_2< Traits, PointPMap, MassPMap >
This class provides a means to reconstruct a 1-dimensional shape from a set of 2D points with masses.
The algorithm computes an initial 2D Delaunay triangulation from the input points, and performs a simplification of the triangulation by performing half edge collapses, edge flips and vertex relocations.
The edges are either processed in the order imposed by an priority queue, or in an order based on random selection of edge collapse operators. As the exhaustive priority queue guarantees a higher quality it is the default. The user can switch to the other method, for example for an initial simplification round, by calling set_random_sample_size()
.
By default edge flip operators are applied to ensure that every edge of the triangulation are candidate to be collapsed, while preserving a valid embedding of the triangulation. This option can be disabled by calling set_use_flip(false)
to reduce the running times.
By default the vertices are not relocated after each half edge collapse. This option can be changed by setting the number of vertex relocation steps performed between two edge collapse operators.
The simplification is performed by calling either run_until(n)
or run(steps)
. The former simplifies the triangulation until n points remain, while the latter stops after steps
edge collapse operators have been performed. Furthermore, we can relocate the vertices by calling relocate_all_points()
.
- Template Parameters
-
- Examples:
- Optimal_transportation_reconstruction_2/otr2_indexed_output_example.cpp, Optimal_transportation_reconstruction_2/otr2_list_output_example.cpp, Optimal_transportation_reconstruction_2/otr2_mass_example.cpp, Optimal_transportation_reconstruction_2/otr2_simplest_example.cpp, and Optimal_transportation_reconstruction_2/otr2_simplest_example_with_tolerance.cpp.
|
void | set_random_sample_size (std::size_t sample_size) |
| If sample_size == 0 , the simplification is performed using an exhaustive priority queue. More...
|
|
void | set_verbose (int verbose) |
| Determines how much console output the algorithm generates. More...
|
|
void | set_use_flip (const bool use_flip) |
| The use_flip parameter determines whether the edge flipping procedure is used for the half-edge collapse.
|
|
void | set_relocation (unsigned int relocation) |
| Sets the number of vertex relocations that are performed between two edge collapses.
|
|
void | set_relevance (const FT relevance) |
|
|
You can freely mix calls of the following functions.
|
bool | run_until (std::size_t np) |
| Computes a shape consisting of np points, reconstructing the input points. More...
|
|
bool | run (const unsigned int steps) |
| Computes a shape, reconstructing the input, by performing steps edge collapse operators on the output simplex. More...
|
|
void | run_under_wasserstein_tolerance (const FT tolerance) |
| Computes a shape, reconstructing the input, by performing edge collapse operators on the output simplex until the user-defined tolerance is reached. More...
|
|
void | relocate_all_points () |
| Since noise and missing data may prevent the reconstructed shape to have sharp corners well located, the algorithm offers the possibility to automatically relocate points after each edge collapse. More...
|
|
|
template<typename PointOutputIterator , typename IndexOutputIterator , typename IndexPairOutputIterator > |
std::tuple< PointOutputIterator, IndexOutputIterator, IndexPairOutputIterator > | indexed_output (PointOutputIterator points, IndexOutputIterator isolated_points, IndexPairOutputIterator segments) const |
| Writes the points and segments of the output simplex in an indexed format into output iterators. More...
|
|
template<class PointOutputIterator , class SegmentOutputIterator > |
void | list_output (PointOutputIterator v_it, SegmentOutputIterator e_it) const |
| Returns the solid edges and vertices present after the reconstruction process finished. More...
|
|
template<class Traits , class PointPMap = boost::typed_identity_property_map <typename Traits::Point_2>, class MassPMap = boost::static_property_map <typename Traits::FT>>
template<class InputRange >
Constructor of the optimal transportation reconstruction class.
It builds an initial simplicial complex for a given range of point-mass pairs.
- Template Parameters
-
InputRange | is a model of Range with forward iterators, providing input points and point masses through the PointPMap and MassPMap property maps. |
- Parameters
-
input_range | Range of input data. |
point_map | A ReadablePropertyMap used to access the input points. |
mass_map | A ReadablePropertyMap used to access the input points' masses. |
sample_size | If sample_size != 0 , the size of the random sample which replaces the exhaustive priority queue. |
use_flip | If true the edge flipping procedure is used to ensure that every edge can be made collapsible. |
relocation | The number of point relocations that are performed between two edge collapses. |
verbose | Controls how much console output is produced by the algorithm. The values are 0, 1, or > 1. |
traits | The traits class. |
template<class Traits , class PointPMap = boost::typed_identity_property_map <typename Traits::Point_2>, class MassPMap = boost::static_property_map <typename Traits::FT>>
template<typename PointOutputIterator , typename IndexOutputIterator , typename IndexPairOutputIterator >
std::tuple< PointOutputIterator, IndexOutputIterator, IndexPairOutputIterator> CGAL::Optimal_transportation_reconstruction_2< Traits, PointPMap, MassPMap >::indexed_output |
( |
PointOutputIterator |
points, |
|
|
IndexOutputIterator |
isolated_points, |
|
|
IndexPairOutputIterator |
segments |
|
) |
| const |
Writes the points and segments of the output simplex in an indexed format into output iterators.
- Template Parameters
-
PointOutputIterator | An output iterator with value type Point . |
IndexOutputIterator | An output iterator with value type std::size_t . |
IndexPairOutputIterator | An output iterator with value type std::pair<std::size_t, std::size_t> . |
- Parameters
-
points | The output iterator for all points. |
isolated_points | The output iterator for the indices of isolated points. |
segments | The output iterator for the pairs of segment indices. |
template<class Traits , class PointPMap = boost::typed_identity_property_map <typename Traits::Point_2>, class MassPMap = boost::static_property_map <typename Traits::FT>>
template<class PointOutputIterator , class SegmentOutputIterator >
Returns the solid edges and vertices present after the reconstruction process finished.
It takes two output iterators, one for storing the isolated points and one for storing the edges of the reconstructed shape.
- Template Parameters
-
PointOutputIterator | An output iterator with value type Point . |
SegmentOutputIterator | An output iterator with value type Segment . |
template<class Traits , class PointPMap = boost::typed_identity_property_map <typename Traits::Point_2>, class MassPMap = boost::static_property_map <typename Traits::FT>>
Since noise and missing data may prevent the reconstructed shape to have sharp corners well located, the algorithm offers the possibility to automatically relocate points after each edge collapse.
The new location of the points is chosen such that the fitting of the output segments to the input points is improved.
template<class Traits , class PointPMap = boost::typed_identity_property_map <typename Traits::Point_2>, class MassPMap = boost::static_property_map <typename Traits::FT>>
Computes a shape, reconstructing the input, by performing edge collapse operators on the output simplex until the user-defined tolerance is reached.
- Note
- The tolerance is given in the sense of the Wasserstein distance. It is not a Hausdorff tolerance: it does not mean that the distance between the input samples and the output polyline is guaranteed to be less than
tolerance
. It means that the square root of transport cost per mass (homogeneous to a distance) is at most tolerance
.
- Parameters
-
tolerance | Tolerance on the Wasserstein distance. |
template<class Traits , class PointPMap = boost::typed_identity_property_map <typename Traits::Point_2>, class MassPMap = boost::static_property_map <typename Traits::FT>>
If sample_size == 0
, the simplification is performed using an exhaustive priority queue.
If sample_size
is strictly positive the simplification is performed using a multiple choice approach, ie, a best-choice selection in a random sample of edge collapse operators, of size sample_size
. A typical value for the sample size is 15, but this value must be enlarged when targeting a very coarse simplification.
- Parameters
-
sample_size | If sample_size != 0 , the size of the random sample replaces the priority queue. |