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