DGtal 1.3.0
Loading...
Searching...
No Matches
io/boards/dgtalBoard2D-2-sets.cpp

This simple example shows also some basic usage of a Board2D to export graphical representations of dgtal objects (here, a digital set and a digital object). Note also the use of different modes that may be defined for some classes. An object may thus be displayed just as a set of points, but also as a set of points with neighborhood structure (a graph).

visualization of resulting export (first export dgtalBoard2D-2-sets-1).
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/helpers/StdDefs.h"
using namespace std;
using namespace DGtal;
using namespace Z2i;
int main( )
{
trace.beginBlock ( "Example dgtalBoard2D-2-sets" );
Point p1( -10, -7 );
Point p2( 10, 7 );
Domain domain( p1, p2 );
DigitalSet shape_set( domain );
Shapes<Domain>::addNorm1Ball( shape_set, Point( -5, -1 ), 5 );
Shapes<Domain>::addNorm1Ball( shape_set, Point( 5, 1 ), 5 );
shape_set.erase( Point( -5, -1 ) );
shape_set.erase( Point( 5, 1 ) );
Board2D board;
board << domain << shape_set; // display domain and set
board.saveSVG( "dgtalBoard2D-2-sets-1.svg");
board.saveEPS( "dgtalBoard2D-2-sets-1.eps");
board.saveTikZ( "dgtalBoard2D-2-sets-1.tikz");
#ifdef WITH_CAIRO
board.saveCairo("dgtalBoard2D-2-sets-1-cairo.pdf", Board2D::CairoPDF);
board.saveCairo("dgtalBoard2D-2-sets-1-cairo.png", Board2D::CairoPNG);
board.saveCairo("dgtalBoard2D-2-sets-1-cairo.ps", Board2D::CairoPS);
board.saveCairo("dgtalBoard2D-2-sets-1-cairo.svg", Board2D::CairoSVG);
#endif
board.clear();
// Object with couple (4,8) of adjacency.
Object4_8 shape( dt4_8, shape_set );
board << domain // display domain
<< SetMode( shape.className(), "DrawAdjacencies" )
<< shape; // and object with mode "DrawAdjacencies"
board.saveSVG( "dgtalBoard2D-2-sets-2.svg");
board.saveEPS( "dgtalBoard2D-2-sets-2.eps");
board.saveTikZ( "dgtalBoard2D-2-sets-2.tikz");
#ifdef WITH_CAIRO
board.saveCairo("dgtalBoard2D-2-sets-2-cairo.pdf", Board2D::CairoPDF);
board.saveCairo("dgtalBoard2D-2-sets-2-cairo.png", Board2D::CairoPNG);
board.saveCairo("dgtalBoard2D-2-sets-2-cairo.ps", Board2D::CairoPS);
board.saveCairo("dgtalBoard2D-2-sets-2-cairo.svg", Board2D::CairoSVG);
#endif
board.clear();
// Object with couple (8,4) of adjacency.
Object8_4 shape2( dt8_4, shape_set );
board << domain // display domain
<< SetMode( shape2.className(), "DrawAdjacencies" )
<< shape2; // and object with mode "DrawAdjacencies"
board.saveSVG( "dgtalBoard2D-2-sets-3.svg");
board.saveEPS( "dgtalBoard2D-2-sets-3.eps");
board.saveTikZ( "dgtalBoard2D-2-sets-3.tikz");
#ifdef WITH_CAIRO
board.saveCairo("dgtalBoard2D-2-sets-3-cairo.pdf", Board2D::CairoPDF);
board.saveCairo("dgtalBoard2D-2-sets-3-cairo.png", Board2D::CairoPNG);
board.saveCairo("dgtalBoard2D-2-sets-3-cairo.ps", Board2D::CairoPS);
board.saveCairo("dgtalBoard2D-2-sets-3-cairo.svg", Board2D::CairoSVG);
#endif
trace.endBlock();
return 0;
}
// //
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:71
Aim: A utility class for constructing different shapes (balls, diamonds, and others).
void beginBlock(const std::string &keyword="")
double endBlock()
void saveTikZ(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1219
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition: Board.cpp:152
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1012
void saveCairo(const char *filename, CairoType type=CairoPNG, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1139
DGtal is the top-level namespace which contains all DGtal functions and types.
STL namespace.
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Definition: Board2D.h:247
int main()
Definition: testBits.cpp:56
MyPointD Point
Definition: testClone2.cpp:383
Domain domain
HyperRectDomain< Space > Domain
Z2i::DigitalSet DigitalSet