DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
exampleFrechetShortcut.cpp
Go to the documentation of this file.
1
16
29
30
38
40
#include <iostream>
41
#include "DGtal/base/Common.h"
42
#include "DGtal/helpers/StdDefs.h"
43
44
#include "ConfigExamples.h"
45
#include "DGtal/io/boards/Board2D.h"
46
#include "DGtal/geometry/curves/FrechetShortcut.h"
47
#include "DGtal/geometry/curves/GreedySegmentation.h"
49
50
using namespace
std
;
51
using namespace
DGtal
;
52
using namespace
Z2i
;
53
54
55
56
58
59
int
main
(
int
argc,
char
** argv )
60
{
61
trace
.
beginBlock
(
"Example FrechetShortcut"
);
62
trace
.
info
() <<
"Args:"
;
63
for
(
int
i = 0; i < argc; ++i )
64
trace
.
info
() <<
" "
<< argv[ i ];
65
trace
.
info
() << endl;
66
67
std::string filename;
68
double
error;
69
70
if
(argc == 1)
71
{
72
trace
.
info
() <<
"Use default file and error value\n"
;
73
filename = examplesPath +
"samples/plant-frechet.dat"
;
74
error = 3;
75
}
76
else
77
if
(argc != 3)
78
{
79
trace
.
info
() <<
"Please enter a filename and error value.\n"
;
80
return
0;
81
}
82
else
83
{
84
filename = argv[1];
85
error = atof(argv[2]);
86
}
87
ifstream instream;
// input stream
88
instream.open (filename.c_str(), ifstream::in);
89
90
91
92
Curve
c;
//grid curve
93
c.
initFromVectorStream
(instream);
94
95
Board2D
board;
96
97
// Display the pixels as arrows range to show the way the curve is scanned
98
board << c.
getArrowsRange
();
99
100
trace
.
beginBlock
(
"Simple example"
);
101
103
Curve::PointsRange
r = c.
getPointsRange
();
104
105
typedef
FrechetShortcut<Curve::PointsRange::ConstIterator,int>
Shortcut;
106
107
// Computation of one shortcut
108
Shortcut s(error);
109
110
s.init( r.
begin
() );
111
while
( ( s.end() != r.
end
() )
112
&&( s.extendFront() ) ) {}
113
114
115
116
// Computation of a greedy segmentation
117
118
typedef
GreedySegmentation<Shortcut>
Segmentation
;
119
120
Segmentation
theSegmentation( r.
begin
(), r.
end
(), Shortcut(error) );
121
122
// the segmentation is computed here
123
Segmentation::SegmentComputerIterator it = theSegmentation.
begin
();
124
Segmentation::SegmentComputerIterator itEnd = theSegmentation.
end
();
125
126
for
( ; it != itEnd; ++it) {
127
s=Shortcut(*it);
128
trace
.
info
() << s << std::endl;
129
board << s;
130
}
131
132
board.
saveEPS
(
"FrechetShortcutExample.eps"
,
Board2D::BoundingBox
, 5000 );
133
135
#ifdef DGTAL_WITH_CAIRO
136
board.
saveCairo
(
"FrechetShortcutExample.png"
);
137
#endif
138
139
140
trace
.
endBlock
();
141
return
0;
142
}
143
// //
DGtal::Board2D
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition
Board2D.h:71
DGtal::ConstRangeAdapter::begin
ConstIterator begin() const
Definition
ConstRangeAdapter.h:222
DGtal::ConstRangeAdapter::end
ConstIterator end() const
Definition
ConstRangeAdapter.h:230
DGtal::FrechetShortcut
Aim: On-line computation Computation of the longest shortcut according to the Fréchet distance for a ...
Definition
FrechetShortcut.h:112
DGtal::GreedySegmentation
Aim: Computes the greedy segmentation of a range given by a pair of ConstIterators....
Definition
GreedySegmentation.h:150
DGtal::GridCurve::initFromVectorStream
bool initFromVectorStream(std::istream &in)
DGtal::GridCurve::getPointsRange
PointsRange getPointsRange() const
Definition
GridCurve.h:418
DGtal::GridCurve< K2 >::PointsRange
ConstRangeAdapter< typename Storage::const_iterator, functors::SCellToPoint< KSpace >, Point > PointsRange
Definition
GridCurve.h:413
DGtal::GridCurve::getArrowsRange
ArrowsRange getArrowsRange() const
Definition
GridCurve.h:442
DGtal::SaturatedSegmentation::end
SaturatedSegmentation::SegmentComputerIterator end() const
DGtal::SaturatedSegmentation::begin
SaturatedSegmentation::SegmentComputerIterator begin() const
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Trace::info
std::ostream & info()
DGtal::Trace::endBlock
double endBlock()
LibBoard::Board::BoundingBox
@ BoundingBox
Definition
Board.h:42
LibBoard::Board::saveEPS
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition
Board.cpp:804
LibBoard::Board::saveCairo
void saveCairo(const char *filename, CairoType type=CairoPNG, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition
Board.cpp:1138
DGtal::Z2i
Z2i this namespace gathers the standard of types for 2D imagery.
DGtal::Z2i::Curve
GridCurve< K2 > Curve
Definition
StdDefs.h:116
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::trace
Trace trace
std
STL namespace.
Segmentation
SaturatedSegmentation< SegmentComputer > Segmentation
Definition
testArithmeticalDSSComputerOnSurfels.cpp:56
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
examples
geometry
curves
exampleFrechetShortcut.cpp
Generated on
for DGtal by
1.18.0