DGtal  0.9.3
testBall3DSurface.cpp
Go to the documentation of this file.
1 
29 
31 #include <iostream>
32 #include "DGtal/shapes/parametric/Ball3D.h"
33 #include "DGtal/helpers/StdDefs.h"
34 #include "DGtal/io/Color.h"
36 
37 using namespace std;
38 using namespace DGtal;
39 using namespace Z3i;
40 
42 // Standard services - public :
43 
44 
45 int main(int /*argc*/, char** /*argv*/)
46 {
47 
48 
49 
50  // -------------------------------------------------------------------------- Type declaring
52  typedef Ball3D<Space> EuclideanShape;
53 
54  bool test = true;
55 
56  // -------------------------------------------------------------------------- Creating the shape
57  double radius = 10;
58  RealPoint c1(0, 0, 0 );
59  EuclideanShape ball1( c1, radius );
60 
61  trace.beginBlock("Arc length computing");
62  double arcExp = ball1.arclength( make_pair(0.0,0.0), make_pair(0.0,M_PI) ,500 );
63  double arcTheo = M_PI*radius;
64  trace.info() <<"Computed arc length: "<< arcExp <<endl;
65  trace.info() << "Theoric arc length: "<< arcTheo << endl;
66  if(fabs(arcTheo- arcExp) < 0.1)
67  {
68  trace.info() <<"The arc length has a good value"<<endl;
69  }
70  else
71  {
72  test=false;
73  }
74  trace.endBlock();
75 
76  trace.beginBlock("Surface length computing");
77  double surfaceExp = ball1.surfacelength( make_pair(0.0,0.0), make_pair(M_PI*2,M_PI) ,500 );
78  double surfaceTheo = 4.0*M_PI*radius*radius;
79  trace.info() <<"Computed surface length: "<< surfaceExp <<endl;
80  trace.info() << "Theoric surface length: "<< surfaceTheo << endl;
81  if(fabs(surfaceExp- surfaceTheo) < 0.1)
82  {
83  trace.info() <<"The surface has a good value"<<endl;
84  }
85  else
86  {
87  test=false;
88  }
89  trace.endBlock();
90 
91 
92  if (test)
93  return 0;
94  else
95  return -1;
96 }
97 // //
99 
100 
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
STL namespace.
double endBlock()
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:141
int main(int, char **)
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & info()
Aim: Model of the concept StarShaped3D represents any Sphere in the space.
Definition: Ball3D.h:60
bool test(const I &itb, const I &ite)