DGtal  0.9.2
ctopo-1.cpp
1 
29 #include <iostream>
31 #include "DGtal/base/Common.h"
32 #include "DGtal/helpers/StdDefs.h"
33 #include "DGtal/io/boards/Board2D.h"
34 #include "DGtal/io/Color.h"
35 
37 
38 using namespace std;
39 using namespace DGtal;
40 using namespace DGtal::Z2i;
42 
43 int main()
44 {
45  KSpace K;
46  Point plow(-3,-2);
47  Point pup(5,3);
48  Domain domain( plow, pup );
49  Board2D board; // for 2D display
50  K.init( plow, pup, true );
51  board << SetMode( domain.className(), "Paving" )
52  << domain;
53  Cell pixlow = K.uSpel( plow ); // pixel (-3*2+1,-2*2+1)
54  Cell ptlow = K.uPointel( plow ); // pointel (-3*2,-2*2)
55  Cell pixup = K.uSpel( pup ); // pixel (5*2+1,3*2+1)
56  Cell ptup1 = K.uPointel( pup ); // pointel (5*2,3*2)
57  Cell ptup2 = K.uTranslation( ptup1, Point::diagonal() ); // pointel (6*2,4*2)
58  Cell linelb = K.uCell( Point( 1, 0 ) ); // linel (1,0) bottom
59  Cell linelt = K.uCell( Point( 1, 2 ) ); // linel (1,2) top
60  Cell linell = K.uCell( Point( 0, 1 ) ); // linel (0,1) left
61  Cell linelr = K.uCell( Point( 2, 1 ) ); // linel (2,1) right
62  board << CustomStyle( ptlow.className(),
63  new CustomColors( Color( 0, 0, 200 ),
64  Color( 100, 100, 255 ) ) )
65  << ptlow << ptup2;
66  board << CustomStyle( pixlow.className(),
67  new CustomColors( Color( 200, 0, 0 ),
68  Color( 255, 100, 100 ) ) )
69  << pixlow << pixup;
70  board << CustomStyle( linelb.className(),
71  new CustomColors( Color( 0, 200, 0 ),
72  Color( 100, 255, 100 ) ) )
73  << linelb << linelt << linell << linelr;
74  board.saveSVG("ctopo-1.svg");
75  board.saveEPS("ctopo-1.eps");
76  return 0;
77 }
78 // //
STL namespace.
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition: Board2D.h:278
std::string className() const
Cell uCell(const PreCell &c) const
Cell uPointel(Point p) const
std::string className() const
bool init(const Point &lower, const Point &upper, bool isClosed)
Z2i this namespace gathers the standard of types for 2D imagery.
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
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
Cell uSpel(Point p) const
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex...
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)...
Definition: Board2D.h:70
Cell uTranslation(const Cell &p, const Vector &vec) const