DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
kernelDomain.cpp
Go to the documentation of this file.
1
16
29
30
31
38
39
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::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
MyPoint
Definition
testClone2.cpp:314
DGtal::Z2i::Space
SpaceND< 2, Integer > Space
Definition
StdDefs.h:75
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::Display2DFactory::draw
static void draw(DGtal::Board2D &board, const DGtal::DiscreteExteriorCalculus< dimEmbedded, dimAmbient, TLinearAlgebraBackend, TInteger > &calculus)
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
domain
Domain domain
Definition
testProjection.cpp:88
examples
doc-examples
kernelDomain.cpp
Generated on
for DGtal by
1.18.0