DGtal  1.5.beta
testPreimage.cpp
Go to the documentation of this file.
1 
34 #include <cstdio>
35 #include <cmath>
36 #include <fstream>
37 #include <vector>
38 #include <iostream>
39 #include <sstream>
40 #include <iterator>
41 
42 
43 
44 
45 #include "DGtal/base/Common.h"
46 #include "DGtal/base/Exceptions.h"
47 #include "DGtal/kernel/SpaceND.h"
48 #include "DGtal/kernel/domains/DomainPredicate.h"
49 #include "DGtal/kernel/domains/HyperRectDomain.h"
50 #include "DGtal/topology/KhalimskySpaceND.h"
51 #include "DGtal/geometry/curves/GridCurve.h"
52 #include "DGtal/io/boards/Board2D.h"
53 
54 #include "DGtal/shapes/fromPoints/StraightLineFrom2Points.h"
55 #include "DGtal/geometry/tools/Preimage2D.h"
56 
57 
58 #include "ConfigTest.h"
59 
60 
61 using namespace DGtal;
62 
63 
64 int main()
65 {
66 
67  std::string filename = testPath + "samples/DSS.dat";
68  std::ifstream instream; // input stream
69  instream.open (filename.c_str(), std::ifstream::in);
70 
72  GridCurve<KSpace> c; //grid curve
73  c.initFromVectorStream(instream);
74 
75 
76  trace.beginBlock("Simple preimage test");
77 
79  StraightLine aStraightLine; //instance of straight line
81 
82  GridCurve<KSpace>::IncidentPointsRange r = c.getIncidentPointsRange(); //range
85 
86  //preimage computation
87  Preimage2D thePreimage(it->first, it->second, aStraightLine);
88  ++it;
89  while ( (it != itEnd) &&
90  (thePreimage.addBack(it->first, it->second)) )
91  {
92  trace.info() << (it - r.rbegin()) << std::endl << thePreimage << std::endl;
93  ++it;
94  }
95 
96  trace.endBlock();
97 
98  return 0;
99 }
Aim: model of CConstBidirectionalRange that adapts any range of elements bounded by two iterators [it...
Aim: describes, in a cellular space of dimension n, a closed or open sequence of signed d-cells (or d...
Definition: GridCurve.h:173
bool initFromVectorStream(std::istream &in)
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
Aim: Computes the preimage of the 2D Euclidean shapes crossing a sequence of n straigth segments in O...
Definition: Preimage2D.h:94
bool addBack(const Point &aP, const Point &aQ)
This class adapts any bidirectional iterator so that operator++ calls operator-- and vice versa.
Aim: Represents a straight line uniquely defined by two 2D points and that is able to return for any ...
void beginBlock(const std::string &keyword="")
std::ostream & info()
double endBlock()
DGtal is the top-level namespace which contains all DGtal functions and types.
Trace trace
Definition: Common.h:153
int main()