DGtal  0.9.2
dgtalBoard2D-2-sets.cpp
1 
30 #include <iostream>
32 #include "DGtal/base/Common.h"
33 #include "DGtal/io/boards/Board2D.h"
34 #include "DGtal/shapes/Shapes.h"
35 #include "DGtal/helpers/StdDefs.h"
37 
38 using namespace std;
39 using namespace DGtal;
40 using namespace Z2i;
41 
43 
44 int main( )
45 {
46  trace.beginBlock ( "Example dgtalBoard2D-2-sets" );
47 
48  Point p1( -10, -7 );
49  Point p2( 10, 7 );
50  Domain domain( p1, p2 );
51  DigitalSet shape_set( domain );
52  Shapes<Domain>::addNorm1Ball( shape_set, Point( -5, -1 ), 5 );
53  Shapes<Domain>::addNorm1Ball( shape_set, Point( 5, 1 ), 5 );
54  shape_set.erase( Point( -5, -1 ) );
55  shape_set.erase( Point( 5, 1 ) );
56 
57  Board2D board;
58  board << domain << shape_set; // display domain and set
59  board.saveSVG( "dgtalBoard2D-2-sets-1.svg");
60  board.saveEPS( "dgtalBoard2D-2-sets-1.eps");
61  board.saveTikZ( "dgtalBoard2D-2-sets-1.tikz");
62 
63 #ifdef WITH_CAIRO
64  board.saveCairo("dgtalBoard2D-2-sets-1-cairo.pdf", Board2D::CairoPDF);
65  board.saveCairo("dgtalBoard2D-2-sets-1-cairo.png", Board2D::CairoPNG);
66  board.saveCairo("dgtalBoard2D-2-sets-1-cairo.ps", Board2D::CairoPS);
67  board.saveCairo("dgtalBoard2D-2-sets-1-cairo.svg", Board2D::CairoSVG);
68 #endif
69 
70  board.clear();
71 
72  // Object with couple (4,8) of adjacency.
73  Object4_8 shape( dt4_8, shape_set );
74  board << domain // display domain
75  << SetMode( shape.className(), "DrawAdjacencies" )
76  << shape; // and object with mode "DrawAdjacencies"
77  board.saveSVG( "dgtalBoard2D-2-sets-2.svg");
78  board.saveEPS( "dgtalBoard2D-2-sets-2.eps");
79  board.saveTikZ( "dgtalBoard2D-2-sets-2.tikz");
80 
81 #ifdef WITH_CAIRO
82  board.saveCairo("dgtalBoard2D-2-sets-2-cairo.pdf", Board2D::CairoPDF);
83  board.saveCairo("dgtalBoard2D-2-sets-2-cairo.png", Board2D::CairoPNG);
84  board.saveCairo("dgtalBoard2D-2-sets-2-cairo.ps", Board2D::CairoPS);
85  board.saveCairo("dgtalBoard2D-2-sets-2-cairo.svg", Board2D::CairoSVG);
86 #endif
87 
88  board.clear();
89 
90  // Object with couple (8,4) of adjacency.
91  Object8_4 shape2( dt8_4, shape_set );
92  board << domain // display domain
93  << SetMode( shape2.className(), "DrawAdjacencies" )
94  << shape2; // and object with mode "DrawAdjacencies"
95  board.saveSVG( "dgtalBoard2D-2-sets-3.svg");
96  board.saveEPS( "dgtalBoard2D-2-sets-3.eps");
97  board.saveTikZ( "dgtalBoard2D-2-sets-3.tikz");
98 
99 #ifdef WITH_CAIRO
100  board.saveCairo("dgtalBoard2D-2-sets-3-cairo.pdf", Board2D::CairoPDF);
101  board.saveCairo("dgtalBoard2D-2-sets-3-cairo.png", Board2D::CairoPNG);
102  board.saveCairo("dgtalBoard2D-2-sets-3-cairo.ps", Board2D::CairoPS);
103  board.saveCairo("dgtalBoard2D-2-sets-3-cairo.svg", Board2D::CairoSVG);
104 #endif
105 
106  trace.endBlock();
107  return 0;
108 }
109 // //
void beginBlock(const std::string &keyword="")
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition: StdDefs.h:100
Trace trace
Definition: Common.h:130
Object< DT4_8, DigitalSet > Object4_8
Definition: StdDefs.h:101
STL namespace.
double endBlock()
Object< DT8_4, DigitalSet > Object8_4
Definition: StdDefs.h:105
void saveCairo(const char *filename, CairoType type=CairoPNG, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1139
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
DGtal is the top-level namespace which contains all DGtal functions and types.
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1012
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
Modifier class in a Board2D stream. Useful to choose your own mode for a given class. Realizes the concept CDrawableWithBoard2D.
Definition: Board2D.h:247
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