DGtal
1.5.beta
kernelDomain.cpp
Go to the documentation of this file.
1
41
#include <iostream>
42
#include "DGtal/base/Common.h"
43
#include "DGtal/kernel/SpaceND.h"
44
#include "DGtal/helpers/StdDefs.h"
45
#include "DGtal/kernel/domains/HyperRectDomain.h"
46
#include "DGtal/io/boards/Board2D.h"
47
49
50
using namespace
std;
51
using namespace
DGtal
;
52
54
55
int
main
()
56
{
57
trace
.
beginBlock
(
"Example kernelDomain"
);
58
59
typedef
DGtal::Z2i::Space
MySpace;
60
61
//Point lying in the Z2i::Space
62
typedef
MySpace::Point
MyPoint;
63
64
MyPoint p(13,-5);
65
66
trace
.
info
() <<
"Point p="
<<p<<endl;
67
68
//We create a domain
69
typedef
HyperRectDomain<MySpace>
MyDomain;
70
MyPoint a(-3,-4);
71
MyPoint b(10,4);
72
MyDomain
domain
(a,b);
73
74
//We trace domain information
75
trace
.
info
() <<
"Domain domain="
<<
domain
<<endl;
76
77
//We generate a board
78
Board2D
board;
79
board <<
domain
;
80
board.
saveSVG
(
"kernel-domain.svg"
);
81
82
MyPoint c(5,1);
83
84
if
(
domain
.
isInside
(c) )
85
trace
.
info
() <<
"C is inside the domain"
<<endl;
86
else
87
trace
.
info
() <<
"C is outside the domain"
<<endl;
88
89
board << c;
90
board.
saveSVG
(
"kernel-domain-point.svg"
);
91
92
93
//PointVector example
94
MyPoint q;
95
MyPoint::Coordinate coord = 24;
96
for
(MySpace::Dimension d = 0 ; d < MySpace::dimension; d++)
97
q[d] = coord;
98
trace
.
info
()<<
"Q="
<<q<<endl;
99
100
MyPoint r;
101
for
(MyPoint::Iterator it=r.begin(), itend=r.end() ;
102
it != itend;
103
++it)
104
(*it) = coord;
105
trace
.
info
()<<
"R="
<<r<<endl;
106
107
108
//We scan the domain
109
for
(
MyDomain::ConstIterator
it =
domain
.
begin
(), itend =
domain
.
end
();
110
it != itend;
111
++it)
112
trace
.
info
() <<
"Processing point"
<< (*it) << endl;
113
114
115
board.
clear
();
116
board <<
domain
;
117
//We draw an arrow between two consecutive points during the iteration.
118
MyDomain::ConstIterator
itPrec =
domain
.
begin
();
119
MyDomain::ConstIterator
it = itPrec;
120
MyDomain::Vector
shift;
121
++it;
122
123
board << (*itPrec);
//We display the first point as a pixel.
124
for
(
MyDomain::ConstIterator
itend =
domain
.
end
();
125
it != itend;
126
++it, ++itPrec)
127
{
128
shift = (*it) -(*itPrec);
129
Display2DFactory::draw
(board, shift, (*itPrec));
130
}
131
board.
saveSVG
(
"kernel-domain-it-arrow.svg"
);
132
133
trace
.
endBlock
();
134
return
0;
135
}
136
// //
DGtal::Board2D
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition:
Board2D.h:71
DGtal::HyperRectDomain
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Definition:
HyperRectDomain.h:100
DGtal::HyperRectDomain::isInside
bool isInside(const Point &p) const
DGtal::HyperRectDomain::end
const ConstIterator & end() const
Definition:
HyperRectDomain.h:201
DGtal::HyperRectDomain::begin
const ConstIterator & begin() const
Definition:
HyperRectDomain.h:176
DGtal::SpaceND< 2, Integer >
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Trace::info
std::ostream & info()
DGtal::Trace::endBlock
double endBlock()
LibBoard::Board::clear
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition:
Board.cpp:151
LibBoard::Board::saveSVG
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition:
Board.cpp:1011
Vector
DigitalPlane::Point Vector
Definition:
examplePlaneProbingParallelepipedEstimator.cpp:45
ConstIterator
MyDigitalSurface::ConstIterator ConstIterator
Definition:
greedy-plane-segmentation-ex2.cpp:93
main
int main()
Definition:
kernelDomain.cpp:55
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::trace
Trace trace
Definition:
Common.h:153
Point
MyPointD Point
Definition:
testClone2.cpp:383
domain
Domain domain
Definition:
testProjection.cpp:88
draw
void draw(const Iterator &itb, const Iterator &ite, Board &aBoard)
Definition:
testSegmentation.cpp:75
examples
doc-examples
kernelDomain.cpp
Generated on Sun Dec 22 2024 16:59:18 for DGtal by
1.9.1