Loading [MathJax]/extensions/TeX/AMSsymbols.js
DGtal 2.0.0
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(int argc, char** argv)
53 {
54 // -------------------------------------------------------------------------- Type declaring
56 typedef Ball3D<Space> EuclideanShape;
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;
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;
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();
129it != 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// //
143
144
Aim: Model of the concept StarShaped3D represents any Sphere in the space.
Definition Ball3D.h:61
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
void attach(ConstAlias< EuclideanShape > shape)
void init(const RealPoint &xLow, const RealPoint &xUp, typename RealVector::Component gridStep)
Domain getDomain() const
void show() override
Starts the event loop and display of elements.
PointVector< dim, double > RealPoint
Definition SpaceND.h:117
std::pair< double, double > AngularCoordinates
static void trackBoundary(SCellSet &surface, const KSpace &K, const SurfelAdjacency< KSpace::dimension > &surfel_adj, const PointPredicate &pp, const SCell &start_surfel)
static SCell findABel(const KSpace &K, const PointPredicate &pp, unsigned int nbtries=1000)
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
MyDigitalSurface::SurfelSet SurfelSet
Z3i this namespace gathers the standard of types for 3D imagery.
KhalimskySpaceND< 3, Integer > KSpace
Definition StdDefs.h:146
Space::RealPoint RealPoint
Definition StdDefs.h:170
DGtal is the top-level namespace which contains all DGtal functions and types.
STL namespace.
Aim: A trivial embedder for signed cell, which corresponds to the canonic injection of cell centroids...
Attach a property to an element.
Definition Display3D.h:327
int main()
Definition testBits.cpp:56
KSpace K
GaussDigitizer< Space, ImplicitShape > DigitalShape
Domain domain