31#include <unordered_set>
32#include "DGtal/base/Common.h"
33#include "DGtal/helpers/StdDefs.h"
34#include "DGtalCatch.h"
36#include "DGtal/geometry/volumes/distance/VoronoiMapComplete.h"
37#include "DGtal/geometry/volumes/distance/VoronoiMap.h"
48 std::unordered_set<Z2i::Point>>
54 std::vector<Point> Sites;
60 Sites.push_back( point );
63 std::cout << std::endl;
68 std::unordered_set<Point> voronoi_points;
69 double voronoi_distance =
70 std::numeric_limits<int>::max();
71 for (
Point site : Sites )
73 if ( ( point - site ).norm() < voronoi_distance )
75 voronoi_points.clear();
76 voronoi_points.insert( site );
77 voronoi_distance = ( point - site ).norm();
79 else if ( ( point - site ).norm() == voronoi_distance )
81 voronoi_points.insert( site );
84 voronoi_map->
setValue( point, voronoi_points );
97 Point lowerBound( 0, 0 ), upperBound( 31, 31 );
101 int point_setup_index = 0;
105 while ( point_setup_index < 400 )
124 "Testing that VoronoiMapComplete class gives the right voronoi sites sets" )
126 for (
Point point : set )
128 std::unordered_set<Point> brut_force_set =
129 brut_force_vmap->operator()( point );
134 for (
Point voronoi_point : brut_force_set )
136 REQUIRE( std::find( class_set.begin(), class_set.end(),
137 voronoi_point ) != class_set.end() );
142 for (
Point voronoi_point : class_set )
144 REQUIRE( std::find( brut_force_set.begin(), brut_force_set.end(),
145 voronoi_point ) != brut_force_set.end() );
151 "Testing Complete Voronoi Map from Discrete Bisector Function paper" )
153 Point lowerBound( 0, 0 ), upperBound( 6, 7 );
158 if ( point !=
Point( 1, 0 ) && point !=
Point( 5, 0 ) &&
159 point !=
Point( 2, 2 ) && point !=
Point( 4, 4 ) &&
160 point !=
Point( 0, 6 ) && point !=
Point( 6, 6 ) &&
161 point !=
Point( 3, 7 ) )
169 for (
Point point : set )
171 std::unordered_set<Point> brut_force_set =
172 brutForceVoronoiMap->operator()( point );
177 for (
Point voronoi_point : brut_force_set )
178 REQUIRE( std::find( class_set.begin(), class_set.end(),
179 voronoi_point ) != class_set.end() );
183 for (
Point voronoi_point : class_set )
184 REQUIRE( std::find( brut_force_set.begin(), brut_force_set.end(),
185 voronoi_point ) != brut_force_set.end() );
195 Point lowerBound( 0, 0 ), upperBound( 255, 255 );
212 Point lowerBound( 0, 0 ), upperBound( 255, 255 );
216 int point_setup_index = 0;
220 while ( point_setup_index < 5000 )
227 std::cout << std::endl;
234 maxsize = std::max( maxsize, v.size() );
235 trace.
info() <<
"Max number of co-cyclic points = " << maxsize << std::endl;
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
const Domain & domain() const
void insert(const Point &p)
void setValue(const Point &aPoint, const Value &aValue)
void beginBlock(const std::string &keyword="")
Aim: Implementation of the linear in time Voronoi map construction.
OutputImage::Value Value
Definition of the image value type.
ConstRange constRange() const
Aim: Implementation of the linear in time Voronoi map construction.
static const L2Metric l2Metric
DGtal is the top-level namespace which contains all DGtal functions and types.
SECTION("Testing constant forward iterators")
REQUIRE(domain.isInside(aPoint))
ImageContainerBySTLVector< HyperRectDomain< Z2i::Space >, std::unordered_set< Z2i::Point > > TImageContainer
TImageContainer * brut_force_voronoi_map_complete(DigitalSet &set)
TEST_CASE("Testing VoronoiMapComplete 2D")
Z2i::DigitalSet DigitalSet
VoronoiMapComplete< Z2i::Space, DigitalSet, Z2i::L2Metric > CompleteVMap
VoronoiMap< Z2i::Space, DigitalSet, Z2i::L2Metric > VMap