DGtal  1.3.beta
topology/cubical-complex-illustrations.cpp

Source of examples used to generate illustrations of Cubical Complex module documention.

Cubical Complex
One of the generated illustration: displaying a 2D cubical complex on a Board.
#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"
using namespace std;
using namespace DGtal;
int main( int /* argc */, char** /* argv */ )
{
using namespace DGtal::Z2i;
K.init( Point( 0,0 ), Point( 5,3 ), true );
trace.beginBlock( "Creating Cubical Complex" );
CC X( K );
Domain domain( Point( 0,0 ), Point( 5,3 ) );
X.insertCell( K.uSpel( Point(1,1) ) );
X.insertCell( K.uSpel( Point(2,1) ) );
X.insertCell( K.uSpel( Point(3,1) ) );
X.insertCell( K.uSpel( Point(2,2) ) );
X.insertCell( K.uSpel( Point(3,2) ) );
X.insertCell( K.uSpel( Point(4,2) ) );
X.close();
trace.beginBlock( "Displays Cubical Complex" );
Board2D board;
board << domain;
board << CustomStyle( X.className(),
new CustomColors( Color(80,80,100), Color(180,180,200) ) )
<< X;
board.saveTikZ( "cubical-complex-illustrations-X.tikz" );
CC S( K );
S.insertCell( K.uCell( Point( 5, 4 ) ) ); // a linel
S.insertCell( K.uCell( Point( 4, 4 ) ) ); // a pointel
S.insertCell( K.uCell( Point( 7, 5 ) ) ); // a pixel
board << CustomStyle( X.className(),
new CustomColors( Color::Black, Color(60,60,60) ) )
<< S;
board.saveTikZ( "cubical-complex-illustrations-S.tikz" );
board.clear();
board << domain;
board << CustomStyle( X.className(),
new CustomColors( Color(80,80,100), Color(180,180,200) ) )
<< X;
board << CustomStyle( X.className(),
new CustomColors( Color::Red, Color(255,120,120) ) )
<< X.closure( S );
board.saveTikZ( "cubical-complex-illustrations-closure.tikz" );
board.clear();
board << domain;
board << CustomStyle( X.className(),
new CustomColors( Color(80,80,100), Color(180,180,200) ) )
<< X;
board << CustomStyle( X.className(),
new CustomColors( Color::Blue, Color(120,120,255) ) )
<< X.star( S );
board.saveTikZ( "cubical-complex-illustrations-star.tikz" );
board.clear();
board << domain;
board << CustomStyle( X.className(),
new CustomColors( Color(80,80,100), Color(180,180,200) ) )
<< X;
board << CustomStyle( X.className(),
new CustomColors( Color::Green, Color(120,255,120) ) )
board.clear();
board << domain;
board << CustomStyle( X.className(),
new CustomColors( Color(80,80,100), Color(180,180,200) ) )
<< X;
board << CustomStyle( X.className(),
new CustomColors( Color::Magenta, Color(255,120,255) ) )
<< X.boundary();
board.saveTikZ( "cubical-complex-illustrations-bd.tikz" );
board.clear();
board << domain;
board << CustomStyle( X.className(),
new CustomColors( Color(80,80,100), Color(180,180,200) ) )
<< X;
board << CustomStyle( X.className(),
new CustomColors( Color::Cyan, Color(120,255,255) ) )
<< X.interior();
board.saveTikZ( "cubical-complex-illustrations-int.tikz" );
board.clear();
board << domain;
board << CustomStyle( X.className(),
new CustomColors( Color(80,80,100), Color(180,180,200) ) )
<< X;
Cell p1 = K.uCell( Point(2,2) );
Cell p2 = K.uCell( Point(10,6) );
X[ p1 ] = CC::FIXED;
X[ p2 ] = CC::FIXED;
functions::collapse( X, X.begin(), X.end(), P, true, true, true );
board << CustomStyle( X.className(),
new CustomColors( Color(255,120,20), Color(255,150,50) ) )
<< X
new CustomColors( Color::Blue, Color(120,120,255) ) )
<< p1 << p2;
board.saveTikZ( "cubical-complex-illustrations-collapse.tikz" );
board.clear();
return 0;
}
DGtal::KhalimskyCell::className
std::string className() const
Return the style name used for drawing this object.
DGtal::KhalimskySpaceND::uCell
Cell uCell(const PreCell &c) const
From an unsigned cell, returns an unsigned cell lying into this Khalismky space.
DGtal::HyperRectDomain< Space >
DGtal::Trace::endBlock
double endBlock()
DGtal::CubicalComplex::close
void close()
DGtal::Z2i
Z2i this namespace gathers the standard of types for 2D imagery.
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition: Color.h:67
DGtal::KhalimskySpaceND::uSpel
Cell uSpel(Point p) const
From the digital coordinates of a point in Zn, builds the corresponding spel (cell of maximal dimensi...
DGtal::KhalimskySpaceND::init
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
DGtal::trace
Trace trace
Definition: Common.h:154
K
KSpace K
Definition: testCubicalComplex.cpp:62
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::CubicalComplex::insertCell
void insertCell(const Cell &aCell, const Data &data=Data())
LibBoard::Board::clear
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition: Board.cpp:152
DGtal::CustomStyle
Definition: Board2D.h:217
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::CustomColors
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition: Board2D.h:278
CC
CubicalComplex< KSpace, Map > CC
Definition: testCubicalComplex.cpp:58
main
int main(int argc, char **argv)
Definition: testArithmeticDSS-benchmark.cpp:147
DGtal::Board2D
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:70
LibBoard::Board::saveTikZ
void saveTikZ(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1219
domain
Domain domain
Definition: testProjection.cpp:88
DGtal::PointVector< dim, Integer >
DGtal::CubicalComplex
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space....
Definition: CubicalComplex.h:84
Point
MyPointD Point
Definition: testClone2.cpp:383
DGtal::KhalimskyCell< dim, Integer >
DGtal::CubicalComplex::className
std::string className() const
DGtal::KhalimskySpaceND
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
Definition: KhalimskySpaceND.h:64