]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/Contour/ContourExtractData.cxx
RaC Changes that includes a Polygon contour in creaMaracasVisu. It includes changes
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / Contour / ContourExtractData.cxx
1
2 #include "ContourExtractData.h"
3
4
5 //----------------------------------------------------------------------
6 ContourExtractData::ContourExtractData( bool okImagesResults)
7 {
8         this->imagedata                 = NULL;
9         imagedataValueResult    = NULL;
10         imagedataMaskResult             = NULL;
11         this->okImagesResults   = okImagesResults;
12         _typeOperation                  = 0;
13 }
14
15 // ------------------------------------------------------------------------
16
17 ContourExtractData::~ContourExtractData()
18 {
19 }
20
21
22 //----------------------------------------------------------------------
23 void ContourExtractData::SetImage( vtkImageData* imagedata)
24 {
25         this->imagedata                 = imagedata;
26
27         // RaC 20-11-09 Changes in InitLstContoursLinesYPoints
28         int ext[6];
29         this->imagedata->GetWholeExtent(ext);
30         _sizeImageY = ext[3]-ext[2]+1;
31
32         // init vtk image result : valuesImage maskImage  
33         if (this->okImagesResults==true){  InitVtkImagesResult(); }
34 }
35 //----------------------------------------------------------------------
36 void ContourExtractData::SetZtoBeAnalys( int z )
37 {
38         this->zImage                    = z;
39 }
40
41 //------------------------------------------------------------------------
42 void ContourExtractData::SetLstManualContourModel( std::vector<manualBaseModel*> lstManConMod)
43 {
44         this->lstManConMod = lstManConMod;
45 }
46
47
48 //------------------------------------------------------------------------
49 void ContourExtractData::GetMinMaxPoint(int *minPoint, 
50                                                                                 int *maxPoint, 
51                                                                                 manualBaseModel *manualcontourmodel
52                                                                                 )
53 {
54         int i;
55         //int   np              = manualcontourmodel->GetSizeLstPoints( );  // number of control points // JPRx
56
57         // JSTG 26-02-08 ---------------------------------------------------------------------------------------
58         //int nps = manualviewbaseecontour->GetNumberOfPointsSpline(); // number of points in the spline
59         int nps = manualcontourmodel->GetNumberOfPointsSpline(); // number of points in the spline
60         //------------------------------------------------------------------------------------------------------
61
62         // JSTG 26-02-08 ---------------------------------------------------------------------------------------
63         //double x,y,z,t;
64         double x,y,z;
65         //double delta=( double ) ( np  ) / ( double ) ( nps  );
66         manualcontourmodel->UpdateSpline();
67         for (i=0; i<nps; i++)
68         {
69                 //t= delta * (double)i;
70                 //manualcontourmodel->GetSplinePoint(t,x,y,z);
71                 manualcontourmodel->GetSpline_i_Point(i,&x,&y,&z);
72                 if (x<minPoint[0]){ minPoint[0]=(int)x; }
73                 if (y<minPoint[1]){ minPoint[1]=(int)y; }
74                 if (x>maxPoint[0]){ maxPoint[0]=(int)x; }
75                 if (y>maxPoint[1]){ maxPoint[1]=(int)y; }
76         }
77         minPoint[0]--;
78         minPoint[1]--;
79         maxPoint[0]++;
80         maxPoint[1]++;
81         //------------------------------------------------------------------------------------------------------
82 }
83
84 //------------------------------------------------------------------------
85 void ContourExtractData::GetMinMaxPoint_Of_LstManConMod(        int *minPoint, 
86                                                                                                                 int *maxPoint
87                                                                                                                 )
88
89 {
90         int i,size = lstManConMod.size();
91
92         for(i=0 ; i<size ; i++)
93         {
94                 GetMinMaxPoint(minPoint,maxPoint,lstManConMod[i]);
95         }
96 }
97
98
99 //------------------------------------------------------------------------
100 int ContourExtractData::AnalisisContourInsideV2(int x, int y, int iContour )
101 {
102         bool inBorder=false;
103         int result      = 0;
104         int i;
105
106         //cout<<"RaC ContourExtractData::AnalisisContourInsideV2-iContour:"<<iContour<<" y:"<<y<<endl; 
107
108         int nps=_lstlstlstVecX1[iContour][y].size();
109
110         double x1,y1,x2,y2;
111         double borderX, borderY;
112         double xx1, yy1,xx2, yy2;
113         double xx=x, yy=y;
114         double d;
115
116         for (i=0; i<nps; i++)
117         {
118                 x1=_lstlstlstVecX1[iContour][y][i];
119                 y1=_lstlstlstVecY1[iContour][y][i];
120                 x2=_lstlstlstVecX2[iContour][y][i];
121                 y2=_lstlstlstVecY2[iContour][y][i];
122
123                 borderX=x1;
124                 borderY=y1;
125
126                 if (y1<y2) 
127                 { 
128                         xx1=x1; yy1=y1; xx2=x2; yy2=y2;
129                 } else {
130                         xx1=x2; yy1=y2; xx2=x1; yy2=y1; 
131                 } 
132
133                 double difxx2xx1=fabs(xx2-xx1);
134                 if (difxx2xx1==0) difxx2xx1=0.0000000001;
135
136                 // Finding border looking in vertical direction  AND  verifing if pixel is at right of the line 
137                 if  ( (yy>=yy1)&&(yy<=yy2) ) 
138                 {
139                         //by triangle similarity
140                         d = ( fabs(xx2-xx1)*(yy-yy1) ) / (yy2-yy1) ;
141                         if ( (xx1<=xx2)&&(x<(xx1+d)) )  {       result++;       }
142                         if ( (xx1>xx2)&&(x<(xx1-d)) )   {       result++;       } 
143
144                         if ( (yy2-yy1)/difxx2xx1 >= 1.0)
145                         {
146                                 if (xx1<=xx2)   
147                                 { 
148                                         borderX = xx1+d;
149                                         borderY = y;
150                                 } else { 
151                                         borderX = xx1-d;
152                                         borderY = y;
153                                 } 
154                         } 
155                 } // if point inside y 
156
157
158                 // Finding border looking in vertical direction
159                 if ( ((xx1<=xx2)&&(xx>=xx1)&&(xx<xx2)) || ((xx1>xx2)&&(xx>=xx2)&&(xx<xx1)) )
160                 {
161                         if ( (yy2-yy1)/difxx2xx1 <= 1.0)
162                         {
163                                 //by triangle similarity
164                                 d = ( fabs(xx1-xx)*(yy2-yy1) ) / difxx2xx1;
165                                 if (yy1+d<=yy2) {
166                                         borderX=x;
167                                         borderY=yy1+d;
168                                 }
169                         }                       
170                 } // if point inside x                  
171
172
173                 //Border verification
174                 if (   (x==(int)borderX) && (y==(int)borderY)   )  { inBorder=true; }// if point in border
175
176                 // Verification : border in horizontal line 
177                 if ( ((int)y1==(int)y2)  &&  ((int)y1==y) && (x1<x2) && (x>=x1) && (x<=x2))             { inBorder=true;        }
178                 if ( ((int)y1==(int)y2)  &&  ((int)y1==y) && (x2<x1) && (x>=x2) && (x<=x1))             { inBorder=true;        }
179
180                 if (inBorder==true){ i=nps; }           
181         } // for i
182
183         if (inBorder==true)     { result=1;     }
184
185         return result;
186 }
187
188
189
190 //------------------------------------------------------------------------
191 // typeOperation=0 AND
192 // typeOperation=1 OR
193 // typeOperation=2 XOR
194 bool ContourExtractData::isInside(int x, int y, int typeOperation)
195 {
196         bool result                             = false;
197         int numberLeft                  = 0;
198         int i,size                              = this->lstManConMod.size();
199         int numberInside        = 0;
200
201         /* RaC 20-11-09 (C1) Changes to use the method without the image.
202         int ext[6];
203         imagedata->GetExtent(ext);
204
205         if ((x>=0) && (x<=ext[1]) && (y>=0) && (y<=ext[3]))
206         {
207         */
208
209         if (typeOperation==0)  // AND  Intersection
210         {
211                 for (i=0;i<size;i++)
212                 {
213                         // To process the statistics of the Points contour the procedure is different
214                         // RaC 19-09-09
215                         manualBaseModel *mbm = lstManConMod[i];
216                         if(mbm->GetTypeModel()==7)
217                         {
218                                 if(mbm->IsPoint(x,y)==true)
219                                 {
220                                         numberLeft=1;
221                                 }
222                         }//if
223                         else
224                         {
225                                 numberLeft =  AnalisisContourInsideV2(x,y, i );
226                         }//else
227
228                         if ( (numberLeft % 2) ==1){         numberInside++;  }
229                 }
230                 if ( numberInside == (size) ){ result=true; }
231         } // AND  Intersection
232
233         numberLeft=0;
234
235         if (typeOperation==1)  // OR  All
236         {
237                 for (i=0;i<size;i++)
238                 {
239                         // To process the statistics of the Points contour the procedure is different
240                         // RaC 19-09-09
241                         manualBaseModel *mbm = lstManConMod[i];
242                         if(mbm->GetTypeModel()==7)
243                         {
244                                 if(mbm->IsPoint(x,y)==true)
245                                 {
246                                         numberLeft=1;
247                                 }
248                         }//if
249                         else
250                         {
251                                 numberLeft =  AnalisisContourInsideV2(x,y, i );
252                         }//else
253                         if ( (numberLeft % 2) ==1){ result=true;  }
254                 }
255         } // OR  All
256
257         numberLeft=0;
258
259         if (typeOperation==2)  // XOR  crown
260         {
261                 for (i=0;i<size;i++)
262                 {
263                         // To process the statistics of the Points contour the procedure is different
264                         // RaC 19-09-09
265                         manualBaseModel *mbm = lstManConMod[i];
266                         if(mbm->GetTypeModel()==7)
267                         {
268                                 if(mbm->IsPoint(x,y)==true)
269                                 {
270                                         numberLeft=1;
271                                 }
272                         }//if
273                         else
274                         {
275                                 numberLeft =  numberLeft + AnalisisContourInsideV2(x,y, i );
276                         }//else
277
278                 }
279                 if ( numberLeft % 2 ==1){       result = true;  } 
280         }// XOR  crown
281
282
283
284         //RaC }
285
286         return result;
287 }
288
289 //------------------------------------------------------------------------
290
291 double ContourExtractData::GetDataValue(int x, int y, int z)
292 {
293         //      wxVtk2DBaseView *wxvtk2dbaseview = (wxVtk2DBaseView*)wxvtkbaseview;
294         //      int z = (int)wxvtk2dbaseview->GetVtkBaseData()->GetZ();
295         //JSTG 13-03-08-----
296         //EED OJO avec JS       _zz = z;
297         //------------------
298         double result;
299         void *p;
300         p = imagedata->GetScalarPointer(x,y,z);
301
302         if (imagedata->GetScalarType()==VTK_CHAR)
303         {
304                 char *pp = (char*)p;
305                 result = (double)(*pp);
306         }
307         else if (imagedata->GetScalarType()==VTK_SIGNED_CHAR)
308         {
309                 signed char *pp = (signed char*)p;
310                 result = (double)(*pp);
311         }
312         else if (imagedata->GetScalarType()==VTK_UNSIGNED_CHAR)
313         {
314                 unsigned char *pp = (unsigned char*)p;
315                 result = (double)(*pp);
316         }
317         else if (imagedata->GetScalarType()==VTK_SHORT)
318         {
319                 short *pp = (short*)p;
320                 result = (double)(*pp);
321         }
322         else if (imagedata->GetScalarType()==VTK_UNSIGNED_SHORT)
323         {
324                 unsigned short *pp = (unsigned short*)p;
325                 result = (double)(*pp);
326         }
327         else if (imagedata->GetScalarType()==VTK_INT)
328         {
329                 int *pp = (int*)p;
330                 result = (double)(*pp);
331         }
332         else if (imagedata->GetScalarType()==VTK_UNSIGNED_INT)
333         {
334                 unsigned int *pp = (unsigned int*)p;
335                 result = (double)(*pp);
336         }
337         else if (imagedata->GetScalarType()==VTK_LONG)
338         {
339                 long *pp = (long*)p;
340                 result = (double)(*pp);
341         }
342         else if (imagedata->GetScalarType()==VTK_UNSIGNED_LONG)
343         {
344                 unsigned long *pp = (unsigned long*)p;
345                 result = (double)(*pp);
346         }
347         else if (imagedata->GetScalarType()==VTK_FLOAT)
348         {       
349                 float *pp = (float*)p;
350                 result = (double)(*pp);
351         }
352         else if (imagedata->GetScalarType()==VTK_DOUBLE)
353         {
354                 double *pp = (double*)p;
355                 result = (double)(*pp);
356         }
357
358         return result;
359 }
360
361 //------------------------------------------------------------------------
362
363 void ContourExtractData::PutVtkImageDataResultValue( int x, int y, int z, double value )
364 {
365         unsigned short *pValue;
366         unsigned short *pMask;
367         pValue  = (unsigned short *)imagedataValueResult->GetScalarPointer(x,y,z);
368         pMask   = (unsigned short *)imagedataMaskResult->GetScalarPointer(x,y,z);
369         *pMask  = 255;
370         *pValue = (unsigned short)value;
371 }
372
373 //------------------------------------------------------------------------
374 void ContourExtractData::ResetImageResult(int z)
375 {
376         if (okImagesResults==true)
377         {
378                 unsigned short *pValue;
379                 unsigned short *pMask;
380                 pValue  = (unsigned short *)imagedataValueResult->GetScalarPointer(0,0,z);
381                 pMask   = (unsigned short *)imagedataMaskResult->GetScalarPointer(0,0,z);
382
383                 int ext[6];
384                 imagedataValueResult->GetExtent(ext);
385
386                 int size = (ext[1]-ext[0]+1) * (ext[3]-ext[2]+1); 
387                 memset(pValue,0,size*2);
388                 memset(pMask,0,size*2);
389         } // if
390 }
391
392
393 //------------------------------------------------------------------------
394 void ContourExtractData::CalculateImageResult()
395 {
396         if (okImagesResults==true)
397         {
398                 ResetImageResult(zImage);
399
400                 int minPoint[2];
401                 int maxPoint[2];
402                 int i,j;
403                 double value;
404
405                 minPoint[0] = 999999;
406                 minPoint[1] = 999999;
407                 maxPoint[0] = -999999;
408                 maxPoint[1] = -999999;
409
410                 GetMinMaxPoint_Of_LstManConMod(minPoint,maxPoint);
411                 InitLstContoursLinesYPoints();
412
413                 for (j=minPoint[1]; j<=maxPoint[1]; j++)
414                 {
415                         for (i=minPoint[0]; i<=maxPoint[0]; i++)
416                         {
417
418                                 //RaC 20-11-09 Changes specified in isInside (C1)
419                                 int ext[6];
420                                 imagedata->GetExtent(ext);
421
422                                 if ((i>=0) && (i<=ext[1]) && (j>=0) && (j<=ext[3]))
423                                 {
424                                         if (isInside(i,j,_typeOperation)==true)
425                                         {
426                                                 value = GetDataValue(i,j,zImage);
427                                                 PutVtkImageDataResultValue(i,j,zImage,  value );
428                                         } // if
429
430                                 }//if
431
432                         } // for i
433                 } // for j
434
435
436                 imagedataValueResult->Modified();
437                 imagedataMaskResult->Modified();
438                 imagedataValueResult->Update();
439                 imagedataMaskResult->Update();
440         } // if
441
442 }
443
444 //------------------------------------------------------------------------
445 void ContourExtractData::GetValuesInsideCrown(std::vector<double> *pLstValue,
446                                                                                           std::vector<double> *pLstValuePosX,
447                                                                                           std::vector<double> *pLstValuePosY,
448                                                                                           std::vector<double> *pLstValuePosZ)
449 {
450         pLstValue->clear();
451         pLstValuePosX->clear();
452         pLstValuePosY->clear();
453         pLstValuePosZ->clear();
454
455         //      if (okImagesResults==true)
456         //      {
457         //              ResetImageResult(zImage);
458         //      }
459
460         int minPoint[2];
461         int maxPoint[2];
462         int i,j;
463         double value;
464
465
466         minPoint[0] = 999999;
467         minPoint[1] = 999999;
468         maxPoint[0] = -999999;
469         maxPoint[1] = -999999;
470
471         GetMinMaxPoint_Of_LstManConMod(minPoint,maxPoint);
472         InitLstContoursLinesYPoints();
473
474         for (j=minPoint[1]; j<=maxPoint[1]; j++)
475         {
476                 for (i=minPoint[0]; i<=maxPoint[0]; i++)
477                 {
478                         //RaC 20-11-09 Changes specified in isInside (C1)
479                         int ext[6];
480                         imagedata->GetExtent(ext);
481
482                         if ((i>=0) && (i<=ext[1]) && (j>=0) && (j<=ext[3]))
483                         {
484
485                                 if (isInside(i,j,_typeOperation)==true)
486                                 {
487                                         value = GetDataValue(i,j,zImage);
488
489                                         // Borrame
490                                         //                              if (okImagesResults==true){
491                                         //                                      PutVtkImageDataResultValue(i,j,zImage,  value );
492                                         //                              }
493
494                                         pLstValue               -> push_back( value );
495                                         pLstValuePosX   -> push_back( i );
496                                         pLstValuePosY   -> push_back( j );
497                                         pLstValuePosZ   -> push_back( -1 );
498                                 } // if
499
500                         } //if
501
502                 } // for
503         } // for
504
505         // Borrame
506         //      if (this->okImagesResults==true){
507         //              imagedataValueResult->Modified();
508         //              imagedataMaskResult->Modified();
509         //      }
510
511
512 }
513
514 //------------------------------------------------------------------------
515
516 vtkImageData *ContourExtractData::GetVtkImageValueResult()
517 {
518         return imagedataValueResult;
519 }
520 //------------------------------------------------------------------------
521 vtkImageData *ContourExtractData::GetVtkImageMaskResult()
522 {
523         return imagedataMaskResult;
524 }
525 // ------------------------------------------------------------------------
526 void ContourExtractData::InitVtkImagesResult()
527 {
528         int ext[6];
529         int newDim[3];
530         double spc[3];
531         int scalartype;
532
533         imagedata->GetSpacing(spc);
534         imagedata->GetExtent(ext);
535         newDim[0]=ext[1]-ext[0]+1;
536         newDim[1]=ext[3]-ext[2]+1;
537         newDim[2]=ext[5]-ext[4]+1;
538         scalartype = imagedata->GetScalarType();
539
540         if (imagedataValueResult!=NULL)
541         {
542                 imagedataValueResult->Delete();
543         }
544         imagedataValueResult = vtkImageData::New();
545         //        imagedataValueResult->SetScalarType(scalartype);
546         imagedataValueResult->SetScalarTypeToUnsignedShort();
547         imagedataValueResult->SetSpacing(spc);
548         imagedataValueResult->SetDimensions( newDim );
549         imagedataValueResult->AllocateScalars();
550
551         if (imagedataMaskResult!=NULL)
552         {
553                 imagedataMaskResult->Delete();
554         }
555         imagedataMaskResult  = vtkImageData::New();
556         //        imagedataMaskResult->SetScalarType(scalartype);
557         imagedataMaskResult->SetScalarTypeToUnsignedShort();
558         imagedataMaskResult->SetSpacing(spc);
559         imagedataMaskResult->SetDimensions( newDim );
560         imagedataMaskResult->AllocateScalars();
561 }
562
563
564 //------------------------------------------------------------------------
565 void ContourExtractData::InitVolumeStatistics()
566 {
567         vol_rCountRange                         = 0;
568         vol_rsize                                       = 0;
569         vol_minValue                            = 9999999;
570         vol_maxValue                            =-9999999;
571         vol_acum_average                        = 0;
572         vol_acum_standardeviation       = 0;
573 }
574
575 //------------------------------------------------------------------------
576 void ContourExtractData::SetVolumeStatistics(int rCountRange, 
577                                                                                          int rsize,
578                                                                                          double minValue,
579                                                                                          double maxValue,
580                                                                                          double acum_average,
581                                                                                          double acum_standardeviation)
582 {
583         vol_rCountRange                         = vol_rCountRange + rCountRange; 
584         vol_rsize                                       = vol_rsize + rsize; 
585
586         if (minValue<vol_minValue){ vol_minValue = minValue;  }
587         if (maxValue>vol_maxValue){ vol_maxValue = maxValue;  }
588
589         vol_acum_average                        = vol_acum_average + acum_average; 
590         vol_acum_standardeviation       = vol_acum_standardeviation + acum_standardeviation; 
591 }
592
593 //------------------------------------------------------------------------
594 void ContourExtractData::GetVolumeStatistics(int *vol_rCountRange, 
595                                                                                          int *vol_rsize,
596                                                                                          double *vol_minValue,
597                                                                                          double *vol_maxValue,
598                                                                                          double *vol_average,
599                                                                                          double *vol_standardeviation)
600 {
601         *vol_rCountRange                = this->vol_rCountRange; 
602         *vol_rsize                              = this->vol_rsize; 
603         *vol_minValue                   = this->vol_minValue; 
604         *vol_maxValue                   = this->vol_maxValue; 
605         *vol_average                    = this->vol_acum_average / this->vol_rsize;
606         *vol_standardeviation   = sqrt(this->vol_acum_standardeviation / this->vol_rsize);
607 }
608
609
610 //------------------------------------------------------------------------
611 void ContourExtractData::Statistics( std::vector<double> *inputLstValue, 
612                                                                         int     grayRangeMin,
613                                                                         int     grayRangeMax,
614                                                                         int             *rCountRange, 
615                                                                         int             *rsize, 
616                                                                         double  *rmin, 
617                                                                         double  *rmax,
618                                                                         double  *raverage,
619                                                                         double  *rstandardeviation
620                                                                         )
621 {
622         double min                                              = 0;
623         double max                                              = 0;
624         double average                                  = 0;
625         double standardeviation                 = 0;
626         double acum_average                             = 0;
627         double acum_standardeviation            = 0;
628         int      size                                           = 0;
629         int      countRange                                     = 0;
630         double ng;
631
632         if (inputLstValue!=NULL)
633         {
634                 size=inputLstValue->size();
635                 if (size>0){
636                         max=(*inputLstValue)[0];
637                         min=(*inputLstValue)[0];
638                         // Average , countRange
639                         int i;
640                         for ( i=0; i<size; i++ )
641                         {
642                                 ng=(*inputLstValue)[i];
643                                 acum_average = acum_average + ng;
644                                 if (max<ng) max=ng;             // Max
645                                 if (min>ng) min=ng;     // Min
646                                 if ((ng>=grayRangeMin) && (ng<=grayRangeMax)) countRange++;  // countRange
647                         } // for average
648                         average = acum_average / size;
649
650                         // Standar Deviation
651                         acum_standardeviation=0;
652                         double tmp;
653                         for ( i=0; i<size; i++ )
654                         {
655                                 tmp = (*inputLstValue)[i] - average;
656                                 acum_standardeviation = acum_standardeviation + tmp*tmp;
657                         } // for standar deviation
658                         standardeviation = sqrt(acum_standardeviation/size);
659                         SetVolumeStatistics(countRange, size,
660                                 min,max,
661                                 acum_average,acum_standardeviation);
662                 } // if size
663         } // if NULL
664
665         // OUTPUT
666         *rsize                          = size; 
667         *rCountRange            = countRange;
668         *rmin                           = min; 
669         *rmax                           = max;
670         *raverage                       = average;
671         *rstandardeviation      = standardeviation;
672 }
673
674 //------------------------------------------------------------------------
675 void ContourExtractData::SetTypeOperation(int type)
676 {
677         _typeOperation=type;
678 }
679
680 //------------------------------------------------------------------------
681 void ContourExtractData::Fill_lstlstlstVecXY(int iContour, int sizeY)
682 {
683         int i,y;
684         double x1,y1,z1,x2,y2,z2;
685         manualBaseModel *manualcontourmodel= lstManConMod[iContour];    
686         int nps = manualcontourmodel->GetNumberOfPointsSpline(); // number of points in the spline
687         manualcontourmodel->UpdateSpline();
688         //------------------------------------------------------------------------------------------------------
689
690         for (y=0;y<sizeY;y++)
691         {
692                 manualcontourmodel->GetSpline_i_Point(0,&x1,&y1,&z1);
693                 x1=x1+0.5; y1=y1+0.5;
694                 for (i=1; i<nps; i++)
695                 {
696                         manualcontourmodel->GetSpline_i_Point(i,&x2,&y2,&z2);
697                         x2=x2+0.5; y2=y2+0.5;
698                         if ( ((y1<y2)&&(y>=y1)&&(y<=y2)) || ((y1>y2)&&(y>=y2)&&(y<=y1)) || ((int)y1==y) || ((int)y2==y)  )
699                         {
700                                 _lstlstlstVecX1[iContour][y].push_back(x1);
701                                 _lstlstlstVecY1[iContour][y].push_back(y1);
702                                 _lstlstlstVecX2[iContour][y].push_back(x2);
703                                 _lstlstlstVecY2[iContour][y].push_back(y2);
704                         } 
705                         x1=x2; y1=y2; z1=z2;
706                 } // for i  Points in spline
707         } // y
708
709 }
710
711 void ContourExtractData::InitLstContoursLinesYPoints()
712 {
713         // init InInside Optimisation  
714         int i;
715
716         _lstlstlstVecX1.clear();
717         _lstlstlstVecY1.clear();
718         _lstlstlstVecX2.clear();
719         _lstlstlstVecY2.clear();
720
721         /* RaC 20-11-09
722         int ext[6];
723         this->imagedata->GetWholeExtent(ext);
724         int sizeY = ext[3]-ext[2]+1;
725         */
726         std::vector<double> vecDouble;
727         std::vector< std::vector<double> > vecVecDouble;
728         for ( i=0 ; i<_sizeImageY ; i++ )
729         {
730                 vecVecDouble.push_back( vecDouble );
731         }
732
733         //Fill structure with points
734         int sizeContours = lstManConMod.size();
735         for( i=0 ; i<sizeContours ; i++ )
736         {
737                 _lstlstlstVecX1.push_back( vecVecDouble );
738                 _lstlstlstVecY1.push_back( vecVecDouble );
739                 _lstlstlstVecX2.push_back( vecVecDouble );
740                 _lstlstlstVecY2.push_back( vecVecDouble );
741                 Fill_lstlstlstVecXY(i,_sizeImageY);
742         }
743
744 }
745
746 void ContourExtractData::SetSizeImageY(int pSizeImageY)
747 {
748         _sizeImageY=pSizeImageY;
749 }