Orfeo Toolbox  3.16
itkBinaryMask3DMeshSource.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3 Program: Insight Segmentation & Registration Toolkit
4 Module: $RCSfile: itkBinaryMask3DMeshSource.txx,v $
5 Language: C++
6 Date: $Date: 2009-10-06 19:11:58 $
7 Version: $Revision: 1.30 $
8 
9 Copyright (c) Insight Software Consortium. All rights reserved.
10 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkBinaryMask3DMeshSource_txx
18 #define __itkBinaryMask3DMeshSource_txx
19 
20 
21 #ifdef __INTEL_COMPILER
22 #pragma warning(disable: 592)
23 #endif
24 
26 #include "itkNumericTraits.h"
27 
28 namespace itk
29 {
30 
31 template<class TInputImage, class TOutputMesh>
34 {
35  // Modify superclass default values, can be overridden by subclasses
36  this->SetNumberOfRequiredInputs(1);
37 
38  m_NumberOfCells = 0;
39  m_NumberOfNodes = 0;
40 
41  m_NodeLimit = 2000;
42  m_CellLimit = 4000;
43  m_LastRowIndex = 0;
44  m_LastVoxelIndex = 0;
45  m_LastFrameIndex = 0;
46  m_CurrentRowIndex = 0;
47  m_CurrentFrameIndex = 0;
48  m_CurrentFrame = 0;
49  m_CurrentRow = 0;
50  m_LastRow = 0;
51  m_LastRowNum = 0;
52  m_LastFrameNum = 0;
53  m_LastFrame = 0;
54  m_CurrentRowNum = 200;
55  m_CurrentFrameNum = 2000;
56  this->GetOutput()->GetPoints()->Reserve(m_NodeLimit);
57  this->GetOutput()->GetCells()->Reserve(m_CellLimit);
58 
59  m_ObjectValue = NumericTraits< InputPixelType >::One;
60 }
61 
62 template<class TInputImage, class TOutputMesh>
65 {
66  int i;
67 
68  if (m_CurrentFrame)
69  {
70  for (i = 0; i < 2000; i++)
71  {
72  free(m_CurrentFrame[i]);
73  }
74  free (m_CurrentFrame);
75  }
76  if (m_CurrentRow)
77  {
78  for (i = 0; i < 200; i++)
79  {
80  free(m_CurrentRow[i]);
81  }
82  free (m_CurrentRow);
83  }
84  if (m_LastFrame)
85  {
86  for (i = 0; i < m_LastFrameNum; i++)
87  {
88  free(m_LastFrame[i]);
89  }
90  free (m_LastFrame);
91  }
92  if (m_LastRow)
93  {
94  for (i = 0; i < m_LastRowNum; i++)
95  {
96  free(m_LastRow[i]);
97  }
98  free (m_LastRow);
99  }
100 }
101 
102 
103 template<class TInputImage, class TOutputMesh>
104 void
107 {
109  const_cast< InputImageType * >( image ) );
110 }
111 
113 template<class TInputImage, class TOutputMesh>
114 void
117 {
118  this->InitializeLUT();
119  this->CreateMesh();
120 }
121 
122 template<class TInputImage, class TOutputMesh>
123 void
125 ::XFlip(unsigned char *x)
126 {
127  unsigned char nodeindex;
128 
129  int i=0;
130 
131  while ( i < 3 )
132  {
133  nodeindex = x[i];
134  switch ( (int)nodeindex )
135  {
136  case 1:
137  break;
138  case 2:
139  x[i] = 4;
140  break;
141  case 3:
142  break;
143  case 4:
144  x[i] = 2;
145  break;
146  case 5:
147  break;
148  case 6:
149  x[i] = 8;
150  break;
151  case 7:
152  break;
153  case 8:
154  x[i] = 6;
155  break;
156  case 9:
157  x[i] = 10;
158  break;
159  case 10:
160  x[i] = 9;
161  break;
162  case 11:
163  x[i] = 12;
164  break;
165  case 12:
166  x[i] = 11;
167  break;
168  case 13:
169  break;
170  }
171  i++;
172  }
173 }
174 
175 template<class TInputImage, class TOutputMesh>
176 void
178 ::YFlip(unsigned char *x)
179 {
180  unsigned char nodeindex;
181 
182  int i=0;
183 
184  while ( i < 3 )
185  {
186  nodeindex = x[i];
187  switch ( (int)nodeindex )
188  {
189  case 1:
190  x[i] = 3;
191  break;
192  case 2:
193  break;
194  case 3:
195  x[i] = 1;
196  break;
197  case 4:
198  break;
199  case 5:
200  x[i] = 7;
201  break;
202  case 6:
203  break;
204  case 7:
205  x[i] = 5;
206  break;
207  case 8:
208  break;
209  case 9:
210  x[i] = 12;
211  break;
212  case 10:
213  x[i] = 11;
214  break;
215  case 11:
216  x[i] = 10;
217  break;
218  case 12:
219  x[i] = 9;
220  break;
221  case 13:
222  break;
223  }
224  i++;
225  }
226 }
227 
228 template<class TInputImage, class TOutputMesh>
229 void
231 ::ZFlip(unsigned char *x)
232 {
233  unsigned char nodeindex;
234 
235  int i=0;
236 
237  while ( i < 3 )
238  {
239  nodeindex = x[i];
240  switch ( (int)nodeindex )
241  {
242  case 1:
243  x[i] = 5;
244  break;
245  case 2:
246  x[i] = 6;
247  break;
248  case 3:
249  x[i] = 7;
250  break;
251  case 4:
252  x[i] = 8;
253  break;
254  case 5:
255  x[i] = 1;
256  break;
257  case 6:
258  x[i] = 2;
259  break;
260  case 7:
261  x[i] = 3;
262  break;
263  case 8:
264  x[i] = 4;
265  break;
266  case 9:
267  break;
268  case 10:
269  break;
270  case 11:
271  break;
272  case 12:
273  break;
274  case 13:
275  break;
276  }
277  i++;
278  }
279 }
280 
281 template<class TInputImage, class TOutputMesh>
282 void
284 ::XRotation(unsigned char *x)
285 {
286  unsigned char nodeindex;
287 
288  int i=0;
289 
290  while ( i<3 )
291  {
292  nodeindex = x[i];
293  switch ( (int)nodeindex )
294  {
295  case 1:
296  x[i] = 4;
297  break;
298  case 2:
299  x[i] = 1;
300  break;
301  case 3:
302  x[i] = 2;
303  break;
304  case 4:
305  x[i] = 3;
306  break;
307  case 5:
308  x[i] = 8;
309  break;
310  case 6:
311  x[i] = 5;
312  break;
313  case 7:
314  x[i] = 6;
315  break;
316  case 8:
317  x[i] = 7;
318  break;
319  case 9:
320  x[i] = 12;
321  break;
322  case 10:
323  x[i] = 9;
324  break;
325  case 11:
326  x[i] = 10;
327  break;
328  case 12:
329  x[i] = 11;
330  break;
331  case 13:
332  break;
333  }
334  i++;
335  }
336 }
337 
338 template<class TInputImage, class TOutputMesh>
339 void
341 ::YRotation(unsigned char *x)
342 {
343  unsigned char nodeindex;
344 
345  int i=0;
346 
347  while ( i<3 )
348  {
349  nodeindex = x[i];
350  switch ( (int)nodeindex )
351  {
352  case 1:
353  x[i] = 9;
354  break;
355  case 2:
356  x[i] = 4;
357  break;
358  case 3:
359  x[i] = 12;
360  break;
361  case 4:
362  x[i] = 8;
363  break;
364  case 5:
365  x[i] = 10;
366  break;
367  case 6:
368  x[i] = 2;
369  break;
370  case 7:
371  x[i] = 11;
372  break;
373  case 8:
374  x[i] = 6;
375  break;
376  case 9:
377  x[i] = 5;
378  break;
379  case 10:
380  x[i] = 1;
381  break;
382  case 11:
383  x[i] = 3;
384  break;
385  case 12:
386  x[i] = 7;
387  break;
388  case 13:
389  break;
390  }
391  i++;
392  }
393 }
394 
395 template<class TInputImage, class TOutputMesh>
396 void
398 ::ZRotation(unsigned char *x)
399 {
400  unsigned char nodeindex;
401 
402  int i=0;
403 
404  while ( i<3 )
405  {
406  nodeindex = x[i];
407  switch ( (int)nodeindex )
408  {
409  case 1:
410  x[i] = 3;
411  break;
412  case 2:
413  x[i] = 11;
414  break;
415  case 3:
416  x[i] = 7;
417  break;
418  case 4:
419  x[i] = 12;
420  break;
421  case 5:
422  x[i] = 1;
423  break;
424  case 6:
425  x[i] = 10;
426  break;
427  case 7:
428  x[i] = 5;
429  break;
430  case 8:
431  x[i] = 9;
432  break;
433  case 9:
434  x[i] = 4;
435  break;
436  case 10:
437  x[i] = 2;
438  break;
439  case 11:
440  x[i] = 6;
441  break;
442  case 12:
443  x[i] = 8;
444  break;
445  case 13:
446  break;
447  }
448  i++;
449  }
450 }
451 
452 template<class TInputImage, class TOutputMesh>
453 void
455 ::inverse(unsigned char *x)
456 {
457  unsigned char tmp;
458  tmp = x[2];
459  x[2] = x[1];
460  x[1] = tmp;
461 }
462 
463 template<class TInputImage, class TOutputMesh>
464 void
467 {
468  m_LUT[0][0] = 0;
469  m_LUT[1][0] = 1;
470  m_LUT[2][0] = 1;
471  m_LUT[3][0] = 2;
472  m_LUT[4][0] = 1;
473  m_LUT[5][0] = 3;
474  m_LUT[6][0] = 2;
475  m_LUT[7][0] = 5;
476  m_LUT[8][0] = 1;
477  m_LUT[9][0] = 2;
478  m_LUT[10][0] = 3;
479  m_LUT[11][0] = 5;
480  m_LUT[12][0] = 2;
481  m_LUT[13][0] = 5;
482  m_LUT[14][0] = 5;
483  m_LUT[15][0] = 8;
484  m_LUT[16][0] = 1;
485  m_LUT[17][0] = 2;
486  m_LUT[18][0] = 3;
487  m_LUT[19][0] = 5;
488  m_LUT[20][0] = 4;
489  m_LUT[21][0] = 6;
490  m_LUT[22][0] = 6;
491  m_LUT[23][0] = 11;
492  m_LUT[24][0] = 3;
493  m_LUT[25][0] = 5;
494  m_LUT[26][0] = 7;
495  m_LUT[27][0] = 9;
496  m_LUT[28][0] = 6;
497  m_LUT[29][0] = 11;
498  m_LUT[30][0] = 12;
499  m_LUT[31][0] = 5;
500  m_LUT[32][0] = 1;
501  m_LUT[33][0] = 3;
502  m_LUT[34][0] = 2;
503  m_LUT[35][0] = 5;
504  m_LUT[36][0] = 3;
505  m_LUT[37][0] = 7;
506  m_LUT[38][0] = 5;
507  m_LUT[39][0] = 9;
508  m_LUT[40][0] = 4;
509  m_LUT[41][0] = 6;
510  m_LUT[42][0] = 6;
511  m_LUT[43][0] = 11;
512  m_LUT[44][0] = 6;
513  m_LUT[45][0] = 12;
514  m_LUT[46][0] = 11;
515  m_LUT[47][0] = 5;
516  m_LUT[48][0] = 2;
517  m_LUT[49][0] = 5;
518  m_LUT[50][0] = 5;
519  m_LUT[51][0] = 8;
520  m_LUT[52][0] = 6;
521  m_LUT[53][0] = 12;
522  m_LUT[54][0] = 11;
523  m_LUT[55][0] = 5;
524  m_LUT[56][0] = 6;
525  m_LUT[57][0] = 11;
526  m_LUT[58][0] = 12;
527  m_LUT[59][0] = 5;
528  m_LUT[60][0] = 10;
529  m_LUT[61][0] = 16;
530  m_LUT[62][0] = 16;
531  m_LUT[63][0] = 2;
532  m_LUT[64][0] = 1;
533  m_LUT[65][0] = 4;
534  m_LUT[66][0] = 3;
535  m_LUT[67][0] = 6;
536  m_LUT[68][0] = 2;
537  m_LUT[69][0] = 6;
538  m_LUT[70][0] = 5;
539  m_LUT[71][0] = 11;
540  m_LUT[72][0] = 3;
541  m_LUT[73][0] = 6;
542  m_LUT[74][0] = 7;
543  m_LUT[75][0] = 12;
544  m_LUT[76][0] = 5;
545  m_LUT[77][0] = 11;
546  m_LUT[78][0] = 9;
547  m_LUT[79][0] = 5;
548  m_LUT[80][0] = 3;
549  m_LUT[81][0] = 6;
550  m_LUT[82][0] = 7;
551  m_LUT[83][0] = 12;
552  m_LUT[84][0] = 6;
553  m_LUT[85][0] = 10;
554  m_LUT[86][0] = 12;
555  m_LUT[87][0] = 16;
556  m_LUT[88][0] = 7;
557  m_LUT[89][0] = 12;
558  m_LUT[90][0] = 13;
559  m_LUT[91][0] = 14;
560  m_LUT[92][0] = 12;
561  m_LUT[93][0] = 16;
562  m_LUT[94][0] = 14;
563  m_LUT[95][0] = 15;
564  m_LUT[96][0] = 2;
565  m_LUT[97][0] = 6;
566  m_LUT[98][0] = 5;
567  m_LUT[99][0] = 11;
568  m_LUT[100][0] = 5;
569  m_LUT[101][0] = 12;
570  m_LUT[102][0] = 8;
571  m_LUT[103][0] = 5;
572  m_LUT[104][0] = 6;
573  m_LUT[105][0] = 10;
574  m_LUT[106][0] = 12;
575  m_LUT[107][0] = 16;
576  m_LUT[108][0] = 11;
577  m_LUT[109][0] = 16;
578  m_LUT[110][0] = 5;
579  m_LUT[111][0] = 2;
580  m_LUT[112][0] = 5;
581  m_LUT[113][0] = 11;
582  m_LUT[114][0] = 9;
583  m_LUT[115][0] = 5;
584  m_LUT[116][0] = 11;
585  m_LUT[117][0] = 16;
586  m_LUT[118][0] = 5;
587  m_LUT[119][0] = 2;
588  m_LUT[120][0] = 12;
589  m_LUT[121][0] = 16;
590  m_LUT[122][0] = 14;
591  m_LUT[123][0] = 15;
592  m_LUT[124][0] = 16;
593  m_LUT[125][0] = 4;
594  m_LUT[126][0] = 15;
595  m_LUT[127][0] = 1;
596  m_LUT[128][0] = 1;
597  m_LUT[129][0] = 3;
598  m_LUT[130][0] = 4;
599  m_LUT[131][0] = 6;
600  m_LUT[132][0] = 3;
601  m_LUT[133][0] = 7;
602  m_LUT[134][0] = 6;
603  m_LUT[135][0] = 12;
604  m_LUT[136][0] = 2;
605  m_LUT[137][0] = 5;
606  m_LUT[138][0] = 6;
607  m_LUT[139][0] = 11;
608  m_LUT[140][0] = 5;
609  m_LUT[141][0] = 9;
610  m_LUT[142][0] = 11;
611  m_LUT[143][0] = 5;
612  m_LUT[144][0] = 2;
613  m_LUT[145][0] = 5;
614  m_LUT[146][0] = 6;
615  m_LUT[147][0] = 11;
616  m_LUT[148][0] = 6;
617  m_LUT[149][0] = 12;
618  m_LUT[150][0] = 10;
619  m_LUT[151][0] = 16;
620  m_LUT[152][0] = 5;
621  m_LUT[153][0] = 8;
622  m_LUT[154][0] = 12;
623  m_LUT[155][0] = 5;
624  m_LUT[156][0] = 11;
625  m_LUT[157][0] = 5;
626  m_LUT[158][0] = 16;
627  m_LUT[159][0] = 2;
628  m_LUT[160][0] = 3;
629  m_LUT[161][0] = 7;
630  m_LUT[162][0] = 6;
631  m_LUT[163][0] = 12;
632  m_LUT[164][0] = 7;
633  m_LUT[165][0] = 13;
634  m_LUT[166][0] = 12;
635  m_LUT[167][0] = 14;
636  m_LUT[168][0] = 6;
637  m_LUT[169][0] = 12;
638  m_LUT[170][0] = 10;
639  m_LUT[171][0] = 16;
640  m_LUT[172][0] = 12;
641  m_LUT[173][0] = 14;
642  m_LUT[174][0] = 16;
643  m_LUT[175][0] = 15;
644  m_LUT[176][0] = 5;
645  m_LUT[177][0] = 9;
646  m_LUT[178][0] = 11;
647  m_LUT[179][0] = 5;
648  m_LUT[180][0] = 12;
649  m_LUT[181][0] = 14;
650  m_LUT[182][0] = 16;
651  m_LUT[183][0] = 15;
652  m_LUT[184][0] = 11;
653  m_LUT[185][0] = 5;
654  m_LUT[186][0] = 16;
655  m_LUT[187][0] = 2;
656  m_LUT[188][0] = 16;
657  m_LUT[189][0] = 15;
658  m_LUT[190][0] = 4;
659  m_LUT[191][0] = 1;
660  m_LUT[192][0] = 2;
661  m_LUT[193][0] = 6;
662  m_LUT[194][0] = 6;
663  m_LUT[195][0] = 10;
664  m_LUT[196][0] = 5;
665  m_LUT[197][0] = 12;
666  m_LUT[198][0] = 11;
667  m_LUT[199][0] = 16;
668  m_LUT[200][0] = 5;
669  m_LUT[201][0] = 11;
670  m_LUT[202][0] = 12;
671  m_LUT[203][0] = 16;
672  m_LUT[204][0] = 8;
673  m_LUT[205][0] = 5;
674  m_LUT[206][0] = 5;
675  m_LUT[207][0] = 2;
676  m_LUT[208][0] = 5;
677  m_LUT[209][0] = 11;
678  m_LUT[210][0] = 12;
679  m_LUT[211][0] = 16;
680  m_LUT[212][0] = 11;
681  m_LUT[213][0] = 16;
682  m_LUT[214][0] = 16;
683  m_LUT[215][0] = 4;
684  m_LUT[216][0] = 9;
685  m_LUT[217][0] = 5;
686  m_LUT[218][0] = 14;
687  m_LUT[219][0] = 15;
688  m_LUT[220][0] = 5;
689  m_LUT[221][0] = 2;
690  m_LUT[222][0] = 15;
691  m_LUT[223][0] = 1;
692  m_LUT[224][0] = 5;
693  m_LUT[225][0] = 12;
694  m_LUT[226][0] = 11;
695  m_LUT[227][0] = 16;
696  m_LUT[228][0] = 9;
697  m_LUT[229][0] = 14;
698  m_LUT[230][0] = 5;
699  m_LUT[231][0] = 15;
700  m_LUT[232][0] = 11;
701  m_LUT[233][0] = 16;
702  m_LUT[234][0] = 16;
703  m_LUT[235][0] = 4;
704  m_LUT[236][0] = 5;
705  m_LUT[237][0] = 15;
706  m_LUT[238][0] = 2;
707  m_LUT[239][0] = 1;
708  m_LUT[240][0] = 8;
709  m_LUT[241][0] = 5;
710  m_LUT[242][0] = 5;
711  m_LUT[243][0] = 2;
712  m_LUT[244][0] = 5;
713  m_LUT[245][0] = 15;
714  m_LUT[246][0] = 2;
715  m_LUT[247][0] = 1;
716  m_LUT[248][0] = 5;
717  m_LUT[249][0] = 2;
718  m_LUT[250][0] = 15;
719  m_LUT[251][0] = 1;
720  m_LUT[252][0] = 2;
721  m_LUT[253][0] = 1;
722  m_LUT[254][0] = 1;
723  m_LUT[255][0] = 0;
724  m_LUT[0][1] = 0;
725  m_LUT[1][1] = 0;
726  m_LUT[2][1] = 4;
727  m_LUT[3][1] = 0;
728  m_LUT[4][1] = 6;
729  m_LUT[5][1] = 0;
730  m_LUT[6][1] = 34;
731  m_LUT[7][1] = 8;
732  m_LUT[8][1] = 2;
733  m_LUT[9][1] = 32;
734  m_LUT[10][1] = 2;
735  m_LUT[11][1] = 12;
736  m_LUT[12][1] = 2;
737  m_LUT[13][1] = 13;
738  m_LUT[14][1] = 9;
739  m_LUT[15][1] = 8;
740  m_LUT[16][1] = 1;
741  m_LUT[17][1] = 16;
742  m_LUT[18][1] = 11;
743  m_LUT[19][1] = 5;
744  m_LUT[20][1] = 1;
745  m_LUT[21][1] = 16;
746  m_LUT[22][1] = 34;
747  m_LUT[23][1] = 1;
748  m_LUT[24][1] = 16;
749  m_LUT[25][1] = 24;
750  m_LUT[26][1] = 6;
751  m_LUT[27][1] = 1;
752  m_LUT[28][1] = 6;
753  m_LUT[29][1] = 37;
754  m_LUT[30][1] = 9;
755  m_LUT[31][1] = 75;
756  m_LUT[32][1] = 5;
757  m_LUT[33][1] = 9;
758  m_LUT[34][1] = 17;
759  m_LUT[35][1] = 1;
760  m_LUT[36][1] = 17;
761  m_LUT[37][1] = 2;
762  m_LUT[38][1] = 26;
763  m_LUT[39][1] = 5;
764  m_LUT[40][1] = 2;
765  m_LUT[41][1] = 32;
766  m_LUT[42][1] = 17;
767  m_LUT[43][1] = 5;
768  m_LUT[44][1] = 2;
769  m_LUT[45][1] = 13;
770  m_LUT[46][1] = 39;
771  m_LUT[47][1] = 79;
772  m_LUT[48][1] = 1;
773  m_LUT[49][1] = 4;
774  m_LUT[50][1] = 0;
775  m_LUT[51][1] = 0;
776  m_LUT[52][1] = 1;
777  m_LUT[53][1] = 4;
778  m_LUT[54][1] = 16;
779  m_LUT[55][1] = 70;
780  m_LUT[56][1] = 5;
781  m_LUT[57][1] = 17;
782  m_LUT[58][1] = 0;
783  m_LUT[59][1] = 66;
784  m_LUT[60][1] = 25;
785  m_LUT[61][1] = 23;
786  m_LUT[62][1] = 22;
787  m_LUT[63][1] = 67;
788  m_LUT[64][1] = 7;
789  m_LUT[65][1] = 0;
790  m_LUT[66][1] = 19;
791  m_LUT[67][1] = 0;
792  m_LUT[68][1] = 19;
793  m_LUT[69][1] = 19;
794  m_LUT[70][1] = 27;
795  m_LUT[71][1] = 35;
796  m_LUT[72][1] = 8;
797  m_LUT[73][1] = 36;
798  m_LUT[74][1] = 0;
799  m_LUT[75][1] = 12;
800  m_LUT[76][1] = 3;
801  m_LUT[77][1] = 7;
802  m_LUT[78][1] = 7;
803  m_LUT[79][1] = 78;
804  m_LUT[80][1] = 1;
805  m_LUT[81][1] = 20;
806  m_LUT[82][1] = 3;
807  m_LUT[83][1] = 5;
808  m_LUT[84][1] = 23;
809  m_LUT[85][1] = 9;
810  m_LUT[86][1] = 27;
811  m_LUT[87][1] = 7;
812  m_LUT[88][1] = 5;
813  m_LUT[89][1] = 24;
814  m_LUT[90][1] = 1;
815  m_LUT[91][1] = 1;
816  m_LUT[92][1] = 3;
817  m_LUT[93][1] = 1;
818  m_LUT[94][1] = 7;
819  m_LUT[95][1] = 1;
820  m_LUT[96][1] = 35;
821  m_LUT[97][1] = 35;
822  m_LUT[98][1] = 30;
823  m_LUT[99][1] = 20;
824  m_LUT[100][1] = 31;
825  m_LUT[101][1] = 31;
826  m_LUT[102][1] = 26;
827  m_LUT[103][1] = 93;
828  m_LUT[104][1] = 39;
829  m_LUT[105][1] = 0;
830  m_LUT[106][1] = 30;
831  m_LUT[107][1] = 14;
832  m_LUT[108][1] = 22;
833  m_LUT[109][1] = 15;
834  m_LUT[110][1] = 92;
835  m_LUT[111][1] = 97;
836  m_LUT[112][1] = 10;
837  m_LUT[113][1] = 0;
838  m_LUT[114][1] = 4;
839  m_LUT[115][1] = 71;
840  m_LUT[116][1] = 34;
841  m_LUT[117][1] = 6;
842  m_LUT[118][1] = 89;
843  m_LUT[119][1] = 82;
844  m_LUT[120][1] = 10;
845  m_LUT[121][1] = 8;
846  m_LUT[122][1] = 4;
847  m_LUT[123][1] = 8;
848  m_LUT[124][1] = 16;
849  m_LUT[125][1] = 67;
850  m_LUT[126][1] = 16;
851  m_LUT[127][1] = 67;
852  m_LUT[128][1] = 3;
853  m_LUT[129][1] = 18;
854  m_LUT[130][1] = 3;
855  m_LUT[131][1] = 4;
856  m_LUT[132][1] = 10;
857  m_LUT[133][1] = 4;
858  m_LUT[134][1] = 38;
859  m_LUT[135][1] = 8;
860  m_LUT[136][1] = 18;
861  m_LUT[137][1] = 25;
862  m_LUT[138][1] = 18;
863  m_LUT[139][1] = 33;
864  m_LUT[140][1] = 7;
865  m_LUT[141][1] = 3;
866  m_LUT[142][1] = 3;
867  m_LUT[143][1] = 74;
868  m_LUT[144][1] = 33;
869  m_LUT[145][1] = 28;
870  m_LUT[146][1] = 33;
871  m_LUT[147][1] = 21;
872  m_LUT[148][1] = 37;
873  m_LUT[149][1] = 28;
874  m_LUT[150][1] = 1;
875  m_LUT[151][1] = 10;
876  m_LUT[152][1] = 29;
877  m_LUT[153][1] = 24;
878  m_LUT[154][1] = 29;
879  m_LUT[155][1] = 95;
880  m_LUT[156][1] = 23;
881  m_LUT[157][1] = 94;
882  m_LUT[158][1] = 11;
883  m_LUT[159][1] = 99;
884  m_LUT[160][1] = 3;
885  m_LUT[161][1] = 7;
886  m_LUT[162][1] = 21;
887  m_LUT[163][1] = 1;
888  m_LUT[164][1] = 1;
889  m_LUT[165][1] = 0;
890  m_LUT[166][1] = 26;
891  m_LUT[167][1] = 5;
892  m_LUT[168][1] = 22;
893  m_LUT[169][1] = 25;
894  m_LUT[170][1] = 8;
895  m_LUT[171][1] = 3;
896  m_LUT[172][1] = 7;
897  m_LUT[173][1] = 3;
898  m_LUT[174][1] = 5;
899  m_LUT[175][1] = 3;
900  m_LUT[176][1] = 14;
901  m_LUT[177][1] = 0;
902  m_LUT[178][1] = 4;
903  m_LUT[179][1] = 67;
904  m_LUT[180][1] = 14;
905  m_LUT[181][1] = 0;
906  m_LUT[182][1] = 12;
907  m_LUT[183][1] = 10;
908  m_LUT[184][1] = 32;
909  m_LUT[185][1] = 91;
910  m_LUT[186][1] = 2;
911  m_LUT[187][1] = 83;
912  m_LUT[188][1] = 17;
913  m_LUT[189][1] = 17;
914  m_LUT[190][1] = 64;
915  m_LUT[191][1] = 71;
916  m_LUT[192][1] = 3;
917  m_LUT[193][1] = 7;
918  m_LUT[194][1] = 3;
919  m_LUT[195][1] = 24;
920  m_LUT[196][1] = 2;
921  m_LUT[197][1] = 2;
922  m_LUT[198][1] = 18;
923  m_LUT[199][1] = 20;
924  m_LUT[200][1] = 6;
925  m_LUT[201][1] = 19;
926  m_LUT[202][1] = 6;
927  m_LUT[203][1] = 21;
928  m_LUT[204][1] = 2;
929  m_LUT[205][1] = 64;
930  m_LUT[206][1] = 68;
931  m_LUT[207][1] = 65;
932  m_LUT[208][1] = 15;
933  m_LUT[209][1] = 36;
934  m_LUT[210][1] = 15;
935  m_LUT[211][1] = 19;
936  m_LUT[212][1] = 6;
937  m_LUT[213][1] = 0;
938  m_LUT[214][1] = 13;
939  m_LUT[215][1] = 66;
940  m_LUT[216][1] = 2;
941  m_LUT[217][1] = 90;
942  m_LUT[218][1] = 2;
943  m_LUT[219][1] = 19;
944  m_LUT[220][1] = 65;
945  m_LUT[221][1] = 81;
946  m_LUT[222][1] = 11;
947  m_LUT[223][1] = 69;
948  m_LUT[224][1] = 11;
949  m_LUT[225][1] = 11;
950  m_LUT[226][1] = 38;
951  m_LUT[227][1] = 18;
952  m_LUT[228][1] = 6;
953  m_LUT[229][1] = 6;
954  m_LUT[230][1] = 88;
955  m_LUT[231][1] = 18;
956  m_LUT[232][1] = 2;
957  m_LUT[233][1] = 9;
958  m_LUT[234][1] = 4;
959  m_LUT[235][1] = 65;
960  m_LUT[236][1] = 69;
961  m_LUT[237][1] = 9;
962  m_LUT[238][1] = 80;
963  m_LUT[239][1] = 65;
964  m_LUT[240][1] = 10;
965  m_LUT[241][1] = 73;
966  m_LUT[242][1] = 77;
967  m_LUT[243][1] = 66;
968  m_LUT[244][1] = 76;
969  m_LUT[245][1] = 0;
970  m_LUT[246][1] = 96;
971  m_LUT[247][1] = 66;
972  m_LUT[248][1] = 72;
973  m_LUT[249][1] = 98;
974  m_LUT[250][1] = 2;
975  m_LUT[251][1] = 70;
976  m_LUT[252][1] = 64;
977  m_LUT[253][1] = 68;
978  m_LUT[254][1] = 64;
979  m_LUT[255][1] = 0;
980 
981  m_LocationOffset[1][0] = 0.5;
982  m_LocationOffset[2][0] = 1;
983  m_LocationOffset[3][0] = 0.5;
984  m_LocationOffset[4][0] = 0;
985  m_LocationOffset[5][0] = 0.5;
986  m_LocationOffset[6][0] = 1;
987  m_LocationOffset[7][0] = 0.5;
988  m_LocationOffset[8][0] = 0;
989  m_LocationOffset[9][0] = 0;
990  m_LocationOffset[10][0] = 1;
991  m_LocationOffset[11][0] = 1;
992  m_LocationOffset[12][0] = 0;
993  m_LocationOffset[13][0] = 0.5;
994  m_LocationOffset[1][1] = 0;
995  m_LocationOffset[2][1] = 0.5;
996  m_LocationOffset[3][1] = 1;
997  m_LocationOffset[4][1] = 0.5;
998  m_LocationOffset[5][1] = 0;
999  m_LocationOffset[6][1] = 0.5;
1000  m_LocationOffset[7][1] = 1;
1001  m_LocationOffset[8][1] = 0.5;
1002  m_LocationOffset[9][1] = 0;
1003  m_LocationOffset[10][1] = 0;
1004  m_LocationOffset[11][1] = 1;
1005  m_LocationOffset[12][1] = 1;
1006  m_LocationOffset[13][1] = 0.5;
1007  m_LocationOffset[1][2] = 0;
1008  m_LocationOffset[2][2] = 0;
1009  m_LocationOffset[3][2] = 0;
1010  m_LocationOffset[4][2] = 0;
1011  m_LocationOffset[5][2] = 1;
1012  m_LocationOffset[6][2] = 1;
1013  m_LocationOffset[7][2] = 1;
1014  m_LocationOffset[8][2] = 1;
1015  m_LocationOffset[9][2] = 0.5;
1016  m_LocationOffset[10][2] = 0.5;
1017  m_LocationOffset[11][2] = 0.5;
1018  m_LocationOffset[12][2] = 0.5;
1019  m_LocationOffset[13][2] = 0.5;
1020 
1021 }
1022 
1023 template<class TInputImage, class TOutputMesh>
1024 void
1027 {
1028  // NOTE ALEX: this is checked by the new pipeline
1029  // through SetNumberOfRequiredInput
1030  // if (this->GetNumberOfInputs() < 1)
1031  // {
1032  // std::cout << "BinaryMask3DMeshSource : Binary image mask not set";
1033  // std::cout << std::endl;
1034  // return;
1035  // }
1036 
1037  // Initialize variables
1038  m_NumberOfCells = 0;
1039  m_NumberOfNodes = 0;
1040  m_NodeLimit = 2000;
1041  m_CellLimit = 4000;
1042  m_LastRowIndex = 0;
1043  m_LastVoxelIndex = 0;
1044  m_LastFrameIndex = 0;
1045  m_CurrentRowIndex = 0;
1046  m_CurrentFrameIndex = 0;
1047  m_CurrentFrame = 0;
1048  m_CurrentRow = 0;
1049  m_LastRow = 0;
1050  m_LastRowNum = 0;
1051  m_LastFrameNum = 0;
1052  m_LastFrame = 0;
1053  m_CurrentRowNum = 200;
1054  m_CurrentFrameNum = 2000;
1055 
1056  InputImageConstPointer m_InputImage =
1057  static_cast<const InputImageType * >(this->ProcessObject::GetInput(0) );
1058 
1059  InputImageIterator it1( m_InputImage, m_InputImage->GetBufferedRegion() );
1060  InputImageIterator it2( m_InputImage, m_InputImage->GetBufferedRegion() );
1061  InputImageIterator it3( m_InputImage, m_InputImage->GetBufferedRegion() );
1062  InputImageIterator it4( m_InputImage, m_InputImage->GetBufferedRegion() );
1063 
1064  it1.GoToBegin();
1065  it2.GoToBegin();
1066  it3.GoToBegin();
1067  it4.GoToBegin();
1068 
1069  InputImageSizeType inputImageSize = m_InputImage->GetBufferedRegion().GetSize();
1070  m_ImageWidth = inputImageSize[0];
1071  m_ImageHeight = inputImageSize[1];
1072  m_ImageDepth = inputImageSize[2];
1073  int frame = m_ImageWidth * m_ImageHeight;
1074  int row = m_ImageWidth;
1075 
1076  int i = 0;
1077  int j;
1078 
1079  while ( i < frame )
1080  {
1081  ++it3;
1082  ++it4;
1083  i++;
1084  }
1085 
1086  i = 0;
1087 
1088  while ( i < row )
1089  {
1090  ++it2;
1091  ++it4;
1092  i++;
1093  }
1094 
1095  unsigned char vertexindex;
1096 
1097  if (m_CurrentRow)
1098  {
1099  for (i = 0; i < 200; i++)
1100  {
1101  free(m_CurrentRow[i]);
1102  }
1103  free (m_CurrentRow);
1104  }
1105  m_CurrentRow = ( unsigned long ** ) malloc( 200*sizeof(unsigned long *) );
1106  for ( i=0; i<200; i++ )
1107  {
1108  m_CurrentRow[i] = ( unsigned long * ) malloc( 2*sizeof( unsigned long ) );
1109  }
1110 
1111  if (m_CurrentFrame)
1112  {
1113  for (i = 0; i < 2000; i++)
1114  {
1115  free(m_CurrentFrame[i]);
1116  }
1117  free (m_CurrentFrame);
1118  }
1119 
1120  m_CurrentFrame = ( unsigned long ** ) malloc( 2000*sizeof(unsigned short *) );
1121 
1122  for ( i=0; i<2000; i++ )
1123  {
1124  m_CurrentFrame[i] = ( unsigned long * ) malloc( 2*sizeof( unsigned long ) );
1125  }
1126 
1127  i = 0;
1128 
1129  while ( !it4.IsAtEnd() )
1130  {
1131  vertexindex = 0;
1132 
1133  if ( it1.Value() == m_ObjectValue ) vertexindex += 1;
1134  if ( it2.Value() == m_ObjectValue ) vertexindex += 8;
1135  if ( it3.Value() == m_ObjectValue ) vertexindex += 16;
1136  if ( it4.Value() == m_ObjectValue ) vertexindex += 128;
1137  ++it1;
1138  ++it2;
1139  ++it3;
1140  ++it4;
1141 
1142 
1143  if (( i % m_ImageWidth < m_ImageWidth - 1 ) && ((i % (m_ImageWidth*m_ImageHeight)) / m_ImageWidth < m_ImageHeight - 1) )
1144  {
1145  if ( it1.Value() == m_ObjectValue ) vertexindex += 2;
1146  if ( it2.Value() == m_ObjectValue ) vertexindex += 4;
1147  if ( it3.Value() == m_ObjectValue ) vertexindex += 32;
1148  if ( it4.Value() == m_ObjectValue ) vertexindex += 64;
1149  }
1150  else
1151  {
1152  if ((i % (m_ImageWidth*m_ImageHeight)) / m_ImageWidth == m_ImageHeight - 1)
1153  {
1154  if ( vertexindex > 50 ) vertexindex -= 128;
1155  if ( ((vertexindex > 7) && (vertexindex < 10)) || (vertexindex > 17) ) vertexindex -= 8;
1156  if ( it1.Value() == m_ObjectValue ) vertexindex += 2;
1157  if ( it3.Value() == m_ObjectValue ) vertexindex += 32;
1158  }
1159  }
1160 
1161  for ( j=0; j<14; j++ ) m_CurrentVoxel[j] = 0;
1162 
1163  if ( ( vertexindex == 0 ) || (vertexindex == 255 ) )
1164  {
1165 // for ( j=0; j<13; j++ ) m_LastVoxel[j] = 0;
1166  }
1167  else
1168  {
1169  this->AddCells( m_LUT[vertexindex][0], m_LUT[vertexindex][1], i );
1170  }
1171  i++;
1172  }
1173 
1174  // This indicates that the current BufferedRegion is equal to the
1175  // requested region. This action prevents useless rexecutions of
1176  // the pipeline.
1177  this->GetOutput()->SetBufferedRegion( this->GetOutput()->GetRequestedRegion() );
1178 
1179 
1180 }
1181 
1182 template<class TInputImage, class TOutputMesh>
1183 void
1185 ::AddCells( unsigned char celltype, unsigned char celltran, int index )
1186 {
1187  int i;
1188  unsigned long **currentrowtmp;
1189  unsigned long **currentframetmp;
1190  currentrowtmp = ( unsigned long ** ) malloc( 4*sizeof(unsigned long *) );
1191  for ( i=0; i<4; i++ )
1192  {
1193  currentrowtmp[i] = ( unsigned long * ) malloc( 2*sizeof( unsigned long ) );
1194  currentrowtmp[i][0] = 0;
1195  currentrowtmp[i][1] = 0;
1196  }
1197  currentframetmp = ( unsigned long ** ) malloc( 4*sizeof(unsigned long *) );
1198  for ( i=0; i<4; i++ )
1199  {
1200  currentframetmp[i] = ( unsigned long * ) malloc( 2*sizeof( unsigned long ) );
1201  currentframetmp[i][0] = 0;
1202  currentframetmp[i][1] = 0;
1203  }
1204 
1205  if ( (index % m_ImageWidth == 0) || (index > m_LastVoxelIndex + 1) )
1206  {
1207  m_ColFlag = 0;
1208  for (i=0; i<14; i++)
1209  {
1210  m_LastVoxel[i] = 0;
1211  }
1212  }
1213  else
1214  {
1215  m_ColFlag = 1;
1216  }
1217 
1218  if ( ((index % (m_ImageWidth*m_ImageHeight)) < m_ImageWidth) ||
1219  ((index / m_ImageWidth) > m_LastRowIndex + 1) )
1220  {
1221  m_RowFlag = 0;
1222  }
1223  else
1224  {
1225  m_RowFlag = 1;
1226  }
1227 
1228  if ( ( index < m_ImageWidth*m_ImageHeight) ||
1229  ((index / (m_ImageWidth*m_ImageHeight)) > m_LastFrameIndex + 1) )
1230  {
1231  m_FrameFlag = 0;
1232  }
1233  else
1234  {
1235  m_FrameFlag = 1;
1236  }
1237 
1239  if ( m_RowFlag == 1 )
1240  {
1241  if ( (index / m_ImageWidth) != m_LastRowIndex )
1242  {
1243  if ( m_LastRowNum == 0 )
1244  {
1245  m_LastRow = ( unsigned long ** ) malloc( m_CurrentRowIndex*sizeof(unsigned long *) );
1246  }
1247  else
1248  {
1249  if (m_LastRowNum > m_CurrentRowIndex)
1250  {
1251  for (i = m_CurrentRowIndex; i < m_LastRowNum; i++)
1252  {
1253  free(m_LastRow[i]);
1254  }
1255  }
1256  m_LastRow = ( unsigned long ** ) realloc( m_LastRow, m_CurrentRowIndex*sizeof(unsigned long *) );
1257  }
1258  for ( i=0; i<m_CurrentRowIndex; i++ )
1259  {
1260  if ( i > m_LastRowNum-1 )
1261  {
1262  m_LastRow[i] = (unsigned long *) malloc( 2*sizeof( unsigned long ) );
1263  }
1264  m_LastRow[i][0] = m_CurrentRow[i][0];
1265  m_LastRow[i][1] = m_CurrentRow[i][1];
1266  }
1267  m_LastRowNum = m_CurrentRowIndex;
1268  m_CurrentRowIndex = 0;
1269  }
1270  }
1271  else
1272  {
1273  if ( m_ColFlag == 0 )
1274  {
1275  if ( m_LastRowNum > 0 )
1276  {
1277  for ( i=0; i<m_LastRowNum; i++ )
1278  {
1279  free (m_LastRow[i]);
1280  }
1281  free (m_LastRow);
1282  m_LastRow = NULL;
1283  }
1284  m_LastRowNum = 0;
1285  }
1286  }
1287 
1288  if ( m_FrameFlag == 1 )
1289  {
1290  if ( (index / (m_ImageWidth * m_ImageHeight)) != m_LastFrameIndex )
1291  {
1292  if ( m_LastFrameNum == 0 )
1293  {
1294  m_LastFrame = ( unsigned long ** ) malloc( m_CurrentFrameIndex*sizeof(unsigned long *) );
1295  }
1296  else
1297  {
1298  if (m_LastFrameNum > m_CurrentFrameIndex)
1299  {
1300  for (i = m_CurrentFrameIndex; i < m_LastFrameNum; i++)
1301  {
1302  free(m_LastFrame[i]);
1303  }
1304  }
1305  m_LastFrame = ( unsigned long ** ) realloc( m_LastFrame, m_CurrentFrameIndex*sizeof(unsigned long *) );
1306  }
1307  for ( i=0; i<m_CurrentFrameIndex; i++ )
1308  {
1309  if ( i > m_LastFrameNum-1 )
1310  {
1311  m_LastFrame[i] = ( unsigned long * ) malloc( 2*sizeof( unsigned long ) );
1312  }
1313  m_LastFrame[i][0] = m_CurrentFrame[i][0];
1314  m_LastFrame[i][1] = m_CurrentFrame[i][1];
1315  }
1316  m_LastFrameNum = m_CurrentFrameIndex;
1317  m_CurrentFrameIndex = 0;
1318  }
1319  }
1320  else
1321  {
1322  if ( index % (m_ImageWidth * m_ImageHeight) == 0 )
1323  {
1324  for ( i=0; i<m_LastFrameNum; i++ )
1325  {
1326  free (m_LastFrame[i]);
1327  }
1328  free (m_LastFrame);
1329  m_LastFrame = 0;
1330  }
1331  }
1332 
1333  m_LastVoxelIndex = index;
1334  m_LastRowIndex = index / m_ImageWidth;
1335  m_LastFrameIndex = index / (m_ImageWidth*m_ImageHeight);
1336 
1337  m_AvailableNodes[1] = 0;
1338  m_AvailableNodes[2] = 0;
1339  m_AvailableNodes[3] = 0;
1340  m_AvailableNodes[4] = 0;
1341  m_AvailableNodes[5] = 0;
1342  m_AvailableNodes[6] = 1;
1343  m_AvailableNodes[7] = 1;
1344  m_AvailableNodes[8] = 0;
1345  m_AvailableNodes[9] = 0;
1346  m_AvailableNodes[10] = 0;
1347  m_AvailableNodes[11] = 1;
1348  m_AvailableNodes[12] = 0;
1349  m_AvailableNodes[13] = 1;
1350 
1351  if ( m_ColFlag == 0 )
1352  {
1353  m_AvailableNodes[4] = 1;
1354  m_AvailableNodes[8] = 1;
1355  m_AvailableNodes[9] = 1;
1356  m_AvailableNodes[12] = 1;
1357  }
1358 
1359  if ( m_RowFlag == 0 )
1360  {
1361  m_AvailableNodes[1] = 1;
1362  m_AvailableNodes[5] = 1;
1363  m_AvailableNodes[9] = 1;
1364  m_AvailableNodes[10] = 1;
1365  }
1366 
1367 
1368  if ( m_FrameFlag == 0 )
1369  {
1370  m_AvailableNodes[1] = 1;
1371  m_AvailableNodes[2] = 1;
1372  m_AvailableNodes[3] = 1;
1373  m_AvailableNodes[4] = 1;
1374  }
1375 
1376  typename TriCell::CellAutoPointer insertCell;
1377  unsigned long tripoints[3];
1378  unsigned char *tp;
1379  tp = (unsigned char *) malloc( 3*sizeof( unsigned char ) );
1380 
1381  unsigned long *tpl;
1382  tpl = (unsigned long *) malloc( 3*sizeof( unsigned long ) );
1383 
1384  switch ( (int) celltype )
1385  {
1386  case 1:
1387  tp[0] = 1;
1388  tp[1] = 9;
1389  tp[2] = 4;
1390  CellTransfer( tp, celltran );
1391  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1392  tripoints[0] = tpl[0];
1393  tripoints[1] = tpl[2];
1394  tripoints[2] = tpl[1];
1395  insertCell.TakeOwnership( new TriCell );
1396  insertCell->SetPointIds(tripoints);
1397  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1398  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1399  m_NumberOfCells++;
1400  break;
1401  case 2:
1402  tp[0] = 4;
1403  tp[1] = 2;
1404  tp[2] = 9;
1405  CellTransfer( tp, celltran );
1406  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1407  tripoints[0] = tpl[0];
1408  tripoints[1] = tpl[2];
1409  tripoints[2] = tpl[1];
1410  insertCell.TakeOwnership( new TriCell );
1411  insertCell->SetPointIds(tripoints);
1412  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1413  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1414  m_NumberOfCells++;
1415  tp[0] = 10;
1416  tp[1] = 9;
1417  tp[2] = 2;
1418  CellTransfer( tp, celltran );
1419  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1420  tripoints[0] = tpl[0];
1421  tripoints[1] = tpl[2];
1422  tripoints[2] = tpl[1];
1423  insertCell.TakeOwnership( new TriCell );
1424  insertCell->SetPointIds(tripoints);
1425  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1426  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1427  m_NumberOfCells++;
1428  break;
1429  case 3:
1430  tp[0] = 1;
1431  tp[1] = 9;
1432  tp[2] = 4;
1433  CellTransfer( tp, celltran );
1434  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1435  tripoints[0] = tpl[0];
1436  tripoints[1] = tpl[2];
1437  tripoints[2] = tpl[1];
1438  insertCell.TakeOwnership( new TriCell );
1439  insertCell->SetPointIds(tripoints);
1440  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1441  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1442  m_NumberOfCells++;
1443  tp[0] = 2;
1444  tp[1] = 3;
1445  tp[2] = 11;
1446  CellTransfer( tp, celltran );
1447  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1448  tripoints[0] = tpl[0];
1449  tripoints[1] = tpl[2];
1450  tripoints[2] = tpl[1];
1451  insertCell.TakeOwnership( new TriCell );
1452  insertCell->SetPointIds(tripoints);
1453  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1454  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1455  m_NumberOfCells++;
1456  break;
1457  case 4:
1458  tp[0] = 1;
1459  tp[1] = 9;
1460  tp[2] = 4;
1461  CellTransfer( tp, celltran );
1462  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1463  tripoints[0] = tpl[0];
1464  tripoints[1] = tpl[2];
1465  tripoints[2] = tpl[1];
1466  insertCell.TakeOwnership( new TriCell );
1467  insertCell->SetPointIds(tripoints);
1468  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1469  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1470  m_NumberOfCells++;
1471  tp[0] = 6;
1472  tp[1] = 11;
1473  tp[2] = 7;
1474  CellTransfer( tp, celltran );
1475  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1476  tripoints[0] = tpl[0];
1477  tripoints[1] = tpl[2];
1478  tripoints[2] = tpl[1];
1479  insertCell.TakeOwnership( new TriCell );
1480  insertCell->SetPointIds(tripoints);
1481  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1482  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1483  m_NumberOfCells++;
1484  break;
1485  case 5:
1486  tp[0] = 1;
1487  tp[1] = 2;
1488  tp[2] = 13;
1489  CellTransfer( tp, celltran );
1490  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1491  tripoints[0] = tpl[0];
1492  tripoints[1] = tpl[2];
1493  tripoints[2] = tpl[1];
1494  insertCell.TakeOwnership( new TriCell );
1495  insertCell->SetPointIds(tripoints);
1496  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1497  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1498  m_NumberOfCells++;
1499  tp[0] = 1;
1500  tp[1] = 13;
1501  tp[2] = 9;
1502  CellTransfer( tp, celltran );
1503  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1504  tripoints[0] = tpl[0];
1505  tripoints[1] = tpl[2];
1506  tripoints[2] = tpl[1];
1507  insertCell.TakeOwnership( new TriCell );
1508  insertCell->SetPointIds(tripoints);
1509  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1510  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1511  m_NumberOfCells++;
1512  tp[0] = 9;
1513  tp[1] = 13;
1514  tp[2] = 8;
1515  CellTransfer( tp, celltran );
1516  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1517  tripoints[0] = tpl[0];
1518  tripoints[1] = tpl[2];
1519  tripoints[2] = tpl[1];
1520  insertCell.TakeOwnership( new TriCell );
1521  insertCell->SetPointIds(tripoints);
1522  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1523  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1524  m_NumberOfCells++;
1525  tp[0] = 13;
1526  tp[1] = 2;
1527  tp[2] = 6;
1528  CellTransfer( tp, celltran );
1529  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1530  tripoints[0] = tpl[0];
1531  tripoints[1] = tpl[2];
1532  tripoints[2] = tpl[1];
1533  insertCell.TakeOwnership( new TriCell );
1534  insertCell->SetPointIds(tripoints);
1535  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1536  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1537  m_NumberOfCells++;
1538  tp[0] = 13;
1539  tp[1] = 6;
1540  tp[2] = 8;
1541  CellTransfer( tp, celltran );
1542  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1543  tripoints[0] = tpl[0];
1544  tripoints[1] = tpl[2];
1545  tripoints[2] = tpl[1];
1546  insertCell.TakeOwnership( new TriCell );
1547  insertCell->SetPointIds(tripoints);
1548  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1549  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1550  m_NumberOfCells++;
1551  break;
1552  case 6:
1553  tp[0] = 10;
1554  tp[1] = 9;
1555  tp[2] = 2;
1556  CellTransfer( tp, celltran );
1557  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1558  tripoints[0] = tpl[0];
1559  tripoints[1] = tpl[2];
1560  tripoints[2] = tpl[1];
1561  insertCell.TakeOwnership( new TriCell );
1562  insertCell->SetPointIds(tripoints);
1563  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1564  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1565  m_NumberOfCells++;
1566  tp[0] = 4;
1567  tp[1] = 2;
1568  tp[2] = 9;
1569  CellTransfer( tp, celltran );
1570  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1571  tripoints[0] = tpl[0];
1572  tripoints[1] = tpl[2];
1573  tripoints[2] = tpl[1];
1574  insertCell.TakeOwnership( new TriCell );
1575  insertCell->SetPointIds(tripoints);
1576  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1577  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1578  m_NumberOfCells++;
1579  tp[0] = 6;
1580  tp[1] = 11;
1581  tp[2] = 7;
1582  CellTransfer( tp, celltran );
1583  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1584  tripoints[0] = tpl[0];
1585  tripoints[1] = tpl[2];
1586  tripoints[2] = tpl[1];
1587  insertCell.TakeOwnership( new TriCell );
1588  insertCell->SetPointIds(tripoints);
1589  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1590  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1591  m_NumberOfCells++;
1592  break;
1593  case 7:
1594  tp[0] = 1;
1595  tp[1] = 2;
1596  tp[2] = 10;
1597  CellTransfer( tp, celltran );
1598  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1599  tripoints[0] = tpl[0];
1600  tripoints[1] = tpl[2];
1601  tripoints[2] = tpl[1];
1602  insertCell.TakeOwnership( new TriCell );
1603  insertCell->SetPointIds(tripoints);
1604  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1605  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1606  m_NumberOfCells++;
1607  tp[0] = 6;
1608  tp[1] = 11;
1609  tp[2] = 7;
1610  CellTransfer( tp, celltran );
1611  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1612  tripoints[0] = tpl[0];
1613  tripoints[1] = tpl[2];
1614  tripoints[2] = tpl[1];
1615  insertCell.TakeOwnership( new TriCell );
1616  insertCell->SetPointIds(tripoints);
1617  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1618  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1619  m_NumberOfCells++;
1620  tp[0] = 3;
1621  tp[1] = 4;
1622  tp[2] = 12;
1623  CellTransfer( tp, celltran );
1624  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1625  tripoints[0] = tpl[0];
1626  tripoints[1] = tpl[2];
1627  tripoints[2] = tpl[1];
1628  insertCell.TakeOwnership( new TriCell );
1629  insertCell->SetPointIds(tripoints);
1630  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1631  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1632  m_NumberOfCells++;
1633  break;
1634  case 8:
1635  tp[0] = 13;
1636  tp[1] = 2;
1637  tp[2] = 6;
1638  CellTransfer( tp, celltran );
1639  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1640  tripoints[0] = tpl[0];
1641  tripoints[1] = tpl[2];
1642  tripoints[2] = tpl[1];
1643  insertCell.TakeOwnership( new TriCell );
1644  insertCell->SetPointIds(tripoints);
1645  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1646  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1647  m_NumberOfCells++;
1648  tp[0] = 13;
1649  tp[1] = 6;
1650  tp[2] = 8;
1651  CellTransfer( tp, celltran );
1652  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1653  tripoints[0] = tpl[0];
1654  tripoints[1] = tpl[2];
1655  tripoints[2] = tpl[1];
1656  insertCell.TakeOwnership( new TriCell );
1657  insertCell->SetPointIds(tripoints);
1658  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1659  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1660  m_NumberOfCells++;
1661  tp[0] = 13;
1662  tp[1] = 8;
1663  tp[2] = 4;
1664  CellTransfer( tp, celltran );
1665  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1666  tripoints[0] = tpl[0];
1667  tripoints[1] = tpl[2];
1668  tripoints[2] = tpl[1];
1669  insertCell.TakeOwnership( new TriCell );
1670  insertCell->SetPointIds(tripoints);
1671  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1672  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1673  m_NumberOfCells++;
1674  tp[0] = 13;
1675  tp[1] = 4;
1676  tp[2] = 2;
1677  CellTransfer( tp, celltran );
1678  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1679  tripoints[0] = tpl[0];
1680  tripoints[1] = tpl[2];
1681  tripoints[2] = tpl[1];
1682  insertCell.TakeOwnership( new TriCell );
1683  insertCell->SetPointIds(tripoints);
1684  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1685  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1686  m_NumberOfCells++;
1687  break;
1688  case 9:
1689  tp[0] = 1;
1690  tp[1] = 10;
1691  tp[2] = 13;
1692  CellTransfer( tp, celltran );
1693  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1694  tripoints[0] = tpl[0];
1695  tripoints[1] = tpl[2];
1696  tripoints[2] = tpl[1];
1697  insertCell.TakeOwnership( new TriCell );
1698  insertCell->SetPointIds(tripoints);
1699  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1700  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1701  m_NumberOfCells++;
1702  tp[0] = 10;
1703  tp[1] = 6;
1704  tp[2] = 13;
1705  CellTransfer( tp, celltran );
1706  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1707  tripoints[0] = tpl[0];
1708  tripoints[1] = tpl[2];
1709  tripoints[2] = tpl[1];
1710  insertCell.TakeOwnership( new TriCell );
1711  insertCell->SetPointIds(tripoints);
1712  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1713  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1714  m_NumberOfCells++;
1715  tp[0] = 6;
1716  tp[1] = 7;
1717  tp[2] = 13;
1718  CellTransfer( tp, celltran );
1719  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1720  tripoints[0] = tpl[0];
1721  tripoints[1] = tpl[2];
1722  tripoints[2] = tpl[1];
1723  insertCell.TakeOwnership( new TriCell );
1724  insertCell->SetPointIds(tripoints);
1725  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1726  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1727  m_NumberOfCells++;
1728  tp[0] = 7;
1729  tp[1] = 12;
1730  tp[2] = 13;
1731  CellTransfer( tp, celltran );
1732  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1733  tripoints[0] = tpl[0];
1734  tripoints[1] = tpl[2];
1735  tripoints[2] = tpl[1];
1736  insertCell.TakeOwnership( new TriCell );
1737  insertCell->SetPointIds(tripoints);
1738  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1739  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1740  m_NumberOfCells++;
1741  tp[0] = 12;
1742  tp[1] = 4;
1743  tp[2] = 13;
1744  CellTransfer( tp, celltran );
1745  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1746  tripoints[0] = tpl[0];
1747  tripoints[1] = tpl[2];
1748  tripoints[2] = tpl[1];
1749  insertCell.TakeOwnership( new TriCell );
1750  insertCell->SetPointIds(tripoints);
1751  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1752  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1753  m_NumberOfCells++;
1754  tp[0] = 1;
1755  tp[1] = 13;
1756  tp[2] = 4;
1757  CellTransfer( tp, celltran );
1758  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1759  tripoints[0] = tpl[0];
1760  tripoints[1] = tpl[2];
1761  tripoints[2] = tpl[1];
1762  insertCell.TakeOwnership( new TriCell );
1763  insertCell->SetPointIds(tripoints);
1764  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1765  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1766  m_NumberOfCells++;
1767  break;
1768  case 10:
1769  tp[0] = 1;
1770  tp[1] = 9;
1771  tp[2] = 3;
1772  CellTransfer( tp, celltran );
1773  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1774  tripoints[0] = tpl[0];
1775  tripoints[1] = tpl[2];
1776  tripoints[2] = tpl[1];
1777  insertCell.TakeOwnership( new TriCell );
1778  insertCell->SetPointIds(tripoints);
1779  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1780  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1781  m_NumberOfCells++;
1782  tp[0] = 9;
1783  tp[1] = 12;
1784  tp[2] = 3;
1785  CellTransfer( tp, celltran );
1786  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1787  tripoints[0] = tpl[0];
1788  tripoints[1] = tpl[2];
1789  tripoints[2] = tpl[1];
1790  insertCell.TakeOwnership( new TriCell );
1791  insertCell->SetPointIds(tripoints);
1792  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1793  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1794  m_NumberOfCells++;
1795  tp[0] = 5;
1796  tp[1] = 10;
1797  tp[2] = 7;
1798  CellTransfer( tp, celltran );
1799  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1800  tripoints[0] = tpl[0];
1801  tripoints[1] = tpl[2];
1802  tripoints[2] = tpl[1];
1803  insertCell.TakeOwnership( new TriCell );
1804  insertCell->SetPointIds(tripoints);
1805  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1806  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1807  m_NumberOfCells++;
1808  tp[0] = 10;
1809  tp[1] = 11;
1810  tp[2] = 7;
1811  CellTransfer( tp, celltran );
1812  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1813  tripoints[0] = tpl[0];
1814  tripoints[1] = tpl[2];
1815  tripoints[2] = tpl[1];
1816  insertCell.TakeOwnership( new TriCell );
1817  insertCell->SetPointIds(tripoints);
1818  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1819  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1820  m_NumberOfCells++;
1821  break;
1822  case 11:
1823  tp[0] = 1;
1824  tp[1] = 10;
1825  tp[2] = 13;
1826  CellTransfer( tp, celltran );
1827  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1828  tripoints[0] = tpl[0];
1829  tripoints[1] = tpl[2];
1830  tripoints[2] = tpl[1];
1831  insertCell.TakeOwnership( new TriCell );
1832  insertCell->SetPointIds(tripoints);
1833  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1834  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1835  m_NumberOfCells++;
1836  tp[0] = 13;
1837  tp[1] = 10;
1838  tp[2] = 11;
1839  CellTransfer( tp, celltran );
1840  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1841  tripoints[0] = tpl[0];
1842  tripoints[1] = tpl[2];
1843  tripoints[2] = tpl[1];
1844  insertCell.TakeOwnership( new TriCell );
1845  insertCell->SetPointIds(tripoints);
1846  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1847  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1848  m_NumberOfCells++;
1849  tp[0] = 7;
1850  tp[1] = 13;
1851  tp[2] = 11;
1852  CellTransfer( tp, celltran );
1853  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1854  tripoints[0] = tpl[0];
1855  tripoints[1] = tpl[2];
1856  tripoints[2] = tpl[1];
1857  insertCell.TakeOwnership( new TriCell );
1858  insertCell->SetPointIds(tripoints);
1859  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1860  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1861  m_NumberOfCells++;
1862  tp[0] = 7;
1863  tp[1] = 8;
1864  tp[2] = 13;
1865  CellTransfer( tp, celltran );
1866  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1867  tripoints[0] = tpl[0];
1868  tripoints[1] = tpl[2];
1869  tripoints[2] = tpl[1];
1870  insertCell.TakeOwnership( new TriCell );
1871  insertCell->SetPointIds(tripoints);
1872  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1873  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1874  m_NumberOfCells++;
1875  tp[0] = 13;
1876  tp[1] = 8;
1877  tp[2] = 4;
1878  CellTransfer( tp, celltran );
1879  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1880  tripoints[0] = tpl[0];
1881  tripoints[1] = tpl[2];
1882  tripoints[2] = tpl[1];
1883  insertCell.TakeOwnership( new TriCell );
1884  insertCell->SetPointIds(tripoints);
1885  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1886  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1887  m_NumberOfCells++;
1888  tp[0] = 1;
1889  tp[1] = 13;
1890  tp[2] = 4;
1891  CellTransfer( tp, celltran );
1892  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1893  tripoints[0] = tpl[0];
1894  tripoints[1] = tpl[2];
1895  tripoints[2] = tpl[1];
1896  insertCell.TakeOwnership( new TriCell );
1897  insertCell->SetPointIds(tripoints);
1898  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1899  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1900  m_NumberOfCells++;
1901  break;
1902  case 12:
1903  tp[0] = 1;
1904  tp[1] = 2;
1905  tp[2] = 13;
1906  CellTransfer( tp, celltran );
1907  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1908  tripoints[0] = tpl[0];
1909  tripoints[1] = tpl[2];
1910  tripoints[2] = tpl[1];
1911  insertCell.TakeOwnership( new TriCell );
1912  insertCell->SetPointIds(tripoints);
1913  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1914  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1915  m_NumberOfCells++;
1916  tp[0] = 1;
1917  tp[1] = 13;
1918  tp[2] = 9;
1919  CellTransfer( tp, celltran );
1920  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1921  tripoints[0] = tpl[0];
1922  tripoints[1] = tpl[2];
1923  tripoints[2] = tpl[1];
1924  insertCell.TakeOwnership( new TriCell );
1925  insertCell->SetPointIds(tripoints);
1926  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1927  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1928  m_NumberOfCells++;
1929  tp[0] = 9;
1930  tp[1] = 13;
1931  tp[2] = 8;
1932  CellTransfer( tp, celltran );
1933  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1934  tripoints[0] = tpl[0];
1935  tripoints[1] = tpl[2];
1936  tripoints[2] = tpl[1];
1937  insertCell.TakeOwnership( new TriCell );
1938  insertCell->SetPointIds(tripoints);
1939  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1940  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1941  m_NumberOfCells++;
1942  tp[0] = 13;
1943  tp[1] = 2;
1944  tp[2] = 6;
1945  CellTransfer( tp, celltran );
1946  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1947  tripoints[0] = tpl[0];
1948  tripoints[1] = tpl[2];
1949  tripoints[2] = tpl[1];
1950  insertCell.TakeOwnership( new TriCell );
1951  insertCell->SetPointIds(tripoints);
1952  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1953  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1954  m_NumberOfCells++;
1955  tp[0] = 13;
1956  tp[1] = 6;
1957  tp[2] = 8;
1958  CellTransfer( tp, celltran );
1959  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1960  tripoints[0] = tpl[0];
1961  tripoints[1] = tpl[2];
1962  tripoints[2] = tpl[1];
1963  insertCell.TakeOwnership( new TriCell );
1964  insertCell->SetPointIds(tripoints);
1965  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1966  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1967  m_NumberOfCells++;
1968  tp[0] = 3;
1969  tp[1] = 4;
1970  tp[2] = 12;
1971  CellTransfer( tp, celltran );
1972  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1973  tripoints[0] = tpl[0];
1974  tripoints[1] = tpl[2];
1975  tripoints[2] = tpl[1];
1976  insertCell.TakeOwnership( new TriCell );
1977  insertCell->SetPointIds(tripoints);
1978  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1979  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1980  m_NumberOfCells++;
1981  break;
1982  case 13:
1983  tp[0] = 1;
1984  tp[1] = 9;
1985  tp[2] = 4;
1986  CellTransfer( tp, celltran );
1987  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
1988  tripoints[0] = tpl[0];
1989  tripoints[1] = tpl[2];
1990  tripoints[2] = tpl[1];
1991  insertCell.TakeOwnership( new TriCell );
1992  insertCell->SetPointIds(tripoints);
1993  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
1994  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
1995  m_NumberOfCells++;
1996  tp[0] = 5;
1997  tp[1] = 10;
1998  tp[2] = 6;
1999  CellTransfer( tp, celltran );
2000  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
2001  tripoints[0] = tpl[0];
2002  tripoints[1] = tpl[2];
2003  tripoints[2] = tpl[1];
2004  insertCell.TakeOwnership( new TriCell );
2005  insertCell->SetPointIds(tripoints);
2006  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
2007  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
2008  m_NumberOfCells++;
2009  tp[0] = 2;
2010  tp[1] = 3;
2011  tp[2] = 11;
2012  CellTransfer( tp, celltran );
2013  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
2014  tripoints[0] = tpl[0];
2015  tripoints[1] = tpl[2];
2016  tripoints[2] = tpl[1];
2017  insertCell.TakeOwnership( new TriCell );
2018  insertCell->SetPointIds(tripoints);
2019  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
2020  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
2021  m_NumberOfCells++;
2022  tp[0] = 8;
2023  tp[1] = 7;
2024  tp[2] = 12;
2025  CellTransfer( tp, celltran );
2026  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
2027  tripoints[0] = tpl[0];
2028  tripoints[1] = tpl[2];
2029  tripoints[2] = tpl[1];
2030  insertCell.TakeOwnership( new TriCell );
2031  insertCell->SetPointIds(tripoints);
2032  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
2033  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
2034  m_NumberOfCells++;
2035  break;
2036  case 14:
2037  tp[0] = 1;
2038  tp[1] = 10;
2039  tp[2] = 13;
2040  CellTransfer( tp, celltran );
2041  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
2042  tripoints[0] = tpl[0];
2043  tripoints[1] = tpl[2];
2044  tripoints[2] = tpl[1];
2045  insertCell.TakeOwnership( new TriCell );
2046  insertCell->SetPointIds(tripoints);
2047  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
2048  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
2049  m_NumberOfCells++;
2050  tp[0] = 10;
2051  tp[1] = 6;
2052  tp[2] = 13;
2053  CellTransfer( tp, celltran );
2054  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
2055  tripoints[0] = tpl[0];
2056  tripoints[1] = tpl[2];
2057  tripoints[2] = tpl[1];
2058  insertCell.TakeOwnership( new TriCell );
2059  insertCell->SetPointIds(tripoints);
2060  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
2061  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
2062  m_NumberOfCells++;
2063  tp[0] = 6;
2064  tp[1] = 7;
2065  tp[2] = 13;
2066  CellTransfer( tp, celltran );
2067  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
2068  tripoints[0] = tpl[0];
2069  tripoints[1] = tpl[2];
2070  tripoints[2] = tpl[1];
2071  insertCell.TakeOwnership( new TriCell );
2072  insertCell->SetPointIds(tripoints);
2073  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
2074  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
2075  m_NumberOfCells++;
2076  tp[0] = 7;
2077  tp[1] = 12;
2078  tp[2] = 13;
2079  CellTransfer( tp, celltran );
2080  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
2081  tripoints[0] = tpl[0];
2082  tripoints[1] = tpl[2];
2083  tripoints[2] = tpl[1];
2084  insertCell.TakeOwnership( new TriCell );
2085  insertCell->SetPointIds(tripoints);
2086  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
2087  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
2088  m_NumberOfCells++;
2089  tp[0] = 12;
2090  tp[1] = 4;
2091  tp[2] = 13;
2092  CellTransfer( tp, celltran );
2093  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
2094  tripoints[0] = tpl[0];
2095  tripoints[1] = tpl[2];
2096  tripoints[2] = tpl[1];
2097  insertCell.TakeOwnership( new TriCell );
2098  insertCell->SetPointIds(tripoints);
2099  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
2100  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
2101  m_NumberOfCells++;
2102  tp[0] = 1;
2103  tp[1] = 13;
2104  tp[2] = 4;
2105  CellTransfer( tp, celltran );
2106  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
2107  tripoints[0] = tpl[0];
2108  tripoints[1] = tpl[2];
2109  tripoints[2] = tpl[1];
2110  insertCell.TakeOwnership( new TriCell );
2111  insertCell->SetPointIds(tripoints);
2112  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
2113  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
2114  m_NumberOfCells++;
2115  tp[0] = 2;
2116  tp[1] = 3;
2117  tp[2] = 11;
2118  CellTransfer( tp, celltran );
2119  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
2120  tripoints[0] = tpl[0];
2121  tripoints[1] = tpl[2];
2122  tripoints[2] = tpl[1];
2123  insertCell.TakeOwnership( new TriCell );
2124  insertCell->SetPointIds(tripoints);
2125  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
2126  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
2127  m_NumberOfCells++;
2128  break;
2129  case 15:
2130  tp[0] = 1;
2131  tp[1] = 10;
2132  tp[2] = 13;
2133  CellTransfer( tp, celltran );
2134  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
2135  tripoints[0] = tpl[0];
2136  tripoints[1] = tpl[2];
2137  tripoints[2] = tpl[1];
2138  insertCell.TakeOwnership( new TriCell );
2139  insertCell->SetPointIds(tripoints);
2140  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
2141  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
2142  m_NumberOfCells++;
2143  tp[0] = 2;
2144  tp[1] = 13;
2145  tp[2] = 10;
2146  CellTransfer( tp, celltran );
2147  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
2148  tripoints[0] = tpl[0];
2149  tripoints[1] = tpl[2];
2150  tripoints[2] = tpl[1];
2151  insertCell.TakeOwnership( new TriCell );
2152  insertCell->SetPointIds(tripoints);
2153  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
2154  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
2155  m_NumberOfCells++;
2156  tp[0] = 2;
2157  tp[1] = 3;
2158  tp[2] = 13;
2159  CellTransfer( tp, celltran );
2160  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
2161  tripoints[0] = tpl[0];
2162  tripoints[1] = tpl[2];
2163  tripoints[2] = tpl[1];
2164  insertCell.TakeOwnership( new TriCell );
2165  insertCell->SetPointIds(tripoints);
2166  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
2167  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
2168  m_NumberOfCells++;
2169  tp[0] = 3;
2170  tp[1] = 12;
2171  tp[2] = 13;
2172  CellTransfer( tp, celltran );
2173  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
2174  tripoints[0] = tpl[0];
2175  tripoints[1] = tpl[2];
2176  tripoints[2] = tpl[1];
2177  insertCell.TakeOwnership( new TriCell );
2178  insertCell->SetPointIds(tripoints);
2179  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
2180  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
2181  m_NumberOfCells++;
2182  tp[0] = 4;
2183  tp[1] = 13;
2184  tp[2] = 12;
2185  CellTransfer( tp, celltran );
2186  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
2187  tripoints[0] = tpl[0];
2188  tripoints[1] = tpl[2];
2189  tripoints[2] = tpl[1];
2190  insertCell.TakeOwnership( new TriCell );
2191  insertCell->SetPointIds(tripoints);
2192  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
2193  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
2194  m_NumberOfCells++;
2195  tp[0] = 1;
2196  tp[1] = 13;
2197  tp[2] = 4;
2198  CellTransfer( tp, celltran );
2199  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
2200  tripoints[0] = tpl[0];
2201  tripoints[1] = tpl[2];
2202  tripoints[2] = tpl[1];
2203  insertCell.TakeOwnership( new TriCell );
2204  insertCell->SetPointIds(tripoints);
2205  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
2206  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
2207  m_NumberOfCells++;
2208  break;
2209  case 16:
2210  tp[0] = 13;
2211  tp[1] = 1;
2212  tp[2] = 5;
2213  CellTransfer( tp, celltran );
2214  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
2215  tripoints[0] = tpl[0];
2216  tripoints[1] = tpl[2];
2217  tripoints[2] = tpl[1];
2218  insertCell.TakeOwnership( new TriCell );
2219  insertCell->SetPointIds(tripoints);
2220  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
2221  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
2222  m_NumberOfCells++;
2223  tp[0] = 5;
2224  tp[1] = 6;
2225  tp[2] = 13;
2226  CellTransfer( tp, celltran );
2227  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
2228  tripoints[0] = tpl[0];
2229  tripoints[1] = tpl[2];
2230  tripoints[2] = tpl[1];
2231  insertCell.TakeOwnership( new TriCell );
2232  insertCell->SetPointIds(tripoints);
2233  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
2234  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
2235  m_NumberOfCells++;
2236  tp[0] = 13;
2237  tp[1] = 6;
2238  tp[2] = 2;
2239  CellTransfer( tp, celltran );
2240  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
2241  tripoints[0] = tpl[0];
2242  tripoints[1] = tpl[2];
2243  tripoints[2] = tpl[1];
2244  insertCell.TakeOwnership( new TriCell );
2245  insertCell->SetPointIds(tripoints);
2246  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
2247  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
2248  m_NumberOfCells++;
2249  tp[0] = 2;
2250  tp[1] = 3;
2251  tp[2] = 13;
2252  CellTransfer( tp, celltran );
2253  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
2254  tripoints[0] = tpl[0];
2255  tripoints[1] = tpl[2];
2256  tripoints[2] = tpl[1];
2257  insertCell.TakeOwnership( new TriCell );
2258  insertCell->SetPointIds(tripoints);
2259  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
2260  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
2261  m_NumberOfCells++;
2262  tp[0] = 3;
2263  tp[1] = 12;
2264  tp[2] = 13;
2265  CellTransfer( tp, celltran );
2266  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
2267  tripoints[0] = tpl[0];
2268  tripoints[1] = tpl[2];
2269  tripoints[2] = tpl[1];
2270  insertCell.TakeOwnership( new TriCell );
2271  insertCell->SetPointIds(tripoints);
2272  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
2273  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
2274  m_NumberOfCells++;
2275  tp[0] = 4;
2276  tp[1] = 13;
2277  tp[2] = 12;
2278  CellTransfer( tp, celltran );
2279  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
2280  tripoints[0] = tpl[0];
2281  tripoints[1] = tpl[2];
2282  tripoints[2] = tpl[1];
2283  insertCell.TakeOwnership( new TriCell );
2284  insertCell->SetPointIds(tripoints);
2285  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
2286  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
2287  m_NumberOfCells++;
2288  tp[0] = 1;
2289  tp[1] = 13;
2290  tp[2] = 4;
2291  CellTransfer( tp, celltran );
2292  AddNodes(index, tp, tpl, currentrowtmp, currentframetmp);
2293  tripoints[0] = tpl[0];
2294  tripoints[1] = tpl[2];
2295  tripoints[2] = tpl[1];
2296  insertCell.TakeOwnership( new TriCell );
2297  insertCell->SetPointIds(tripoints);
2298  this->GetOutput()->SetCell(m_NumberOfCells, insertCell);
2299  this->GetOutput()->SetCellData(m_NumberOfCells, 0.0);
2300  m_NumberOfCells++;
2301  break;
2302  }
2303 
2304  i = 0;
2305  int j;
2306  while (i < 4)
2307  {
2308  if ( currentrowtmp[i][0] != 0 )
2309  {
2310  m_CurrentRow[m_CurrentRowIndex][1] = currentrowtmp[i][1];
2311  m_CurrentRow[m_CurrentRowIndex++][0] = currentrowtmp[i][0];
2312  if ( m_CurrentRowIndex == m_CurrentRowNum )
2313  {
2314  m_CurrentRowNum += 100;
2315  m_CurrentRow = (unsigned long **) realloc(m_CurrentRow, sizeof(unsigned long *) * m_CurrentRowNum);
2316  for ( j = m_CurrentRowIndex; j < m_CurrentRowNum; j++ ) m_CurrentRow[j] = (unsigned long *) malloc(sizeof(unsigned long) * 2);
2317  }
2318  }
2319 
2320  if ( currentframetmp[i][0] != 0 )
2321  {
2322  m_CurrentFrame[m_CurrentFrameIndex][1] = currentframetmp[i][1];
2323  m_CurrentFrame[m_CurrentFrameIndex++][0] = currentframetmp[i][0];
2324  if ( m_CurrentFrameIndex == m_CurrentFrameNum )
2325  {
2326  m_CurrentFrameNum += 1000;
2327  m_CurrentFrame = (unsigned long **) realloc(m_CurrentFrame, sizeof(unsigned long *) * m_CurrentFrameNum);
2328  for ( j = m_CurrentFrameIndex; j < m_CurrentFrameNum; j++ ) m_CurrentFrame[j] = (unsigned long *) malloc(sizeof(unsigned long) * 2);
2329  }
2330  }
2331 
2332  i++;
2333  }
2334 
2335  for ( i=0; i<4; i++ )
2336  {
2337  free (currentrowtmp[i]);
2338  }
2339  free (currentrowtmp);
2340 
2341  for ( i=0; i<4; i++ )
2342  {
2343  free (currentframetmp[i]);
2344  }
2345 
2346  free (currentframetmp);
2347 
2348  free (tp);
2349  free (tpl);
2350 
2351  m_LastVoxel[4] = m_CurrentVoxel[2];
2352  m_LastVoxel[9] = m_CurrentVoxel[10];
2353  m_LastVoxel[8] = m_CurrentVoxel[6];
2354  m_LastVoxel[12] = m_CurrentVoxel[11];
2355  for ( i=1; i<14; i++ ) m_CurrentVoxel[i] = 0;
2356 }
2357 
2358 template<class TInputImage, class TOutputMesh>
2359 void
2361 ::AddNodes( int index, unsigned char *nodesid, unsigned long *globalnodesid, unsigned long **currentrowtmp, unsigned long **currentframetmp )
2362 {
2363  int i;
2364  OPointType new_p;
2365 
2366  for ( i=0; i<3; i++ )
2367  {
2368  m_PointFound = 0;
2369  if ( m_AvailableNodes[nodesid[i]] != 0 )
2370  {
2371  m_PointFound = 1;
2372 
2373  OPointType indTemp;
2374  indTemp[0] = m_LocationOffset[nodesid[i]][0]
2375  + ( index % m_ImageWidth );
2376  indTemp[1] = m_LocationOffset[nodesid[i]][1]
2377  + ( (index % (m_ImageWidth*m_ImageHeight)) / m_ImageWidth );
2378  indTemp[2] = m_LocationOffset[nodesid[i]][2]
2379  + ( index / (m_ImageWidth*m_ImageHeight) );
2380 
2381  // We transform the point to the physical space since the mesh does not have the notion
2382  // of spacing and origin
2383  //this->GetInput(0)->TransformIndexToPhysicalPoint(indTemp,new_p);
2384 
2385  SpacingType spacing = this->GetInput(0)->GetSpacing();
2386  OriginType origin = this->GetInput(0)->GetOrigin();
2387 
2388  new_p[0] = indTemp[0]*spacing[0]+origin[0];
2389  new_p[1] = indTemp[1]*spacing[1]+origin[1];
2390  new_p[2] = indTemp[2]*spacing[2]+origin[2];
2391 
2392  this->GetOutput()->SetPoint( m_NumberOfNodes, new_p );
2393 
2394  switch ( nodesid[i] )
2395  {
2396  case 2:
2397  m_CurrentVoxel[2] = m_NumberOfNodes;
2398  break;
2399  case 6:
2400  m_CurrentVoxel[6] = m_NumberOfNodes;
2401  currentframetmp[1][1] = m_NumberOfNodes;
2402  currentframetmp[1][0] = (index%(m_ImageWidth*m_ImageHeight))*13+2;
2403  break;
2404  case 10:
2405  m_CurrentVoxel[10] = m_NumberOfNodes;
2406  break;
2407  case 11:
2408  m_CurrentVoxel[11] = m_NumberOfNodes;
2409  currentrowtmp[3][1] = m_NumberOfNodes;
2410  currentrowtmp[3][0] = (index%m_ImageWidth)*13+10;
2411  break;
2412  case 3:
2413  currentrowtmp[0][1] = m_NumberOfNodes;
2414  currentrowtmp[0][0] = (index%m_ImageWidth)*13+1;
2415  break;
2416  case 7:
2417  currentrowtmp[1][1] = m_NumberOfNodes;
2418  currentrowtmp[1][0] = (index%m_ImageWidth)*13+5;
2419  currentframetmp[2][1] = m_NumberOfNodes;
2420  currentframetmp[2][0] = (index%(m_ImageWidth*m_ImageHeight))*13+3;
2421  break;
2422  case 12:
2423  currentrowtmp[2][1] = m_NumberOfNodes;
2424  currentrowtmp[2][0] = (index%m_ImageWidth)*13+9;
2425  break;
2426  case 5:
2427  currentframetmp[0][1] = m_NumberOfNodes;
2428  currentframetmp[0][0] = (index%(m_ImageWidth*m_ImageHeight))*13+1;
2429  break;
2430  case 8:
2431  currentframetmp[3][1] = m_NumberOfNodes;
2432  currentframetmp[3][0] = (index%(m_ImageWidth*m_ImageHeight))*13+4;
2433  break;
2434  case 1:
2435  m_CurrentVoxel[1] = m_NumberOfNodes;
2436  break;
2437  case 4:
2438  m_CurrentVoxel[4] = m_NumberOfNodes;
2439  break;
2440  case 9:
2441  m_CurrentVoxel[9] = m_NumberOfNodes;
2442  break;
2443  case 13:
2444  m_CurrentVoxel[13] = m_NumberOfNodes;
2445  break;
2446  }
2447  globalnodesid[i] = m_NumberOfNodes;
2448  m_AvailableNodes[ nodesid[i] ] = 0;
2449  m_CurrentVoxel[ nodesid[i] ] = m_NumberOfNodes;
2450  m_NumberOfNodes++;
2451  }
2452  else
2453  {
2454  if ( m_CurrentVoxel[ nodesid[i] ] != 0 )
2455  {
2456  globalnodesid[i] = m_CurrentVoxel[ nodesid[i] ];
2457  m_PointFound = 1;
2458 
2459  continue;
2460  }
2461  if ( m_LastVoxel[ nodesid[i] ] != 0 )
2462  {
2463  globalnodesid[i] = m_LastVoxel[ nodesid[i] ];
2464  m_PointFound = 1;
2465 
2466  continue;
2467  }
2468  if ( (m_LastRowNum != 0) && ( (nodesid[i] == 1) || (nodesid[i] == 5) || (nodesid[i] == 9) || (nodesid[i] == 10) ) )
2469  {
2470 
2471  globalnodesid[i] = this->SearchThroughLastRow((index % m_ImageWidth)*13+nodesid[i], 0, m_LastRowNum-1);
2472  if ( m_PointFound != 0 ) continue;
2473  else
2474  {
2475  if (nodesid[i] == 9) globalnodesid[i] = this->SearchThroughLastRow((index % m_ImageWidth)*13-3, 0, m_LastRowNum-1);
2476  if (nodesid[i] == 10) globalnodesid[i] = this->SearchThroughLastRow((index % m_ImageWidth)*13+22, 0, m_LastRowNum-1);
2477  if ( m_PointFound != 0 ) continue;
2478  }
2479  }
2480  if ( (m_LastFrameNum != 0) && ( (nodesid[i] == 1) || (nodesid[i] == 2) || (nodesid[i] == 3) || (nodesid[i] == 4) ) )
2481  {
2482 
2483  globalnodesid[i] = this->SearchThroughLastFrame((index % (m_ImageWidth*m_ImageHeight))*13+nodesid[i], 0, m_LastFrameNum-1);
2484  if ( m_PointFound != 0 ) continue;
2485  else
2486  {
2487  if (nodesid[i] == 4) globalnodesid[i] = this->SearchThroughLastFrame((index % (m_ImageWidth*m_ImageHeight))*13-11, 0, m_LastFrameNum-1);
2488  if (nodesid[i] == 1) globalnodesid[i] = this->SearchThroughLastFrame((index % (m_ImageWidth*m_ImageHeight) - m_ImageWidth)*13+3, 0, m_LastFrameNum-1);
2489  if ( m_PointFound != 0 ) continue;
2490  }
2491  }
2492  }
2493 
2494  if (m_PointFound == 0)
2495  {
2496  m_AvailableNodes[nodesid[i]] = 1;
2497  i--;
2498  }
2499  }
2500 }
2501 
2502 template<class TInputImage, class TOutputMesh>
2503 void
2505 ::CellTransfer( unsigned char *nodesid, unsigned char celltran )
2506 {
2507  if ( (celltran & 1) != 0 )
2508  {
2509  this->ZFlip(nodesid);
2510  if ( celltran > 64 ) celltran -= 64;
2511  else celltran += 64;
2512  }
2513  if ( (celltran & 2) != 0 )
2514  {
2515  this->YFlip(nodesid);
2516  if ( celltran > 64 ) celltran -= 64;
2517  else celltran += 64;
2518  }
2519  if ( (celltran & 4) != 0 )
2520  {
2521  this->XFlip(nodesid);
2522  if ( celltran > 64 ) celltran -= 64;
2523  else celltran += 64;
2524  }
2525  if ( (celltran & 8) != 0 ) this->ZRotation(nodesid);
2526  if ( (celltran & 16) != 0 ) this->YRotation(nodesid);
2527  if ( (celltran & 32) != 0 ) this->XRotation(nodesid);
2528  if ( (celltran & 64) != 0 ) this->inverse(nodesid);
2529 }
2530 
2531 template<class TInputImage, class TOutputMesh>
2532 unsigned long
2534 ::SearchThroughLastRow( int index, int start, int end )
2535 {
2536  int mid;
2537  unsigned long lindex = static_cast<unsigned long>( index );
2538  if ( (end - start) > 1 )
2539  {
2540  mid = static_cast<int>( vcl_floor(static_cast<float>((start + end)/2)) );
2541  if ( lindex == m_LastRow[mid][0] )
2542  {
2543  m_PointFound = 1;
2544  return m_LastRow[mid][1];
2545  }
2546  else
2547  {
2548  if( lindex > m_LastRow[mid][0] )
2549  {
2550  return this->SearchThroughLastRow(index, mid+1, end);
2551  }
2552  else
2553  {
2554  return this->SearchThroughLastRow(index, start, mid);
2555  }
2556  }
2557  }
2558  else
2559  {
2560  if ( lindex == m_LastRow[start][0] )
2561  {
2562  m_PointFound = 1;
2563  return m_LastRow[start][1];
2564  }
2565  if ( lindex == m_LastRow[end][0] )
2566  {
2567  m_PointFound = 1;
2568  return m_LastRow[end][1];
2569  }
2570  }
2571  return 0;
2572 }
2573 
2574 template<class TInputImage, class TOutputMesh>
2575 unsigned long
2577 ::SearchThroughLastFrame( int index, int start, int end )
2578 {
2579  int mid;
2580  unsigned long lindex = static_cast<unsigned long>( index );
2581  unsigned long result = 0;
2582  if ( (end - start) > 1 )
2583  {
2584  mid = static_cast<int>( vcl_floor(static_cast<float>((start + end)/2)) );
2585  if ( lindex == m_LastFrame[mid][0] )
2586  {
2587  m_PointFound = 1;
2588  result = m_LastFrame[mid][1];
2589  }
2590  else
2591  {
2592  if ( lindex > m_LastFrame[mid][0] )
2593  {
2594  result = this->SearchThroughLastFrame(index, mid+1, end);
2595  }
2596  else
2597  {
2598  result = this->SearchThroughLastFrame(index, start, mid);
2599  }
2600  }
2601  }
2602  else
2603  {
2604  if ( lindex == m_LastFrame[start][0] )
2605  {
2606  m_PointFound = 1;
2607  result = m_LastFrame[start][1];
2608  }
2609  if ( lindex == m_LastFrame[end][0] )
2610  {
2611  m_PointFound = 1;
2612  result = m_LastFrame[end][1];
2613  }
2614  }
2615  return result;
2616 }
2617 
2619 template<class TInputImage, class TOutputMesh>
2620 void
2622 ::PrintSelf( std::ostream& os, Indent indent ) const
2623 {
2624  Superclass::PrintSelf(os, indent);
2625 
2626  os << indent
2627  << "ObjectValue: "
2628  << static_cast<NumericTraits<unsigned char>::PrintType>(m_ObjectValue)
2629  << std::endl;
2630 
2631  os << indent
2632  << "NumberOfNodes: "
2633  << m_NumberOfNodes
2634  << std::endl;
2635 
2636  os << indent
2637  << "NumberOfCells: "
2638  << m_NumberOfCells
2639  << std::endl;
2640 }
2641 
2642 }
2644 #endif

Generated at Sat Feb 2 2013 23:27:09 for Orfeo Toolbox with doxygen 1.8.1.1