DGtal  1.5.beta
shapes/exampleEuclideanShapesDecorator.cpp

Example of EuclideanShapesDecorator

See also
Shapes, Shapers and Digitizers
Result obtained from CSG operations with implicit balls.
#include <iostream>
#include "DGtal/base/Common.h"
// Shape construction
#include "DGtal/shapes/GaussDigitizer.h"
#include "DGtal/topology/LightImplicitDigitalSurface.h"
#include "DGtal/topology/DigitalSurface.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/images/ImageHelper.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/shapes/implicit/ImplicitBall.h"
#include "DGtal/shapes/EuclideanShapesDecorator.h"
// Drawing
#include "DGtal/io/boards/Board2D.h"
using namespace std;
using namespace DGtal;
int main( int argc, char** argv )
{
trace.beginBlock ( "Example EuclideanShapesDecorator" );
trace.info() << "Args:";
for ( int i = 0; i < argc; ++i )
trace.info() << " " << argv[ i ];
trace.info() << endl;
double h = 1.0;
typedef ImplicitBall< Z2i::Space > MyEuclideanShapeA;
typedef ImplicitBall< Z2i::Space > MyEuclideanShapeB;
MyEuclideanShapeA shapeA( Z2i::RealPoint( 0.0, 0.0 ), 15 );
MyEuclideanShapeB shapeB( Z2i::RealPoint( 0.0, 0.0 ), 10 );
MyEuclideanShapeB shapeC( Z2i::RealPoint( -5.0, 0.0 ), 5 );
typedef EuclideanShapesCSG< MyEuclideanShapeA, MyEuclideanShapeB > Minus;
Minus s_minus ( shapeA );
s_minus.minus( shapeB );
s_minus.plus( shapeC );
typedef GaussDigitizer< Z2i::Space, Minus > MyGaussDigitizer;
MyGaussDigitizer digShape;
digShape.attach( s_minus );
digShape.init( s_minus.getLowerBound(), s_minus.getUpperBound(), h );
Z2i::Domain domainShape = digShape.getDomain();
Z2i::DigitalSet aSet( domainShape );
Shapes<Z2i::Domain>::digitalShaper( aSet, digShape );
Board2D board;
board << SetMode( domainShape.className(), "Paving" )
<< domainShape;
Color dorange ( 255, 136, 0, 220 );
board << CustomStyle( aSet.className(), new CustomFillColor( dorange ));
board << aSet;
board.saveSVG ( "example-EuclideanShapesDecorator.svg" );
return 0;
}
// //
void beginBlock(const std::string &keyword="")
std::ostream & info()
double endBlock()
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition: Common.h:153
int main(int argc, char **argv)
HyperRectDomain< Space > Domain
PointVector< 3, double > RealPoint
Z2i::DigitalSet DigitalSet