DGtal 1.4.0
Loading...
Searching...
No Matches
testLambdaMST2D.cpp
Go to the documentation of this file.
1
31#include <iostream>
32#include <fstream>
33#include <iterator>
34#include <vector>
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/ArithmeticalDSSComputer.h"
40#include "DGtal/geometry/curves/estimation/LambdaMST2D.h"
41#include "DGtal/geometry/curves/SaturatedSegmentation.h"
42
44
45using namespace std;
46using namespace DGtal;
47using namespace Z2i;
48
50// Functions for testing class LambdaMST2D.
52
53class testLambdaMST2D
54{
55 typedef vector < Point > Range;
56 typedef Range::const_iterator ConstIterator;
57 typedef ArithmeticalDSSComputer < ConstIterator, int, 8 > SegmentComputer;
59private:
60 Range curve;
61public:
62 testLambdaMST2D ()
63 {
64 fstream inputStream;
65 inputStream.open ( (testPath + "samples/sinus2D4.dat").c_str(), ios::in );
66 try {
68 if ( curve.size() == 0) throw IOException();
69 } catch (DGtal::IOException & ioe) {
70 trace.error() << "Size is null." << endl;
71 }
72 }
73 bool lambda64ByPoint ()
74 {
75 Segmentation segmenter ( curve.begin(), curve.end(), SegmentComputer() );
76 LambdaMST2D < Segmentation > lmst64;
77 lmst64.attach ( segmenter );
78 for ( ConstIterator it = curve.begin(); it != curve.end(); ++it )
79 lmst64.eval ( *it );
80 return true;
81 }
82 bool lambda64()
83 {
84 Segmentation segmenter ( curve.begin(), curve.end(), SegmentComputer() );
85 LambdaMST2D < Segmentation > lmst64;
86 lmst64.attach ( segmenter );
87 lmst64.init ( curve.begin(), curve.end() );
88 std::vector < RealVector > tangent;
89 lmst64.eval < back_insert_iterator< vector < RealVector > > > ( curve.begin(), curve.end(), back_inserter ( tangent ) );
90 return true;
91 }
92};
93
94
96// Standard services - public :
97
98int main( int , char** )
99{
100 bool res = true;
101 testLambdaMST2D testLMST;
102 trace.beginBlock ( "Testing LambdaMST2D" );
103 trace.beginBlock ( "Testing point only calculation" );
104 res &= testLMST.lambda64ByPoint();
105 trace.endBlock();
106 trace.beginBlock ( "Testing calculation for whole curve" );
107 res &= testLMST.lambda64();
108 trace.endBlock();
109 trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
110 trace.endBlock();
111 return res ? 0 : 1;
112}
113// //
Aim: This class is a wrapper around ArithmeticalDSS that is devoted to the dynamic recognition of dig...
RealVector eval(const Point &p)
void init(ConstIterator itb, ConstIterator ite)
void attach(Alias< TSegmentation > SegmentComputer)
Aim: Computes the saturated segmentation, that is the whole set of maximal segments within a range gi...
Aim: model of CBidirectionalRangeFromPoint that adapts any range of elements bounded by two iterators...
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & error()
double endBlock()
MyDigitalSurface::ConstIterator ConstIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition Common.h:153
STL namespace.
static std::vector< TPoint > getPointsFromInputStream(std::istream &in, std::vector< unsigned int > aVectPosition=std::vector< unsigned int >())
int main()
Definition testBits.cpp:56