DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testImageSpanIterators.cpp
Go to the documentation of this file.
1
16
27
32
33
#include <cstdio>
34
#include <cmath>
35
#include <iostream>
36
37
#include "DGtal/base/Common.h"
38
#include "DGtal/kernel/SpaceND.h"
39
#include "DGtal/kernel/domains/HyperRectDomain.h"
40
#include "DGtal/images/ImageContainerBySTLVector.h"
41
42
using namespace
DGtal
;
43
using namespace
std
;
44
45
46
bool
testSpanIterators
()
47
{
48
typedef
SpaceND<3>
Space3Type;
49
typedef
Space3Type::Point
Point
;
50
typedef
HyperRectDomain<Space3Type>
TDomain;
51
typedef
ImageContainerBySTLVector<TDomain, double>
TContainerV;
52
53
const
Point::Component t[ ] = { 0, 0, 0};
54
const
Point::Component t2[ ] = { 5, 5, 5};
55
const
Point::Component t3[ ] = { 0, 0, 0};
56
Point
a ( t );
57
Point
b ( t2 );
58
Point
c( t3 );
59
60
trace
.
beginBlock
(
"Test of Concepts"
);
61
TContainerV myImageV ( TDomain(a,b ));
62
63
double
cpt=0;
64
//Image Construction
65
for
( TContainerV::Iterator it = myImageV.begin();
66
it != myImageV.end();
67
++it)
68
{
69
(*it) = cpt ;
70
cpt++;
71
}
72
73
74
//We process a 1D slice
75
trace
.
info
()<<
"Slice dim 0 "
;
76
for
( TContainerV::SpanIterator it = myImageV.spanBegin(c,0), itend = myImageV.spanEnd(c,0);
77
it != itend;
78
++it)
79
trace
.
info
() << (*it)<<
" "
;
80
trace
.
info
() << endl;
81
82
//We process a 1D slice
83
trace
.
info
()<<
"Slice dim 1 "
;
84
for
( TContainerV::SpanIterator it = myImageV.spanBegin(c,1), itend = myImageV.spanEnd(c,1);
85
it != itend;
86
++it)
87
trace
.
info
() << (*it)<<
" "
;
88
trace
.
info
() << endl;
89
90
//We process a 1D slice
91
trace
.
info
()<<
"Slice dim 2 "
;
92
for
( TContainerV::SpanIterator it = myImageV.spanBegin(c,2), itend = myImageV.spanEnd(c,2);
93
it != itend;
94
++it)
95
trace
.
info
() << (*it)<<
" "
;
96
trace
.
info
() << endl;
97
98
99
//We process a 1D slice to set a value
100
trace
.
info
()<<
"SetValue Slice dim 1 "
<<endl;
101
for
( TContainerV::SpanIterator it = myImageV.spanBegin(c,1), itend = myImageV.spanEnd(c,1);
102
it != itend;
103
++it)
104
myImageV.setValue(it, 12);
105
106
//We check the a 1D slice
107
trace
.
info
()<<
"Check Slice dim 1 "
;
108
for
( TContainerV::SpanIterator it = myImageV.spanBegin(c,1), itend = myImageV.spanEnd(c,1);
109
it != itend;
110
++it)
111
trace
.
info
() << (*it)<<
" "
;
112
trace
.
info
() << endl;
113
114
115
116
trace
.
endBlock
();
117
118
return
true
;
119
120
}
121
122
123
124
int
main
()
125
{
126
127
if
(
testSpanIterators
())
128
return
0;
129
else
130
return
1;
131
}
132
DGtal::HyperRectDomain
Aim: Parallelepidec region of a digital space, model of a 'CDomain'.
Definition
HyperRectDomain.h:100
DGtal::ImageContainerBySTLVector
Definition
ImageContainerBySTLVector.h:127
DGtal::SpaceND
Definition
SpaceND.h:96
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
std
STL namespace.
testSpanIterators
bool testSpanIterators()
Definition
testImageSpanIterators.cpp:46
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
tests
images
testImageSpanIterators.cpp
Generated on
for DGtal by
1.18.0