DGtal  1.3.beta
topology/ctopo-1.cpp

A simple example of cellular grid space with several cells instantiated and visualized. This program outputs this image.

See also
Creating (unsigned) cells in a cellular grid space
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/io/Color.h"
using namespace std;
using namespace DGtal;
using namespace DGtal::Z2i;
int main()
{
Point plow(-3,-2);
Point pup(5,3);
Domain domain( plow, pup );
Board2D board; // for 2D display
K.init( plow, pup, true );
board << SetMode( domain.className(), "Paving" )
<< domain;
Cell pixlow = K.uSpel( plow ); // pixel (-3*2+1,-2*2+1)
Cell ptlow = K.uPointel( plow ); // pointel (-3*2,-2*2)
Cell pixup = K.uSpel( pup ); // pixel (5*2+1,3*2+1)
Cell ptup1 = K.uPointel( pup ); // pointel (5*2,3*2)
Cell ptup2 = K.uTranslation( ptup1, Point::diagonal() ); // pointel (6*2,4*2)
Cell linelb = K.uCell( Point( 1, 0 ) ); // linel (1,0) bottom
Cell linelt = K.uCell( Point( 1, 2 ) ); // linel (1,2) top
Cell linell = K.uCell( Point( 0, 1 ) ); // linel (0,1) left
Cell linelr = K.uCell( Point( 2, 1 ) ); // linel (2,1) right
board << CustomStyle( ptlow.className(),
new CustomColors( Color( 0, 0, 200 ),
Color( 100, 100, 255 ) ) )
<< ptlow << ptup2;
board << CustomStyle( pixlow.className(),
new CustomColors( Color( 200, 0, 0 ),
Color( 255, 100, 100 ) ) )
<< pixlow << pixup;
board << CustomStyle( linelb.className(),
new CustomColors( Color( 0, 200, 0 ),
Color( 100, 255, 100 ) ) )
<< linelb << linelt << linell << linelr;
board.saveSVG("ctopo-1.svg");
board.saveEPS("ctopo-1.eps");
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::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:66
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::HyperRectDomain::className
std::string className() const
K
KSpace K
Definition: testCubicalComplex.cpp:62
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
LibBoard::Board::saveSVG
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1012
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::saveEPS
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
domain
Domain domain
Definition: testProjection.cpp:88
DGtal::PointVector< dim, Integer >
DGtal::SetMode
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Definition: Board2D.h:247
DGtal::KhalimskySpaceND::uPointel
Cell uPointel(Point p) const
From the digital coordinates of a point in Zn, builds the corresponding pointel (cell of dimension 0)...
Point
MyPointD Point
Definition: testClone2.cpp:383
DGtal::KhalimskySpaceND::uTranslation
Cell uTranslation(const Cell &p, const Vector &vec) const
Add the vector [vec] to [p].
DGtal::KhalimskyCell< dim, Integer >
DGtal::KhalimskySpaceND
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
Definition: KhalimskySpaceND.h:64