]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx
#3507 ManualContourModel_Box Usage with 1 group of points
[creaMaracasVisu.git] / bbtk / src / bbcreaMaracasVisuManualContourModel_Box.cxx
1 //===== 
2 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
3 //===== 
4 #include "bbcreaMaracasVisuManualContourModel_Box.h"
5 #include "bbcreaMaracasVisuPackage.h"
6
7 #include <creaContoursFactory.h>
8
9
10 namespace bbcreaMaracasVisu
11 {
12
13 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ManualContourModel_Box)
14 BBTK_BLACK_BOX_IMPLEMENTATION(ManualContourModel_Box,bbtk::AtomicBlackBox);
15 //===== 
16 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
17 //===== 
18
19
20 void ManualContourModel_Box::ProcessBySegment(  
21                         int Type, 
22                         int &iGeneral, int sizeSegment,
23                         std::vector<double> *lstInX,std::vector<double> *lstInY, std::vector<double> *lstInZ,
24                         std::vector<double> *lstOutX,std::vector<double> *lstOutY, std::vector<double> *lstOutZ,
25                         std::vector<int>        *lstIndexsOut, bool open )
26 {
27         creaContoursFactory f;
28         manualContourModel      *m;
29         int i,size=iGeneral+sizeSegment;
30         double x,y,z;
31         m = (manualContourModel*)f.getContourModel( bbGetInputType() );
32         m->SetNumberOfPointsSpline( bbGetInputNbPoints() );
33         m->SetCloseContour( open );
34         for (i=iGeneral;i<size;i++)
35         {
36                 m->AddPoint( (*lstInX)[i] , (*lstInY)[i] , (*lstInZ)[i] );
37         } // for
38         m->UpdateSpline();
39         int sizeContour = bbGetInputNbPoints();
40         for (i=0;i<sizeContour;i++)
41         {
42                 m->GetSpline_i_Point(i,&x,&y,&z);
43                 lstOutX->push_back(x);
44                 lstOutY->push_back(y);
45                 lstOutZ->push_back(z);
46         } // for
47         iGeneral=iGeneral+sizeSegment;
48         lstIndexsOut->push_back( sizeContour );
49         delete m;
50 }
51
52
53 void ManualContourModel_Box::RedistributionPoints(      std::vector<double> *lstOutX,
54                                                                                                         std::vector<double> *lstOutY, 
55                                                                                                         std::vector<double> *lstOutZ,
56                                                                                                         std::vector<int> *lstIndexsOut )
57 {
58         std::vector<double> lstRstX;
59         std::vector<double> lstRstY;
60         std::vector<double> lstRstZ;
61         int iLstIndexOut,sizeLstIndexOut = lstIndexsOut->size();
62         int ii, iGeneral=0;
63         int size;
64         for (iLstIndexOut=0;  iLstIndexOut<sizeLstIndexOut; iLstIndexOut++)
65         {
66                 lstRstX.clear();
67                 lstRstY.clear();
68                 lstRstZ.clear();
69                 size=(*lstIndexsOut)[iLstIndexOut];
70                 if (size>2)
71                 {
72                         double dist=0,dist2,distSeg,delta;
73                         double dd,dx,dy,dz;
74                         int i,k;
75                         for ( i=iGeneral+1 ; i<iGeneral+size ; i++ )
76                         {
77                                 dx      = (*lstOutX)[i]-(*lstOutX)[i-1];
78                                 dy      = (*lstOutY)[i]-(*lstOutY)[i-1];
79                                 dz      = (*lstOutZ)[i]-(*lstOutZ)[i-1];
80                                 dist= dist+sqrt( dx*dx + dy*dy + dz*dz );
81                         } //for
82                         delta = dist/(size-1);
83                         lstRstX.push_back( (*lstOutX)[iGeneral] );
84                         lstRstY.push_back( (*lstOutY)[iGeneral] );
85                         lstRstZ.push_back( (*lstOutZ)[iGeneral] );
86                         for (i=iGeneral+1; i<iGeneral+size;i++)
87                         {
88                                 dist2 = 0;
89                                 for (k=iGeneral+1; k<iGeneral+size;k++)
90                                 {
91                                         dx = (*lstOutX)[k]-(*lstOutX)[k-1];
92                                         dy = (*lstOutY)[k]-(*lstOutY)[k-1];
93                                         dz = (*lstOutZ)[k]-(*lstOutZ)[k-1];
94                                         distSeg = sqrt( dx*dx + dy*dy + dz*dz );
95                                         ii = i-iGeneral;
96                                         if ( dist2+distSeg >= ii*delta )
97                                         {
98                                                 dd=(ii*delta-dist2)/distSeg;
99                                                 if (distSeg==0)
100                                                 {
101                                                         dd = 0;
102                                                 } // if distSeg == 0
103                                                 lstRstX.push_back( (*lstOutX)[k-1] + dd*dx );
104                                                 lstRstY.push_back( (*lstOutY)[k-1] + dd*dy );
105                                                 lstRstZ.push_back( (*lstOutZ)[k-1] + dd*dz );
106                                                 k=iGeneral+size;
107                                         } else {
108                                                 if ( k==iGeneral+size-1 )
109                                                 {
110                                                         dd = 1;
111                                                         lstRstX.push_back( (*lstOutX)[k-1] + dd*dx );
112                                                         lstRstY.push_back( (*lstOutY)[k-1] + dd*dy );
113                                                         lstRstZ.push_back( (*lstOutZ)[k-1] + dd*dz );
114                                                 }
115                                         }// if dist2 
116                                         dist2 = dist2+distSeg;
117                                 } // for k
118                         } //for i   
119                         if (lstRstX.size()!=size) 
120                         {
121                                 printf("EED Warnning!   ManualContourModel_Box::RedistributionPoints  >> This list is not coherent  iLstIndexOut=%d  lstRstX.size()=%d  size=%d\n",iLstIndexOut, lstRstX.size(), size);
122                         }
123                         for (i=iGeneral; i<iGeneral+size;i++)
124                         {
125                                 ii=i-iGeneral;
126                                 (*lstOutX)[i] = lstRstX[ii];
127                                 (*lstOutY)[i] = lstRstY[ii];
128                                 (*lstOutZ)[i] = lstRstZ[ii];
129                         } // for i
130                 } // if size>2
131                 iGeneral=iGeneral+size;
132         }// for iLstIndexOut
133 }
134
135
136 //-------------------------------------------------------------------------------------------------------------
137
138
139 void ManualContourModel_Box::ExtractContour(    std::vector<double> *lstX,
140                                                                                                 std::vector<double> *lstY, 
141                                                                                                 std::vector<double> *lstZ,
142                                                                                                 std::vector<int>        *lstIndexs,
143                                                                                                 int contour,
144                                                                                                 std::vector<double> *lstOutX,
145                                                                                                 std::vector<double> *lstOutY, 
146                                                                                                 std::vector<double> *lstOutZ )
147 {
148         int     i;
149 //      int     iLstIndex;
150         int     iContour;
151         int     sizeLstIndexslstIndexs;
152         int     iGeneral;
153         int     iGeneralPlusSize;
154         if ( (lstX!=NULL) &&  (lstY!=NULL) && (lstZ!=NULL) && (lstIndexs!=NULL) && (lstOutX!=NULL) && (lstOutY!=NULL) && (lstOutZ!=NULL) )
155         {
156                 sizeLstIndexslstIndexs  = (*lstIndexs).size();
157                 if  ( sizeLstIndexslstIndexs!=0 ) 
158                 {
159                         (*lstOutX).clear();
160                         (*lstOutY).clear();
161                         (*lstOutZ).clear();
162                         iGeneral                                = 0;
163                         iGeneralPlusSize                = (*lstIndexs)[0];
164                         for ( iContour=1 ; iContour<=contour ; iContour++ )
165                         {
166                                 iGeneral                        = iGeneral+(*lstIndexs)[iContour-1];
167                                 iGeneralPlusSize        = iGeneral+(*lstIndexs)[iContour];
168                         } // for iContour
169                         for ( i=iGeneral ; i<iGeneralPlusSize ; i++ )
170                         {
171                                 (*lstOutX).push_back( (*lstX)[i] );
172                                 (*lstOutY).push_back( (*lstY)[i] );
173                                 (*lstOutZ).push_back( (*lstZ)[i] );                             
174                         } //for
175                 } // size
176         } // NULL
177 }
178
179 void ManualContourModel_Box::PutPointsInContour(std::vector<double> *lstTmpX,
180                                                                                                 std::vector<double> *lstTmpY, 
181                                                                                                 std::vector<double> *lstTmpZ,
182                                                                                                 int contour,
183                                                                                                 std::vector<double> *lstOutX,
184                                                                                                 std::vector<double> *lstOutY, 
185                                                                                                 std::vector<double> *lstOutZ,
186                                                                                                 std::vector<int>        *lstOutIndexs )
187 {
188         int     i;
189 //      int     iLstIndex;
190         int     iContour;
191         int     sizeLstIndexslstIndexs;
192         int     iGeneral;
193         int     iGeneralPlusSize;
194         int     iSize;
195         int     SizeContour;
196         if ( (lstTmpX!=NULL) &&  (lstTmpY!=NULL) && (lstTmpZ!=NULL)  && (lstOutX!=NULL) && (lstOutY!=NULL) && (lstOutZ!=NULL) && (lstOutIndexs!=NULL) )
197         {
198                 sizeLstIndexslstIndexs  = (*lstOutIndexs).size();
199                 if  ( sizeLstIndexslstIndexs!=0 ) 
200                 {
201                         iGeneral                                = 0;
202                         SizeContour                             = (*lstOutIndexs)[0];
203                         iGeneralPlusSize                = iGeneral + SizeContour;
204                         for ( iContour=1 ; iContour<=contour ; iContour++ )
205                         {
206                                 iGeneral                        = iGeneral + (*lstOutIndexs)[iContour-1];
207                                 SizeContour             = (*lstOutIndexs)[iContour];
208                                 iGeneralPlusSize        = iGeneral + SizeContour;
209                         } // for iContour
210                         
211                         if(SizeContour==(*lstTmpX).size() )
212                         {
213                                 int iSize=0;
214                                 for ( i=iGeneral ; i<iGeneralPlusSize ; i++ )
215                                 {
216                                         (*lstOutX)[i] = (*lstTmpX)[iSize] ;
217                                         (*lstOutY)[i] = (*lstTmpY)[iSize] ;
218                                         (*lstOutZ)[i] = (*lstTmpZ)[iSize] ;
219                                         iSize++;                                        
220                                 } //for                 
221                         } else {
222                                 printf("EED Warnning!! ManualContourModel_Box::PutPointsInContour  the lstTmp vector is not of the correct size. SizeContour=%d  lstTmp.size=%d\n"
223                                                                                                                                                                                                                 ,SizeContour, (*lstTmpX).size() );
224                                 for ( i=iGeneral ; i<iGeneralPlusSize ; i++ )
225                                 {
226                                         (*lstOutX)[i] = -9999 ;
227                                         (*lstOutY)[i] = -9999 ;
228                                         (*lstOutZ)[i] = -9999 ;
229                                 } //for                 
230                         }
231                 } // size
232         } // NULL
233 }
234
235
236 void ManualContourModel_Box::Redistribution_SIN(        double alpha,
237                                                                                                         double beta,
238                                                                                                         std::vector<double> *lstC1X,
239                                                                                                         std::vector<double> *lstC1Y, 
240                                                                                                         std::vector<double> *lstC1Z,
241                                                                                                         double sizeOfContour,
242                                                                                                         std::vector<double> *lstC2X,
243                                                                                                         std::vector<double> *lstC2Y, 
244                                                                                                         std::vector<double> *lstC2Z  )
245 {
246         std::vector<double> lstRstX;
247         std::vector<double> lstRstY;
248         std::vector<double> lstRstZ;
249         int     ii,iGeneral;
250         int     size,iGeneralPlusSize;
251         int             iGeneralPlusSizeMoisUn;
252         int             iGeneralPlusSizeMoisDeux;
253         int     i,k;
254         int     firstK;
255         double  iiByDelta;
256         double  dist2,distSeg;
257         double  dd,dx,dy,dz;
258         double  t,tt, PI;
259         double  TwoPI;
260         double  dist;
261         dist            = sizeOfContour;
262         PI                      = 3.14159265;
263         TwoPI           = 2*PI;
264         iGeneral        = 0;
265         size = (*lstC1X).size();
266         iGeneralPlusSize        = iGeneral+size;
267         iGeneralPlusSizeMoisUn          = iGeneralPlusSize-1;
268         iGeneralPlusSizeMoisDeux        = iGeneralPlusSize-2;
269         if (size>2)
270         {
271                 firstK  = 0;                    
272                 for (i=iGeneral; i<iGeneralPlusSize;i++)                                //  For each point of one contour
273                 {
274                         ii              = i-iGeneral;
275                         dist2   = 0;
276
277                         t               = ((double)ii) / ((double)(size-1));
278                         tt              = t + 0.70710678182*sin(t*TwoPI)*beta + alpha;
279                         if (tt>1) { tt=tt-1; }
280                         if (tt<0) { tt=tt+1; }
281                         iiByDelta = tt * dist;
282
283                         for ( k=iGeneral ; k<iGeneralPlusSizeMoisUn ; k++ )                     // Search inside
284                         {
285                                 dx              = (*lstC1X)[k+1]-(*lstC1X)[k];
286                                 dy              = (*lstC1Y)[k+1]-(*lstC1Y)[k];
287                                 dz              = (*lstC1Z)[k+1]-(*lstC1Z)[k];
288                                 distSeg = sqrt( dx*dx + dy*dy + dz*dz );
289                                 if ( dist2+distSeg >= iiByDelta )
290                                 {
291                                         if (distSeg==0)
292                                         {
293                                                 dd = 0;
294                                         } else {
295                                                 dd=(iiByDelta-dist2)/distSeg;
296                                         }// if distSeg == 0
297                                         lstRstX.push_back( (*lstC1X)[k] + dd*dx );
298                                         lstRstY.push_back( (*lstC1Y)[k] + dd*dy );
299                                         lstRstZ.push_back( (*lstC1Z)[k] + dd*dz );
300                                         if (ii==0) { firstK=k; }
301                                         k = iGeneralPlusSize-1;
302                                 } else {
303                                         if ( k==iGeneralPlusSizeMoisDeux )
304                                         {
305                                                 dd = 1;
306                                                 lstRstX.push_back( (*lstC1X)[k] + dd*dx );
307                                                 lstRstY.push_back( (*lstC1Y)[k] + dd*dy );
308                                                 lstRstZ.push_back( (*lstC1Z)[k] + dd*dz );
309                                         } // if k
310                                 }// if dist2 
311                                 dist2 = dist2 + distSeg;
312                         } // for k
313                 } //for i                       
314                 if (lstRstX.size()!=size) 
315                 {
316                         printf("EED Warnning!   ManualContourModel_Box::Redistribution_SIN  >> This list is not coherent lstRstX.size()=%d  size=%d\n", lstRstX.size(), size);
317                 }
318                 (*lstC2X).clear();
319                 (*lstC2Y).clear();
320                 (*lstC2Z).clear();
321                 for (i=iGeneral; i<iGeneralPlusSize;i++)
322                 {
323                         (*lstC2X).push_back(-1);        
324                         (*lstC2Y).push_back(-1);        
325                         (*lstC2Z).push_back(-1);        
326                 } // for i
327                 int iii;
328                 for (i=iGeneral; i<iGeneralPlusSize;i++)
329                 {
330                         ii                              = i-iGeneral;
331                         iii                             = iGeneral+ ( (i-iGeneral) + firstK) % size ;
332                         (*lstC2X)[iii]  = lstRstX[ii];
333                         (*lstC2Y)[iii]  = lstRstY[ii];
334                         (*lstC2Z)[iii]  = lstRstZ[ii];
335                 } // for i
336                 (*lstC2X)[iGeneralPlusSize-1]=(*lstC2X)[iGeneral];
337                 (*lstC2Y)[iGeneralPlusSize-1]=(*lstC2Y)[iGeneral];
338                 (*lstC2Z)[iGeneralPlusSize-1]=(*lstC2Z)[iGeneral];
339         } else {
340                 for (i=0; i<size ; i++)
341                 {
342                         (*lstC2X)[i] = (*lstC1X)[i];
343                         (*lstC2Y)[i] = (*lstC1Y)[i];
344                         (*lstC2Z)[i] = (*lstC1Z)[i];
345                 } // for i
346         }// if size>2
347 }
348
349 void ManualContourModel_Box::CopyContour2InContour1(
350                                                                                                         std::vector<double> *lstInX,
351                                                                                                         std::vector<double> *lstInY, 
352                                                                                                         std::vector<double> *lstInZ,
353                                                                                                         std::vector<double> *lstOutX,
354                                                                                                         std::vector<double> *lstOutY, 
355                                                                                                         std::vector<double> *lstOutZ )
356 {
357         int i,sizeLstInX=(*lstInX).size();
358         (*lstOutX).clear();     
359         (*lstOutY).clear();     
360         (*lstOutZ).clear();     
361         for ( i=0 ; i<sizeLstInX ; i++ )
362         {
363                 (*lstOutX).push_back( (*lstInX)[i] );
364                 (*lstOutY).push_back( (*lstInY)[i] );
365                 (*lstOutZ).push_back( (*lstInZ)[i] );
366         } // for i
367 }
368
369 double ManualContourModel_Box::IntegralDistanceTwoContours(std::vector<double> *lstTmpAX,
370                                                                                                                         std::vector<double> *lstTmpAY, 
371                                                                                                                         std::vector<double> *lstTmpAZ,
372                                                                                                                         std::vector<double> *lstTmpBX,
373                                                                                                                         std::vector<double> *lstTmpBY, 
374                                                                                                                         std::vector<double> *lstTmpBZ )
375 {
376         int     i;
377         double  dx;
378         double  dy;
379         double  dz;
380         double  dist            = 0;
381         int     iSize           = (*lstTmpAX).size();
382         for ( i=0 ; i<iSize ; i++ )
383         {
384                 dx              = (*lstTmpAX)[i]-(*lstTmpBX)[i];
385                 dy              = (*lstTmpAY)[i]-(*lstTmpBY)[i];
386                 dz              = (*lstTmpAZ)[i]-(*lstTmpBZ)[i];
387 //              dist    = dist + sqrt( dx*dx + dy*dy + dz*dz );
388                 dist    = dist +  (dx*dx + dy*dy + dz*dz) ;
389         } //for i
390         return dist;
391 }
392
393 void ManualContourModel_Box::findAlphaBetaSinDistribution(      std::vector<double> *ptrLstTmp2X,
394                                                                                                                         std::vector<double> *ptrLstTmp2Y,
395                                                                                                                         std::vector<double> *ptrLstTmp2Z ,
396                                                                                                                         int sizeContour,
397                                                                                                                         std::vector<double> *ptrLstTmp1X,
398                                                                                                                         std::vector<double> *ptrLstTmp1Y,
399                                                                                                                         std::vector<double> *ptrLstTmp1Z,  
400                                                                                                                         double *alphaOut,
401                                                                                                                         double *betaOut) 
402 {
403         std::vector<double> lstTmp2aX;
404         std::vector<double> lstTmp2aY;
405         std::vector<double> lstTmp2aZ;
406         double  alpha,iAlpha,deltaAlpha;
407         double  beta,iBeta,deltaBeta;
408         double  distAcum;
409         double  minDistAcum;
410         deltaAlpha      = 0.1 / 2;      
411         deltaBeta       = 0.01 / 2;     
412         beta            = 0.05;
413         alpha           = 0;
414         minDistAcum = 999999999999;
415         for (iAlpha=0 ; iAlpha<1; iAlpha=iAlpha+deltaAlpha ) 
416         {
417                 Redistribution_SIN( iAlpha,beta, ptrLstTmp2X,ptrLstTmp2Y,ptrLstTmp2Z ,sizeContour, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
418                 distAcum = IntegralDistanceTwoContours( ptrLstTmp1X,ptrLstTmp1Y,ptrLstTmp1Z , &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
419                 if (distAcum<minDistAcum) 
420                 {
421                         alpha           = iAlpha;
422                         minDistAcum     = distAcum;
423                 } // if integerDist
424         } // for alpha
425 // find Beta
426         minDistAcum = 999999999999;
427         for (iBeta=0.0 ; iBeta<0.2; iBeta=iBeta+deltaBeta) 
428         {
429                 Redistribution_SIN( alpha,iBeta, ptrLstTmp2X,ptrLstTmp2Y,ptrLstTmp2Z ,sizeContour, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
430                 distAcum = IntegralDistanceTwoContours( ptrLstTmp1X,ptrLstTmp1Y,ptrLstTmp1Z , &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
431                 if (distAcum<minDistAcum) 
432                 {
433                         beta            = iBeta;
434                         minDistAcum     = distAcum;
435                 } // if integerDist
436         } // for iBeta                  
437         *alphaOut       = alpha;
438         *betaOut        = beta;
439 }
440
441
442
443 double ManualContourModel_Box::SizeContour(     std::vector<double> *lstX,
444                                                                                         std::vector<double> *lstY, 
445                                                                                         std::vector<double> *lstZ)
446 {
447         int     i;
448         double  dx;
449         double  dy;
450         double  dz;
451         double  dist            = 0;
452         int     iSize           = (*lstX).size()  - 1;
453         for ( i=0 ; i<iSize ; i++ )
454         {
455                 dx      = (*lstX)[i+1]-(*lstX)[i];
456                 dy      = (*lstY)[i+1]-(*lstY)[i];
457                 dz      = (*lstZ)[i+1]-(*lstZ)[i];
458                 dist= dist+sqrt( dx*dx + dy*dy + dz*dz );
459         } //for i
460         return dist;
461 }
462
463
464
465 void ManualContourModel_Box::CalculeLstSizeContours(    std::vector<double> *lstOutX,
466                                                                                                                 std::vector<double> *lstOutY,
467                                                                                                                 std::vector<double> *lstOutZ,
468                                                                                                                 std::vector<int>        *lstIndexsOut,
469                                                                                                                 std::vector<double> *lstSizeContours    )
470 {
471         int     i;
472 //      int     iLstIndex;
473         int     iContour;
474         int     sizeLstIndexs;
475         int     iGeneral;
476         int     iGeneralPlusSize;
477         double  dx,dy,dz;
478         double  dist;
479         (*lstSizeContours).clear();
480         if ( (lstOutX!=NULL) &&  (lstOutY!=NULL) && (lstOutZ!=NULL) && (lstIndexsOut!=NULL)  )
481         {
482                 sizeLstIndexs   = (*lstIndexsOut).size();
483                 if  ( sizeLstIndexs!=0 ) 
484                 {       
485                         iGeneral                                = 0;
486                         for ( iContour=0 ; iContour<sizeLstIndexs ; iContour++ )
487                         {
488                                 dist                            = 0;
489                                 iGeneralPlusSize        = iGeneral + (*lstIndexsOut)[iContour];
490                                 for ( i=iGeneral+1 ; i<iGeneralPlusSize ; i++ )
491                                 {
492                                         dx      = (*lstOutX)[i]-(*lstOutX)[i-1] ;
493                                         dy      = (*lstOutY)[i]-(*lstOutY)[i-1] ;
494                                         dz      = (*lstOutZ)[i]-(*lstOutZ)[i-1] ;
495                                         dist= dist + sqrt( dx*dx +dy*dy + dz*dz );
496                                 } // for iGeneral
497                                 (*lstSizeContours).push_back( dist );
498                                 iGeneral = iGeneralPlusSize;
499                         } // for iContour
500                 } // sizeLstIndexs 
501         } // if lst NULL
502 }
503
504
505 void ManualContourModel_Box::RedistributionPointsAllContours_SIN(       std::vector<double> *lstOutX,
506                                                                                                                                         std::vector<double> *lstOutY, 
507                                                                                                                                         std::vector<double> *lstOutZ,
508                                                                                                                                         std::vector<int>        *lstIndexsOut )
509 {
510         std::vector<double> lstTmp1X;
511         std::vector<double> lstTmp1Y;
512         std::vector<double> lstTmp1Z;
513         std::vector<double> lstTmp2X;
514         std::vector<double> lstTmp2Y;
515         std::vector<double> lstTmp2Z;
516         std::vector<double> lstTmp2aX;
517         std::vector<double> lstTmp2aY;
518         std::vector<double> lstTmp2aZ;
519         std::vector<double> lstTmp3X;
520         std::vector<double> lstTmp3Y;
521         std::vector<double> lstTmp3Z;
522         std::vector<int>        lstContourExeption;
523         std::vector<double>     lstSizeContours;
524         int     iContour;
525         double  nbContours              = (*lstIndexsOut).size();
526         double  alpha,beta;
527         double  sizeContour1;
528         double  sizeContour2;
529         double  sizeContour3;
530         
531         CalculeLstSizeContours(lstOutX,lstOutY,lstOutZ,lstIndexsOut, &lstSizeContours);
532         
533 // ------------ Wave 1    Back to Fordward (redistribution for the little one)----------------- 
534         ExtractContour(lstOutX,lstOutY,lstOutZ,lstIndexsOut,0,&lstTmp1X,&lstTmp1Y,&lstTmp1Z);
535 //      sizeContour1    = SizeContour( &lstTmp1X, &lstTmp1Y, &lstTmp1Z );
536         sizeContour1 = lstSizeContours[0];
537         
538 // Increment    
539         for ( iContour=0; iContour<nbContours-1 ; iContour++ )   // Back to Fordward
540         {
541                 ExtractContour( lstOutX,lstOutY,lstOutZ,lstIndexsOut, iContour+1 ,&lstTmp2X,&lstTmp2Y,&lstTmp2Z );              
542 //              sizeContour2    = SizeContour( &lstTmp2X, &lstTmp2Y, &lstTmp2Z );
543                 sizeContour2 = lstSizeContours[ iContour+1 ];
544                 
545                 if (iContour+2<nbContours)
546                 {
547 //                      ExtractContour( lstOutX,lstOutY,lstOutZ,lstIndexsOut, iContour+2 ,&lstTmp3X,&lstTmp3Y,&lstTmp3Z );              
548 //                      sizeContour3    = SizeContour( &lstTmp3X, &lstTmp3Y, &lstTmp3Z );
549                         sizeContour3 = lstSizeContours[ iContour+2 ];
550                 } else {
551                         sizeContour3=-1;
552                 }
553                 if ( (sizeContour1>=sizeContour2) && (sizeContour2>sizeContour3) )
554                 {
555                         findAlphaBetaSinDistribution( &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2,  &lstTmp1X,&lstTmp1Y,&lstTmp1Z,  &alpha,&beta);
556                         Redistribution_SIN( alpha,beta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
557                           sizeContour2                                  = SizeContour( &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
558                           lstSizeContours[ iContour+1 ] = sizeContour2;
559                         PutPointsInContour(&lstTmp2aX,&lstTmp2aY,&lstTmp2aZ, iContour+1 ,lstOutX,lstOutY,lstOutZ,lstIndexsOut);                         
560                         CopyContour2InContour1( &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ , &lstTmp1X,&lstTmp1Y,&lstTmp1Z );
561                 } else {
562                         if ( (sizeContour3!=-1) && (sizeContour1<sizeContour2) && (sizeContour2>sizeContour3) )  // Warning for a maximum local
563                         {
564                                 lstInconsistentContourY.push_back( lstTmp2Y[0] );
565                                 lstInconsistentContourID.push_back( iContour+1 );
566                         } // if maximum local
567                         CopyContour2InContour1( &lstTmp2aX,&lstTmp2Y,&lstTmp2Z , &lstTmp1X,&lstTmp1Y,&lstTmp1Z );
568                  } //if sizeContour1>sizeContour2>sizeContour3           
569                 sizeContour1 = sizeContour2;
570         } // for iContour 
571
572         
573 // ------------ Wave 2  fordward  to back  (redistribute the litle one)-----------------
574         ExtractContour(lstOutX,lstOutY,lstOutZ,lstIndexsOut,nbContours-1,&lstTmp1X,&lstTmp1Y,&lstTmp1Z);
575 //      sizeContour1    = SizeContour( &lstTmp1X, &lstTmp1Y, &lstTmp1Z );
576         sizeContour1    = lstSizeContours[ nbContours-1 ];
577
578 // Increment    
579         for ( iContour=nbContours-1; iContour>0 ; iContour-- )  // Fordward to Back
580         {
581                 ExtractContour( lstOutX,lstOutY,lstOutZ,lstIndexsOut, iContour-1 ,&lstTmp2X,&lstTmp2Y,&lstTmp2Z );              
582 //              sizeContour2    = SizeContour( &lstTmp2X, &lstTmp2Y, &lstTmp2Z );
583                 sizeContour2    = lstSizeContours[ iContour-1 ];
584                 if (iContour-2>=0)
585                 {
586 //                      ExtractContour( lstOutX,lstOutY,lstOutZ,lstIndexsOut, iContour-2 ,&lstTmp3X,&lstTmp3Y,&lstTmp3Z );              
587 //                      sizeContour3    = SizeContour( &lstTmp3X, &lstTmp3Y, &lstTmp3Z );
588                         sizeContour3    = lstSizeContours[ iContour-2 ];
589                 } else {
590                         sizeContour3=-1;
591                 }
592                 if ( (sizeContour1>sizeContour2) && (sizeContour2>sizeContour3) )
593                 {
594                         findAlphaBetaSinDistribution( &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2,  &lstTmp1X,&lstTmp1Y,&lstTmp1Z,  &alpha,&beta);
595                         Redistribution_SIN( alpha,beta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
596                           sizeContour2                                  = SizeContour( &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
597                           lstSizeContours[ iContour-1 ] = sizeContour2;
598                         PutPointsInContour(&lstTmp2aX,&lstTmp2aY,&lstTmp2aZ, iContour-1 ,lstOutX,lstOutY,lstOutZ,lstIndexsOut);                 
599                         CopyContour2InContour1( &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ , &lstTmp1X,&lstTmp1Y,&lstTmp1Z );
600                 } else {
601                         if ( (sizeContour1>sizeContour2) && (sizeContour2<sizeContour3) )  // Warning for a minim local
602                         {
603                                 lstContourExeption.push_back( iContour-1 );
604                         } // if minimum local
605                         if ( (sizeContour3!=-1) && (sizeContour1<sizeContour2) && (sizeContour2>sizeContour3) )  // Warning for a maximum local
606                         {
607                                 lstInconsistentContourY.push_back( lstTmp2Y[0] );
608                                 lstInconsistentContourID.push_back( iContour-1 );
609                         } // if Maximum local
610                         CopyContour2InContour1( &lstTmp2X,&lstTmp2Y,&lstTmp2Z , &lstTmp1X,&lstTmp1Y,&lstTmp1Z );
611                 } //if  sizeContour1>sizeContour2>sizeContour3
612                 sizeContour1 = sizeContour2;
613         } // for iContour 
614
615 // ------------ Wave 3  redistribution for the minimun detected in Wave 1 -----------------
616         double alpha1,alpha2;
617         double beta1,beta2;
618         double iExtra,sizeExtra=lstContourExeption.size();
619         for ( iExtra=0 ; iExtra<sizeExtra ; iExtra++ )
620         {        
621                 iContour = lstContourExeption[iExtra];
622                 ExtractContour(lstOutX,lstOutY,lstOutZ,lstIndexsOut, iContour-1 , &lstTmp1X,&lstTmp1Y,&lstTmp1Z);
623                 ExtractContour(lstOutX,lstOutY,lstOutZ,lstIndexsOut, iContour   , &lstTmp2X,&lstTmp2Y,&lstTmp2Z);
624                 ExtractContour(lstOutX,lstOutY,lstOutZ,lstIndexsOut, iContour+1 , &lstTmp3X,&lstTmp3Y,&lstTmp3Z);
625 //              sizeContour2    = SizeContour( &lstTmp2X, &lstTmp2Y, &lstTmp2Z );
626                 sizeContour2    = lstSizeContours[ iContour  ];
627                 printf("EED Warnning!  ManualContourModel_Box::RedistributionPointsAllContours_SIN  wave3 posible inconsistent contour y=%f  iContour=%d\n", lstTmp2Y[0], iContour );
628                 lstInconsistentContourY.push_back( lstTmp2Y[0] );
629                 lstInconsistentContourID.push_back( iContour );
630                 findAlphaBetaSinDistribution( &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2,  &lstTmp1X,&lstTmp1Y,&lstTmp1Z,  &alpha1,&beta1);
631                 findAlphaBetaSinDistribution( &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2,  &lstTmp3X,&lstTmp3Y,&lstTmp3Z,  &alpha2,&beta2);
632                 if (beta2>beta1)
633                 {
634                         alpha   = alpha2;
635                 } else {
636                         alpha   = alpha1;
637                 }
638                 beta = ( beta1 + beta2 ) / 2;
639                 Redistribution_SIN( alpha,beta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
640                           sizeContour2                                  = SizeContour( &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
641                           lstSizeContours[ iContour ]   = sizeContour2;
642                 PutPointsInContour(&lstTmp2aX,&lstTmp2aY,&lstTmp2aZ,  iContour  ,lstOutX,lstOutY,lstOutZ,lstIndexsOut);
643         } // for iExtra
644
645
646 }
647  
648 void ManualContourModel_Box::ClockwisePoints(   std::vector<double> *lstInX,
649                                                                                         std::vector<double> *lstInY, 
650                                                                                         std::vector<double> *lstInZ,
651                                                                                         std::vector<int> *lstIndexsIn )
652 {
653         int     iLstIndexIn,sizeLstIndexIn=lstIndexsIn->size();
654         int     i,iGeneral=0;
655         int     size,size2;
656         double  cx,cy,cz;
657         double  px,py,pz;
658         double  backpx,backpy,backpz;
659         double  ang;
660         char    dir=-1;
661         bool    dirx,diry,dirz;
662         int     flagAng=0;
663         float   backang;
664         double  tmp;
665
666         // For each contour
667         for (iLstIndexIn=0;  iLstIndexIn<sizeLstIndexIn; iLstIndexIn++)
668         {
669                 // Step 1. Find gravity center and direction
670                 size    = (*lstIndexsIn)[iLstIndexIn];
671                 if (size>2)  // for contour with more than 2 points
672                 {
673                         cx              = 0;
674                         cy              = 0;
675                         cz              = 0;
676                         dirx    = true;
677                         diry    = true;
678                         dirz    = true;
679                         for ( i=0 ; i<size ; i++ )
680                         {
681                                 px=(*lstInX)[iGeneral+i];
682                                 py=(*lstInY)[iGeneral+i];
683                                 pz=(*lstInZ)[iGeneral+i];
684                                 cx      = px + cx;
685                                 cy      = py + cy;
686                                 cz      = pz + cz;
687                                 if (i!=0) 
688                                 { 
689                                         if (backpx!=px) { dirx=false; } 
690                                         if (backpy!=py) { diry=false; } 
691                                         if (backpz!=pz) { dirz=false; } 
692                                         backpx=px;
693                                         backpy=py;
694                                         backpz=pz;
695                                 } // if i!=0
696                                 backpx=px; 
697                                 backpy=py; 
698                                 backpz=pz; 
699                         } // for i 
700                         cx=cx/size;
701                         cy=cy/size;
702                         cz=cz/size;
703                         if (dirx==true) { dir=1; }  // YZ 
704                         if (diry==true) { dir=2; }  // XZ 
705                         if (dirz==true) { dir=0; }  // XZ 
706                         // Step 2. Find angle diference find 
707                         flagAng=0;
708                         for ( i=0 ; i<size ; i++ )
709                         {
710                                 px = (*lstInX)[iGeneral+i]-cx;
711                                 py = (*lstInY)[iGeneral+i]-cy;
712                                 pz = (*lstInZ)[iGeneral+i]-cz;
713                                 if (dir==0) { ang=atan2( py , px ); } // XY
714                                 if (dir==1) { ang=atan2( pz , py ); } // YZ
715                                 if (dir==2) { ang=atan2( pz , px ); } // XZ
716                                 if (i>0) 
717                                 { 
718                                         if (backang<ang) 
719                                         {
720                                                 flagAng++;
721                                         } else {
722                                                 flagAng--;
723                                         }// if backang<ang
724                                 } // if i
725                                 backang=ang; 
726                         } // for i 
727
728
729                         // Step 3. Invert order of points
730                         if (flagAng<0)
731                         {
732                                 size2 = size/2;
733                                 for ( i=0 ; i<size2 ; i++ )
734                                 {
735                                         tmp                                                     = (*lstInX)[iGeneral+i];
736                                         (*lstInX)[iGeneral+i]                   = (*lstInX)[iGeneral+size-1-i];
737                                         (*lstInX)[iGeneral+size-1-i]    = tmp;
738                                         tmp                                                     = (*lstInY)[iGeneral+i];
739                                         (*lstInY)[iGeneral+i]                   = (*lstInY)[iGeneral+size-1-i];
740                                         (*lstInY)[iGeneral+size-1-i]    = tmp;
741                                         tmp                                                     = (*lstInZ)[iGeneral+i];
742                                         (*lstInZ)[iGeneral+i]                   = (*lstInZ)[iGeneral+size-1-i];
743                                         (*lstInZ)[iGeneral+size-1-i]    = tmp;
744                                 } // for i
745                         } // flagAng
746                 } // size>2
747                 iGeneral = iGeneral+size;
748         } // for iLstIndexIn
749 }
750
751
752 void ManualContourModel_Box::ShiftValues(       std::vector<double> *lstInX,
753                                                                                         std::vector<double> *lstInY, 
754                                                                                         std::vector<double> *lstInZ,
755                                                                                         std::vector<int> *lstIndexsIn )
756 {
757         int iLstIndexIn,sizeLstIndexIn=lstIndexsIn->size();
758         int ii, iGeneral=0;
759         int size,size2;
760         double dist,distMin;
761         int i,iBack;
762         int ig;
763         double dx,dy,dz;
764         std::vector<double> LstTmpX;
765         std::vector<double> LstTmpY;
766         std::vector<double> LstTmpZ;
767         if (sizeLstIndexIn>=2)
768         {        
769                 for (iLstIndexIn=0;  iLstIndexIn<sizeLstIndexIn-1; iLstIndexIn++)
770                 {
771                         size  = (*lstIndexsIn)[iLstIndexIn];
772                         size2 = (*lstIndexsIn)[iLstIndexIn+1];
773                         //find min distance and  iBack
774                         distMin = 10000000;
775                         iBack   = 0;
776                     // Comparing distance between two contours  
777                     // Both contours need the same size 
778                         for (ig=0; ig<size; ig++)
779                         {
780                                 dist=0;
781                                 for ( i=0 ; i<size2 ; i++ )
782                                 {
783                                         dx      = (*lstInX)[iGeneral+i]-(*lstInX)[iGeneral+size+(i+ig)%size];
784                                         dy      = (*lstInY)[iGeneral+i]-(*lstInY)[iGeneral+size+(i+ig)%size];
785                                         dz      = (*lstInZ)[iGeneral+i]-(*lstInZ)[iGeneral+size+(i+ig)%size];
786                                         dist= dist + sqrt( dx*dx + dy*dy + dz*dz );
787                                 } // for i size2
788                                 if ( dist<distMin ) 
789                                 {
790                                         iBack   = ig+size;
791                                         distMin = dist;
792                                 }                       
793                         } // for ig size                        
794                         if (iBack!=0)
795                         {
796                                 LstTmpX.clear();
797                                 LstTmpY.clear();
798                                 LstTmpZ.clear();
799                                 for (i=0 ; i<size2 ; i++) 
800                                 {
801                                         ii = (i+iBack)%size2;
802                                         if (ii<(size2-1)) // Skip the last item
803                                         {
804                                                 LstTmpX.push_back( (*lstInX)[iGeneral+size+ii] );
805                                                 LstTmpY.push_back( (*lstInY)[iGeneral+size+ii] );
806                                                 LstTmpZ.push_back( (*lstInZ)[iGeneral+size+ii] );
807                                         }
808                                 } // for i
809                                 //Repeat the first item at the end to close the contour
810                                 LstTmpX.push_back( LstTmpX[0] );
811                                 LstTmpY.push_back( LstTmpY[0] );
812                                 LstTmpZ.push_back( LstTmpZ[0] );
813                                 for (i=0 ; i<size2 ; i++) 
814                                 {
815                                         (*lstInX)[iGeneral+size+i] = LstTmpX[i];
816                                         (*lstInY)[iGeneral+size+i] = LstTmpY[i];
817                                         (*lstInZ)[iGeneral+size+i] = LstTmpZ[i];
818                                 } // for i                              
819                         }
820                         iGeneral=iGeneral+size;
821                 } // for iLstIndexIn
822         } // if sizeLstIndexIn
823 }
824
825
826
827 void ManualContourModel_Box::Process()
828 {
829 // THE MAIN PROCESSING METHOD BODY
830 //   Here we simply set the input 'In' value to the output 'Out'
831 //   And print out the output value
832 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
833 //    void bbSet{Input|Output}NAME(const TYPE&)
834 //    const TYPE& bbGet{Input|Output}NAME() const 
835 //    Where :
836 //    * NAME is the name of the input/output
837 //      (the one provided in the attribute 'name' of the tag 'input')
838 //    * TYPE is the C++ type of the input/output
839 //      (the one provided in the attribute 'type' of the tag 'input')
840
841 //    bbSetOutputOut( bbGetInputIn() );
842 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
843
844         if (bbGetInputActive()==true)
845         {
846                 lstInconsistentContourY.clear();
847                 lstInconsistentContourID.clear();
848
849                 // First Step  Spline Interpolation
850         
851         std::vector<int>     lstIndexsIn = bbGetInputLstIndexsIn();
852         std::vector<int>     lstIndexsOut;
853         std::vector<double>  lstOutX;
854         std::vector<double>  lstOutY;
855         std::vector<double>  lstOutZ;
856
857                 std::vector<double> lstInX = bbGetInputLstControlPointsX();
858                 std::vector<double> lstInY = bbGetInputLstControlPointsY();
859                 std::vector<double> lstInZ = bbGetInputLstControlPointsZ();
860         
861         bool ok_abortMethod = false;
862                 if ( (lstInX.size()!=lstInY.size()) || (lstInY.size()!=lstInZ.size()) ) 
863                 { 
864             ok_abortMethod=true;
865                         printf("Warnning !!  .. ManualContourModel_Box: The list X Y Z, no have the same number of elements \n");
866                 }
867
868         if ( (lstInX.size()==0) && (lstInY.size()==0) && (lstInZ.size()==0) )
869         {
870             ok_abortMethod=true;
871             printf("Warnning !!  .. ManualContourModel_Box: The lists X Y Z, are empty \n");
872         }
873
874         if (ok_abortMethod==true)
875         {
876             bbSetOutputLstContourPointsX( lstOutX );
877             bbSetOutputLstContourPointsY( lstOutY );
878             bbSetOutputLstContourPointsZ( lstOutZ );
879             bbSetOutputLstIndexsOut( lstIndexsOut );
880             return;
881         } // if 
882         
883         
884         
885                 if (bbGetInputLstIndexsIn().size()==0)
886                 {
887                         lstIndexsIn.push_back( lstInX.size() );
888                 }
889                 
890     // Step 0. Clean lstIndexIn
891         int i,size    = lstIndexsIn.size();
892         for (i=size-1 ; i>=0; i--)
893         {
894             if (lstIndexsIn[i]==0)
895             {
896                 lstIndexsIn.erase( lstIndexsIn.begin()+i );
897             } // if
898         } // for i
899         
900         // Step 1.  All contours the same clockwise direction (Control Points)
901                 if ((bbGetInputDoubleContour()==1) && (bbGetInputOpenClose()==true))
902                 {
903                         ClockwisePoints( &lstInX , &lstInY , &lstInZ , &lstIndexsIn );  // wich is the plane base XY? XZ ZY  ??????
904         //              ShiftValues( &lstInX , &lstInY , &lstInZ , &lstIndexsIn );
905                 } // DoubleContour
906                 size    = lstIndexsIn.size();
907                 int iGeneral= 0;
908                 
909         // Step 2.  Spline interpolation of control points      
910                 for (i=0;i<size;i++)
911                 {
912                         ProcessBySegment(       bbGetInputType() , 
913                                                                 iGeneral,  lstIndexsIn[i] ,
914                                                                 &lstInX ,  &lstInY  , &lstInZ,
915                                                                 &lstOutX , &lstOutY , &lstOutZ,
916                                                                 &lstIndexsOut,bbGetInputOpenClose() );
917                 } // for
918
919                 if (bbGetInputDoubleContour()==0 || size == 1)
920                 {
921         // Finish if Simple contours
922                         //////////////////// Set Out   DoubleContour = 0
923                         bbSetOutputLstContourPointsX(lstOutX);  
924                         bbSetOutputLstContourPointsY(lstOutY);  
925                         bbSetOutputLstContourPointsZ(lstOutZ);
926                         bbSetOutputLstIndexsOut(lstIndexsOut);  
927                 } else {
928         // Step 3. Interpolation in the other direction
929         // Step 3.1 Linear Normalice points around contours     
930                         RedistributionPoints(&lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut);
931         //EED 01/2021           
932         // Step 3.2 Shift points to find minimun acumulate distance
933             if (bbGetInputOpenClose()==true)
934             {
935                 ShiftValues( &lstOutX, &lstOutY, &lstOutZ, &lstIndexsOut );
936             } // if OpenClose
937         // Step 3.3. SIN Normalice points around contours       
938                         if (bbGetInputParam().size()==2)
939                         {
940                                 if (bbGetInputParam()[0]==1) // type param 1
941                                 {
942                     if (bbGetInputOpenClose()==true)
943                     {
944                         RedistributionPointsAllContours_SIN( &lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut);
945                         ShiftValues( &lstOutX, &lstOutY, &lstOutZ, &lstIndexsOut );
946                     } // if OpenClose
947                 } // if type param =  1
948                         } // if size
949         // Step 3.4 Transpose the vectors   
950                         lstInX.clear();
951                         lstInY.clear();
952                         lstInZ.clear();
953                         lstIndexsIn.clear();
954                         size  = bbGetInputNbPoints();
955                         int j,size2 = lstIndexsOut.size();
956                         for (i=0;i<size;i++)
957                         {
958                                 for (j=0;j<size2;j++)
959                                 {
960                                         lstInX.push_back( lstOutX[ j*lstIndexsOut[j] + i ] );
961                                         lstInY.push_back( lstOutY[ j*lstIndexsOut[j] + i ] );
962                                         lstInZ.push_back( lstOutZ[ j*lstIndexsOut[j] + i ] );
963                                 } // for j
964                                 lstIndexsIn.push_back( size2 );
965                         } // for i
966                         lstOutX.clear();
967                         lstOutY.clear();
968                         lstOutZ.clear();
969                         lstIndexsOut.clear();
970         // Step 3.5 Interponation 2
971                         size=lstIndexsIn.size();
972                         iGeneral=0;
973                         for (i=0;i<size;i++)
974                         {
975                                 ProcessBySegment(       bbGetInputType() , 
976                                                                         iGeneral, lstIndexsIn[i] ,
977                                                                         &lstInX,&lstInY,&lstInZ,
978                                                                         &lstOutX,&lstOutY,&lstOutZ,
979                                                                         &lstIndexsOut,bbGetInputOpenClose2());
980                         } // for
981                         RedistributionPoints(&lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut);
982         // Step 3.6 Transpose the vectors   
983                         lstInX.clear();
984                         lstInY.clear();
985                         lstInZ.clear();
986                         lstIndexsIn.clear();
987                         size  = bbGetInputNbPoints();
988                         size2 = lstIndexsOut.size();
989                         for (i=0;i<size;i++)
990                         {
991                                 for (j=0;j<size2;j++)
992                                 {
993                                         lstInX.push_back( lstOutX[ j*lstIndexsOut[j] + i ] );
994                                         lstInY.push_back( lstOutY[ j*lstIndexsOut[j] + i ] );
995                                         lstInZ.push_back( lstOutZ[ j*lstIndexsOut[j] + i ] );
996                                 } // for j
997                                 lstIndexsIn.push_back( size2 );
998                         } // for i
999                         lstOutX.clear();
1000                         lstOutY.clear();
1001                         lstOutZ.clear();
1002                         lstIndexsOut.clear();
1003                         //////////////////// Set Out   DoubleContour = 1
1004                         bbSetOutputLstContourPointsX( lstInX ); 
1005                         bbSetOutputLstContourPointsY( lstInY ); 
1006                         bbSetOutputLstContourPointsZ( lstInZ );
1007                         bbSetOutputLstIndexsOut( lstIndexsIn ); 
1008                         bbSetOutputLstPssblIncnsnstntCntrY( lstInconsistentContourY );
1009                         bbSetOutputLstPssblIncnsnstntCntrID( lstInconsistentContourID );
1010                 } // if DoubleContour 
1011         } // if Active
1012 }
1013
1014 //===== 
1015 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
1016 //===== 
1017 void ManualContourModel_Box::bbUserSetDefaultValues()
1018 {
1019 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
1020 //    Here we initialize the input 'In' to 0
1021    bbSetInputActive(true);
1022    bbSetInputType(1);   
1023    bbSetInputDoubleContour(0);
1024    bbSetInputOpenClose(false);
1025    bbSetInputOpenClose2(false);
1026    bbSetInputNbPoints(100); 
1027 }
1028
1029 //===== 
1030 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
1031 //===== 
1032 void ManualContourModel_Box::bbUserInitializeProcessing()
1033 {
1034 //  THE INITIALIZATION METHOD BODY :
1035 //    Here does nothing 
1036 //    but this is where you should allocate the internal/output pointers 
1037 //    if any 
1038 }
1039
1040 //===== 
1041 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
1042 //===== 
1043 void ManualContourModel_Box::bbUserFinalizeProcessing()
1044 {
1045 //  THE FINALIZATION METHOD BODY :
1046 //    Here does nothing 
1047 //    but this is where you should desallocate the internal/output pointers 
1048 //    if any 
1049 }
1050
1051 } // EO namespace bbcreaMaracasVisu
1052
1053