DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testBall3D.cpp
Go to the documentation of this file.
1
16
28
30
#include <iostream>
31
#include "DGtal/shapes/parametric/Ball3D.h"
32
#include "DGtal/helpers/StdDefs.h"
33
#include "DGtal/shapes/GaussDigitizer.h"
34
#include "DGtal/io/Color.h"
35
#include "DGtal/topology/SurfelAdjacency.h"
36
#include "DGtal/topology/DigitalSurface.h"
37
#include "DGtal/topology/helpers/BoundaryPredicate.h"
38
#include "DGtal/topology/SetOfSurfels.h"
39
#include "DGtal/io/colormaps/GradientColorMap.h"
40
#include "DGtal/topology/SCellsFunctors.h"
41
#include "DGtal/io/viewers/PolyscopeViewer.h"
43
44
using namespace
std
;
45
using namespace
DGtal
;
46
using namespace
Z3i
;
47
49
// Standard services - public :
50
51
52
int
main
()
53
{
54
// -------------------------------------------------------------------------- Type declaring
55
typedef
Space::RealPoint
RealPoint
;
56
typedef
Ball3D<Space>
EuclideanShape;
57
typedef
GaussDigitizer<Space,EuclideanShape>
DigitalShape
;
58
59
// -------------------------------------------------------------------------- Creating the shape
60
RealPoint
c1(0, 0, 0 );
61
EuclideanShape ball1( c1, 12.2 );
62
63
// -------------------------------------------------------------------------- GaussDigitizing
64
DigitalShape
dshape;
65
dshape.
attach
( ball1 );
66
RealPoint
p1 =
RealPoint
( -15.0, -15.0, -15.0 );
67
RealPoint
p2 =
RealPoint
( 15.0, 15.0, 15.0 );
68
dshape.
init
(
RealPoint
( p1 ),
RealPoint
( p2 ), 1.0);
69
Domain
domain
= dshape.
getDomain
();
70
71
72
// -------------------------------------------------------------------------- Khalimskhy
73
KSpace
K
;
74
bool
space_ok =
K
.
init
(
domain
.lowerBound(),
domain
.upperBound(),
true
);
75
if
(!space_ok)
76
{
77
return
2;
78
}
79
80
81
// -------------------------------------------------------------------------- Other types
82
typedef
SurfelAdjacency<KSpace::dimension>
MySurfelAdjacency;
83
typedef
KSpace::Surfel
Surfel
;
84
typedef
KSpace::SurfelSet
SurfelSet
;
85
typedef
SetOfSurfels< KSpace, SurfelSet >
MySetOfSurfels;
86
87
88
// -------------------------------------------------------------------------- Tracking the boudnadry
89
MySurfelAdjacency surfAdj(
true
);
// interior in all directions.
90
MySetOfSurfels theSetOfSurfels(
K
, surfAdj );
91
Surfel
bel =
Surfaces<KSpace>::findABel
(
K
, dshape, 1000 );
92
Surfaces<KSpace>::trackBoundary
( theSetOfSurfels.surfelSet(),
K
, surfAdj, dshape, bel );
93
94
95
96
PolyscopeViewer<>
viewer;
97
//-----------------------------------------------------------------------
98
// Looking for the min and max values
99
100
double
minCurv=1;
101
double
maxCurv=0;
102
CanonicSCellEmbedder<KSpace>
midpoint(
K
);
103
for
( std::set<SCell>::iterator it = theSetOfSurfels.begin(), it_end = theSetOfSurfels.end();
104
it != it_end; ++it)
105
{
106
107
RealPoint
A
= midpoint( *it );
108
DGtal::StarShaped3D<Space>::AngularCoordinates
Angles= ball1.parameter(
A
);
109
double
a =ball1.meanCurvature(Angles);
110
// double a =ball1.gaussianCurvature(Angles);
111
112
if
(a>maxCurv)
113
{
114
maxCurv=a;
115
}
116
if
(a<minCurv)
117
{
118
minCurv=a;
119
}
120
}
121
//-----------------------------------------------------------------------
122
//Drawing the ball && giving a color to the surfels( depending on the
123
//curvature)
124
125
unsigned
int
nbSurfels = 0;
126
127
viewer.
allowReuseList
=
true
;
128
for
( std::set<SCell>::iterator it = theSetOfSurfels.begin(), it_end = theSetOfSurfels.end();
129
it != it_end; ++it, ++nbSurfels )
130
{
131
RealPoint
A
= midpoint( *it );
132
133
DGtal::StarShaped3D<Space>::AngularCoordinates
Angles= ball1.parameter(
A
);
134
double
curvature =ball1.meanCurvature(Angles);
135
viewer <<
WithQuantity
(*it,
"Curvature"
, curvature);
136
}
137
138
viewer.
show
();
139
return
0;
140
}
141
// //
DGtal::Ball3D
Aim: Model of the concept StarShaped3D represents any Sphere in the space.
Definition
Ball3D.h:61
DGtal::Display3D::allowReuseList
bool allowReuseList
Definition
Display3D.h:749
DGtal::GaussDigitizer
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
Definition
GaussDigitizer.h:80
DGtal::GaussDigitizer::attach
void attach(ConstAlias< EuclideanShape > shape)
DGtal::GaussDigitizer::init
void init(const RealPoint &xLow, const RealPoint &xUp, typename RealVector::Component gridStep)
DGtal::GaussDigitizer::getDomain
Domain getDomain() const
DGtal::KhalimskySpaceND< 3, Integer >::SurfelSet
std::set< SCell > SurfelSet
Definition
KhalimskySpaceND.h:450
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::KhalimskySpaceND< 3, Integer >::Surfel
SCell Surfel
Definition
KhalimskySpaceND.h:420
DGtal::PolyscopeViewer
Definition
PolyscopeViewer.h:57
DGtal::PolyscopeViewer::show
void show() override
Starts the event loop and display of elements.
Definition
PolyscopeViewer.h:73
DGtal::SetOfSurfels< KSpace, SurfelSet >
DGtal::SpaceND< 3, Integer >::RealPoint
PointVector< dim, double > RealPoint
Definition
SpaceND.h:117
DGtal::StarShaped3D::AngularCoordinates
std::pair< double, double > AngularCoordinates
Definition
StarShaped3D.h:77
DGtal::Surfaces::trackBoundary
static void trackBoundary(SCellSet &surface, const KSpace &K, const SurfelAdjacency< KSpace::dimension > &surfel_adj, const PointPredicate &pp, const SCell &start_surfel)
DGtal::Surfaces::findABel
static SCell findABel(const KSpace &K, const PointPredicate &pp, unsigned int nbtries=1000)
DGtal::SurfelAdjacency
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
Definition
SurfelAdjacency.h:66
DGtal::Domain
SurfelSet
MyDigitalSurface::SurfelSet SurfelSet
Definition
greedy-plane-segmentation-ex2.cpp:92
DGtal::Z3i
Z3i this namespace gathers the standard of types for 3D imagery.
DGtal::Z3i::KSpace
KhalimskySpaceND< 3, Integer > KSpace
Definition
StdDefs.h:146
DGtal::Z3i::RealPoint
Space::RealPoint RealPoint
Definition
StdDefs.h:170
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
std
STL namespace.
A
Definition
testCountedConstPtrOrConstPtr.cpp:43
DGtal::CanonicSCellEmbedder
Aim: A trivial embedder for signed cell, which corresponds to the canonic injection of cell centroids...
Definition
CanonicSCellEmbedder.h:66
DGtal::WithQuantity::WithQuantity
WithQuantity(const T &_object, const std::string &_name, const Type &value, QuantityScale s=QuantityScale::UNKNOWN)
Definition
Display3D.h:332
Surfel
KSpace::SCell Surfel
Definition
testArithmeticalDSSComputerOnSurfels.cpp:50
K
KSpace K
Definition
testCubicalComplex.cpp:62
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
DigitalShape
GaussDigitizer< Space, ImplicitShape > DigitalShape
Definition
testPolynomial.cpp:73
domain
Domain domain
Definition
testProjection.cpp:88
tests
shapes
testBall3D.cpp
Generated on
for DGtal by
1.18.0