DGtal 1.3.0
Loading...
Searching...
No Matches
cubical-complex-illustrations.cpp
Go to the documentation of this file.
1
39#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/io/boards/Board2D.h"
47
49
50using namespace std;
51using namespace DGtal;
52
53
54int main( int /* argc */, char** /* argv */ )
55{
56
58 using namespace DGtal::Z2i;
60
61 KSpace K;
62 K.init( Point( 0,0 ), Point( 5,3 ), true );
63 trace.beginBlock( "Creating Cubical Complex" );
64 CC X( K );
65 Domain domain( Point( 0,0 ), Point( 5,3 ) );
66 X.insertCell( K.uSpel( Point(1,1) ) );
67 X.insertCell( K.uSpel( Point(2,1) ) );
68 X.insertCell( K.uSpel( Point(3,1) ) );
69 X.insertCell( K.uSpel( Point(2,2) ) );
70 X.insertCell( K.uSpel( Point(3,2) ) );
71 X.insertCell( K.uSpel( Point(4,2) ) );
72 X.close();
74
75 trace.beginBlock( "Displays Cubical Complex" );
76 Board2D board;
77 board << domain;
78 board << CustomStyle( X.className(),
79 new CustomColors( Color(80,80,100), Color(180,180,200) ) )
80 << X;
81 board.saveTikZ( "cubical-complex-illustrations-X.tikz" );
84
86 CC S( K );
87 S.insertCell( K.uCell( Point( 5, 4 ) ) ); // a linel
88 S.insertCell( K.uCell( Point( 4, 4 ) ) ); // a pointel
89 S.insertCell( K.uCell( Point( 7, 5 ) ) ); // a pixel
90 board << CustomStyle( X.className(),
91 new CustomColors( Color::Black, Color(60,60,60) ) )
92 << S;
93 board.saveTikZ( "cubical-complex-illustrations-S.tikz" );
94 board.clear();
96
98 board << domain;
99 board << CustomStyle( X.className(),
100 new CustomColors( Color(80,80,100), Color(180,180,200) ) )
101 << X;
102 board << CustomStyle( X.className(),
103 new CustomColors( Color::Red, Color(255,120,120) ) )
104 << X.closure( S );
105 board.saveTikZ( "cubical-complex-illustrations-closure.tikz" );
106 board.clear();
108
110 board << domain;
111 board << CustomStyle( X.className(),
112 new CustomColors( Color(80,80,100), Color(180,180,200) ) )
113 << X;
114 board << CustomStyle( X.className(),
115 new CustomColors( Color::Blue, Color(120,120,255) ) )
116 << X.star( S );
117 board.saveTikZ( "cubical-complex-illustrations-star.tikz" );
118 board.clear();
120
122 board << domain;
123 board << CustomStyle( X.className(),
124 new CustomColors( Color(80,80,100), Color(180,180,200) ) )
125 << X;
126 board << CustomStyle( X.className(),
127 new CustomColors( Color::Green, Color(120,255,120) ) )
128 << X.link( S );
129 board.saveTikZ( "cubical-complex-illustrations-link.tikz" );
130 board.clear();
132
134 board << domain;
135 board << CustomStyle( X.className(),
136 new CustomColors( Color(80,80,100), Color(180,180,200) ) )
137 << X;
138 board << CustomStyle( X.className(),
139 new CustomColors( Color::Magenta, Color(255,120,255) ) )
140 << X.boundary();
141 board.saveTikZ( "cubical-complex-illustrations-bd.tikz" );
142 board.clear();
144
146 board << domain;
147 board << CustomStyle( X.className(),
148 new CustomColors( Color(80,80,100), Color(180,180,200) ) )
149 << X;
150 board << CustomStyle( X.className(),
151 new CustomColors( Color::Cyan, Color(120,255,255) ) )
152 << X.interior();
153 board.saveTikZ( "cubical-complex-illustrations-int.tikz" );
154 board.clear();
156
158 board << domain;
159 board << CustomStyle( X.className(),
160 new CustomColors( Color(80,80,100), Color(180,180,200) ) )
161 << X;
162 Cell p1 = K.uCell( Point(2,2) );
163 Cell p2 = K.uCell( Point(10,6) );
164 X[ p1 ] = CC::FIXED;
165 X[ p2 ] = CC::FIXED;
167 functions::collapse( X, X.begin(), X.end(), P, true, true, true );
168 board << CustomStyle( X.className(),
169 new CustomColors( Color(255,120,20), Color(255,150,50) ) )
170 << X
171 << CustomStyle( p1.className(),
172 new CustomColors( Color::Blue, Color(120,120,255) ) )
173 << p1 << p2;
174 board.saveTikZ( "cubical-complex-illustrations-collapse.tikz" );
175 board.clear();
177
178 return 0;
179}
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:71
Structure representing an RGB triple with alpha component.
Definition: Color.h:68
static const Color Cyan
Definition: Color.h:420
static const Color Green
Definition: Color.h:417
static const Color Red
Definition: Color.h:416
static const Color Blue
Definition: Color.h:419
static const Color Black
Definition: Color.h:413
static const Color Magenta
Definition: Color.h:421
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space....
CubicalComplex closure(const CubicalComplex &S, bool hintClosed=false) const
ConstIterator end() const
std::string className() const
CubicalComplex boundary(bool hintClosed=false) const
CubicalComplex link(const CubicalComplex &S, bool hintClosed=false, bool hintOpen=false) const
CubicalComplex star(const CubicalComplex &S, bool hintOpen=false) const
CubicalComplex interior() const
void insertCell(const Cell &aCell, const Data &data=Data())
ConstIterator begin() const
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
Cell uSpel(Point p) const
From the digital coordinates of a point in Zn, builds the corresponding spel (cell of maximal dimensi...
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
Cell uCell(const PreCell &c) const
From an unsigned cell, returns an unsigned cell lying into this Khalismky space.
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
Z2i this namespace gathers the standard of types for 2D imagery.
uint64_t collapse(CubicalComplex< TKSpace, TCellContainer > &K, CellConstIterator S_itB, CellConstIterator S_itE, const CellMapIteratorPriority &priority, bool hintIsSClosed=false, bool hintIsKClosed=false, bool verbose=false)
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition: Common.h:154
STL namespace.
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition: Board2D.h:279
std::string className() const
Return the style name used for drawing this object.
int main()
Definition: testBits.cpp:56
MyPointD Point
Definition: testClone2.cpp:383
KSpace K
CubicalComplex< KSpace, Map > CC
Domain domain