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