32 #include "DGtal/base/Common.h"
33 #include "DGtal/io/boards/Board2D.h"
34 #include "DGtal/io/colormaps/GradientColorMap.h"
35 #include "DGtal/kernel/sets/DigitalSetSelector.h"
36 #include "DGtal/shapes/GaussDigitizer.h"
37 #include "DGtal/helpers/StdDefs.h"
38 #include "DGtal/shapes/parametric/Ellipse2D.h"
39 #include "DGtal/shapes/parametric/Flower2D.h"
40 #include "DGtal/shapes/Shapes.h"
41 #include "DGtal/topology/helpers/Surfaces.h"
42 #include "DGtal/geometry/curves/GridCurve.h"
43 #include "DGtal/shapes/CDigitalOrientedShape.h"
44 #include "DGtal/shapes/CDigitalBoundedShape.h"
49 using namespace DGtal;
71 template <
typename Space,
typename Shape>
73 testDigitization(
const Shape & aShape,
double h,
74 const string & fileName )
76 typedef typename Space::Point
Point;
77 typedef typename Space::RealPoint RealPoint;
84 RealPoint xLow( -5.3, -4.3 );
85 RealPoint xUp( 7.4, 4.7 );
88 dig.
init( xLow, xUp, h );
115 std::vector<Point> points;
123 board <<
SetMode( domain.className(),
"Paving" )
137 board.
saveEPS( ( fileName +
".eps" ).c_str() );
138 board.
saveSVG( ( fileName +
".svg" ).c_str() );
147 bool testGaussDigitizer()
149 unsigned int nbok = 0;
152 trace.
beginBlock (
"Testing GaussDigitizer as a Digital Shape functor." );
155 MyEllipse ellipse( 1.2, 0.1, 4.0, 3.0, 0.3 );
156 nbok += testDigitization<Z2i::Space,MyEllipse>
157 ( ellipse, 1.0,
"gauss-ellipse-1" ) ? 1 : 0;
159 nbok += testDigitization<Z2i::Space,MyEllipse>
160 ( ellipse, 0.5,
"gauss-ellipse-0_5" ) ? 1 : 0;
162 nbok += testDigitization<Z2i::Space,MyEllipse>
163 ( ellipse, 0.25,
"gauss-ellipse-0_25" ) ? 1 : 0;
167 MyFlower flower( 0.5, -2.3, 5.0, 0.7, 6, 0.3 );
168 nbok += testDigitization<Z2i::Space,MyFlower>
169 ( flower, 1.0,
"gauss-flower-1" ) ? 1 : 0;
171 nbok += testDigitization<Z2i::Space,MyFlower>
172 ( flower, 0.5,
"gauss-flower-0_5" ) ? 1 : 0;
174 nbok += testDigitization<Z2i::Space,MyFlower>
175 ( flower, 0.25,
"gauss-flower-0_25" ) ? 1 : 0;
178 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
179 <<
"true == true" << std::endl;
188 int main(
int argc,
char** argv )
192 for (
int i = 0; i < argc; ++i )
196 bool res = testConcept() && testGaussDigitizer();
197 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;