DGtal  0.9.4beta
exampleEuclideanShapesDecorator.cpp
1 
31 
34 #include <iostream>
35 #include "DGtal/base/Common.h"
36 
37 // Shape construction
38 #include "DGtal/shapes/GaussDigitizer.h"
39 #include "DGtal/topology/LightImplicitDigitalSurface.h"
40 #include "DGtal/topology/DigitalSurface.h"
41 #include "DGtal/io/boards/Board2D.h"
42 #include "DGtal/images/ImageHelper.h"
43 #include "DGtal/shapes/Shapes.h"
44 #include "DGtal/shapes/implicit/ImplicitBall.h"
45 #include "DGtal/shapes/EuclideanShapesDecorator.h"
46 
47 // Drawing
48 #include "DGtal/io/boards/Board2D.h"
49 
51 
52 using namespace std;
53 using namespace DGtal;
54 
56 
57 int main( int argc, char** argv )
58 {
59  trace.beginBlock ( "Example EuclideanShapesDecorator" );
60  trace.info() << "Args:";
61  for ( int i = 0; i < argc; ++i )
62  trace.info() << " " << argv[ i ];
63  trace.info() << endl;
64 
66  double h = 1.0;
67 
69  typedef ImplicitBall< Z2i::Space > MyEuclideanShapeA;
70  typedef ImplicitBall< Z2i::Space > MyEuclideanShapeB;
71  MyEuclideanShapeA shapeA( Z2i::RealPoint( 0.0, 0.0 ), 15 );
72  MyEuclideanShapeB shapeB( Z2i::RealPoint( 0.0, 0.0 ), 10 );
73  MyEuclideanShapeB shapeC( Z2i::RealPoint( -5.0, 0.0 ), 5 );
74 
76  Minus s_minus ( shapeA );
77  s_minus.minus( shapeB );
78  s_minus.plus( shapeC );
80 
81  typedef GaussDigitizer< Z2i::Space, Minus > MyGaussDigitizer;
82  MyGaussDigitizer digShape;
83  digShape.attach( s_minus );
84  digShape.init( s_minus.getLowerBound(), s_minus.getUpperBound(), h );
85  Z2i::Domain domainShape = digShape.getDomain();
86  Z2i::DigitalSet aSet( domainShape );
87  Shapes<Z2i::Domain>::digitalShaper( aSet, digShape );
88 
89  Board2D board;
90  board << SetMode( domainShape.className(), "Paving" )
91  << domainShape;
92 
93  Color dorange ( 255, 136, 0, 220 );
94 
95  board << CustomStyle( aSet.className(), new CustomFillColor( dorange ));
96  board << aSet;
97 
98  board.saveSVG ( "example-EuclideanShapesDecorator.svg" );
99 
100  trace.endBlock();
101  return 0;
102 }
103 
105 // //
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
Custom style class redefining the fill color. You may use Board2D::Color::None for transparent color...
Definition: Board2D.h:342
STL namespace.
double endBlock()
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:141
void attach(const EuclideanShape &shape)
std::string className() const
Aim: Constructive Solid Geometry (CSG) between models of CEuclideanBoundedShape and CEuclideanOriente...
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a ball in nD...
Definition: ImplicitBall.h:64
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 saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1012
std::ostream & info()
Modifier class in a Board2D stream. Useful to choose your own mode for a given class. Realizes the concept CDrawableWithBoard2D.
Definition: Board2D.h:247
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
Aim: A utility class for constructing different shapes (balls, diamonds, and others).
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)...
Definition: Board2D.h:70