DGtal 1.4.0
Loading...
Searching...
No Matches
topology/cubical-complex-illustrations.cpp

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

See also
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.endBlock();
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" );
trace.endBlock();
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;
CC::DefaultCellMapIteratorPriority P;
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;
}
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
Aim: This class represents an arbitrary cubical complex living in some Khalimsky 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.
DGtal is the top-level namespace which contains all DGtal functions and types.
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
KSpace K
KSpace::Cell Cell
CubicalComplex< KSpace, Map > CC
Domain domain
HyperRectDomain< Space > Domain