34 #include "DGtal/base/Common.h" 35 #include "ConfigTest.h" 36 #include "DGtal/helpers/StdDefs.h" 37 #include "DGtal/geometry/volumes/distance/ChamferNorm2D.h" 38 #include "DGtal/geometry/volumes/distance/CMetricSpace.h" 39 #include "DGtal/geometry/volumes/distance/CSeparableMetric.h" 41 #include "DGtal/geometry/volumes/distance/VoronoiMap.h" 43 #include "DGtal/io/colormaps/HueShadeColorMap.h" 44 #include "DGtal/io/colormaps/RandomColorMap.h" 46 #include "DGtal/io/boards/Board2D.h" 50 using namespace DGtal;
56 template <
typename VoroMap>
57 void saveVoroMap(
const std::string &filename,
const VoroMap &output)
64 if ( output(*it) > maxdt)
72 itend = output.domain().end();
79 board.
saveSVG(filename.c_str());
85 bool testChamferVoro()
87 unsigned int nbok = 0;
93 Metric::Directions dirs5711;
94 Metric::Directions normals5711;
114 Metric mask5711(dirs5711,normals5711);
125 mySet.insertNew( *it );
162 VoroChamf voro(&
domain, &mySet,&mask5711);
169 itend = voro.domain().end();
173 int c =
abs(p[1]*11+ p[0]*17);
188 for(
int j= -20; j <= 20 ; j++)
197 bool testChamferVoroLarge()
199 unsigned int nbok = 0;
205 Metric::Directions dirs5711;
206 Metric::Directions normals5711;
226 Metric mask5711(dirs5711,normals5711);
238 mySet.insertNew( *it );
242 for(
unsigned int i = 0; i < N; i++)
243 sites.insert(
Z2i::Point( rand() % N , rand()% N ));
245 std::copy(sites.begin(), sites.end() , std::ostream_iterator<Z2i::Point>(std::cout,
", "));
252 VoroChamf voro(&
domain, &mySet,&mask5711);
257 itend = voro.domain().end();
261 int c =
abs(p[1]*11+ p[0]*17);
275 board.
saveSVG(
"Voromap-large.svg");
285 int main(
int argc,
char** argv )
289 for (
int i = 0; i < argc; ++i )
293 bool res = testChamferVoro()&& testChamferVoroLarge();
294 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
void beginBlock(const std::string &keyword="")
Aim: Implementation of the linear in time Voronoi map construction.
const ConstIterator & end() const
const Domain domain(Point(1, 2), Point(6, 5))
MyDigitalSurface::ConstIterator ConstIterator
Aim: access to random color from a gradientColorMap.
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Aim: implements a model of CSeparableMetric for Chamfer and path based norms.
const ConstIterator & begin() const
int main(int argc, char **argv)
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
void saveVoroMap(const std::string &filename, const VoroMap &output, const double p)
Structure representing an RGB triple with alpha component.
Container::const_iterator ConstIterator
ConstIterator type of the container;.
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)...