DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
digitalSetToCubicalComplexes2D.cpp
Go to the documentation of this file.
1
16
29
30
37
38
40
#include <iostream>
41
#include <cmath>
42
#include <map>
43
#include "ConfigExamples.h"
44
#include "DGtal/helpers/StdDefs.h"
45
#include "DGtal/base/Common.h"
46
// Cellular grid
47
#include "DGtal/topology/CubicalComplex.h"
48
// Shape construction
49
#include "DGtal/shapes/GaussDigitizer.h"
50
#include "DGtal/shapes/Shapes.h"
51
#include "DGtal/shapes/EuclideanShapesDecorator.h"
52
#include "DGtal/shapes/parametric/Flower2D.h"
53
// Drawing
54
#include "DGtal/io/boards/Board2D.h"
55
#include "DGtal/io/Color.h"
57
58
using namespace
std
;
59
using namespace
DGtal
;
60
using namespace
functors
;
61
using namespace
Z2i
;
62
64
65
int
main
(
int
,
char
** )
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
;
89
typedef
CubicalComplex< KSpace, Map >
CC
;
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
98
typedef
CC::CellMapConstIterator
CellMapConstIterator
;
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
}
123
// //
DGtal::Board2D
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition
Board2D.h:71
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition
Color.h:77
DGtal::Color::Color
Color()
Definition
Color.h:139
DGtal::CubicalComplex< KSpace, Map >
DGtal::CubicalComplex< KSpace, Map >::CellMapConstIterator
CellMap::const_iterator CellMapConstIterator
Definition
CubicalComplex.h:252
DGtal::DigitalSetByAssociativeContainer::className
std::string className() const
DGtal::Flower2D< Space >
DGtal::GaussDigitizer< Space, MyEuclideanShape >
DGtal::GaussDigitizer::attach
void attach(ConstAlias< EuclideanShape > shape)
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::Shapes::digitalShaper
static void digitalShaper(TDigitalSet &aSet, const TShapeFunctor &aFunctor)
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Trace::endBlock
double endBlock()
DGtal::Domain
LibBoard::Board::saveEPS
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition
Board.cpp:804
DGtal::Z2i
Z2i this namespace gathers the standard of types for 2D imagery.
DGtal::Z2i::KSpace
KhalimskySpaceND< 2, Integer > KSpace
Definition
StdDefs.h:77
DGtal::Z2i::RealPoint
Space::RealPoint RealPoint
Definition
StdDefs.h:97
DGtal::Z2i::DigitalSet
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition
StdDefs.h:100
DGtal::functors
functors namespace gathers all DGtal functors.
Definition
BasicBoolFunctors.h:49
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::Dimension
DGtal::uint32_t Dimension
Definition
Common.h:119
DGtal::trace
Trace trace
std
STL namespace.
DGtal::CustomColors
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition
Board2D.h:279
DGtal::CustomFillColor
Custom style class redefining the fill color. You may use Board2D::Color::None for transparent color.
Definition
Board2D.h:343
DGtal::CustomStyle::CustomStyle
CustomStyle(std::string classname, DrawableWithBoard2D *style)
Definition
Board2D.h:224
DGtal::SetMode::SetMode
SetMode(std::string classname, std::string mode)
Definition
Board2D.h:254
K
KSpace K
Definition
testCubicalComplex.cpp:62
Map
std::unordered_map< Cell, CubicalCellData > Map
Definition
testCubicalComplex.cpp:57
CC
CubicalComplex< KSpace, Map > CC
Definition
testCubicalComplex.cpp:58
CellMapConstIterator
CC::CellMapConstIterator CellMapConstIterator
Definition
testCubicalComplex.cpp:59
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
examples
topology
digitalSetToCubicalComplexes2D.cpp
Generated on
for DGtal by
1.18.0