File: itkContourExtractor2DImageFilterTest.cxx

package info (click to toggle)
insighttoolkit 3.18.0-5
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 110,432 kB
  • ctags: 74,559
  • sloc: cpp: 412,627; ansic: 196,210; fortran: 28,000; python: 3,852; tcl: 2,005; sh: 1,186; java: 583; makefile: 458; csh: 220; perl: 193; xml: 20
file content (583 lines) | stat: -rw-r--r-- 29,306 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    $RCSfile: itkContourExtractor2DImageFilterTest.cxx,v $
  Language:  C++
  Date:      $Date: 2009-03-14 16:10:14 $
  Version:   $Revision: 1.11 $

  Copyright (c) Insight Software Consortium. All rights reserved.
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/

#include "itkImageFileReader.h"
#include "itkContourExtractor2DImageFilter.h"

namespace itkContourExtractor2DImageFilterTestNamespace
{
const unsigned int Dimension = 2;
typedef unsigned char                                   PixelType;
typedef itk::Image<PixelType, Dimension>                ImageType;
typedef itk::ImageFileReader<ImageType>                 ReaderType;
typedef itk::ContourExtractor2DImageFilter<ImageType>   ExtractorType;
typedef ExtractorType::VertexType                       VertexType;
typedef std::pair<double, double>                       MyVertexType;
typedef std::vector<MyVertexType>                       MyVertexListType;
typedef std::vector<MyVertexListType>                   MyVertexListList;
const float FLOAT_EPSILON = 0.0001;
}

/* ----------------------------------------------------------------------- */
itkContourExtractor2DImageFilterTestNamespace::MyVertexType _bottom_right[] = 
   {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11.5, 8),
    itkContourExtractor2DImageFilterTestNamespace::MyVertexType(12, 7.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType
                                bottom_right(_bottom_right, _bottom_right + 2);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType
    _rev_bottom_right[] = 
   {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(12, 7.5), 
    itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11.5, 8)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
                    rev_bottom_right(_rev_bottom_right, _rev_bottom_right + 2);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType _bottom_left[] = 
  {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(0, 7.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(0.5, 8)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType
                    bottom_left(_bottom_left, _bottom_left + 2);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType 
   _rev_bottom_left[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(0.5, 8),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(0, 7.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
                   rev_bottom_left(_rev_bottom_left, _rev_bottom_left + 2);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType _row2_col4[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11, 6.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10, 6.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(9.5, 6), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10, 5.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10.5, 5),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11, 4.5),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11.5, 5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11.5, 6), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11, 6.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
                            row2_col4(_row2_col4, _row2_col4 + 9);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType _rev_row2_col4[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11, 6.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11.5, 6),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11.5, 5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11, 4.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10.5, 5),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10, 5.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(9.5, 6), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10, 6.5),
 itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11, 6.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
                   rev_row2_col4(_rev_row2_col4, _rev_row2_col4 + 9);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType _row2_col3[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(8, 6.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(7, 6.5),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(6.5, 6), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(6.5, 5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(7, 4.5),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(7.5, 5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(8, 5.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(8.5, 6),
 itkContourExtractor2DImageFilterTestNamespace::MyVertexType(8, 6.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
                            row2_col3(_row2_col3, _row2_col3 + 9);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType _rev_row2_col3[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(8, 6.5),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(8.5, 6),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(8, 5.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(7.5, 5),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(7, 4.5),  
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(6.5, 5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(6.5, 6),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(7, 6.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(8, 6.5),};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
               rev_row2_col3(_rev_row2_col3, _rev_row2_col3 + 9);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType _row2_col2[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(5, 6.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(4.5, 6), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(4, 5.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(3.5, 5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(4, 4.5),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(5, 4.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(5.5, 5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(5.5, 6),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(5, 6.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
              row2_col2(_row2_col2, _row2_col2 + 9);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType _rev_row2_col2[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(5, 6.5),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(5.5, 6),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(5.5, 5),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(5, 4.5),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(4, 4.5),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(3.5, 5),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(4, 5.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(4.5, 6),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(5, 6.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
              rev_row2_col2(_rev_row2_col2, _rev_row2_col2 + 9);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType _row2_col1[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(1, 6.5),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(0.5, 6),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(0.5, 5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(1, 4.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(2, 4.5),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(2.5, 5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(2, 5.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(1.5, 6),
 itkContourExtractor2DImageFilterTestNamespace::MyVertexType(1, 6.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
             row2_col1(_row2_col1, _row2_col1 + 9);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType _rev_row2_col1[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(1, 6.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(1.5, 6),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(2, 5.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(2.5, 5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(2, 4.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(1, 4.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(0.5, 5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(0.5, 6),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(1, 6.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
             rev_row2_col1(_rev_row2_col1, _rev_row2_col1 + 9);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType 
     _row1_col4_middle[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10, 3.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(9.5, 3), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10, 2.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10.5, 3),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10, 3.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
                   row1_col4_middle(_row1_col4_middle, _row1_col4_middle + 5);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType 
   _rev_row1_col4_middle[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10, 3.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10.5, 3),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10, 2.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(9.5, 3),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10, 3.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
    rev_row1_col4_middle(_rev_row1_col4_middle, _rev_row1_col4_middle + 5);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType _row1_col2[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(5, 3.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(4, 3.5),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(3.5, 3), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(4, 2.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(5, 2.5),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(5.5, 3), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(5, 3.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
              row1_col2(_row1_col2, _row1_col2 + 7);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType _rev_row1_col2[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(5, 3.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(5.5, 3),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(5, 2.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(4, 2.5),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(3.5, 3),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(4, 3.5),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(5, 3.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
             rev_row1_col2(_rev_row1_col2, _rev_row1_col2 + 7);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType _row1_col1[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(2, 3.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(1.5, 3),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(2, 2.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(2.5, 3), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(2, 3.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
                     row1_col1(_row1_col1, _row1_col1 + 5);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType _rev_row1_col1[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(2, 3.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(2.5, 3),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(2, 2.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(1.5, 3), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(2, 3.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
            rev_row1_col1(_rev_row1_col1, _rev_row1_col1 + 5);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType 
  _row1_col4_right[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11, 2.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10.5, 2), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11, 1.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11.5, 2), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11, 2.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
               row1_col4_right(_row1_col4_right, _row1_col4_right + 5);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType 
   _rev_row1_col4_right[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11, 2.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11.5, 2), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11, 1.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10.5, 2), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11, 2.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
      rev_row1_col4_right(_rev_row1_col4_right, _rev_row1_col4_right + 5);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType 
   _row1_col4_left[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(9, 2.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(8.5, 2), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(9, 1.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(9.5, 2), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(9, 2.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
     row1_col4_left(_row1_col4_left, _row1_col4_left + 5);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType 
   _rev_row1_col4_left[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(9, 2.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(9.5, 2), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(9, 1.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(8.5, 2), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(9, 2.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
      rev_row1_col4_left(_rev_row1_col4_left, _rev_row1_col4_left + 5);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType _row1_col3[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(7, 3.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(6.5, 3), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(6.5, 2), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(7, 1.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(7.5, 2), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(7.5, 3), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(7, 3.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
       row1_col3(_row1_col3, _row1_col3 + 7);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType _rev_row1_col3[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(7, 3.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(7.5, 3), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(7.5, 2),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(7, 1.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(6.5, 2), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(6.5, 3), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(7, 3.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
    rev_row1_col3(_rev_row1_col3, _rev_row1_col3 + 7);


itkContourExtractor2DImageFilterTestNamespace::MyVertexType _top_right[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(12, 0.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11.5, 0)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
    top_right(_top_right, _top_right + 2);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType _rev_top_right[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11.5, 0),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(12, 0.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
    rev_top_right(_rev_top_right, _rev_top_right + 2);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType _top_left[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(1.5, 0), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(1, 0.5), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(0.5, 1), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(0, 1.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
   top_left(_top_left, _top_left + 4);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType _rev_top_left[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(0, 1.5),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(0.5, 1),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(1, 0.5),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(1.5, 0)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
   rev_top_left(_rev_top_left, _rev_top_left + 4);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType 
  _top_left_cropped[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(0.5, 1), 
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(0, 1.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType
   top_left_cropped(_top_left_cropped, _top_left_cropped + 2);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType 
   _rev_top_left_cropped[] = 
 {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(0, 1.5),
  itkContourExtractor2DImageFilterTestNamespace::MyVertexType(0.5, 1)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
   rev_top_left_cropped(_rev_top_left_cropped, _rev_top_left_cropped + 2);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType _row1_col4_all[] = 
  {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10, 3.5), 
   itkContourExtractor2DImageFilterTestNamespace::MyVertexType(9.5, 3), 
   itkContourExtractor2DImageFilterTestNamespace::MyVertexType(9, 2.5), 
   itkContourExtractor2DImageFilterTestNamespace::MyVertexType(8.5, 2), 
   itkContourExtractor2DImageFilterTestNamespace::MyVertexType(9, 1.5), 
   itkContourExtractor2DImageFilterTestNamespace::MyVertexType(9.5, 2), 
   itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10, 2.5), 
   itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10.5, 2), 
   itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11, 1.5), 
   itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11.5, 2), 
   itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11, 2.5), 
   itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10.5, 3), 
   itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10, 3.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
   row1_col4_all(_row1_col4_all, _row1_col4_all + 13);

itkContourExtractor2DImageFilterTestNamespace::MyVertexType 
  _rev_row1_col4_all[] = 
  {itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10, 3.5), 
   itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10.5, 3),
   itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11, 2.5),
   itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11.5, 2),
   itkContourExtractor2DImageFilterTestNamespace::MyVertexType(11, 1.5),
   itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10.5, 2),  
   itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10, 2.5),
   itkContourExtractor2DImageFilterTestNamespace::MyVertexType(9.5, 2),
   itkContourExtractor2DImageFilterTestNamespace::MyVertexType(9, 1.5),
   itkContourExtractor2DImageFilterTestNamespace::MyVertexType(8.5, 2),
   itkContourExtractor2DImageFilterTestNamespace::MyVertexType(9, 2.5),
   itkContourExtractor2DImageFilterTestNamespace::MyVertexType(9.5, 3),
   itkContourExtractor2DImageFilterTestNamespace::MyVertexType(10, 3.5)};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListType 
   rev_row1_col4_all(_rev_row1_col4_all, _rev_row1_col4_all + 13);

itkContourExtractor2DImageFilterTestNamespace::MyVertexListType _edco[] = 
  {top_left, top_right, row1_col3, row1_col4_left, 
   row1_col4_right, row1_col1, row1_col2, row1_col4_middle, row2_col1,
   row2_col2, row2_col3, row2_col4, bottom_left, bottom_right};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListList 
   expected_disconnected_clockwise_outputs(_edco, _edco + 14);

itkContourExtractor2DImageFilterTestNamespace::MyVertexListType _edcco[] = 
  {rev_top_left, rev_top_right, rev_row1_col3,
   rev_row1_col4_left, rev_row1_col4_right, rev_row1_col1, rev_row1_col2, 
   rev_row1_col4_middle, rev_row2_col1, rev_row2_col2, rev_row2_col3, 
   rev_row2_col4, rev_bottom_left, rev_bottom_right};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListList 
   expected_disconnected_counterclockwise_outputs(_edcco, _edcco + 14);

itkContourExtractor2DImageFilterTestNamespace::MyVertexListType _ecco[] = 
  {top_left, top_right, row1_col3, row1_col4_all, 
   row1_col1, row1_col2, row2_col1, row2_col2, row2_col3, row2_col4, 
   bottom_left, bottom_right};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListList 
  expected_connected_clockwise_outputs(_ecco, _ecco + 12);

itkContourExtractor2DImageFilterTestNamespace::MyVertexListType _edcro[] = 
  {top_left_cropped, row1_col3, row1_col4_left, 
   row1_col4_right, row1_col1, row1_col2, row1_col4_middle, row2_col1, 
   row2_col2, row2_col3, row2_col4};
itkContourExtractor2DImageFilterTestNamespace::MyVertexListList 
   expected_disconnected_clockwise_cropped_outputs(_edcro, _edcro + 11);

/*--------------------------------------------------------------------------*/

bool HasCorrectOutput(
itkContourExtractor2DImageFilterTestNamespace::ExtractorType::Pointer 
   extractor, 
itkContourExtractor2DImageFilterTestNamespace::MyVertexListList& correct)
{
  if (extractor->GetNumberOfOutputs() != correct.size()) 
    {
    return false;
    }

  for(unsigned int i = 0; i < correct.size(); i++)
    {
    itkContourExtractor2DImageFilterTestNamespace::ExtractorType::
                    VertexListConstPointer 
        vertices = extractor->GetOutput(i)->GetVertexList();

    itkContourExtractor2DImageFilterTestNamespace::MyVertexListType& 
                correctVertices = correct[i];

    if (vertices->Size() != correctVertices.size()) 
      {
      return false;
      }
    for(unsigned int j = 0; j < correctVertices.size(); j++)
      {
      const itkContourExtractor2DImageFilterTestNamespace::MyVertexType& 
          correctVertex = correctVertices[j];

      const itkContourExtractor2DImageFilterTestNamespace::VertexType& 
          vertex = vertices->ElementAt(j);
      if (vnl_math_abs(correctVertex.first - vertex[0]) > 
            itkContourExtractor2DImageFilterTestNamespace::FLOAT_EPSILON ||
          vnl_math_abs(correctVertex.second - vertex[1]) > 
            itkContourExtractor2DImageFilterTestNamespace::FLOAT_EPSILON)
        {
        return false;
        }
      }
    }
  return true;
}

int itkContourExtractor2DImageFilterTest(int argc, char *argv[])
{
  if( argc < 2 )
    {
    std::cerr << "Missing Parameters " << std::endl;
    std::cerr << "Usage: " << argv[0];
    std::cerr << " Input Test Image  " << std::endl;
    return 1;
    }
 
  itkContourExtractor2DImageFilterTestNamespace::ReaderType::Pointer 
    reader = itkContourExtractor2DImageFilterTestNamespace::ReaderType::New();

  reader->SetFileName(argv[1]);
  itkContourExtractor2DImageFilterTestNamespace::ExtractorType::Pointer 
   extractor = 
      itkContourExtractor2DImageFilterTestNamespace::ExtractorType::New();

  extractor->SetInput(reader->GetOutput());

  // exercise Set/Get ContourValue methods 
  extractor->SetContourValue( 255.0 );
  if( extractor->GetContourValue() != 255.0 )
    {
    std::cerr << " Contour Value Set/Get problem" << std::endl;
    return EXIT_FAILURE;
    } 

  extractor->SetContourValue(127.5);

  // exercise Set/Get methods of VertexConnectHighPixels 
  extractor->VertexConnectHighPixelsOn();
  if( extractor->GetVertexConnectHighPixels() != true )
    {
    std::cerr << "VertexConnectHighPixels Set/Get Problem" << std::endl;
    return EXIT_FAILURE;
    }

  // exercise Set/Get methods of ReverseContourOrientation 
  extractor->ReverseContourOrientationOn();
  if( extractor->GetReverseContourOrientation() != true )
    {
    std::cerr << "ReverseContourOrientation Set/Get Problem" << std::endl;
    return EXIT_FAILURE;
    }
 
  bool testsPassed = true;
  try 
    {
    extractor->VertexConnectHighPixelsOff();
    extractor->ReverseContourOrientationOff();
    extractor->Update();
    std::cout << "Test 1... ";
    if (!HasCorrectOutput(extractor, expected_disconnected_clockwise_outputs))
      {
      testsPassed = false;
      std::cout << "failed." << std::endl;
      }
    else std::cout << "passed." << std::endl;

    extractor->VertexConnectHighPixelsOff();
    extractor->ReverseContourOrientationOn();
    extractor->Update();
    std::cout << "Test 2... ";
    if (!HasCorrectOutput(extractor, 
            expected_disconnected_counterclockwise_outputs))
      {
      testsPassed = false;
      std::cout << "failed." << std::endl;
      }
    else 
      {
      std::cout << "passed." << std::endl;
      }

    extractor->VertexConnectHighPixelsOn();
    extractor->ReverseContourOrientationOff();
    extractor->Update();
    std::cout << "Test 3... ";
    if (!HasCorrectOutput(extractor, expected_connected_clockwise_outputs))
      {
      testsPassed = false;
      std::cout << "failed." << std::endl;
      }
    else
      {
       std::cout << "passed." << std::endl;
      }

    extractor->VertexConnectHighPixelsOff();
    extractor->ReverseContourOrientationOff();
    // Move the region to evaluate in by one on the top and bottom
    itkContourExtractor2DImageFilterTestNamespace::ImageType::RegionType 
              region = reader->GetOutput()->GetLargestPossibleRegion();

    itkContourExtractor2DImageFilterTestNamespace::ImageType::IndexType 
              index = region.GetIndex();

    itkContourExtractor2DImageFilterTestNamespace::ImageType::SizeType 
              size = region.GetSize();

    index[1] += 1;
    size[1] -= 2;

    extractor->SetRequestedRegion(
       itkContourExtractor2DImageFilterTestNamespace::ImageType::RegionType(
                   index, size));

    // exercise Set/Get RequestRegion
    if ( extractor->GetRequestedRegion() != 
     itkContourExtractor2DImageFilterTestNamespace::ImageType::RegionType(
                   index, size) ) 
      {
      std::cerr << "RequestedRegion Set/Get Problem" << std::endl;
      return EXIT_FAILURE;
      }   

    extractor->Update();
    std::cout << "Test 4... ";
    if (!HasCorrectOutput(extractor, 
          expected_disconnected_clockwise_cropped_outputs))
      {
      testsPassed = false;
      std::cerr << "failed." << std::endl;
      }
    else
      {
      std::cout << "passed." << std::endl;
      }
    } 
  catch( itk::ExceptionObject & err ) 
    { 
    std::cerr << "ExceptionObject caught !" << std::endl; 
    std::cerr << err << std::endl; 
    return -1;
    }

  if (testsPassed)
    {
    std::cout << "All tests passed." << std::endl;
    return 0;
    }

  return 1;
}