DGtal  1.5.beta
cubical-complex-illustrations.cpp File Reference
#include <iostream>
#include <map>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/topology/KhalimskySpaceND.h"
#include "DGtal/topology/CubicalComplex.h"
#include "DGtal/io/boards/Board2D.h"
Include dependency graph for cubical-complex-illustrations.cpp:

Go to the source code of this file.

Functions

int main (int, char **)
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Jacques-Olivier Lachaud (jacqu.nosp@m.es-o.nosp@m.livie.nosp@m.r.la.nosp@m.chaud.nosp@m.@uni.nosp@m.v-sav.nosp@m.oie..nosp@m.fr ) Laboratory of Mathematics (CNRS, UMR 5127), University of Savoie, France
Date
2015/08/28

An example file named cubical-complex-collapse.cpp.

This file is part of the DGtal library.

Definition in file cubical-complex-illustrations.cpp.

Function Documentation

◆ main()

int main ( int  ,
char **   
)

[cubical-complex-illustrations-X]

[cubical-complex-illustrations-X]

[cubical-complex-illustrations-S]

[cubical-complex-illustrations-S]

[cubical-complex-illustrations-closure]

[cubical-complex-illustrations-closure]

[cubical-complex-illustrations-star]

[cubical-complex-illustrations-star]

[cubical-complex-illustrations-link]

[cubical-complex-illustrations-link]

[cubical-complex-illustrations-bd]

[cubical-complex-illustrations-bd]

[cubical-complex-illustrations-int]

[cubical-complex-illustrations-int]

[cubical-complex-illustrations-collapse]

[cubical-complex-illustrations-collapse]

Definition at line 54 of file cubical-complex-illustrations.cpp.

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();
73  trace.endBlock();
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" );
82  trace.endBlock();
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....
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:1218
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition: Board.cpp:151
Z2i this namespace gathers the standard of types for 2D imagery.
Space::Point Point
Definition: StdDefs.h:95
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)
Trace trace
Definition: Common.h:153
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.
KSpace K
CubicalComplex< KSpace, Map > CC
Domain domain

References DGtal::CubicalComplex< TKSpace, TCellContainer >::begin(), DGtal::Trace::beginBlock(), DGtal::CubicalComplex< TKSpace, TCellContainer >::boundary(), DGtal::CubicalComplex< TKSpace, TCellContainer >::className(), DGtal::KhalimskyCell< dim, TInteger >::className(), LibBoard::Board::clear(), DGtal::CubicalComplex< TKSpace, TCellContainer >::close(), DGtal::CubicalComplex< TKSpace, TCellContainer >::closure(), domain, DGtal::CubicalComplex< TKSpace, TCellContainer >::end(), DGtal::Trace::endBlock(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), DGtal::CubicalComplex< TKSpace, TCellContainer >::insertCell(), DGtal::CubicalComplex< TKSpace, TCellContainer >::interior(), K, DGtal::CubicalComplex< TKSpace, TCellContainer >::link(), LibBoard::Board::saveTikZ(), DGtal::CubicalComplex< TKSpace, TCellContainer >::star(), DGtal::trace, DGtal::KhalimskySpaceND< dim, TInteger >::uCell(), and DGtal::KhalimskySpaceND< dim, TInteger >::uSpel().