DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testImplicitShape.cpp
Go to the documentation of this file.
1
16
29
31
#include <iostream>
32
#include "DGtal/base/Common.h"
33
#include "DGtal/helpers/StdDefs.h"
34
#include "DGtal/shapes/Shapes.h"
35
#include "DGtal/shapes/ShapeFactory.h"
36
#include "DGtal/io/boards/Board2D.h"
37
#include "DGtal/io/colormaps/GrayscaleColorMap.h"
38
#include "DGtal/io/writers/VolWriter.h"
39
#include "DGtal/images/ImageContainerBySTLVector.h"
41
42
using namespace
std
;
43
using namespace
DGtal
;
44
46
// Functions for testing class ImplicitShape.
48
52
bool
testImplicitShape
()
53
{
54
trace
.
beginBlock
(
"Testing implicit shaper ..."
);
55
Z2i::Point
a(0,0);
56
Z2i::Point
b(64,64);
57
Z2i::Point
c(32,32);
58
59
Board2D
board;
60
61
Z2i::Domain
domain
(a,b);
62
Z2i::DigitalSet
set(
domain
);
63
64
Shapes<Z2i::Domain>::euclideanShaper
( set,
65
ImplicitBall<Z2i::Space>
( c, 10));
66
board << set;
67
board.
saveSVG
(
"implicitball.svg"
);
68
69
set.clear();
70
board.
clear
();
71
Shapes<Z2i::Domain>::euclideanShaper
( set,
72
ImplicitHyperCube<Z2i::Space>
( c, 10));
73
board << set;
74
board.
saveSVG
(
"implicitcube.svg"
);
75
76
77
set.clear();
78
board.
clear
();
79
Shapes<Z2i::Domain>::euclideanShaper
( set,
80
ImplicitNorm1Ball<Z2i::Space>
( c, 10));
81
board << set;
82
board.
saveSVG
(
"implicitlosange.svg"
);
83
84
set.clear();
85
board.
clear
();
86
Shapes<Z2i::Domain>::euclideanShaper
( set,
87
ImplicitRoundedHyperCube<Z2i::Space>
( c, 10, 1));
88
board << set;
89
board.
saveSVG
(
"implicitrounded-1.svg"
);
90
91
92
set.clear();
93
board.
clear
();
94
Shapes<Z2i::Domain>::euclideanShaper
( set,
95
ImplicitRoundedHyperCube<Z2i::Space>
( c, 10, 2.5));
96
board << set;
97
board.
saveSVG
(
"implicitrounded-2.5.svg"
);
98
99
100
return
true
;
101
}
102
106
bool
testImplicitShape3D
()
107
{
108
trace
.
beginBlock
(
"Testing implicit shaper in 3D..."
);
109
Z3i::Point
a(0,0);
110
Z3i::Point
b(64,64,64);
111
Z3i::Point
c(32,32,32);
112
113
Z3i::Domain
domain
(a,b);
114
115
typedef
ImageContainerBySTLVector<Z3i::Domain, DGtal::uint8_t>
Image
;
116
117
Image
image
(
domain
);
118
Z3i::DigitalSet
set(
domain
);
119
120
Shapes<Z3i::Domain>::euclideanShaper
( set,
121
ImplicitRoundedHyperCube<Z3i::Space>
( c, 10, 2.5));
122
123
for
(
Z3i::DigitalSet::ConstIterator
it=set.begin(), itend=set.end();
124
it != itend;
125
++it)
126
{
127
image
.
setValue
((*it), 128);
128
}
129
130
VolWriter<Image>::exportVol
(
"implicitrounded.vol"
,
image
);
131
132
return
true
;
133
}
134
136
// Standard services - public :
137
138
int
main
(
int
argc,
char
** argv )
139
{
140
trace
.
beginBlock
(
"Testing class ImplicitShape"
);
141
trace
.
info
() <<
"Args:"
;
142
for
(
int
i = 0; i < argc; ++i )
143
trace
.
info
() <<
" "
<< argv[ i ];
144
trace
.
info
() << endl;
145
146
bool
res =
testImplicitShape
() &&
testImplicitShape3D
();
// && ... other tests
147
trace
.
emphase
() << ( res ?
"Passed."
:
"Error."
) << endl;
148
trace
.
endBlock
();
149
return
res ? 0 : 1;
150
}
151
// //
DGtal::Board2D
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition
Board2D.h:71
DGtal::DigitalSetByAssociativeContainer< Domain, std::unordered_set< typename Domain::Point > >::ConstIterator
Container::const_iterator ConstIterator
Definition
DigitalSetByAssociativeContainer.h:108
DGtal::ImageContainerBySTLVector
Definition
ImageContainerBySTLVector.h:127
DGtal::Image
Aim: implements association between points lying in a digital domain and values.
Definition
Image.h:70
DGtal::Image::setValue
void setValue(const Point &aPoint, const Value &aValue)
Definition
Image.h:247
DGtal::ImplicitBall
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a ball in nD....
Definition
ImplicitBall.h:65
DGtal::ImplicitHyperCube
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create an hypercube in n...
Definition
ImplicitHyperCube.h:60
DGtal::ImplicitNorm1Ball
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a ball for the L_...
Definition
ImplicitNorm1Ball.h:60
DGtal::ImplicitRoundedHyperCube
Aim: model of CEuclideanOrientedShape and CEuclideanBoundedShape concepts to create a rounded hypercu...
Definition
ImplicitRoundedHyperCube.h:63
DGtal::Shapes::euclideanShaper
static void euclideanShaper(TDigitalSet &aSet, const TShapeFunctor &aFunctor, const double h=1.0)
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Trace::emphase
std::ostream & emphase()
DGtal::Trace::info
std::ostream & info()
DGtal::Trace::endBlock
double endBlock()
LibBoard::Board::clear
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition
Board.cpp:151
LibBoard::Board::saveSVG
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition
Board.cpp:1011
DGtal::Z2i::Point
Space::Point Point
Definition
StdDefs.h:95
DGtal::Z2i::DigitalSet
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition
StdDefs.h:100
DGtal::Z2i::Domain
HyperRectDomain< Space > Domain
Definition
StdDefs.h:99
DGtal::Z3i::Domain
HyperRectDomain< Space > Domain
Definition
StdDefs.h:172
DGtal::Z3i::Point
Space::Point Point
Definition
StdDefs.h:168
DGtal::Z3i::DigitalSet
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition
StdDefs.h:173
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::trace
Trace trace
std
STL namespace.
DGtal::VolWriter::exportVol
static bool exportVol(const std::string &filename, const Image &aImage, const bool compressed=true, const Functor &aFunctor=Functor())
testImplicitShape
bool testImplicitShape()
Definition
testImplicitShape.cpp:52
testImplicitShape3D
bool testImplicitShape3D()
Definition
testImplicitShape.cpp:106
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
domain
Domain domain
Definition
testProjection.cpp:88
image
Image image(domain)
tests
helpers
testImplicitShape.cpp
Generated on
for DGtal by
1.18.0