DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testPreimage.cpp
Go to the documentation of this file.
1
16
28
33
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
71
typedef
KhalimskySpaceND<2,int>
KSpace
;
72
GridCurve<KSpace>
c;
//grid curve
73
c.
initFromVectorStream
(instream);
74
75
76
trace
.
beginBlock
(
"Simple preimage test"
);
77
78
typedef
StraightLineFrom2Points<GridCurve<KSpace>::Point
> StraightLine;
79
StraightLine aStraightLine;
//instance of straight line
80
typedef
Preimage2D<StraightLine>
Preimage2D
;
81
82
GridCurve<KSpace>::IncidentPointsRange
r = c.
getIncidentPointsRange
();
//range
83
GridCurve<KSpace>::IncidentPointsRange::ConstReverseIterator
it (r.
rbegin
());
//iterators
84
GridCurve<KSpace>::IncidentPointsRange::ConstReverseIterator
itEnd (r.
rend
());
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::ConstRangeAdapter::rbegin
ConstReverseIterator rbegin() const
Definition
ConstRangeAdapter.h:238
DGtal::ConstRangeAdapter< typename Storage::const_iterator, functors::SCellToIncidentPoints< KSpace >, std::pair< Point, Point > >::ConstReverseIterator
ReverseIterator< ConstIterator > ConstReverseIterator
Definition
ConstRangeAdapter.h:96
DGtal::ConstRangeAdapter::rend
ConstReverseIterator rend() const
Definition
ConstRangeAdapter.h:246
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:173
DGtal::GridCurve::initFromVectorStream
bool initFromVectorStream(std::istream &in)
DGtal::GridCurve::getIncidentPointsRange
IncidentPointsRange getIncidentPointsRange() const
Definition
GridCurve.h:478
DGtal::GridCurve::IncidentPointsRange
ConstRangeAdapter< typename Storage::const_iterator, functors::SCellToIncidentPoints< KSpace >, std::pair< Point, Point > > IncidentPointsRange
Definition
GridCurve.h:473
DGtal::KhalimskySpaceND
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
Definition
KhalimskySpaceND.h:394
DGtal::Preimage2D
Aim: Computes the preimage of the 2D Euclidean shapes crossing a sequence of n straight segments in O...
Definition
Preimage2D.h:94
DGtal::Preimage2D::addBack
bool addBack(const Point &aP, const Point &aQ)
DGtal::StraightLineFrom2Points
Aim: Represents a straight line uniquely defined by two 2D points and that is able to return for any ...
Definition
StraightLineFrom2Points.h:69
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Trace::info
std::ostream & info()
DGtal::Trace::endBlock
double endBlock()
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::trace
Trace trace
KSpace
Z3i::KSpace KSpace
Definition
testArithmeticalDSSComputerOnSurfels.cpp:48
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
tests
geometry
tools
testPreimage.cpp
Generated on
for DGtal by
1.18.0