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).
#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 Z2i;
{
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.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();
<< SetMode( shape.className(), "DrawAdjacencies" )
<< shape;
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();
<< SetMode( shape2.className(), "DrawAdjacencies" )
<< shape2;
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
return 0;
}
void beginBlock(const std::string &keyword="")
Object< DT8_4, DigitalSet > Object8_4
Object< DT4_8, DigitalSet > Object4_8
DGtal is the top-level namespace which contains all DGtal functions and types.
int main(int argc, char **argv)
HyperRectDomain< Space > Domain
Z2i::DigitalSet DigitalSet