DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
examplePreimage.cpp
Go to the documentation of this file.
1
16
29
30
31
37
39
#include <iostream>
40
41
#include "DGtal/base/Common.h"
42
#include "DGtal/helpers/StdDefs.h"
43
#include "ConfigExamples.h"
44
45
#include "DGtal/geometry/tools/Preimage2D.h"
46
#include "DGtal/shapes/fromPoints/StraightLineFrom2Points.h"
47
#include "DGtal/shapes/fromPoints/CircleFrom2Points.h"
48
49
#include "DGtal/io/boards/Board2D.h"
50
52
53
using namespace
std
;
54
using namespace
DGtal
;
55
using namespace
Z2i
;
56
57
59
int
main
(
int
argc,
char
** argv )
60
{
61
trace
.
beginBlock
(
"Example for Preimage computation"
);
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 = examplesPath +
"samples/DSS.dat"
;
68
ifstream instream;
// input stream
69
instream.open (filename.c_str(), ifstream::in);
70
71
Curve
c;
//grid curve
72
c.
initFromVectorStream
(instream);
73
74
{
75
trace
.
beginBlock
(
"Simple preimage example"
);
76
78
typedef
StraightLineFrom2Points<Curve::Point>
StraightLine;
79
StraightLine aStraightLine;
//instance of straight line
80
typedef
Preimage2D<StraightLine>
Preimage2D
;
82
83
85
Curve::IncidentPointsRange
r = c.
getIncidentPointsRange
();
//range
86
Curve::IncidentPointsRange::ConstIterator
it (r.
begin
());
//iterators
87
Curve::IncidentPointsRange::ConstIterator
itEnd (r.
end
());
88
89
//preimage computation
90
Preimage2D
thePreimage(it->first, it->second, aStraightLine);
91
++it;
92
while
( (it != itEnd) &&
93
(thePreimage.
addFront
(it->first, it->second)) )
94
{
95
++it;
96
}
97
trace
.
info
() << thePreimage << endl;
98
//display
99
Board2D
board;
100
board.
setUnit
(
Board2D::UCentimeter
);
101
board << r << thePreimage;
102
board.
saveEPS
(
"PreimageExample.eps"
);
104
105
trace
.
endBlock
();
106
}
107
108
{
109
trace
.
beginBlock
(
"Preimage example with circles"
);
110
Curve::Point
pole(7,2);
111
113
typedef
CircleFrom2Points<Curve::Point>
Circle;
114
Circle aCircle( pole );
//instance of circle passing through point 'pole'
115
typedef
Preimage2D<Circle>
Preimage2D
;
117
118
Curve::IncidentPointsRange
r = c.
getIncidentPointsRange
();
//range
119
Curve::IncidentPointsRange::ConstIterator
it (r.
begin
());
//iterators
120
Curve::IncidentPointsRange::ConstIterator
itEnd (r.
end
());
121
122
//preimage computation
123
Preimage2D
thePreimage(it->first, it->second, aCircle);
124
++it;
125
while
( (it != itEnd) &&
126
(thePreimage.
addFront
(it->first, it->second)) )
127
{
128
++it;
129
}
130
trace
.
info
() << thePreimage << endl;
131
//display
132
Board2D
board;
133
board.
setUnit
(
Board2D::UCentimeter
);
134
board << r <<
SetMode
(pole.
className
(),
"Grid"
) << pole << thePreimage;
135
board.
saveEPS
(
"PreimageExample2.eps"
);
136
board.
saveSVG
(
"PreimageExample2.svg"
);
137
#ifdef DGTAL_WITH_CAIRO
138
board.
saveCairo
(
"PreimageExample2.pdf"
,
Board2D::CairoPDF
);
139
#endif
140
141
trace
.
endBlock
();
142
}
143
144
return
0;
145
}
146
// //
DGtal::Board2D
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition
Board2D.h:71
DGtal::CircleFrom2Points
Aim: Represents a circle that passes through a given point and that is thus uniquely defined by two o...
Definition
CircleFrom2Points.h:68
DGtal::ConstRangeAdapter::begin
ConstIterator begin() const
Definition
ConstRangeAdapter.h:222
DGtal::ConstRangeAdapter::end
ConstIterator end() const
Definition
ConstRangeAdapter.h:230
DGtal::GridCurve::initFromVectorStream
bool initFromVectorStream(std::istream &in)
DGtal::GridCurve::getIncidentPointsRange
IncidentPointsRange getIncidentPointsRange() const
Definition
GridCurve.h:478
DGtal::GridCurve< K2 >::IncidentPointsRange
ConstRangeAdapter< typename Storage::const_iterator, functors::SCellToIncidentPoints< KSpace >, std::pair< Point, Point > > IncidentPointsRange
Definition
GridCurve.h:473
DGtal::GridCurve< K2 >::Point
KSpace::Point Point
Definition
GridCurve.h:179
DGtal::GridCurve< K2 >::ConstIterator
Storage::const_iterator ConstIterator
Definition
GridCurve.h:306
DGtal::PointVector::className
std::string className() const
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::addFront
bool addFront(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()
LibBoard::Board::UCentimeter
@ UCentimeter
Definition
Board.h:43
LibBoard::Board::saveEPS
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition
Board.cpp:804
LibBoard::Board::saveSVG
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition
Board.cpp:1011
LibBoard::Board::CairoPDF
@ CairoPDF
Definition
Board.h:40
LibBoard::Board::setUnit
void setUnit(Unit unit)
Definition
Board.cpp:239
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.
DGtal::SetMode::SetMode
SetMode(std::string classname, std::string mode)
Definition
Board2D.h:254
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
examples
geometry
tools
examplePreimage.cpp
Generated on
for DGtal by
1.18.0