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/Ball2D.h"
39 #include "DGtal/shapes/parametric/Astroid2D.h"
40 #include "DGtal/shapes/parametric/Ellipse2D.h"
41 #include "DGtal/shapes/parametric/Flower2D.h"
42 #include "DGtal/shapes/parametric/Lemniscate2D.h"
43 #include "DGtal/shapes/Shapes.h"
44 #include "DGtal/topology/helpers/Surfaces.h"
45 #include "DGtal/geometry/curves/GridCurve.h"
46 #include "DGtal/shapes/CDigitalOrientedShape.h"
47 #include "DGtal/shapes/CDigitalBoundedShape.h"
52 using namespace DGtal;
74 template <
typename Space,
typename Shape>
77 const string & fileName )
116 std::vector<Point> points;
133 board.
saveEPS( ( fileName +
".eps" ).c_str() );
134 board.
saveSVG( ( fileName +
".svg" ).c_str() );
145 unsigned int nbok = 0;
148 trace.
beginBlock (
"Testing GaussDigitizer as a Digital Shape functor." );
151 MyAstroid astroid( 6.2, -2.1, 7.3, 4.9 );
152 nbok += testDigitization<Z2i::Space,MyAstroid>
153 ( astroid, 1.0,
"gauss-astroid-1" ) ? 1 : 0;
155 nbok += testDigitization<Z2i::Space,MyAstroid>
156 ( astroid, 0.5,
"gauss-astroid-0_5" ) ? 1 : 0;
158 nbok += testDigitization<Z2i::Space,MyAstroid>
159 ( astroid, 0.25,
"gauss-astroid-0_25" ) ? 1 : 0;
163 MyBall ball( 6.2, -2.1, 7.3 );
164 nbok += testDigitization<Z2i::Space,MyBall>
165 ( ball, 1.0,
"gauss-ball-1" ) ? 1 : 0;
167 nbok += testDigitization<Z2i::Space,MyBall>
168 ( ball, 0.5,
"gauss-ball-0_5" ) ? 1 : 0;
170 nbok += testDigitization<Z2i::Space,MyBall>
171 ( ball, 0.25,
"gauss-ball-0_25" ) ? 1 : 0;
175 MyEllipse ellipse( 1.2, 0.1, 4.0, 3.0, 0.3 );
176 nbok += testDigitization<Z2i::Space,MyEllipse>
177 ( ellipse, 1.0,
"gauss-ellipse-1" ) ? 1 : 0;
179 nbok += testDigitization<Z2i::Space,MyEllipse>
180 ( ellipse, 0.5,
"gauss-ellipse-0_5" ) ? 1 : 0;
182 nbok += testDigitization<Z2i::Space,MyEllipse>
183 ( ellipse, 0.25,
"gauss-ellipse-0_25" ) ? 1 : 0;
187 MyFlower flower( 0.5, -2.3, 5.0, 0.7, 6, 0.3 );
188 nbok += testDigitization<Z2i::Space,MyFlower>
189 ( flower, 1.0,
"gauss-flower-1" ) ? 1 : 0;
191 nbok += testDigitization<Z2i::Space,MyFlower>
192 ( flower, 0.5,
"gauss-flower-0_5" ) ? 1 : 0;
194 nbok += testDigitization<Z2i::Space,MyFlower>
195 ( flower, 0.25,
"gauss-flower-0_25" ) ? 1 : 0;
199 MyLemniscate lemniscate( 0.5, -2.3, 5.0 );
200 nbok += testDigitization<Z2i::Space,MyLemniscate>
201 ( lemniscate, 1.0,
"gauss-lemniscate-1" ) ? 1 : 0;
203 nbok += testDigitization<Z2i::Space,MyLemniscate>
204 ( lemniscate, 0.5,
"gauss-lemniscate-0_5" ) ? 1 : 0;
206 nbok += testDigitization<Z2i::Space,MyLemniscate>
207 ( lemniscate, 0.25,
"gauss-lemniscate-0_25" ) ? 1 : 0;
210 trace.
info() <<
"(" << nbok <<
"/" << nb <<
") "
211 <<
"true == true" << std::endl;
220 int main(
int argc,
char** argv )
224 for (
int i = 0; i < argc; ++i )
229 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
RealPoint getLowerBound() const
RealPoint getUpperBound() const
Aim: Model of the concept StarShaped represents any circle in the plane.
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Structure representing an RGB triple with alpha component.
Aim: Model of the concept StarShaped represents any ellipse in the plane.
Aim: Model of the concept StarShaped represents any flower with k-petals in the plane.
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
const Point & getLowerBound() const
void attach(ConstAlias< EuclideanShape > shape)
const Point & getUpperBound() const
void init(const RealPoint &xLow, const RealPoint &xUp, typename RealVector::Component gridStep)
Aim: describes, in a cellular space of dimension n, a closed or open sequence of signed d-cells (or d...
std::string className() const
bool initFromVector(const std::vector< Point > &aVectorOfPoints)
std::string className() const
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
Aim: Model of the concept StarShaped represents a lemniscate.
Aim: A utility class for constructing different shapes (balls, diamonds, and others).
Aim: A utility class for constructing surfaces (i.e. set of (n-1)-cells).
void beginBlock(const std::string &keyword="")
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
DGtal is the top-level namespace which contains all DGtal functions and types.
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Aim: Automatically defines an adequate digital set type according to the hints given by the user.
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
std::string className() const
Return the style name used for drawing this object.
Aim: designs the concept of bounded shapes in DGtal (shape for which upper and lower bounding bounds ...
Aim: characterizes models of digital oriented shapes. For example, models should provide an orientati...
int main(int argc, char **argv)
bool testDigitization(const Shape &aShape, double h, const string &fileName)
bool testGaussDigitizer()
HyperRectDomain< Space > Domain
PointVector< 3, double > RealPoint