DGtal  0.9.3
Functions
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.

References DGtal::GaussDigitizer< TSpace, TEuclideanShape >::attach(), DGtal::CubicalComplex< TKSpace, TCellContainer >::begin(), DGtal::Trace::beginBlock(), DGtal::HyperRectDomain< TSpace >::className(), DGtal::CubicalComplex< TKSpace, TCellContainer >::construct(), DGtal::CubicalComplex< TKSpace, TCellContainer >::end(), DGtal::Trace::endBlock(), K, DGtal::HyperRectDomain< TSpace >::lowerBound(), LibBoard::Board::saveEPS(), DGtal::trace, and DGtal::HyperRectDomain< TSpace >::upperBound().

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;
85  trace.endBlock();
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 }
void beginBlock(const std::string &keyword="")
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition: StdDefs.h:100
std::unordered_map< Cell, CubicalCellData > Map
Trace trace
Definition: Common.h:137
Custom style class redefining the fill color. You may use Board2D::Color::None for transparent color...
Definition: Board2D.h:342
DGtal::uint32_t Dimension
Definition: Common.h:120
KhalimskySpaceND< 2, Integer > KSpace
Definition: StdDefs.h:77
const Point & upperBound() const
double endBlock()
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition: Board2D.h:278
CellMap::const_iterator CellMapConstIterator
Const iterator for visiting type CellMap.
void attach(const EuclideanShape &shape)
Aim: Model of the concept StarShaped represents any flower with k-petals in the plane.
Definition: Flower2D.h:64
CC::CellMapConstIterator CellMapConstIterator
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space. Cubical complexes are sets of cells of different dimensions related together with incidence relations. Two cells in a cubical complex are incident if and only if they are incident in the surrounding Khalimsky space. In other words, cubical complexes are defined here as subsets of Khalimsky spaces.
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
std::string className() const
CubicalComplex< KSpace, Map > CC
const Point & lowerBound() const
Modifier class in a Board2D stream. Useful to choose your own mode for a given class. Realizes the concept CDrawableWithBoard2D.
Definition: Board2D.h:247
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
Space::RealPoint RealPoint
Definition: StdDefs.h:97
KSpace K
Aim: A utility class for constructing different shapes (balls, diamonds, and others).
Aim: This class specializes a &#39;Board&#39; class so as to display DGtal objects more naturally (with <<)...
Definition: Board2D.h:70