DGtal 1.4.2
Loading...
Searching...
No Matches
digitalSetToCubicalComplexes2D.cpp File Reference
#include <iostream>
#include <cmath>
#include <map>
#include "ConfigExamples.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/base/Common.h"
#include "DGtal/topology/CubicalComplex.h"
#include "DGtal/shapes/GaussDigitizer.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/shapes/EuclideanShapesDecorator.h"
#include "DGtal/shapes/parametric/Flower2D.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/io/Color.h"
Include dependency graph for digitalSetToCubicalComplexes2D.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
Kacper Pluta (kacpe.nosp@m.r.pl.nosp@m.uta@e.nosp@m.siee.nosp@m..fr ) Laboratoire d'Informatique Gaspard-Monge - LIGM, France
Date
2015/11/03

An example file named digitalSetToCubicalComplexes2D.

This file is part of the DGtal library.

Definition in file digitalSetToCubicalComplexes2D.cpp.

Function Documentation

◆ main()

int main ( int ,
char **  )

Definition at line 65 of file digitalSetToCubicalComplexes2D.cpp.

66{
67 trace.beginBlock ( "Example digitalSetToCubicalComplexes2D" );
68 trace.beginBlock ( "Generate a 2D shape." );
69 typedef Flower2D< Space > MyEuclideanShape;
70 MyEuclideanShape shape( RealPoint( 0.0, 0.0 ), 16, 5, 5, M_PI_2/2. );
71
72 typedef GaussDigitizer< Space, MyEuclideanShape > MyGaussDigitizer;
73 MyGaussDigitizer digShape;
74 digShape.attach( shape );
75 digShape.init ( shape.getLowerBound(), shape.getUpperBound(), 1.0 );
76 Domain domainShape = digShape.getDomain();
77 DigitalSet aSet( domainShape );
78 Shapes<Domain>::digitalShaper( aSet, digShape );
79
80 Board2D board;
81 board << SetMode( domainShape.className(), "Paving" ) << domainShape;
82 Color dorange ( 255, 136, 0, 220 );
83 board << CustomStyle( aSet.className(), new CustomFillColor ( dorange ) );
84 board << aSet;
86
87 trace.beginBlock ( "Generate a 2D cubical representation." );
88 typedef map<Cell, CubicalCellData> Map;
90
91 KSpace K;
92 K.init ( domainShape.lowerBound(), domainShape.upperBound(), true );
93 CC complex ( K );
94 complex.construct< DigitalSet >( aSet );
95
96 board << SetMode( domainShape.className(), "Paving" ) << domainShape;
97
99 for ( Dimension d = 0; d <= 2; ++d )
100 for ( CellMapConstIterator it = complex.begin( d ), itE = complex.end( d );
101 it != itE; ++it )
102 {
103 if ( d == 0 )
104 board << CustomStyle( it->first.className(),
105 new CustomColors( Color( 0, 0, 0 ),
106 Color( 0, 0, 0 ) ) );
107 else if ( d == 1 )
108 board << CustomStyle( it->first.className(),
109 new CustomColors( Color( 200, 0, 0 ),
110 Color( 100, 255, 100 ) ) );
111 else
112 board << CustomStyle( it->first.className(),
113 new CustomColors( Color( 0, 0, 200 ),
114 Color( 100, 255, 100 ) ) );
115 board << it->first;
116 }
117
118 board.saveEPS ( "cubicalComplexes.eps" );
119 trace.endBlock();
120 trace.endBlock();
121 return 0;
122}
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....
CellMap::const_iterator CellMapConstIterator
Const iterator for visiting type CellMap.
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Aim: Model of the concept StarShaped represents any flower with k-petals in the plane.
Definition Flower2D.h:65
void attach(ConstAlias< EuclideanShape > shape)
std::string className() const
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
static void digitalShaper(TDigitalSet &aSet, const TShapeFunctor &aFunctor)
void beginBlock(const std::string &keyword="")
double endBlock()
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition Board.cpp:804
Space::RealPoint RealPoint
Definition StdDefs.h:97
DGtal::uint32_t Dimension
Definition Common.h:136
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
Custom style class redefining the fill color. You may use Board2D::Color::None for transparent color.
Definition Board2D.h:343
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Definition Board2D.h:247
KSpace K
std::unordered_map< Cell, CubicalCellData > Map
CubicalComplex< KSpace, Map > CC
CC::CellMapConstIterator CellMapConstIterator

References DGtal::GaussDigitizer< TSpace, TEuclideanShape >::attach(), DGtal::Trace::beginBlock(), DGtal::DigitalSetByAssociativeContainer< TDomain, TContainer >::className(), DGtal::HyperRectDomain< TSpace >::className(), DGtal::Shapes< TDomain >::digitalShaper(), DGtal::Trace::endBlock(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), K, DGtal::HyperRectDomain< TSpace >::lowerBound(), LibBoard::Board::saveEPS(), DGtal::trace, and DGtal::HyperRectDomain< TSpace >::upperBound().