DGtal  1.0.0
exampleParametricShapes.cpp
Go to the documentation of this file.
1 
30 
33 #include <iostream>
34 #include <DGtal/base/Common.h>
35 
36 // Shape construction
37 #include <DGtal/shapes/Shapes.h>
38 #include <DGtal/shapes/GaussDigitizer.h>
39 #include <DGtal/shapes/parametric/Astroid2D.h>
40 
41 // Drawing
42 #include <DGtal/io/boards/Board2D.h>
43 
44 using namespace DGtal;
46 
47 int main( int argc, char** argv )
48 {
49  trace.beginBlock ( "Example Parametric Shapes" );
50 
51  typedef Z2i::Space Space;
52 
53  /* This example consider the Lemniscate shape.
54  *
55  * To test other shapes, replace Astroid2D by the desirated shape
56  * and adapt parameters of the shape constructor.
57  */
58  typedef Astroid2D<Space> MyShape;
59  MyShape shape( 0, 0, 10, 5 );
60 
61  // Grid step parameter for the Gauzz digitization
62  double h = 1;
63 
64  // Gauss digitization
65  typedef GaussDigitizer< Z2i::Space, MyShape > MyGaussDigitizer;
66  MyGaussDigitizer dig;
67  dig.attach( shape );
68  dig.init( shape.getLowerBound(), shape.getUpperBound(), h );
69 
70  // Create the digital point set from the digitizer
71  Z2i::DigitalSet aSet( dig.getDomain() );
73 
74  // Draw the digitized shape in a file named "shape.svg"
75  Board2D board;
76  board << aSet;
77  board << CustomStyle( aSet.className(), new CustomFillColor(Color::Black));
78  board.saveSVG( "shape.svg" );
79 
80  trace.endBlock();
81  return 0;
82 }
83 
85 // //
void beginBlock(const std::string &keyword="")
static void digitalShaper(TDigitalSet &aSet, const TShapeFunctor &aFunctor)
static const Color Black
Definition: Color.h:388
Trace trace
Definition: Common.h:144
Custom style class redefining the fill color. You may use Board2D::Color::None for transparent color.
Definition: Board2D.h:342
void attach(ConstAlias< EuclideanShape > shape)
double endBlock()
Aim: Model of the concept StarShaped represents an astroid.
Definition: Astroid2D.h:61
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1012
int main(int argc, char **argv)
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
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...
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:70