DGtal  1.3.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 }
DGtal::Trace::endBlock
double endBlock()
DGtal::ConstRangeAdapter
Aim: model of CConstBidirectionalRange that adapts any range of elements bounded by two iterators [it...
Definition: ConstRangeAdapter.h:86
DGtal::GridCurve::initFromVectorStream
bool initFromVectorStream(std::istream &in)
DGtal::Preimage2D
Aim: Computes the preimage of the 2D Euclidean shapes crossing a sequence of n straigth segments in O...
Definition: Preimage2D.h:93
DGtal::trace
Trace trace
Definition: Common.h:154
DGtal::GridCurve
Aim: describes, in a cellular space of dimension n, a closed or open sequence of signed d-cells (or d...
Definition: GridCurve.h:172
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::ReverseIterator
This class adapts any bidirectional iterator so that operator++ calls operator-- and vice versa.
Definition: ReverseIterator.h:68
KSpace
Z3i::KSpace KSpace
Definition: testArithmeticalDSSComputerOnSurfels.cpp:48
DGtal::Trace::info
std::ostream & info()
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::StraightLineFrom2Points
Aim: Represents a straight line uniquely defined by two 2D points and that is able to return for any ...
Definition: StraightLineFrom2Points.h:68
DGtal::Preimage2D::addBack
bool addBack(const Point &aP, const Point &aQ)
main
int main()
Definition: testPreimage.cpp:64
DGtal::KhalimskySpaceND
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
Definition: KhalimskySpaceND.h:64