DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
exampleArithDSS3d.cpp
1 
37 #include <iostream>
38 
39 #include <QtGui/qapplication.h>
40 #include "DGtal/io/viewers/Viewer3D.h"
41 #include "DGtal/io/DrawWithDisplay3DModifier.h"
42 #include "DGtal/io/readers/PointListReader.h"
43 #include "DGtal/io/CDrawableWithDisplay3D.h"
44 
45 #include "DGtal/base/Common.h"
46 #include "DGtal/helpers/StdDefs.h"
47 #include "ConfigExamples.h"
48 
49 #include "DGtal/geometry/curves/ArithmeticalDSS3d.h"
50 #include "DGtal/geometry/curves/SaturatedSegmentation.h"
51 
52 
53 using namespace std;
54 using namespace DGtal;
55 using namespace Z3i;
56 
57 
58 // Standard services - public :
59 
60 int main( int argc, char** argv )
61 {
62 
63 
64  typedef PointVector<3,int> Point;
65  typedef std::vector<Point>::iterator Iterator;
66  typedef ArithmeticalDSS3d<Iterator,int,4> SegmentComputer;
67  typedef SaturatedSegmentation<SegmentComputer> Decomposition;
68 
69  string inputFilename = examplesPath + "samples/sinus.dat";
70  vector<Point> sequence = PointListReader<Point>::getPointsFromFile(inputFilename);
71 
72 
73  SegmentComputer algo;
74  Decomposition theDecomposition(sequence.begin(), sequence.end(), algo);
75 
77  //display
78  bool flag = true;
79  #ifdef WITH_VISU3D_QGLVIEWER
80 
81  QApplication application(argc,argv);
82  Viewer3D viewer;
83  viewer.show();
84 
85  Point p;
86  viewer << SetMode3D(p.className(), "Grid");
87 
88  unsigned int c = 0;
89  Decomposition::SegmentComputerIterator i = theDecomposition.begin();
90  for ( ; i != theDecomposition.end(); ++i) {
91  SegmentComputer currentSegmentComputer(*i);
92  viewer << SetMode3D(currentSegmentComputer.className(), "Points");
93  viewer << currentSegmentComputer;
94  viewer << SetMode3D(currentSegmentComputer.className(), "BoundingBox");
95  viewer << currentSegmentComputer;
96  //cerr << currentSegmentComputer << endl;
97  c++;
98  }
99 
100  viewer << Viewer3D::updateDisplay;
101  flag = application.exec();
102  #endif
103  return flag;
104 }
105