DGtal  1.3.beta
geometry/curves/exampleArithDSS3d.cpp

This example outputs a greedy segmentation of an open and 6-connected 3d digital curve into DSSs.

$ ./examples/geometry/curves/exampleArithDSS3d
Greedy segmentation of a 3d digital curve into DSSs
See also
Analysis of one-dimensional discrete structures
#include <iostream>
#include "DGtal/io/viewers/Viewer3D.h"
#ifdef WITH_CAIRO
#include "DGtal/io/boards/Board3DTo2D.h"
#endif
#include "DGtal/io/DrawWithDisplay3DModifier.h"
#include "DGtal/io/readers/PointListReader.h"
#include "DGtal/io/CDrawableWithDisplay3D.h"
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "ConfigExamples.h"
#include "DGtal/geometry/curves/StandardDSS6Computer.h"
#include "DGtal/geometry/curves/GreedySegmentation.h"
using namespace std;
using namespace DGtal;
using namespace Z3i;
// Standard services - public :
int main( int argc, char** argv )
{
typedef std::vector<Point>::iterator Iterator;
typedef GreedySegmentation<SegmentComputer> Decomposition;
string inputFilename = examplesPath + "samples/sinus.dat";
vector<Point> sequence = PointListReader<Point>::getPointsFromFile(inputFilename);
Decomposition theDecomposition(sequence.begin(), sequence.end(), algo);
//display
bool flag = true;
Point p;
#ifdef WITH_VISU3D_QGLVIEWER
QApplication application(argc,argv);
Viewer3D<> viewer;
viewer.show();
viewer << SetMode3D(p.className(), "Grid");
#endif
#ifdef WITH_CAIRO
Board3DTo2D<> boardViewer;
boardViewer << SetMode3D(p.className(), "Grid");
boardViewer << CameraPosition(-23.500000, 12.500000, 42.078199)
<< CameraDirection(0.7200000, -0.280000, -0.620000)
<< CameraUpVector(0.1900000, 0.950000, -0.200000);
boardViewer << CameraZNearFar(21.578200, 105.578199);
#endif
unsigned int c = 0;
Decomposition::SegmentComputerIterator i = theDecomposition.begin();
for ( ; i != theDecomposition.end(); ++i) {
SegmentComputer currentSegmentComputer(*i);
#ifdef WITH_VISU3D_QGLVIEWER
viewer << SetMode3D(currentSegmentComputer.className(), "Points");
viewer << currentSegmentComputer;
viewer << SetMode3D(currentSegmentComputer.className(), "BoundingBox");
viewer << currentSegmentComputer;
#endif
#ifdef WITH_CAIRO
boardViewer << SetMode3D(currentSegmentComputer.className(), "Points");
boardViewer << currentSegmentComputer;
boardViewer << SetMode3D(currentSegmentComputer.className(), "BoundingBox");
boardViewer << currentSegmentComputer;
#endif
c++;
}
#ifdef WITH_VISU3D_QGLVIEWER
viewer << Viewer3D<>::updateDisplay;
flag = application.exec();
#endif
#ifdef WITH_CAIRO
boardViewer.saveCairo("exampleArithDSS3d.pdf", Board3DTo2D<>::CairoPDF, 600*2, 400*2);
#endif
return flag;
}
DGtal::ArithmeticalDSSComputer< std::vector< Z2i::Point >::const_iterator, int, 4 >
SegmentComputer
ArithmeticalDSSComputer< std::vector< Z2i::Point >::const_iterator, int, 4 > SegmentComputer
Definition: testArithmeticalDSSComputerOnSurfels.cpp:55
DGtal::PointListReader
Aim: Implements method to read a set of points represented in each line of a file.
Definition: PointListReader.h:84
DGtal::GreedySegmentation
Aim: Computes the greedy segmentation of a range given by a pair of ConstIterators....
Definition: GreedySegmentation.h:149
DGtal::Viewer3D
Definition: Viewer3D.h:135
DGtal::Board3DTo2D
Class for PDF, PNG, PS, EPS, SVG export drawings with Cairo with 3D->2D projection.
Definition: Common.h:162
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::CameraZNearFar
CameraZNearFar class to set near and far distance.
Definition: DrawWithBoard3DTo2DModifier.h:132
DGtal::StandardDSS6Computer
Aim: Dynamic recognition of a 3d-digital straight segment (DSS)
Definition: StandardDSS6Computer.h:76
DGtal::CameraDirection
CameraDirection class to set camera direction.
Definition: DrawWithBoard3DTo2DModifier.h:90
DGtal::SetMode3D
Modifier class in a Display3D stream. Useful to choose your own mode for a given class....
Definition: DrawWithDisplay3DModifier.h:73
main
int main(int argc, char **argv)
Definition: testArithmeticDSS-benchmark.cpp:147
DGtal::CameraPosition
CameraPosition class to set camera position.
Definition: DrawWithBoard3DTo2DModifier.h:70
DGtal::PointVector
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:165
DGtal::Viewer3D::show
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
DGtal::CameraUpVector
CameraUpVector class to set camera up-vector.
Definition: DrawWithBoard3DTo2DModifier.h:110
DGtal::Board3DTo2D::saveCairo
void saveCairo(const char *filename, CairoType type, int bWidth, int bHeight)
Point
MyPointD Point
Definition: testClone2.cpp:383