DGtal 2.1.0
Loading...
Searching...
No Matches
testBall3D.cpp File Reference
#include <iostream>
#include "DGtal/shapes/parametric/Ball3D.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/shapes/GaussDigitizer.h"
#include "DGtal/io/Color.h"
#include "DGtal/topology/SurfelAdjacency.h"
#include "DGtal/topology/DigitalSurface.h"
#include "DGtal/topology/helpers/BoundaryPredicate.h"
#include "DGtal/topology/SetOfSurfels.h"
#include "DGtal/io/colormaps/GradientColorMap.h"
#include "DGtal/topology/SCellsFunctors.h"
#include "DGtal/io/viewers/PolyscopeViewer.h"
Include dependency graph for testBall3D.cpp:

Go to the source code of this file.

Functions

int main ()
 

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
Anis Benyoub (anis..nosp@m.beny.nosp@m.oub@i.nosp@m.nsa-.nosp@m.lyon..nosp@m.fr )
Date
2012/°6/05

Functions for testing class Ball3D.

This file is part of the DGtal library.

Definition in file testBall3D.cpp.

Function Documentation

◆ main()

int main ( void  )

Definition at line 52 of file testBall3D.cpp.

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
134 double curvature =ball1.meanCurvature(Angles);
135 viewer << WithQuantity(*it, "Curvature", curvature);
136 }
137
138 viewer.show();
139 return 0;
140}
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...
const Point & lowerBound() const
const Point & upperBound() const
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
std::set< SCell > SurfelSet
Preferred type for defining a set of surfels (always signed cells).
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
Aim: Implements basic operations that will be used in Point and Vector classes.
void show() override
Starts the event loop and display of elements.
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as connected surfels....
std::pair< double, double > AngularCoordinates
virtual AngularCoordinates parameter(const RealPoint &p) const =0
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
Space::RealPoint RealPoint
Definition StdDefs.h:170
Aim: A trivial embedder for signed cell, which corresponds to the canonic injection of cell centroids...
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
Attach a property to an element.
Definition Display3D.h:331
KSpace K
GaussDigitizer< Space, ImplicitShape > DigitalShape
Domain domain

References DGtal::Display3D< Space, KSpace >::allowReuseList, domain, DGtal::Surfaces< TKSpace >::findABel(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), K, DGtal::HyperRectDomain< TSpace >::lowerBound(), DGtal::PolyscopeViewer< Space, KSpace >::show(), DGtal::Surfaces< TKSpace >::trackBoundary(), and DGtal::HyperRectDomain< TSpace >::upperBound().