Карта сайта Kansoftware
НОВОСТИУСЛУГИРЕШЕНИЯКОНТАКТЫ
Разработка программного обеспечения

Voronoi Main

Boost , ,


THE BOOST POLYGON VORONOI EXTENSIONS


The Voronoi extensions of the Boost Polygon library provide functionality to construct a Voronoi diagram of a set of points and linear segments in 2D space with the following set of limitations:
  • Координаты входных точек и конечных точек входных сегментов должны иметь интегральный тип. Тип данных int32 поддерживается реализацией по умолчанию. Поддержка других типов данных (например, int64) может быть достигнута за счет конфигурации признаков типа координат (Voronoi Advanced tutorial).
  • Точки входа и сегменты не должны пересекаться, кроме их конечных точек. Это означает, что входная точка не должна находиться внутри входного сегмента, и входные сегменты не должны пересекаться, кроме своих конечных точек.
While the first restriction is permanent (it allows to give the exact warranties about the output precision and algorithm execution flow), the second one may be resolved using the Boost.Polygon segment utils. The strong sides of the library and the main benefits comparing to the other implementations are discussed in the following paragraphs.

Fully Functional with Segments

There are just a few implementations of the Voronoi diagram construction algorithm that can handle input data sets that contain linear segments, even considering the commercial libraries. Support of the segments allows to discretize any input geometry (sampled floating-point coordinates can be scaled and snapped to the integer grid): circle, ellipse, parabola. This functionality allows to compute the medial axis transform of the arbitrary set of input geometries, with direct applications in the computer vision projects.

Robustness and Efficiency

Robustness issues can be divided onto the two main categories: memory management issues and numeric stability issues. The implementation avoids the first type of the issues using pure STL data structures, thus there is no presence of the new operator in the code. The second category of the problems is resolved using the multiprecision geometric predicates. Even for the commercial libraries, usage of such predicates results in a vast performance slowdown. The library implementation overcomes this by avoiding the multiprecision computations in the 95% of the cases by using the efficient, floating-point based predicates. Such predicates don't produce the correct result always, however the library embeds the relative error arithmetic apparatus to identify such situations and switch to the higher precision predicates when appropriate. As the result, the implementation has a solid performance comparing to the other known libraries (more details in the benchmarks).

Precision of the Output Structures

The implementation guaranties, that the relative error of the coordinates of the output geometries is at most 64 machine epsilons (6 bits of mantissa, for the IEEE-754 floating-point type), while on average it's slightly lower. This means, that the precision of the output geometries can be increased simply by using a floating-point type with the larger mantissa. The practical point of this statements is explained in the following table:
Output Coordinate Type Output Coordinate Value Max Absolute Error Precise Value Range
double (53 bit mantissa) 1 2-53 * 26 = 2-47 1 ± 2-47
double (53 bit mantissa) 231 2-53 * 231 * 26 = 2-16 231 ± 2-16
long double (64 bit mantissa) 1 2-64 * 26 = 2-58 1 ± 2-58
long double (64 bit mantissa) 231 2-64 * 231 * 26 = 2-27 231 ± 2-27
Detailed description of the absolute and relative errors evaluation can be found in the article: "What Every Computer Scientist Should Know About Floating-Point Arithmetic".

During the finalization step the implementation unites Voronoi vertices whose both coordinates are located within the relative error range equal to 128 machine epsilons and removes any Voronoi edges between those. This is the only case, that might cause differences between the algorithm output topology and theoretically precise one, and practically means the following: for a Voronoi diagram of a set of solid bodies inside the Solar System (radius 242 metres) and the long double (64 bit mantissa) output coordinate type the maximum absolute error within the Solar System rectangle will be equal to 2-64 * 242 * 26 = 2-18 metres; as the result, vertices with both coordinates that are within 2-18 metres (8 micrometres or the size of a bacteria) will be considered equal and united.

Simple Interface

The boost/polygon/voronoi.hpp library header defines the following static functions to integrate the Voronoi extensions functionality with the Boost.Polygon interfaces:

template <typename Point, typename VB>
size_t insert(const Point &point, VB *vb)
Вставляет точку в структуру данных конструктора Voronoi.
Тип точки должен моделировать концепцию точки.
Индекс возврата вставленного сайта.
template <typename PointIterator, typename VB>
void insert(PointIterator first,
            PointIterator last,
            VB *vb)
Вставляет диапазон точек итератора в структуру данных строителя Voronoi.
Соответствующий тип точки должен моделировать концепцию точки.
template <typename Segment, typename VB>
size_t insert(const Segment &segment, VB *vb)
Включить сегмент в структуру данных Voronoi builder.
Тип сегмента должен моделировать концепцию сегмента.
Индекс возврата вставленного сайта.
template <typename SegmentIterator, typename VB>
void insert(SegmentIterator first,
            SegmentIterator last,
            VB *vb)
Вставляет диапазон итераторов сегментов в структуру данных Voronoi builder.
Соответствующий тип сегмента должен моделировать концепцию сегмента.
template <typename PointIterator, typename VD>
void construct_voronoi(PointIterator first,
                       PointIterator last,
                       VD *vd)
Построение диаграммы Вороноя набора точек.
Соответствующий тип точки должен моделировать концепцию точки.
Сложность: O(N * log N), использование памяти: O(N), где N - общее количество точек ввода.
template <typename SegmentIterator, typename VD>
void construct_voronoi(SegmentIterator first,
                       SegmentIterator last,
                       VD *vd)
Построение диаграммы Вороноя набора сегментов.
Соответствующий тип сегмента должен моделировать концепцию сегмента.
Сложность: O(N * log N), использование памяти: O(N), где N - общее количество входных сегментов.
template <typename PointIterator,
          typename SegmentIterator,
          typename VD>
void construct_voronoi(PointIterator p_first,
                       PointIterator p_last,
                       SegmentIterator s_first,
                       SegmentIterator s_last,
                       VD *vd)
Построение диаграммы Вороноя набора точек и сегментов.
Соответствующий тип точки должен моделировать концепцию точки.
Соответствующий тип сегмента должен моделировать концепцию сегмента.
Сложность: O(N* log N), использование памяти: O(N), где N - общее количество точек ввода и сегментов.

The following two lines of code construct a Voronoi diagram of a set of points (as long as the corresponding input geometry type satisfies the Boost.Polygon concept model):

voronoi_diagram<double> vd;
construct_voronoi(points.begin(), points.end(), &vd);

The library provides the clear interfaces to associate the user data with the output geometries and efficiently traverse the Voronoi graph. More details on those topics are covered in the basic Voronoi tutorial. Advanced usage of the library with the configuration of the coordinate types is explained in the advanced Voronoi tutorial. The library allows users to implement their own Voronoi diagram / Delaunay triangulation construction routines based on the Voronoi builder API.

No Third Party Dependencies

The Voronoi extensions of the Boost Polygon library doesn't depend on any 3rd party code and contains single dependency on the Boost libraries: boost/cstdint.hpp. All the required multiprecision types and related functionality are encapsulated as part of the implementation. The library is fast to compile (3 public and 4 private heades), has strong cohesion between its components and is clearly modularized from the rest of the Boost Polygon library, with the optional integration through the voronoi.hpp header.

Extensible for the User Provided Coordinate Types

The implementation is coordinate type agnostic. As long as the user provided types satisfy the set of the requirements of the Voronoi builder coordinate type traits, no additional changes are required neither to the algorithm, nor to the implementation of the predicates. For example, it's possible to construct the Voronoi diagram with the 256-bit integer input coordinate type and 512-bit output floating-point type without making any changes to the library.

Future Development

Below one may find the list of the possible directions for the future development of the library.
  • Реализация структуры данных Делаунайской триангуляции.
  • Реализация структуры данных медиальной оси.
  • Утилиты сериализации для структуры данных диаграммы Вороноя.
  • Опустить ограничение на непересекающиеся входные геометрии.
  • Поддержка различных типов метрик расстояния.

Theoretical Research

The Voronoi extensions were developed as part of the Google Summer of Code 2010. The library was actively maintained for the last three years and involved deep mathematical research in the field of algorithms, data structures, relative error arithmetic and numerical robustness. Upon the community request, more details on the theoretical aspects of the implementation will be published. The authors would like to acknowledge the Steven Fortune's article "A Sweepline algorithm for Voronoi diagrams", that covers fundamental ideas of the current implementation.
 
Copyright: Авторское право © Андрей Сидорчук 2010-2013.
License: Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Статья Voronoi Main раздела может быть полезна для разработчиков на c++ и boost.




Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.



:: Главная :: ::


реклама


©KANSoftWare (разработка программного обеспечения, создание программ, создание интерактивных сайтов), 2007
Top.Mail.Ru

Время компиляции файла: 2024-08-30 11:47:00
2025-05-19 17:57:48/0.0074019432067871/0