38 #include "DGtal/base/Common.h"
39 #include "DGtal/base/Exceptions.h"
40 #include "DGtal/kernel/SpaceND.h"
42 #include "DGtal/kernel/domains/HyperRectDomain.h"
43 #include "DGtal/geometry/curves/FrechetShortcut.h"
44 #include "DGtal/io/boards/Board2D.h"
46 #include "DGtal/io/boards/CDrawableWithBoard2D.h"
47 #include "DGtal/geometry/curves/CForwardSegmentComputer.h"
48 #include "DGtal/helpers/StdDefs.h"
50 #include "DGtal/geometry/curves/GreedySegmentation.h"
52 #include "ConfigTest.h"
57 using namespace DGtal;
70 unsigned int nbok = 0;
74 typedef std::vector<Point>::iterator Iterator;
77 std::vector<Point> contour;
78 contour.push_back(
Point(0,0));
79 contour.push_back(
Point(1,0));
80 contour.push_back(
Point(2,0));
81 contour.push_back(
Point(3,0));
82 contour.push_back(
Point(4,0));
83 contour.push_back(
Point(5,0));
84 contour.push_back(
Point(6,0));
85 contour.push_back(
Point(7,0));
86 contour.push_back(
Point(7,1));
87 contour.push_back(
Point(6,1));
88 contour.push_back(
Point(5,1));
89 contour.push_back(
Point(4,1));
90 contour.push_back(
Point(3,1));
91 contour.push_back(
Point(2,1));
92 contour.push_back(
Point(3,2));
93 contour.push_back(
Point(4,2));
94 contour.push_back(
Point(5,2));
95 contour.push_back(
Point(6,2));
96 contour.push_back(
Point(7,2));
97 contour.push_back(
Point(8,2));
98 contour.push_back(
Point(9,2));
103 s.init(contour.begin());
107 while ( (s.end() != contour.end())
108 &&(s.extendFront()) ) {}
133 std::vector<Point> contour;
134 contour.push_back(
Point(0,0));
135 contour.push_back(
Point(1,0));
136 contour.push_back(
Point(2,0));
137 contour.push_back(
Point(3,0));
138 contour.push_back(
Point(4,0));
139 contour.push_back(
Point(5,0));
140 contour.push_back(
Point(6,0));
141 contour.push_back(
Point(7,0));
142 contour.push_back(
Point(7,1));
143 contour.push_back(
Point(6,1));
144 contour.push_back(
Point(5,1));
145 contour.push_back(
Point(4,1));
146 contour.push_back(
Point(3,1));
147 contour.push_back(
Point(2,1));
148 contour.push_back(
Point(2,2));
149 contour.push_back(
Point(3,2));
150 contour.push_back(
Point(4,2));
151 contour.push_back(
Point(5,2));
152 contour.push_back(
Point(6,2));
153 contour.push_back(
Point(7,2));
154 contour.push_back(
Point(8,2));
155 contour.push_back(
Point(9,2));
185 for ( ; it != itEnd; ++it) {
191 trace.
info() << theSegmentation << std::endl;
192 board.
saveEPS(
"FrechetShortcutGreedySegmentationTest.eps", Board2D::BoundingBox, 5000 );
208 for ( ; it != itEnd; ++it) {
214 trace.
info() << theSegmentation << std::endl;
215 board.
saveEPS(
"FrechetShortcutGreedySegmentationTest.eps", Board2D::BoundingBox, 5000 );
227 return (nbok == nb) && (nbok2==nb2);
236 std::size_t pos1 = filename.find(
"samples/");
237 std::size_t
init = pos1+8;
238 std::size_t pos2 = filename.find(
".dat");
239 std::size_t end = pos2-
init;
240 std::string output = filename.substr(
init,end);
246 trace.
info() <<
"Reading input curve" << filename << std::endl;
253 instream.open (filename.c_str(), ifstream::in);
265 trace.
info() <<
"Size of input curve = " << aCurve.
size() << std::endl;
280 for ( ; it != itEnd; ++it)
283 trace.
info() <<
"size of simplified curve = " << size << std::endl;
285 it = theSegmentation.
begin();
286 for ( ; it != itEnd; ++it)
292 string outputFilename =
"FrechetShortcut-"+output+
".eps";
293 board.
saveEPS(outputFilename.c_str(), Board2D::BoundingBox, 5000 );
308 int main(
int argc,
char** argv )
312 for (
int i = 0; i < argc; ++i )
319 std::string Plant054 = testPath +
"samples/Plant054.dat";
320 std::string beetle = testPath +
"samples/beetle-1.dat";
324 trace.
emphase() << ( res ?
"Passed." :
"Error." ) << endl;
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Aim: model of CConstBidirectionalRange that adapts any range of elements bounded by two iterators [it...
Aim: On-line computation Computation of the longest shortcut according to the Fréchet distance for a ...
Aim: Computes the greedy segmentation of a range given by a pair of ConstIterators....
Aim: describes, in a cellular space of dimension n, a closed or open sequence of signed d-cells (or d...
bool initFromVectorStream(std::istream &in)
PointsRange getPointsRange() const
ArrowsRange getArrowsRange() const
Storage::size_type size() const
Storage::const_iterator ConstIterator
bool initFromVector(const std::vector< Point > &aVectorOfPoints)
Aim: Implements basic operations that will be used in Point and Vector classes.
Aim: Specific iterator to visit all the maximal segments of a saturated segmentation.
Aim: Computes the saturated segmentation, that is the whole set of maximal segments within a range gi...
SaturatedSegmentation::SegmentComputerIterator end() const
SaturatedSegmentation::SegmentComputerIterator begin() const
Aim: model of CBidirectionalRangeFromPoint that adapts any range of elements bounded by two iterators...
void beginBlock(const std::string &keyword="")
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
MyDigitalSurface::ConstIterator ConstIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: The concept CDrawableWithBoard2D specifies what are the classes that admit an export with Board2...
Aim: Defines the concept describing a forward segment computer. Like any model of CIncrementalSegment...
ArithmeticalDSSComputer< std::vector< Z2i::Point >::const_iterator, int, 4 > SegmentComputer
SaturatedSegmentation< SegmentComputer > Segmentation
K init(Point(0, 0, 0), Point(512, 512, 512), true)
int main(int argc, char **argv)
bool testSegmentationLarger(const string &filename, int min, int max, double delta)
void testFrechetShortcutConceptChecking()
bool testFrechetShortcut()