DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
testBall3DSurface.cpp
1 
29 
30 
31 #include "DGtal/shapes/parametric/Ball3D.h"
32 #include "DGtal/helpers/StdDefs.h"
33 #include <iostream>
34 #include "DGtal/io/Color.h"
35 #include "DGtal/kernel/sets/SetPredicate.h"
37 
38 using namespace std;
39 using namespace DGtal;
40 using namespace Z3i;
41 
43 // Standard services - public :
44 
45 
46 int main(int /*argc*/, char** /*argv*/)
47 {
48 
49 
50 
51  // -------------------------------------------------------------------------- Type declaring
53  typedef Ball3D<Space> EuclideanShape;
54 
55  bool test = true;
56 
57  // -------------------------------------------------------------------------- Creating the shape
58  double radius = 10;
59  RealPoint c1(0, 0, 0 );
60  EuclideanShape ball1( c1, radius );
61 
62  trace.beginBlock("Arc length computing");
63  double arcExp = ball1.arclength( make_pair(0.0,0.0), make_pair(0.0,M_PI) ,500 );
64  double arcTheo = M_PI*radius;
65  trace.info() <<"Computed arc length: "<< arcExp <<endl;
66  trace.info() << "Theoric arc length: "<< arcTheo << endl;
67  if(fabs(arcTheo- arcExp) < 0.1)
68  {
69  trace.info() <<"The arc length has a good value"<<endl;
70  }
71  else
72  {
73  test=false;
74  }
75  trace.endBlock();
76 
77  trace.beginBlock("Surface length computing");
78  double surfaceExp = ball1.surfacelength( make_pair(0.0,0.0), make_pair(M_PI*2,M_PI) ,500 );
79  double surfaceTheo = 4.0*M_PI*radius*radius;
80  trace.info() <<"Computed surface length: "<< surfaceExp <<endl;
81  trace.info() << "Theoric surface length: "<< surfaceTheo << endl;
82  if(fabs(surfaceExp- surfaceTheo) < 0.1)
83  {
84  trace.info() <<"The surface has a good value"<<endl;
85  }
86  else
87  {
88  test=false;
89  }
90  trace.endBlock();
91 
92 
93  if (test)
94  return 0;
95  else
96  return -1;
97 }
98 // //
100 
101