DGtal 1.4.0
Loading...
Searching...
No Matches
exampleParametricShapes.cpp
Go to the documentation of this file.
1
31
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
44using namespace DGtal;
46
47int 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
81 return 0;
82}
83
85// //
Aim: Model of the concept StarShaped represents an astroid.
Definition Astroid2D.h:62
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition Board2D.h:71
static const Color Black
Definition Color.h:413
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
void attach(ConstAlias< EuclideanShape > shape)
static void digitalShaper(TDigitalSet &aSet, const TShapeFunctor &aFunctor)
void beginBlock(const std::string &keyword="")
double endBlock()
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition Board.cpp:1011
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition Common.h:153
Custom style class redefining the fill color. You may use Board2D::Color::None for transparent color.
Definition Board2D.h:343
int main()
Definition testBits.cpp:56