DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testArithDSS3d.cpp
Go to the documentation of this file.
1
16
28
33
34
35
36
37
#include <iostream>
38
#include <iterator>
39
#include <cstdio>
40
#include <cmath>
41
#include <fstream>
42
#include <vector>
43
44
#include "DGtal/base/Common.h"
45
#include "DGtal/base/Exceptions.h"
46
#include "DGtal/kernel/SpaceND.h"
47
#include "DGtal/kernel/domains/HyperRectDomain.h"
48
#include "DGtal/geometry/curves/StandardDSS6Computer.h"
49
#include "DGtal/geometry/curves/GreedySegmentation.h"
50
51
using namespace
DGtal
;
52
using namespace
std
;
53
54
56
// Functions for testing class StandardDSS6Computer.
58
62
bool
testDSSreco
()
63
{
64
65
typedef
PointVector<3,int>
Point
;
66
typedef
std::vector<Point>::iterator
Iterator
;
67
typedef
StandardDSS6Computer<Iterator,int,4>
SegmentComputer
;
68
69
std::vector<Point> sequence;
70
sequence.push_back(
Point
(0,0,0));
71
sequence.push_back(
Point
(1,0,0));
72
sequence.push_back(
Point
(2,0,0));
73
sequence.push_back(
Point
(2,1,0));
74
sequence.push_back(
Point
(2,1,1));
75
sequence.push_back(
Point
(3,1,1));
76
sequence.push_back(
Point
(4,1,1));
77
sequence.push_back(
Point
(4,2,1));
78
sequence.push_back(
Point
(4,2,2));
79
sequence.push_back(
Point
(5,2,2));
80
sequence.push_back(
Point
(6,2,2));
81
sequence.push_back(
Point
(6,3,2));
82
sequence.push_back(
Point
(6,3,3));
83
sequence.push_back(
Point
(6,4,3));
84
sequence.push_back(
Point
(6,4,4));
85
sequence.push_back(
Point
(6,5,4));
86
87
// Adding step
88
trace
.
beginBlock
(
"Add points while it is possible and display the result"
);
89
90
SegmentComputer
algo;
91
Iterator
i = sequence.begin();
92
algo.
init
(i);
93
trace
.
info
() <<
"init with "
<< (*i) << std::endl;
94
95
while
( (algo.
end
() != sequence.end())
96
&& algo.
extendFront
()) {
97
trace
.
info
() <<
"extended with "
<< (*(--algo.
end
())) << std::endl;
98
}
99
100
101
trace
.
info
() << algo <<
" "
<< algo.
isValid
() << std::endl;
102
103
trace
.
endBlock
();
104
105
return
( algo.
isValid
() && (algo.
end
() == (sequence.begin()+13)) );
106
}
107
108
114
bool
testSegmentation
()
115
{
116
117
typedef
PointVector<3,int>
Point
;
118
typedef
std::vector<Point>::iterator
Iterator
;
119
typedef
StandardDSS6Computer<Iterator,int,4>
SegmentComputer
;
120
typedef
GreedySegmentation<SegmentComputer>
Decomposition;
121
122
std::vector<Point> sequence;
123
sequence.push_back(
Point
(0,0,0));
124
sequence.push_back(
Point
(1,0,0));
125
sequence.push_back(
Point
(2,0,0));
126
sequence.push_back(
Point
(2,1,0));
127
sequence.push_back(
Point
(2,1,1));
128
sequence.push_back(
Point
(3,1,1));
129
sequence.push_back(
Point
(4,1,1));
130
sequence.push_back(
Point
(4,2,1));
131
sequence.push_back(
Point
(4,2,2));
132
sequence.push_back(
Point
(5,2,2));
133
sequence.push_back(
Point
(6,2,2));
134
sequence.push_back(
Point
(6,3,2));
135
sequence.push_back(
Point
(6,3,3));
136
sequence.push_back(
Point
(6,4,3));
137
sequence.push_back(
Point
(6,4,4));
138
sequence.push_back(
Point
(6,5,4));
139
140
//Segmentation
141
trace
.
beginBlock
(
"Segmentation test"
);
142
143
SegmentComputer
algo;
144
Decomposition theDecomposition(sequence.begin(), sequence.end(), algo);
145
146
unsigned
int
c = 0;
147
Decomposition::SegmentComputerIterator i = theDecomposition.begin();
148
for
( ; i != theDecomposition.end(); ++i) {
149
SegmentComputer
currentSegmentComputer(*i);
150
trace
.
info
() << currentSegmentComputer << std::endl;
//standard output
151
c++;
152
}
153
154
trace
.
endBlock
();
155
return
(c==2);
156
}
157
158
159
void
testStandardDSS6ComputerConceptChecking
()
160
{
161
typedef
PointVector<3,int>
Point
;
162
typedef
std::vector<Point>::const_iterator
ConstIterator
;
163
typedef
StandardDSS6Computer<ConstIterator,int,4>
ArithDSS3d;
164
165
trace
.
beginBlock
(
"Concept checking"
);
166
167
BOOST_CONCEPT_ASSERT((
concepts::CForwardSegmentComputer<ArithDSS3d>
));
168
169
trace
.
endBlock
();
170
171
}
172
173
174
175
int
main
(
int
argc,
char
**argv)
176
{
177
trace
.
beginBlock
(
"Testing class ArithmeticalDSSComputer"
);
178
179
testStandardDSS6ComputerConceptChecking
();
180
181
trace
.
info
() <<
"Args:"
;
182
for
(
int
i = 0; i < argc; ++i )
183
trace
.
info
() <<
" "
<< argv[ i ];
184
trace
.
info
() << endl;
185
186
bool
res =
testDSSreco
()
187
&&
testSegmentation
()
188
189
;
190
trace
.
emphase
() << ( res ?
"Passed."
:
"Error."
) << endl;
191
trace
.
endBlock
();
192
193
return
res ? 0 : 1;
194
195
}
DGtal::ArithmeticalDSSComputer::end
ConstIterator end() const
DGtal::ArithmeticalDSSComputer::extendFront
bool extendFront()
DGtal::ArithmeticalDSSComputer::isValid
bool isValid() const
DGtal::ArithmeticalDSSComputer::init
void init(const ConstIterator &it)
DGtal::GreedySegmentation
Aim: Computes the greedy segmentation of a range given by a pair of ConstIterators....
Definition
GreedySegmentation.h:150
DGtal::Iterator
DGtal::PointVector
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition
PointVector.h:593
DGtal::Point
DGtal::StandardDSS6Computer
Aim: Dynamic recognition of a 3d-digital straight segment (DSS).
Definition
StandardDSS6Computer.h:77
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Trace::emphase
std::ostream & emphase()
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.
DGtal::concepts::CForwardSegmentComputer
Aim: Defines the concept describing a forward segment computer. Like any model of CIncrementalSegment...
Definition
CForwardSegmentComputer.h:102
testStandardDSS6ComputerConceptChecking
void testStandardDSS6ComputerConceptChecking()
Definition
testArithDSS3d.cpp:159
testDSSreco
bool testDSSreco()
Definition
testArithDSS3d.cpp:62
testSegmentation
bool testSegmentation()
Definition
testArithDSS3d.cpp:114
SegmentComputer
ArithmeticalDSSComputer< std::vector< Z2i::Point >::const_iterator, int, 4 > SegmentComputer
Definition
testArithmeticalDSSComputerOnSurfels.cpp:55
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
tests
geometry
curves
testArithDSS3d.cpp
Generated on
for DGtal by
1.18.0