DGtal  0.9.2
exampleArithDSS3d.cpp
1 
37 #include <iostream>
38 
39 #include "DGtal/io/viewers/Viewer3D.h"
40 #include "DGtal/io/boards/Board3DTo2D.h"
41 
42 #include "DGtal/io/DrawWithDisplay3DModifier.h"
43 #include "DGtal/io/readers/PointListReader.h"
44 #include "DGtal/io/CDrawableWithDisplay3D.h"
45 
46 #include "DGtal/base/Common.h"
47 #include "DGtal/helpers/StdDefs.h"
48 #include "ConfigExamples.h"
49 
50 #include "DGtal/geometry/curves/StandardDSS6Computer.h"
51 #include "DGtal/geometry/curves/GreedySegmentation.h"
52 
53 
54 using namespace std;
55 using namespace DGtal;
56 using namespace Z3i;
57 
58 
59 // Standard services - public :
60 
61 int main( int argc, char** argv )
62 {
63 
64 
65  typedef PointVector<3,int> Point;
66  typedef std::vector<Point>::iterator Iterator;
67  typedef StandardDSS6Computer<Iterator,int,4> SegmentComputer;
68  typedef GreedySegmentation<SegmentComputer> Decomposition;
69 
70  string inputFilename = examplesPath + "samples/sinus.dat";
71  vector<Point> sequence = PointListReader<Point>::getPointsFromFile(inputFilename);
72 
73 
74  SegmentComputer algo;
75  Decomposition theDecomposition(sequence.begin(), sequence.end(), algo);
76 
78  //display
79  bool flag = true;
80  Point p;
81 
82 #ifdef WITH_VISU3D_QGLVIEWER
83 
84  QApplication application(argc,argv);
85  Viewer3D<> viewer;
86  viewer.show();
87  viewer << SetMode3D(p.className(), "Grid");
88 
89 #endif
90 #ifdef WITH_CAIRO
91  Board3DTo2D<> boardViewer;
92  boardViewer << SetMode3D(p.className(), "Grid");
93  boardViewer << CameraPosition(-23.500000, 12.500000, 42.078199)
94  << CameraDirection(0.7200000, -0.280000, -0.620000)
95  << CameraUpVector(0.1900000, 0.950000, -0.200000);
96  boardViewer << CameraZNearFar(21.578200, 105.578199);
97 #endif
98 
99 
100 
101  unsigned int c = 0;
102  Decomposition::SegmentComputerIterator i = theDecomposition.begin();
103  for ( ; i != theDecomposition.end(); ++i) {
104  SegmentComputer currentSegmentComputer(*i);
105  #ifdef WITH_VISU3D_QGLVIEWER
106  viewer << SetMode3D(currentSegmentComputer.className(), "Points");
107  viewer << currentSegmentComputer;
108  viewer << SetMode3D(currentSegmentComputer.className(), "BoundingBox");
109  viewer << currentSegmentComputer;
110  #endif
111  #ifdef WITH_CAIRO
112  boardViewer << SetMode3D(currentSegmentComputer.className(), "Points");
113  boardViewer << currentSegmentComputer;
114  boardViewer << SetMode3D(currentSegmentComputer.className(), "BoundingBox");
115  boardViewer << currentSegmentComputer;
116  #endif
117  c++;
118  }
119 
120 
121  #ifdef WITH_VISU3D_QGLVIEWER
122  viewer << Viewer3D<>::updateDisplay;
123  flag = application.exec();
124  #endif
125 
126  #ifdef WITH_CAIRO
127  boardViewer.saveCairo("exampleArithDSS3d.pdf", Board3DTo2D<>::CairoPDF, 600*2, 400*2);
128  #endif
129 
130  return flag;
131 }
132 
CameraUpVector class to set camera up-vector.
CameraZNearFar class to set near and far distance.
Aim: Dynamic recognition of a 3d-digital straight segment (DSS)
Class for PDF, PNG, PS, EPS, SVG export drawings with Cairo with 3D->2D projection.
Definition: Common.h:138
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
CameraDirection class to set camera direction.
STL namespace.
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:141
Aim: Computes the greedy segmentation of a range given by a pair of ConstIterators. The last element of a given segment is the first one one of the next segment.
Aim: Implements method to read a set of points represented in each line of a file.
CameraPosition class to set camera position.
DGtal is the top-level namespace which contains all DGtal functions and types.
Modifier class in a Display3D stream. Useful to choose your own mode for a given class. Realizes the concept CDrawableWithDisplay3D.
std::string className() const