DGtal  0.9.3
testLambdaMST3D.cpp
Go to the documentation of this file.
1 
30 #include <iostream>
32 #include <fstream>
33 #include <vector>
34 #include <iterator>
35 #include "DGtal/base/Common.h"
36 #include "ConfigTest.h"
37 #include "DGtal/helpers/StdDefs.h"
38 #include "DGtal/io/readers/PointListReader.h"
39 #include "DGtal/geometry/curves/Naive3DDSSComputer.h"
40 #include "DGtal/geometry/curves/estimation/LambdaMST3D.h"
41 #include "DGtal/geometry/curves/SaturatedSegmentation.h"
42 
44 
45 using namespace std;
46 using namespace DGtal;
47 using namespace Z3i;
48 
50 // Functions for testing class LambdaMST3D.
52 
53 class testLambdaMST3D
54 {
55  typedef DGtal::Z3i::Point Point;
56  typedef DGtal::Z2i::Point Point2D;
57  typedef std::vector < Point > Range;
58  typedef std::list < Point2D > Range2D;
59  typedef Range::const_iterator ConstIterator;
60  typedef Range2D::const_iterator ConstIterator2D;
61  typedef Naive3DDSSComputer < ConstIterator, int, 8 > SegmentComputer;
62  typedef SaturatedSegmentation<SegmentComputer> Segmentation;
64  typedef SaturatedSegmentation<SegmentComputer2D> Segmentation2D;
65 private:
66  Range curve;
67 public:
68  testLambdaMST3D ()
69  {
70  fstream inputStream;
71  inputStream.open ( (testPath + "samples/sinus3D.dat").c_str(), std::ios::in );
72  try {
74  if ( curve.size() == 0) throw IOException();
75  } catch (DGtal::IOException & ioe) {
76  trace.error() << "Size is null." << endl;
77  }
78  }
79  bool lambda64ByPoint ()
80  {
81  Segmentation segmenter ( curve.begin(), curve.end(), SegmentComputer() );
83  lmst64.attach ( segmenter );
84  lmst64.init ( curve.begin(), curve.end() );
85  for ( ConstIterator it = curve.begin(); it != curve.end(); ++it )
86  {
87  lmst64.eval ( it );
88  }
89  return true;
90  }
91  bool lambda64()
92  {
93  Segmentation segmenter ( curve.begin(), curve.end(), SegmentComputer() );
95  lmst64.attach ( segmenter );
96  lmst64.init ( curve.begin(), curve.end() );
97  vector < RealVector > tangent;
98  lmst64.eval < back_insert_iterator< vector < RealVector > > > ( curve.begin(), curve.end(), back_insert_iterator< vector < RealVector > > ( tangent ) );
99  return true;
100  }
101 };
102 
103 
105 // Standard services - public :
106 
107 int main( int , char** )
108 {
109  bool res = true;
110  testLambdaMST3D testLMST;
111  trace.beginBlock ( "Testing LambdaMST3D" );
112  trace.beginBlock ( "Testing point only calculation" );
113  res &= testLMST.lambda64ByPoint();
114  trace.endBlock();
115  trace.beginBlock ( "Testing calculation for whole curve" );
116  res &= testLMST.lambda64();
117  trace.endBlock();
118  trace.endBlock();
119  trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
120  return res ? 0 : 1;
121 }
122 // //
void beginBlock(const std::string &keyword="")
MyDigitalSurface::ConstIterator ConstIterator
Trace trace
Definition: Common.h:137
Aim: Simplify creation of Lambda MST tangent estimator.
Definition: LambdaMST3D.h:173
STL namespace.
double endBlock()
Aim: This class is a wrapper around ArithmeticalDSS that is devoted to the dynamic recognition of dig...
std::ostream & emphase()
int main(int, char **)
Aim: Implements method to read a set of points represented in each line of a file.
DGtal is the top-level namespace which contains all DGtal functions and types.
MyPointD Point
Definition: testClone2.cpp:383
Aim: Dynamic recognition of a 3d-digital straight segment (DSS)
Aim: Computes the saturated segmentation, that is the whole set of maximal segments within a range gi...
std::ostream & error()
void attach(Alias< TSegmentation > segmentComputer)