DGtal 1.3.0
Loading...
Searching...
No Matches
Functions
testParametricCurveDigitization.cpp File Reference

Tests for the parametric curves and their digitization. More...

#include <iostream>
#include "DGtalCatch.h"
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/geometry/curves/parametric/EllipticHelix.h"
#include "DGtal/geometry/curves/parametric/DecoratorParametricCurveTransformation.h"
#include "DGtal/geometry/curves/parametric/Knot_3_1.h"
#include "DGtal/geometry/curves/parametric/Knot_3_2.h"
#include "DGtal/geometry/curves/parametric/Knot_4_1.h"
#include "DGtal/geometry/curves/parametric/Knot_4_3.h"
#include "DGtal/geometry/curves/parametric/Knot_5_1.h"
#include "DGtal/geometry/curves/parametric/Knot_5_2.h"
#include "DGtal/geometry/curves/parametric/Knot_6_2.h"
#include "DGtal/geometry/curves/parametric/Knot_7_4.h"
#include "DGtal/geometry/curves/parametric/NaiveParametricCurveDigitizer3D.h"
#include "DGtal/images/RigidTransformation3D.h"

Go to the source code of this file.

Functions

 TEST_CASE ("Elliptic Helix test")
 
 TEST_CASE ("Parametric Curve Decorator test")
 
 TEST_CASE ("Knot 3_1 test")
 
 TEST_CASE ("Knot 3_2 test")
 
 TEST_CASE ("Knot 4_1 test")
 
 TEST_CASE ("Knot 4_3 test")
 
 TEST_CASE ("Knot 5_1 test")
 
 TEST_CASE ("Knot 5_2 test")
 
 TEST_CASE ("Knot 6_2 test")
 
 TEST_CASE ("Knot 7_4 test")
 

Detailed Description

Tests for the parametric curves and their digitization.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Kacper Pluta (kacpe.nosp@m.r.pl.nosp@m.uta@e.nosp@m.siee.nosp@m..fr ) Laboratoire d'Informatique Gaspard-Monge - LIGM, A3SI, France
Date
2018/08/14

Functions for testing class Digitization of parametric curves.

This file is part of the DGtal library.

See also
UglyNaiveParametricCurveDigitizer3D.h

Definition in file testParametricCurveDigitization.cpp.

Function Documentation

◆ TEST_CASE() [1/10]

TEST_CASE ( "Elliptic Helix test"  )

Definition at line 60 of file testParametricCurveDigitization.cpp.

61{
62 typedef EllipticHelix < Space > MyHelix;
63 typedef NaiveParametricCurveDigitizer3D < MyHelix > DigitizerHelix;
66
67 MyDigitalCurve digitalCurve;
68 MyMetaData metaData;
69 MyHelix helix( 15, 10, 1 );
70 DigitizerHelix digitize;
71 digitize.init ( M_PI / 2., MyHelix::getPeriod() + M_PI / 2., 0.001 );
72 digitize.attach ( &helix );
73 digitize.digitize( back_insert_iterator < MyDigitalCurve> ( digitalCurve ) );
74
75 SECTION("Data")
76 {
77 REQUIRE( digitalCurve.size ( ) > 0 );
78 }
79
80 digitalCurve.clear ( );
81
82 digitize.digitize( back_insert_iterator < MyDigitalCurve> ( digitalCurve ), back_insert_iterator < MyMetaData > ( metaData ) );
83
84 SECTION("Size Comparisons")
85 {
86 REQUIRE( digitalCurve.size ( ) > 0 );
87 REQUIRE( metaData.size ( ) > 0 );
88 REQUIRE( metaData.size ( ) == digitalCurve.size ( ) );
89 }
90
91 SECTION("Inverses")
92 {
93 helix.f ( digitalCurve[0] );
94 helix.g ( digitalCurve[0] );
95 helix.h ( digitalCurve[0] );
96 }
97
98}
std::vector< std::pair< long double, unsigned int > > MetaData
std::vector< Point > DigitalCurve
Digital curve type.
void digitize(Shape &shape, std::vector< SCell > &sCells0, std::vector< SCell > &sCells1, KSpace &kspace, const double h)
SECTION("Testing constant forward iterators")
REQUIRE(domain.isInside(aPoint))

References digitize(), REQUIRE(), and SECTION().

◆ TEST_CASE() [2/10]

TEST_CASE ( "Knot 3_1 test"  )

Definition at line 142 of file testParametricCurveDigitization.cpp.

143{
144 typedef Knot_3_1 < Space > MyKnot;
145 typedef NaiveParametricCurveDigitizer3D < MyKnot > Digitizer;
148
149 MyDigitalCurve digitalCurve;
150 MyMetaData metaData;
151 MyKnot knot( 10, 10, 10 );
152 Digitizer digitize;
153 digitize.init ( -3., 3, 0.0001 );
154 digitize.attach ( &knot );
155 digitize.digitize( back_insert_iterator < MyDigitalCurve> ( digitalCurve ) );
156
157 SECTION("Data")
158 {
159 REQUIRE( digitalCurve.size ( ) > 0 );
160 }
161
162 digitalCurve.clear ( );
163
164 digitize.digitize( back_insert_iterator < MyDigitalCurve> ( digitalCurve ), back_insert_iterator < MyMetaData > ( metaData ) );
165
166 SECTION("Size Comparisons")
167 {
168 REQUIRE( digitalCurve.size ( ) > 0 );
169 REQUIRE( metaData.size ( ) > 0 );
170 REQUIRE( metaData.size ( ) == digitalCurve.size ( ) );
171 }
172}

References digitize(), REQUIRE(), and SECTION().

◆ TEST_CASE() [3/10]

TEST_CASE ( "Knot 3_2 test"  )

Definition at line 175 of file testParametricCurveDigitization.cpp.

176{
177 typedef Knot_3_2 < Space > MyKnot;
178 typedef NaiveParametricCurveDigitizer3D < MyKnot > Digitizer;
181
182 MyDigitalCurve digitalCurve;
183 MyMetaData metaData;
184 MyKnot knot( 10, 10, 10 );
185 Digitizer digitize;
186 digitize.init ( -3., 3, 0.0001 );
187 digitize.attach ( &knot );
188 digitize.digitize( back_insert_iterator < MyDigitalCurve> ( digitalCurve ) );
189
190 SECTION("Data")
191 {
192 REQUIRE( digitalCurve.size ( ) > 0 );
193 }
194
195 digitalCurve.clear ( );
196
197 digitize.digitize( back_insert_iterator < MyDigitalCurve> ( digitalCurve ), back_insert_iterator < MyMetaData > ( metaData ) );
198
199 SECTION("Size Comparisons")
200 {
201 REQUIRE( digitalCurve.size ( ) > 0 );
202 REQUIRE( metaData.size ( ) > 0 );
203 REQUIRE( metaData.size ( ) == digitalCurve.size ( ) );
204 }
205}

References digitize(), REQUIRE(), and SECTION().

◆ TEST_CASE() [4/10]

TEST_CASE ( "Knot 4_1 test"  )

Definition at line 208 of file testParametricCurveDigitization.cpp.

209{
210 typedef Knot_4_1 < Space > MyKnot;
211 typedef NaiveParametricCurveDigitizer3D < MyKnot > Digitizer;
214
215 MyDigitalCurve digitalCurve;
216 MyMetaData metaData;
217 MyKnot knot( 10, 10, 10 );
218 Digitizer digitize;
219 digitize.init ( -3., 3, 0.0001 );
220 digitize.attach ( &knot );
221 digitize.digitize( back_insert_iterator < MyDigitalCurve> ( digitalCurve ) );
222
223 SECTION("Data")
224 {
225 REQUIRE( digitalCurve.size ( ) > 0 );
226 }
227
228 digitalCurve.clear ( );
229
230 digitize.digitize( back_insert_iterator < MyDigitalCurve> ( digitalCurve ), back_insert_iterator < MyMetaData > ( metaData ) );
231
232 SECTION("Size Comparisons")
233 {
234 REQUIRE( digitalCurve.size ( ) > 0 );
235 REQUIRE( metaData.size ( ) > 0 );
236 REQUIRE( metaData.size ( ) == digitalCurve.size ( ) );
237 }
238}

References digitize(), REQUIRE(), and SECTION().

◆ TEST_CASE() [5/10]

TEST_CASE ( "Knot 4_3 test"  )

Definition at line 241 of file testParametricCurveDigitization.cpp.

242{
243 typedef Knot_4_3 < Space > MyKnot;
244 typedef NaiveParametricCurveDigitizer3D < MyKnot > Digitizer;
247
248 MyDigitalCurve digitalCurve;
249 MyMetaData metaData;
250 MyKnot knot( 10, 10, 10 );
251 Digitizer digitize;
252 digitize.init ( -3., 3, 0.0001 );
253 digitize.attach ( &knot );
254 digitize.digitize( back_insert_iterator < MyDigitalCurve> ( digitalCurve ) );
255
256 SECTION("Data")
257 {
258 REQUIRE( digitalCurve.size ( ) > 0 );
259 }
260
261 digitalCurve.clear ( );
262
263 digitize.digitize( back_insert_iterator < MyDigitalCurve> ( digitalCurve ), back_insert_iterator < MyMetaData > ( metaData ) );
264
265 SECTION("Size Comparisons")
266 {
267 REQUIRE( digitalCurve.size ( ) > 0 );
268 REQUIRE( metaData.size ( ) > 0 );
269 REQUIRE( metaData.size ( ) == digitalCurve.size ( ) );
270 }
271}

References digitize(), REQUIRE(), and SECTION().

◆ TEST_CASE() [6/10]

TEST_CASE ( "Knot 5_1 test"  )

Definition at line 274 of file testParametricCurveDigitization.cpp.

275{
276 typedef Knot_5_1 < Space > MyKnot;
277 typedef NaiveParametricCurveDigitizer3D < MyKnot > Digitizer;
280
281 MyDigitalCurve digitalCurve;
282 MyMetaData metaData;
283 MyKnot knot( 10, 10, 10 );
284 Digitizer digitize;
285 digitize.init ( -3., 3, 0.0001 );
286 digitize.attach ( &knot );
287 digitize.digitize( back_insert_iterator < MyDigitalCurve> ( digitalCurve ) );
288
289 SECTION("Data")
290 {
291 REQUIRE( digitalCurve.size ( ) > 0 );
292 }
293
294 digitalCurve.clear ( );
295
296 digitize.digitize( back_insert_iterator < MyDigitalCurve> ( digitalCurve ), back_insert_iterator < MyMetaData > ( metaData ) );
297
298 SECTION("Size Comparisons")
299 {
300 REQUIRE( digitalCurve.size ( ) > 0 );
301 REQUIRE( metaData.size ( ) > 0 );
302 REQUIRE( metaData.size ( ) == digitalCurve.size ( ) );
303 }
304}

References digitize(), REQUIRE(), and SECTION().

◆ TEST_CASE() [7/10]

TEST_CASE ( "Knot 5_2 test"  )

Definition at line 307 of file testParametricCurveDigitization.cpp.

308{
309 typedef Knot_5_2 < Space > MyKnot;
310 typedef NaiveParametricCurveDigitizer3D < MyKnot > Digitizer;
313
314 MyDigitalCurve digitalCurve;
315 MyMetaData metaData;
316 MyKnot knot( 10, 10, 10 );
317 Digitizer digitize;
318 digitize.init ( -3., 3, 0.0001 );
319 digitize.attach ( &knot );
320 digitize.digitize( back_insert_iterator < MyDigitalCurve> ( digitalCurve ) );
321
322 SECTION("Data")
323 {
324 REQUIRE( digitalCurve.size ( ) > 0 );
325 }
326
327 digitalCurve.clear ( );
328
329 digitize.digitize( back_insert_iterator < MyDigitalCurve> ( digitalCurve ), back_insert_iterator < MyMetaData > ( metaData ) );
330
331 SECTION("Size Comparisons")
332 {
333 REQUIRE( digitalCurve.size ( ) > 0 );
334 REQUIRE( metaData.size ( ) > 0 );
335 REQUIRE( metaData.size ( ) == digitalCurve.size ( ) );
336 }
337}

References digitize(), REQUIRE(), and SECTION().

◆ TEST_CASE() [8/10]

TEST_CASE ( "Knot 6_2 test"  )

Definition at line 340 of file testParametricCurveDigitization.cpp.

341{
342 typedef Knot_6_2 < Space > MyKnot;
343 typedef NaiveParametricCurveDigitizer3D < MyKnot > Digitizer;
346
347 MyDigitalCurve digitalCurve;
348 MyMetaData metaData;
349 MyKnot knot( 10, 10, 10 );
350 Digitizer digitize;
351 digitize.init ( -3., 3, 0.0001 );
352 digitize.attach ( &knot );
353 digitize.digitize( back_insert_iterator < MyDigitalCurve> ( digitalCurve ) );
354
355 SECTION("Data")
356 {
357 REQUIRE( digitalCurve.size ( ) > 0 );
358 }
359
360 digitalCurve.clear ( );
361
362 digitize.digitize( back_insert_iterator < MyDigitalCurve> ( digitalCurve ), back_insert_iterator < MyMetaData > ( metaData ) );
363
364 SECTION("Size Comparisons")
365 {
366 REQUIRE( digitalCurve.size ( ) > 0 );
367 REQUIRE( metaData.size ( ) > 0 );
368 REQUIRE( metaData.size ( ) == digitalCurve.size ( ) );
369 }
370}

References digitize(), REQUIRE(), and SECTION().

◆ TEST_CASE() [9/10]

TEST_CASE ( "Knot 7_4 test"  )

Definition at line 373 of file testParametricCurveDigitization.cpp.

374{
375 typedef Knot_7_4 < Space > MyKnot;
376 typedef NaiveParametricCurveDigitizer3D < MyKnot > Digitizer;
379
380 MyDigitalCurve digitalCurve;
381 MyMetaData metaData;
382 MyKnot knot( 10, 10, 10 );
383 Digitizer digitize;
384 digitize.init ( -3., 3, 0.0001 );
385 digitize.attach ( &knot );
386 digitize.digitize( back_insert_iterator < MyDigitalCurve> ( digitalCurve ) );
387
388 SECTION("Data")
389 {
390 REQUIRE( digitalCurve.size ( ) > 0 );
391 }
392
393 digitalCurve.clear ( );
394
395 digitize.digitize( back_insert_iterator < MyDigitalCurve> ( digitalCurve ), back_insert_iterator < MyMetaData > ( metaData ) );
396
397 SECTION("Size Comparisons")
398 {
399 REQUIRE( digitalCurve.size ( ) > 0 );
400 REQUIRE( metaData.size ( ) > 0 );
401 REQUIRE( metaData.size ( ) == digitalCurve.size ( ) );
402 }
403}

References digitize(), REQUIRE(), and SECTION().

◆ TEST_CASE() [10/10]

TEST_CASE ( "Parametric Curve Decorator test"  )

Definition at line 101 of file testParametricCurveDigitization.cpp.

102{
103 typedef EllipticHelix < Space > MyHelix;
104 typedef ForwardRigidTransformation3D < Space, RealPoint, RealPoint, Identity > ForwardTrans;
105 typedef DecoratorParametricCurveTransformation < MyHelix, ForwardTrans > MyRotatedCurve;
106 typedef NaiveParametricCurveDigitizer3D < MyRotatedCurve > Digitizer;
109
110 MyDigitalCurve digitalCurve;
111 MyMetaData metaData;
112 MyHelix helix( 30, 20, 1 );
113
114 double angle = M_PI/3.;
115 RealVector axis ( 1., 0., 1. );
116 ForwardTrans trans ( RealPoint ( 0, 0, 0 ), axis, angle, RealVector ( 0,0,0 ) );
117 MyRotatedCurve rotCurve ( helix, trans );
118
119 Digitizer digitize;
120 digitize.attach ( &rotCurve );
121 digitize.init ( 0, MyHelix::getPeriod(), 0.001 );
122 digitize.digitize( back_insert_iterator < MyDigitalCurve> ( digitalCurve ) );
123
124 SECTION("Data")
125 {
126 REQUIRE( digitalCurve.size ( ) > 0 );
127 }
128
129 digitalCurve.clear ( );
130
131 digitize.digitize( back_insert_iterator < MyDigitalCurve> ( digitalCurve ), back_insert_iterator < MyMetaData > ( metaData ) );
132
133 SECTION("Size Comparisons")
134 {
135 REQUIRE( digitalCurve.size ( ) > 0 );
136 REQUIRE( metaData.size ( ) > 0 );
137 REQUIRE( metaData.size ( ) == digitalCurve.size ( ) );
138 }
139}
Aim: Implements basic operations that will be used in Point and Vector classes.
Definition: PointVector.h:593

References digitize(), REQUIRE(), and SECTION().