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

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

See also
Cubical Complex
cubical-complex-illustrations-X.png
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/topology/CubicalComplexFunctions.h"
#include "DGtal/io/boards/Board2D.h"
using namespace std;
using namespace DGtal;
int main( int /* argc */, char** /* argv */ )
{
using namespace DGtal::Z2i;
KSpace K;
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) ) )
<< X.link( S );
board.saveTikZ( "cubical-complex-illustrations-link.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::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
<< CustomStyle( p1.className(),
new CustomColors( Color::Blue, Color(120,120,255) ) )
<< p1 << p2;
board.saveTikZ( "cubical-complex-illustrations-collapse.tikz" );
board.clear();
return 0;
}