DGtal  0.9.3
cubical-complex-illustrations.cpp
Go to the documentation of this file.
1 
38 #include <iostream>
40 #include <map>
41 #include "DGtal/base/Common.h"
42 #include "DGtal/helpers/StdDefs.h"
43 
44 #include "DGtal/topology/KhalimskySpaceND.h"
45 #include "DGtal/topology/CubicalComplex.h"
46 #include "DGtal/topology/CubicalComplexFunctions.h"
47 #include "DGtal/io/boards/Board2D.h"
48 
50 
51 using namespace std;
52 using namespace DGtal;
53 
54 
55 int main( int /* argc */, char** /* argv */ )
56 {
57 
59  using namespace DGtal::Z2i;
61 
62  KSpace K;
63  K.init( Point( 0,0 ), Point( 5,3 ), true );
64  trace.beginBlock( "Creating Cubical Complex" );
65  CC X( K );
66  Domain domain( Point( 0,0 ), Point( 5,3 ) );
67  X.insertCell( K.uSpel( Point(1,1) ) );
68  X.insertCell( K.uSpel( Point(2,1) ) );
69  X.insertCell( K.uSpel( Point(3,1) ) );
70  X.insertCell( K.uSpel( Point(2,2) ) );
71  X.insertCell( K.uSpel( Point(3,2) ) );
72  X.insertCell( K.uSpel( Point(4,2) ) );
73  X.close();
74  trace.endBlock();
75 
76  trace.beginBlock( "Displays Cubical Complex" );
77  Board2D board;
78  board << domain;
79  board << CustomStyle( X.className(),
80  new CustomColors( Color(80,80,100), Color(180,180,200) ) )
81  << X;
82  board.saveTikZ( "cubical-complex-illustrations-X.tikz" );
83  trace.endBlock();
85 
87  CC S( K );
88  S.insertCell( K.uCell( Point( 5, 4 ) ) ); // a linel
89  S.insertCell( K.uCell( Point( 4, 4 ) ) ); // a pointel
90  S.insertCell( K.uCell( Point( 7, 5 ) ) ); // a pixel
91  board << CustomStyle( X.className(),
92  new CustomColors( Color::Black, Color(60,60,60) ) )
93  << S;
94  board.saveTikZ( "cubical-complex-illustrations-S.tikz" );
95  board.clear();
97 
99  board << domain;
100  board << CustomStyle( X.className(),
101  new CustomColors( Color(80,80,100), Color(180,180,200) ) )
102  << X;
103  board << CustomStyle( X.className(),
104  new CustomColors( Color::Red, Color(255,120,120) ) )
105  << X.closure( S );
106  board.saveTikZ( "cubical-complex-illustrations-closure.tikz" );
107  board.clear();
109 
111  board << domain;
112  board << CustomStyle( X.className(),
113  new CustomColors( Color(80,80,100), Color(180,180,200) ) )
114  << X;
115  board << CustomStyle( X.className(),
116  new CustomColors( Color::Blue, Color(120,120,255) ) )
117  << X.star( S );
118  board.saveTikZ( "cubical-complex-illustrations-star.tikz" );
119  board.clear();
121 
123  board << domain;
124  board << CustomStyle( X.className(),
125  new CustomColors( Color(80,80,100), Color(180,180,200) ) )
126  << X;
127  board << CustomStyle( X.className(),
128  new CustomColors( Color::Green, Color(120,255,120) ) )
129  << X.link( S );
130  board.saveTikZ( "cubical-complex-illustrations-link.tikz" );
131  board.clear();
133 
135  board << domain;
136  board << CustomStyle( X.className(),
137  new CustomColors( Color(80,80,100), Color(180,180,200) ) )
138  << X;
139  board << CustomStyle( X.className(),
140  new CustomColors( Color::Magenta, Color(255,120,255) ) )
141  << X.boundary();
142  board.saveTikZ( "cubical-complex-illustrations-bd.tikz" );
143  board.clear();
145 
147  board << domain;
148  board << CustomStyle( X.className(),
149  new CustomColors( Color(80,80,100), Color(180,180,200) ) )
150  << X;
151  board << CustomStyle( X.className(),
152  new CustomColors( Color::Cyan, Color(120,255,255) ) )
153  << X.interior();
154  board.saveTikZ( "cubical-complex-illustrations-int.tikz" );
155  board.clear();
157 
159  board << domain;
160  board << CustomStyle( X.className(),
161  new CustomColors( Color(80,80,100), Color(180,180,200) ) )
162  << X;
163  Cell p1 = K.uCell( Point(2,2) );
164  Cell p2 = K.uCell( Point(10,6) );
165  X[ p1 ] = CC::FIXED;
166  X[ p2 ] = CC::FIXED;
168  functions::collapse( X, X.begin(), X.end(), P, true, true, true );
169  board << CustomStyle( X.className(),
170  new CustomColors( Color(255,120,20), Color(255,150,50) ) )
171  << X
172  << CustomStyle( p1.className(),
173  new CustomColors( Color::Blue, Color(120,120,255) ) )
174  << p1 << p2;
175  board.saveTikZ( "cubical-complex-illustrations-collapse.tikz" );
176  board.clear();
178 
179  return 0;
180 }
void beginBlock(const std::string &keyword="")
std::string className() const
ConstIterator begin() const
int main(int, char **)
const Domain domain(Point(1, 2), Point(6, 5))
Trace trace
Definition: Common.h:137
CubicalComplex star(const CubicalComplex &S, bool hintOpen=false) const
CubicalComplex closure(const CubicalComplex &S, bool hintClosed=false) const
STL namespace.
double endBlock()
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition: Board2D.h:278
CubicalComplex interior() const
CubicalComplex link(const CubicalComplex &S, bool hintClosed=false, bool hintOpen=false) const
void insertCell(const Cell &aCell, const Data &data=Data())
Cell uSpel(Point p) const
bool init(const Point &lower, const Point &upper, bool isClosed)
Cell uCell(const PreCell &c) const
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition: Board.cpp:152
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space. Cubical complexes are sets of cells of different dimensions related together with incidence relations. Two cells in a cubical complex are incident if and only if they are incident in the surrounding Khalimsky space. In other words, cubical complexes are defined here as subsets of Khalimsky spaces.
Z2i this namespace gathers the standard of types for 2D imagery.
DGtal is the top-level namespace which contains all DGtal functions and types.
MyPointD Point
Definition: testClone2.cpp:383
CubicalComplex boundary(bool hintClosed=false) const
CubicalComplex< KSpace, Map > CC
ConstIterator end() const
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
KSpace K
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex...
void saveTikZ(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1219
Aim: This class specializes a &#39;Board&#39; class so as to display DGtal objects more naturally (with <<)...
Definition: Board2D.h:70