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