30 #include <unordered_set>
31 #include "DGtal/base/Common.h"
32 #include "DGtal/helpers/StdDefs.h"
33 #include "DGtalCatch.h"
35 #include "DGtal/geometry/volumes/distance/VoronoiMapComplete.h"
36 #include "DGtal/geometry/volumes/distance/VoronoiMap.h"
38 using namespace DGtal;
47 std::unordered_set<Z2i::Point>>
53 std::vector<Point> Sites;
59 Sites.push_back( point );
62 std::cout << std::endl;
67 std::unordered_set<Point> voronoi_points;
68 double voronoi_distance =
70 for (
Point site : Sites )
72 if ( ( point - site ).norm() < voronoi_distance )
74 voronoi_points.clear();
75 voronoi_points.insert( site );
76 voronoi_distance = ( point - site ).norm();
78 else if ( ( point - site ).norm() == voronoi_distance )
80 voronoi_points.insert( site );
83 voronoi_map->
setValue( point, voronoi_points );
96 Point lowerBound( 0, 0 ), upperBound( 31, 31 );
100 int point_setup_index = 0;
104 while ( point_setup_index < 400 )
123 "Testing that VoronoiMapComplete class gives the right voronoi sites sets" )
125 for (
Point point : set )
127 std::unordered_set<Point> brut_force_set =
128 brut_force_vmap->operator()( point );
133 for (
Point voronoi_point : brut_force_set )
135 REQUIRE( std::find( class_set.begin(), class_set.end(),
136 voronoi_point ) != class_set.end() );
141 for (
Point voronoi_point : class_set )
143 REQUIRE( std::find( brut_force_set.begin(), brut_force_set.end(),
144 voronoi_point ) != brut_force_set.end() );
150 "Testing Complete Voronoi Map from Discrete Bisector Function paper" )
152 Point _lowerBound( 0, 0 ), _upperBound( 6, 7 );
153 Domain _domain( _lowerBound, _upperBound );
157 if ( point !=
Point( 1, 0 ) && point !=
Point( 5, 0 ) &&
158 point !=
Point( 2, 2 ) && point !=
Point( 4, 4 ) &&
159 point !=
Point( 0, 6 ) && point !=
Point( 6, 6 ) &&
160 point !=
Point( 3, 7 ) )
168 for (
Point point : _set )
170 std::unordered_set<Point> brut_force_set =
171 brutForceVoronoiMap->operator()( point );
176 for (
Point voronoi_point : brut_force_set )
177 REQUIRE( std::find( class_set.begin(), class_set.end(),
178 voronoi_point ) != class_set.end() );
182 for (
Point voronoi_point : class_set )
183 REQUIRE( std::find( brut_force_set.begin(), brut_force_set.end(),
184 voronoi_point ) != brut_force_set.end() );
194 Point lowerBound( 0, 0 ), upperBound( 255, 255 );
211 Point lowerBound( 0, 0 ), upperBound( 255, 255 );
215 int point_setup_index = 0;
219 while ( point_setup_index < 5000 )
226 std::cout << std::endl;
233 maxsize =
std::max( maxsize, v.size() );
234 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...
void insert(const Point &p)
const Domain & domain() const
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