DGtal  1.3.beta
Functions
testBall3D.cpp File Reference
#include "DGtal/shapes/parametric/Ball3D.h"
#include "DGtal/helpers/StdDefs.h"
#include <iostream>
#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/Viewer3D.h"
Include dependency graph for testBall3D.cpp:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

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 ( int  argc,
char **  argv 
)

Definition at line 52 of file testBall3D.cpp.

53  {
54 
55 
56 
57  // -------------------------------------------------------------------------- Type declaring
59  typedef Ball3D<Space> EuclideanShape;
61 
62 
63  // -------------------------------------------------------------------------- Creating the shape
64  RealPoint c1(0, 0, 0 );
65  EuclideanShape ball1( c1, 12.2 );
66 
67  // -------------------------------------------------------------------------- GaussDigitizing
68  DigitalShape dshape;
69  dshape.attach( ball1 );
70  RealPoint p1 =RealPoint( -15.0, -15.0, -15.0 );
71  RealPoint p2 =RealPoint( 15.0, 15.0, 15.0 );
72  dshape.init( RealPoint( p1 ), RealPoint( p2 ), 1.0);
73  Domain domain = dshape.getDomain();
74 
75 
76  // -------------------------------------------------------------------------- Khalimskhy
77  KSpace K;
78  bool space_ok = K.init( domain.lowerBound(), domain.upperBound(), true );
79  if (!space_ok)
80  {
81  return 2;
82  }
83 
84 
85  // -------------------------------------------------------------------------- Other types
86  typedef SurfelAdjacency<KSpace::dimension> MySurfelAdjacency;
87  typedef KSpace::Surfel Surfel;
89  typedef SetOfSurfels< KSpace, SurfelSet > MySetOfSurfels;
90 
91 
92  // -------------------------------------------------------------------------- Tracking the boudnadry
93  MySurfelAdjacency surfAdj( true ); // interior in all directions.
94  MySetOfSurfels theSetOfSurfels( K, surfAdj );
95  Surfel bel = Surfaces<KSpace>::findABel( K, dshape, 1000 );
96  Surfaces<KSpace>::trackBoundary( theSetOfSurfels.surfelSet(), K, surfAdj, dshape, bel );
97 
98 
99 
100  QApplication application(argc,argv);
101  Viewer3D<> viewer;
102  viewer.show();
103  viewer << SetMode3D( domain.className(), "BoundingBox" ) << domain;
104 
105 
106 
107 
108 
109 //-----------------------------------------------------------------------
110 // Looking for the min and max values
111 
112  double minCurv=1;
113  double maxCurv=0;
115  for ( std::set<SCell>::iterator it = theSetOfSurfels.begin(), it_end = theSetOfSurfels.end();
116  it != it_end; ++it)
117  {
118 
119  RealPoint A = midpoint( *it );
120  DGtal::StarShaped3D<Space>::AngularCoordinates Angles= ball1.parameter(A);
121  double a =ball1.meanCurvature(Angles);
122 // double a =ball1.gaussianCurvature(Angles);
123 
124  if(a>maxCurv)
125  {
126  maxCurv=a;
127  }
128  if(a<minCurv)
129  {
130  minCurv=a;
131  }
132  }
133 
134 //-----------------------------------------------------------------------
135 //Specifing a color map
136 
137  GradientColorMap<double> cmap_grad( minCurv, maxCurv+1 );
138  cmap_grad.addColor( Color( 50, 50, 255 ) );
139  cmap_grad.addColor( Color( 255, 0, 0 ) );
140  cmap_grad.addColor( Color( 255, 255, 10 ) );
141 
142 
143 //-----------------------------------------------------------------------
144 //Drawing the ball && giving a color to the surfels( depending on the
145 //curvature)
146 
147  unsigned int nbSurfels = 0;
148 
149 
150  for ( std::set<SCell>::iterator it = theSetOfSurfels.begin(), it_end = theSetOfSurfels.end();
151 it != it_end; ++it, ++nbSurfels )
152  {
153  RealPoint A = midpoint( *it );
154 
156  double curvature =ball1.meanCurvature(Angles);
157 // double curvature =ball1.gaussianCurvature(Angles);
158  viewer << CustomColors3D( Color::Black, cmap_grad( curvature));
159  viewer << *it;
160  }
161 
162 
163 
164  viewer << Viewer3D<>::updateDisplay;
165 
166  return application.exec();
167 }

References DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::addColor(), DGtal::GaussDigitizer< TSpace, TEuclideanShape >::attach(), DGtal::HyperRectDomain< TSpace >::className(), domain, DGtal::GaussDigitizer< TSpace, TEuclideanShape >::getDomain(), DGtal::GaussDigitizer< TSpace, TEuclideanShape >::init(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), K, DGtal::HyperRectDomain< TSpace >::lowerBound(), DGtal::Viewer3D< TSpace, TKSpace >::show(), and DGtal::HyperRectDomain< TSpace >::upperBound().

DGtal::GaussDigitizer
Aim: A class for computing the Gauss digitization of some Euclidean shape, i.e. its intersection with...
Definition: GaussDigitizer.h:79
DGtal::Surfaces
Aim: A utility class for constructing surfaces (i.e. set of (n-1)-cells).
Definition: Surfaces.h:78
DGtal::GaussDigitizer::getDomain
Domain getDomain() const
DGtal::HyperRectDomain< Space >
DGtal::KhalimskySpaceND::SurfelSet
std::set< SCell > SurfelSet
Preferred type for defining a set of surfels (always signed cells).
Definition: KhalimskySpaceND.h:450
DGtal::SurfelAdjacency< KSpace::dimension >
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition: Color.h:67
DGtal::HyperRectDomain::upperBound
const Point & upperBound() const
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::StarShaped3D::parameter
virtual AngularCoordinates parameter(const RealPoint &p) const =0
DGtal::HyperRectDomain::className
std::string className() const
DGtal::GaussDigitizer::attach
void attach(ConstAlias< EuclideanShape > shape)
K
KSpace K
Definition: testCubicalComplex.cpp:62
DGtal::SignedKhalimskyCell
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
Definition: KhalimskySpaceND.h:208
DGtal::GaussDigitizer::init
void init(const RealPoint &xLow, const RealPoint &xUp, typename RealVector::Component gridStep)
Surfel
KSpace::SCell Surfel
Definition: testArithmeticalDSSComputerOnSurfels.cpp:50
DGtal::Viewer3D
Definition: Viewer3D.h:135
DGtal::StarShaped3D::AngularCoordinates
std::pair< double, double > AngularCoordinates
Definition: StarShaped3D.h:77
DGtal::CustomColors3D
Definition: DrawWithDisplay3DModifier.h:129
DGtal::SetMode3D
Modifier class in a Display3D stream. Useful to choose your own mode for a given class....
Definition: DrawWithDisplay3DModifier.h:73
domain
Domain domain
Definition: testProjection.cpp:88
DGtal::PointVector
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:165
DGtal::SetOfSurfels
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as connected surfels....
Definition: SetOfSurfels.h:73
DGtal::Viewer3D::show
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
DGtal::CanonicSCellEmbedder< KSpace >
RealPoint
Z2i::RealPoint RealPoint
Definition: testAstroid2D.cpp:46
DGtal::GradientColorMap
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Definition: GradientColorMap.h:119
DGtal::Ball3D
Aim: Model of the concept StarShaped3D represents any Sphere in the space.
Definition: Ball3D.h:60
DGtal::HyperRectDomain::lowerBound
const Point & lowerBound() const
SurfelSet
MyDigitalSurface::SurfelSet SurfelSet
Definition: greedy-plane-segmentation-ex2.cpp:95
DGtal::KhalimskySpaceND
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
Definition: KhalimskySpaceND.h:64