]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx
c8db827940c2755c35471f8d5d14fdfa3c85bdef
[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                         iGeneralPlusSize                = (*lstOutIndexs)[0];
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. \n");
222                                 for ( i=iGeneral ; i<iGeneralPlusSize ; i++ )
223                                 {
224                                         (*lstOutX)[i] = -9999 ;
225                                         (*lstOutY)[i] = -9999 ;
226                                         (*lstOutZ)[i] = -9999 ;
227                                 } //for                 
228                         }
229                 } // size
230         } // NULL
231 }
232
233 double ManualContourModel_Box::SizeContour(     std::vector<double> *lstX,
234                                                                                         std::vector<double> *lstY, 
235                                                                                         std::vector<double> *lstZ)
236 {
237         int     i;
238         double  dx;
239         double  dy;
240         double  dz;
241         double  dist            = 0;
242         int     iSize           = (*lstX).size()  - 1;
243         for ( i=0 ; i<iSize ; i++ )
244         {
245                 dx      = (*lstX)[i+1]-(*lstX)[i];
246                 dy      = (*lstY)[i+1]-(*lstY)[i];
247                 dz      = (*lstZ)[i+1]-(*lstZ)[i];
248                 dist= dist+sqrt( dx*dx + dy*dy + dz*dz );
249         } //for i
250         return dist;
251 }
252
253
254 void ManualContourModel_Box::Redistribution_SIN(        double alpha,
255                                                                                                         double beta,
256                                                                                                         std::vector<double> *lstC1X,
257                                                                                                         std::vector<double> *lstC1Y, 
258                                                                                                         std::vector<double> *lstC1Z,
259                                                                                                         double sizeOfContour,
260                                                                                                         std::vector<double> *lstC2X,
261                                                                                                         std::vector<double> *lstC2Y, 
262                                                                                                         std::vector<double> *lstC2Z )
263 {
264 printf("EED ManualContourModel_Box::Redistribution_SIN  Start \n");
265         std::vector<double> lstRstX;
266         std::vector<double> lstRstY;
267         std::vector<double> lstRstZ;
268         int ii,iGeneral;
269         double iiByDelta;
270         int size,iGeneralPlusSize;
271         double Alpha,Beta,t,tt, PI=3.14159265;
272         double TwoPI=2*PI;
273         double dist=sizeOfContour;
274         double dist2,distSeg,delta;
275         double dd,dx,dy,dz;
276         int i,k;
277         int firstK;
278         double tmpX,tmpY,tmpZ;
279         iGeneral=0;
280 //      for (iLstIndexOut=0;  iLstIndexOut<sizeLstIndexOut; iLstIndexOut++)  // For each contour
281 //      {
282 //              lstRstX.clear();
283 //              lstRstY.clear();
284 //              lstRstZ.clear();
285 //              size                            = (*lstIndexsOut)[iLstIndexOut];
286                 size = (*lstInX).size();
287                 iGeneralPlusSize        = iGeneral+size;
288                 if (size>2)
289                 {
290 //                      dist=0;
291 //                      for ( i=iGeneral ; i<iGeneralPlusSize-1 ; i++ )
292 //                      {
293 //                              dx      = (*lstOutX)[i]-(*lstOutX)[i+1];
294 //                              dy      = (*lstOutY)[i]-(*lstOutY)[i+1];
295 //                              dz      = (*lstOutZ)[i]-(*lstOutZ)[i+1];
296 //                              dist= dist+sqrt( dx*dx + dy*dy + dz*dz );
297 //                      } //for
298                         delta = dist/(size-1);
299
300                         firstK  = 0;                    
301                         for (i=iGeneral; i<iGeneralPlusSize;i++)                                //  For each point of one contour
302                         {
303                                 ii = i-iGeneral;
304                                 dist2   = 0;
305                                 for (k=iGeneral; k<iGeneralPlusSize-1;k++)                      // Search inside
306                                 {
307 //if ( 385==(*lstOutY)[k]  )
308 //{ 
309         t               =       ((double)ii) / ((double)(size-1));
310 //      Beta    = 0.20; //  [0..1]
311 //      Alpha   = 0.0;  // [0..1]
312 //      Beta    = bbGetInputParam()[0];
313 //      Alpha   = bbGetInputParam()[1];
314         tt              = t + 0.70710678182*sin(t*TwoPI)*beta + alpha;
315         if (tt>1) { tt=tt-1; }
316         if (tt<0) { tt=tt+1; }
317         iiByDelta = tt * dist;
318 //} else {
319 //  iiByDelta = ii*delta;
320 //}
321
322 //                                      dx = (*lstOutX)[k+1]-(*lstOutX)[k];
323 //                                      dy = (*lstOutY)[k+1]-(*lstOutY)[k];
324 //                                      dz = (*lstOutZ)[k+1]-(*lstOutZ)[k];
325                                         dx = (*lstC1X)[k+1]-(*lstC1X)[k];
326                                         dy = (*lstC1Y)[k+1]-(*lstC1Y)[k];
327                                         dz = (*lstC1Z)[k+1]-(*lstC1Z)[k];
328                                         distSeg = sqrt( dx*dx + dy*dy + dz*dz );
329                                         if ( dist2+distSeg >= iiByDelta )
330                                         {
331                                                 if (distSeg==0)
332                                                 {
333                                                         dd = 0;
334                                                 } else {
335                                                         dd=(iiByDelta-dist2)/distSeg;
336                                                 }// if distSeg == 0
337                                                 lstRstX.push_back( (*lstC1X)[k] + dd*dx );
338                                                 lstRstY.push_back( (*lstC1Y)[k] + dd*dy );
339                                                 lstRstZ.push_back( (*lstC1Z)[k] + dd*dz );
340                                                 if (ii==0) { firstK=k; }
341                                                 k = iGeneralPlusSize-1;
342                                         } else {
343                                                 if ( k==iGeneral+size-2 )
344                                                 {
345                                                         dd = 1;
346                                                         lstRstX.push_back( (*lstC1X)[k] + dd*dx );
347                                                         lstRstY.push_back( (*lstC1Y)[k] + dd*dy );
348                                                         lstRstZ.push_back( (*lstC1Z)[k] + dd*dz );
349                                                 }
350                                         }// if dist2 
351                                         dist2 = dist2+distSeg;
352                                 } // for k
353                         } //for i   
354                         
355                         
356                         if (lstRstX.size()!=size) 
357                         {
358                                 printf("EED Warnning!   ManualContourModel_Box::Redistribution_SIN  >> This list is not coherent  iLstIndexOut=%d  lstRstX.size()=%d  size=%d\n",iLstIndexOut, lstRstX.size(), size);
359                                 tmpX    = lstRstX[iGeneral];
360                                 tmpY    = lstRstY[iGeneral];
361                                 tmpZ    = lstRstZ[iGeneral];
362                                 lstRstX.push_back( tmpX );
363                                 lstRstY.push_back( tmpY );
364                                 lstRstZ.push_back( tmpZ );
365                         }
366                         for (i=iGeneral; i<iGeneralPlusSize;i++)
367                         {
368                                 lstC2X.push_back(-1);   
369                                 lstC2Y.push_back(-1);   
370                                 lstC2Z.push_back(-1);   
371                         } // for i
372                         int iii;
373                         for (i=iGeneral; i<iGeneralPlusSize;i++)
374                         {
375                                 ii                              = i-iGeneral;
376                                 iii                             = iGeneral+ ( (i-iGeneral) + firstK) % size ;
377 //                              (*lstOutX)[iii] = lstRstX[ii];
378 //                              (*lstOutY)[iii] = lstRstY[ii];
379 //                              (*lstOutZ)[iii] = lstRstZ[ii];
380                                 (*lstC2X)[iii]  = lstRstX[ii];
381                                 (*lstC2Y)[iii]  = lstRstY[ii];
382                                 (*lstC2Z)[iii]  = lstRstZ[ii];
383                         } // for i
384                 } // if size>2
385 //              iGeneral=iGeneral+size;
386 //      }// for iLstIndexOut
387 printf("EED ManualContourModel_Box::Redistribution_SIN  End \n");       
388 }
389
390
391 void ManualContourModel_Box::CopyContour2InContour1(
392                                                                                                         std::vector<double> *lstInX,
393                                                                                                         std::vector<double> *lstInY, 
394                                                                                                         std::vector<double> *lstInZ,
395                                                                                                         std::vector<double> *lstOutX,
396                                                                                                         std::vector<double> *lstOutY, 
397                                                                                                         std::vector<double> *lstOutZ )
398 {
399         int i,sizeLstInX=(*lstInX).size();
400         (*lstOutX).clear();     
401         (*lstOutY).clear();     
402         (*lstOutZ).clear();     
403         for ( i=0 ; i<sizeLstInX ; i++ )
404         {
405                 (*lstOutX).push_back( (*lstInX)[i] );
406                 (*lstOutY).push_back( (*lstInY)[i] );
407                 (*lstOutZ).push_back( (*lstInZ)[i] );
408         } // for i
409 }
410
411 double ManualContourModel_Box::IntegralDistanceTwoContours(std::vector<double> *lstTmpAX,
412                                                                                                                         std::vector<double> *lstTmpAY, 
413                                                                                                                         std::vector<double> *lstTmpAZ,
414                                                                                                                         std::vector<double> *lstTmpBX,
415                                                                                                                         std::vector<double> *lstTmpBY, 
416                                                                                                                         std::vector<double> *lstTmpBZ )
417 {
418         int     i;
419         double  dx;
420         double  dy;
421         double  dz;
422         double  dist            = 0;
423         int     iSize           = (*lstTmpAX).size();
424         for ( i=0 ; i<iSize ; i++ )
425         {
426                 dx              = (*lstTmpAX)[i]-(*lstTmpBX)[i];
427                 dy              = (*lstTmpAY)[i]-(*lstTmpBY)[i];
428                 dz              = (*lstTmpAZ)[i]-(*lstTmpBZ)[i];
429                 dist    = dist + sqrt( dx*dx + dy*dy + dz*dz );
430         } //for i
431         return dist;
432 }
433
434
435 void ManualContourModel_Box::RedistributionPointsAllContours_SIN(       std::vector<double> *lstOutX,
436                                                                                                                                         std::vector<double> *lstOutY, 
437                                                                                                                                         std::vector<double> *lstOutZ,
438                                                                                                                                         std::vector<int>        *lstIndexsOut )
439 {
440         std::vector<double> lstTmp1X;
441         std::vector<double> lstTmp1Y;
442         std::vector<double> lstTmp1Z;
443         std::vector<double> lstTmp2X;
444         std::vector<double> lstTmp2Y;
445         std::vector<double> lstTmp2Z;
446         std::vector<double> lstTmp1aX;
447         std::vector<double> lstTmp1aY;
448         std::vector<double> lstTmp1aZ;
449         int     iContour;
450         double  nbContours              = (*lstIndexsOut).size()-1;
451         double  alpha,iAlpha;
452         double  beta,iBeta;
453         double  sizeContour1;
454         double  sizeContour2;
455         double  distAcum;
456         double minDistAcum;
457         
458         ExtractContour(lstOutX,lstOutY,lstOutZ,lstIndexsOut,0,&lstTmp1X,&lstTmp1Y,&lstTmp1Z);
459         sizeContour1    = SizeContour( &lstTmp1X, &lstTmp1Y, &lstTmp1Z );
460         
461 // Increment    
462         for ( iContour=0; iContour<nbContours ; iContour++ )
463         {
464                 beta    = 0.10;
465 // find Alpha
466                 ExtractContour( lstOutX,lstOutY,lstOutZ,lstIndexsOut, iContour+1 ,&lstTmp2X,&lstTmp2Y,&lstTmp2Z );              
467                 sizeContour2    = SizeContour( &lstTmp2X, &lstTmp2Y, &lstTmp2Z );
468                 if (sizeContour1<sizeContour2){
469                         alpha   = 0;
470                         minDistAcum=-999999999;
471                         for (iAlpha=0.1 ; iAlpha<1; iAlpha=iAlpha+0.1) 
472                         {
473                                 Redistribution_SIN( alpha,beta, &lstTmp1X,&lstTmp1Y,&lstTmp1Z ,sizeContour1, &lstTmp1aX,&lstTmp1aY,&lstTmp1aZ );
474                                 distAcum = IntegralDistanceTwoContours( &lstTmp1aX,&lstTmp1aY,&lstTmp1aZ , &lstTmp2X,&lstTmp2Y,&lstTmp2Z );
475                                 if (distAcum<minDistAcum) 
476                                 {
477                                         alpha           = iAlpha;
478                                         minDistAcum     = distAcum;
479                                 } // if integerDist
480                         } // for alpha
481 // find Beta
482                         for (iBeta=0.0 ; iBeta<0.2; iBeta=iBeta+0.01) 
483                         {
484                                 minDistAcum=-999999999;
485                                 Redistribution_SIN( alpha,beta, &lstTmp1X,&lstTmp1Y,&lstTmp1Z , &lstTmp1aX,&lstTmp1aY,&lstTmp1aZ );
486                                 distAcum = IntegralDistanceTwoContours( &lstTmp1aX,&lstTmp1aY,&lstTmp1aZ , &lstTmp2X,&lstTmp2Y,&lstTmp2Z );
487                                 if (distAcum<minDistAcum) 
488                                 {
489                                         beta            = iBeta;
490                                         minDistAcum     = distAcum;
491                                 } // if integerDist
492
493                         } // for beta
494                 } //if sizeContour2<sizeContour1
495 // Set Alpha y Beta
496                 Redistribution_SIN( alpha,beta, &lstTmp1X,&lstTmp1Y,&lstTmp1Z , &lstTmp1aX,&lstTmp1aY,&lstTmp1aZ );
497                 double nn       = SizeContour( &lstTmp1aX, &lstTmp1aY, &lstTmp1aZ );
498                 PutPointsInContour(&lstTmp1aX,&lstTmp1aY,&lstTmp1aZ, iContour ,lstOutX,lstOutY,lstOutZ,lstIndexsOut);                           
499                 sizeContour1 = sizeContour2;
500                 CopyContour2InContour1( &lstTmp2X,&lstTmp2Y,&lstTmp2Z , &lstTmp1X,&lstTmp1Y,&lstTmp1Z );
501         } // for iContour 
502 }
503  
504
505
506 void ManualContourModel_Box::RedistributionPoints_SIN_iContour(int iContour,    std::vector<double> *lstOutX,
507                                                                                                         std::vector<double> *lstOutY, 
508                                                                                                         std::vector<double> *lstOutZ,
509                                                                                                         std::vector<int> *lstIndexsOut,double alpha, double beta )
510 {
511 printf("EED ManualContourModel_Box::RedistributionPoints_SIN_iContour  Start \n");
512         std::vector<double> lstRstX;
513         std::vector<double> lstRstY;
514         std::vector<double> lstRstZ;
515         int iLstIndexOut,sizeLstIndexOut = lstIndexsOut->size();
516         int ii,iGeneral;
517         double iiByDelta;
518         int size,iGeneralPlusSize;
519         double Alpha,Beta,t,tt, PI=3.14159265;
520         double TwoPI=2*PI;
521         double dist=0,dist2,distSeg,delta;
522         double dd,dx,dy,dz;
523         int i,k;
524         int firstK;
525         double tmpX,tmpY,tmpZ;
526         iGeneral=0;
527         for (iLstIndexOut=0;  iLstIndexOut<sizeLstIndexOut; iLstIndexOut++)  // For each contour
528         {
529                 lstRstX.clear();
530                 lstRstY.clear();
531                 lstRstZ.clear();
532                 size                            = (*lstIndexsOut)[iLstIndexOut];
533                 iGeneralPlusSize        = iGeneral+size;
534                 if (size>2)
535                 {
536                         dist=0;
537                         for ( i=iGeneral ; i<iGeneralPlusSize-1 ; i++ )
538                         {
539                                 dx      = (*lstOutX)[i]-(*lstOutX)[i+1];
540                                 dy      = (*lstOutY)[i]-(*lstOutY)[i+1];
541                                 dz      = (*lstOutZ)[i]-(*lstOutZ)[i+1];
542                                 dist= dist+sqrt( dx*dx + dy*dy + dz*dz );
543                         } //for
544                         delta = dist/(size-1);
545
546                         firstK  = 0;                    
547                         for (i=iGeneral; i<iGeneralPlusSize;i++)                                //  For each point of one contour
548                         {
549                                 ii = i-iGeneral;
550                                 dist2   = 0;
551                                 for (k=iGeneral; k<iGeneralPlusSize-1;k++)                      // Search inside
552                                 {
553 if ( 385==(*lstOutY)[k]  )
554
555         t               =       ((double)ii) / ((double)(size-1));
556         Beta    = 0.20; //  [0..1]
557         Alpha   = 0.0;  // [0..1]
558         Beta    = bbGetInputParam()[0];
559         Alpha   = bbGetInputParam()[1];
560         tt              = t + 0.70710678182*sin(t*TwoPI)*Beta + Alpha;
561         if (tt>1) { tt=tt-1; }
562         if (tt<0) { tt=tt+1; }
563         iiByDelta = tt * dist;
564 } else {
565   iiByDelta = ii*delta;
566 }
567                                         dx = (*lstOutX)[k+1]-(*lstOutX)[k];
568                                         dy = (*lstOutY)[k+1]-(*lstOutY)[k];
569                                         dz = (*lstOutZ)[k+1]-(*lstOutZ)[k];
570                                         distSeg = sqrt( dx*dx + dy*dy + dz*dz );
571                                         if ( dist2+distSeg >= iiByDelta )
572                                         {
573                                                 if (distSeg==0)
574                                                 {
575                                                         dd = 0;
576                                                 } else {
577                                                         dd=(iiByDelta-dist2)/distSeg;
578                                                 }// if distSeg == 0
579                                                 lstRstX.push_back( (*lstOutX)[k] + dd*dx );
580                                                 lstRstY.push_back( (*lstOutY)[k] + dd*dy );
581                                                 lstRstZ.push_back( (*lstOutZ)[k] + dd*dz );
582                                                 if (ii==0) { firstK=k; }
583                                                 k = iGeneralPlusSize-1;
584                                         } else {
585                                                 if ( k==iGeneral+size-2 )
586                                                 {
587                                                         dd = 1;
588                                                         lstRstX.push_back( (*lstOutX)[k] + dd*dx );
589                                                         lstRstY.push_back( (*lstOutY)[k] + dd*dy );
590                                                         lstRstZ.push_back( (*lstOutZ)[k] + dd*dz );
591                                                 }
592                                         }// if dist2 
593                                         dist2 = dist2+distSeg;
594                                 } // for k
595                         } //for i   
596                         
597                         
598                         if (lstRstX.size()!=size) 
599                         {
600                                 printf("EED Warnning!   ManualContourModel_Box::RedistributionPoints  >> This list is not coherent  iLstIndexOut=%d  lstRstX.size()=%d  size=%d\n",iLstIndexOut, lstRstX.size(), size);
601                                 tmpX    = lstRstX[iGeneral];
602                                 tmpY    = lstRstY[iGeneral];
603                                 tmpZ    = lstRstZ[iGeneral];
604                                 lstRstX.push_back( tmpX );
605                                 lstRstY.push_back( tmpY );
606                                 lstRstZ.push_back( tmpZ );
607                         }
608                         int iii;
609                         for (i=iGeneral; i<iGeneralPlusSize;i++)
610                         {
611 //                              ii=( (i-iGeneral) + firstK) % size ;
612                                 ii= i-iGeneral ;
613                                 iii=iGeneral+ ( (i-iGeneral) + firstK) % size ;
614                                 (*lstOutX)[iii] = lstRstX[ii];
615                                 (*lstOutY)[iii] = lstRstY[ii];
616                                 (*lstOutZ)[iii] = lstRstZ[ii];
617                         } // for i
618                 } // if size>2
619                 iGeneral=iGeneral+size;
620         }// for iLstIndexOut
621         
622 printf("EED ManualContourModel_Box::RedistributionPoints_SIN_iContour  End \n");
623         
624 }
625
626
627
628 void ManualContourModel_Box::ClockwisePoints(   std::vector<double> *lstInX,
629                                                                                         std::vector<double> *lstInY, 
630                                                                                         std::vector<double> *lstInZ,
631                                                                                         std::vector<int> *lstIndexsIn )
632 {
633         int     iLstIndexIn,sizeLstIndexIn=lstIndexsIn->size();
634         int     i,iGeneral=0;
635         int     size,size2;
636         double  cx,cy,cz;
637         double  px,py,pz;
638         double  backpx,backpy,backpz;
639         double  ang;
640         char    dir=-1;
641         bool    dirx,diry,dirz;
642         int     flagAng=0;
643         float   backang;
644         double  tmp;
645
646         // For each contour
647         for (iLstIndexIn=0;  iLstIndexIn<sizeLstIndexIn; iLstIndexIn++)
648         {
649                 // Step 1. Find gravity center and direction
650                 size    = (*lstIndexsIn)[iLstIndexIn];
651                 if (size>2)  // for contour with more than 2 points
652                 {
653                         cx              = 0;
654                         cy              = 0;
655                         cz              = 0;
656                         dirx    = true;
657                         diry    = true;
658                         dirz    = true;
659                         for ( i=0 ; i<size ; i++ )
660                         {
661                                 px=(*lstInX)[iGeneral+i];
662                                 py=(*lstInY)[iGeneral+i];
663                                 pz=(*lstInZ)[iGeneral+i];
664                                 cx      = px + cx;
665                                 cy      = py + cy;
666                                 cz      = pz + cz;
667                                 if (i!=0) 
668                                 { 
669                                         if (backpx!=px) { dirx=false; } 
670                                         if (backpy!=py) { diry=false; } 
671                                         if (backpz!=pz) { dirz=false; } 
672                                         backpx=px;
673                                         backpy=py;
674                                         backpz=pz;
675                                 } // if i!=0
676                                 backpx=px; 
677                                 backpy=py; 
678                                 backpz=pz; 
679                         } // for i 
680                         cx=cx/size;
681                         cy=cy/size;
682                         cz=cz/size;
683                         if (dirx==true) { dir=1; }  // YZ 
684                         if (diry==true) { dir=2; }  // XZ 
685                         if (dirz==true) { dir=0; }  // XZ 
686                         // Step 2. Find angle diference find 
687                         flagAng=0;
688                         for ( i=0 ; i<size ; i++ )
689                         {
690                                 px = (*lstInX)[iGeneral+i]-cx;
691                                 py = (*lstInY)[iGeneral+i]-cy;
692                                 pz = (*lstInZ)[iGeneral+i]-cz;
693                                 if (dir==0) { ang=atan2( py , px ); } // XY
694                                 if (dir==1) { ang=atan2( pz , py ); } // YZ
695                                 if (dir==2) { ang=atan2( pz , px ); } // XZ
696                                 if (i>0) 
697                                 { 
698                                         if (backang<ang) 
699                                         {
700                                                 flagAng++;
701                                         } else {
702                                                 flagAng--;
703                                         }// if backang<ang
704                                 } // if i
705                                 backang=ang; 
706                         } // for i 
707
708
709                         // Step 3. Invert order of points
710                         if (flagAng<0)
711                         {
712                                 size2 = size/2;
713                                 for ( i=0 ; i<size2 ; i++ )
714                                 {
715                                         tmp                                                     = (*lstInX)[iGeneral+i];
716                                         (*lstInX)[iGeneral+i]                   = (*lstInX)[iGeneral+size-1-i];
717                                         (*lstInX)[iGeneral+size-1-i]    = tmp;
718                                         tmp                                                     = (*lstInY)[iGeneral+i];
719                                         (*lstInY)[iGeneral+i]                   = (*lstInY)[iGeneral+size-1-i];
720                                         (*lstInY)[iGeneral+size-1-i]    = tmp;
721                                         tmp                                                     = (*lstInZ)[iGeneral+i];
722                                         (*lstInZ)[iGeneral+i]                   = (*lstInZ)[iGeneral+size-1-i];
723                                         (*lstInZ)[iGeneral+size-1-i]    = tmp;
724                                 } // for i
725                         } // flagAng
726                 } // size>2
727                 iGeneral = iGeneral+size;
728         } // for iLstIndexIn
729 }
730
731
732 /*
733 void ManualContourModel_Box::ShiftValues(       std::vector<double> *lstInX,
734                                                                                         std::vector<double> *lstInY, 
735                                                                                         std::vector<double> *lstInZ,
736                                                                                         std::vector<int> *lstIndexsIn )
737 {
738         int iLstIndexIn,sizeLstIndexIn=lstIndexsIn->size();
739         int ii, iGeneral=0;
740         int size,size2;
741         double dist,distMin;
742         int i,iBack;
743         int ig;
744         double dx,dy,dz;
745         std::vector<double> LstTmpX;
746         std::vector<double> LstTmpY;
747         std::vector<double> LstTmpZ;
748         if (sizeLstIndexIn>=2)
749         {
750         
751                 for (iLstIndexIn=0;  iLstIndexIn<sizeLstIndexIn-1; iLstIndexIn++)
752                 {
753                         size  = (*lstIndexsIn)[iLstIndexIn];
754                         size2 = (*lstIndexsIn)[iLstIndexIn+1];
755                         //find min distance and  iBack
756                         distMin = 10000000;
757                         iBack   = 0;
758                         
759                         
760                         for (ig=0; ig<size; ig++)
761                         {
762                                 for ( i=0 ; i<size2 ; i++ )
763                                 {
764                                         dx      = (*lstInX)[iGeneral+ig]-(*lstInX)[iGeneral+size+i];
765                                         dy      = (*lstInY)[iGeneral+ig]-(*lstInY)[iGeneral+size+i];
766                                         dz      = (*lstInZ)[iGeneral+ig]-(*lstInZ)[iGeneral+size+i];
767                                         dist= sqrt( dx*dx + dy*dy + dz*dz );
768                                         if ( dist<distMin ) 
769                                         {
770                                                 iBack   = i-ig;
771                                                 distMin = dist;
772                                         }
773                                 } // for i size2
774                         } // for ig size
775
776 if (iBack<0) 
777 {
778         printf("- "); 
779         iBack = iBack + size2; 
780 }
781                         
782 printf("EED ManualContourModel_Box::ShiftValues px=%f py=%f pz=%f  iBack=%d/%d  size=%d  distMin=%f \n", (*lstInX)[iGeneral]  , (*lstInY)[iGeneral] , (*lstInZ)[iGeneral], iBack, size2,size, distMin);
783                         
784                         if (iBack!=0)
785                         {
786                                 LstTmpX.clear();
787                                 LstTmpY.clear();
788                                 LstTmpZ.clear();
789                                 for (i=0 ; i<size2 ; i++) 
790                                 {
791                                         ii= (i+iBack)%size2;
792                                         LstTmpX.push_back( (*lstInX)[iGeneral+size+ii] );
793                                         LstTmpY.push_back( (*lstInY)[iGeneral+size+ii] );
794                                         LstTmpZ.push_back( (*lstInZ)[iGeneral+size+ii] );
795                                 } // for i                              
796                                 for (i=0 ; i<size2 ; i++) 
797                                 {
798                                         (*lstInX)[iGeneral+size+i] = LstTmpX[i];
799                                         (*lstInY)[iGeneral+size+i] = LstTmpY[i];
800                                         (*lstInZ)[iGeneral+size+i] = LstTmpZ[i];
801                                 } // for i                              
802                         }
803                         iGeneral=iGeneral+size;
804                 } // for iLstIndexIn
805                 
806 //------------          
807                 
808                 iGeneral=0;
809
810                 for (iLstIndexIn=0;  iLstIndexIn<sizeLstIndexIn-1; iLstIndexIn++)
811                 {
812                         size  = (*lstIndexsIn)[iLstIndexIn];
813                         size2 = (*lstIndexsIn)[iLstIndexIn+1];
814                         //find min distance and  iBack
815                         distMin = 10000000;
816                         iBack   = 0;
817                         
818                         
819 //                      for (ig=0; ig<size; ig++)
820 //                      {
821                                 for ( i=0 ; i<size2 ; i++ )
822                                 {
823                                         dx      = (*lstInX)[iGeneral]-(*lstInX)[iGeneral+size+i];
824                                         dy      = (*lstInY)[iGeneral]-(*lstInY)[iGeneral+size+i];
825                                         dz      = (*lstInZ)[iGeneral]-(*lstInZ)[iGeneral+size+i];
826                                         dist= sqrt( dx*dx + dy*dy + dz*dz );
827                                         if ( dist<distMin ) 
828                                         {
829                                                 iBack   = i;
830                                                 distMin = dist;
831                                         }
832                                 } // for i size2
833 //                      } // for ig size
834
835                         
836 printf("EED ManualContourModel_Box::ShiftValues px=%f py=%f pz=%f  iBack=%d/%d  size=%d  distMin=%f \n", (*lstInX)[iGeneral]  , (*lstInY)[iGeneral] , (*lstInZ)[iGeneral], iBack, size2,size, distMin);
837                         
838                         if (iBack!=0)
839                         {
840                                 LstTmpX.clear();
841                                 LstTmpY.clear();
842                                 LstTmpZ.clear();
843                                 for (i=0 ; i<size2 ; i++) 
844                                 {
845                                         ii= (i+iBack)%size2;
846                                         LstTmpX.push_back( (*lstInX)[iGeneral+size+ii] );
847                                         LstTmpY.push_back( (*lstInY)[iGeneral+size+ii] );
848                                         LstTmpZ.push_back( (*lstInZ)[iGeneral+size+ii] );
849                                 } // for i                              
850                                 for (i=0 ; i<size2 ; i++) 
851                                 {
852                                         (*lstInX)[iGeneral+size+i] = LstTmpX[i];
853                                         (*lstInY)[iGeneral+size+i] = LstTmpY[i];
854                                         (*lstInZ)[iGeneral+size+i] = LstTmpZ[i];
855                                 } // for i                              
856                         }
857                         iGeneral=iGeneral+size;
858                 } // for iLstIndexIn
859                 
860         } // if sizeLstIndexIn
861         
862 }
863 */
864
865
866
867 void ManualContourModel_Box::ShiftValues(       std::vector<double> *lstInX,
868                                                                                         std::vector<double> *lstInY, 
869                                                                                         std::vector<double> *lstInZ,
870                                                                                         std::vector<int> *lstIndexsIn )
871 {
872         int iLstIndexIn,sizeLstIndexIn=lstIndexsIn->size();
873         int ii, iGeneral=0;
874         int size,size2;
875         double dist,distMin;
876         int i,iBack;
877         int ig;
878         double dx,dy,dz;
879         std::vector<double> LstTmpX;
880         std::vector<double> LstTmpY;
881         std::vector<double> LstTmpZ;
882         if (sizeLstIndexIn>=2)
883         {
884         
885           
886          
887                 for (iLstIndexIn=0;  iLstIndexIn<sizeLstIndexIn-1; iLstIndexIn++)
888                 {
889                         size  = (*lstIndexsIn)[iLstIndexIn];
890                         size2 = (*lstIndexsIn)[iLstIndexIn+1];
891                         //find min distance and  iBack
892                         distMin = 10000000;
893                         iBack   = 0;
894                         
895                     // Comparing distance between two contours  
896                     // Both contours need the same size 
897                         for (ig=0; ig<size; ig++)
898                         {
899                                 dist=0;
900                                 for ( i=0 ; i<size2 ; i++ )
901                                 {
902                                         dx      = (*lstInX)[iGeneral+i]-(*lstInX)[iGeneral+size+(i+ig)%size];
903                                         dy      = (*lstInY)[iGeneral+i]-(*lstInY)[iGeneral+size+(i+ig)%size];
904                                         dz      = (*lstInZ)[iGeneral+i]-(*lstInZ)[iGeneral+size+(i+ig)%size];
905                                         dist= dist + sqrt( dx*dx + dy*dy + dz*dz );
906                                 } // for i size2
907
908                                 if ( dist<distMin ) 
909                                 {
910                                         iBack   = ig+size;
911                                         distMin = dist;
912                                 }
913                                 
914                         } // for ig size
915
916                         
917 //printf("EED ManualContourModel_Box::ShiftValues px=%f py=%f pz=%f  iBack=%d/%d  size=%d  distMin=%f \n", (*lstInX)[iGeneral]  , (*lstInY)[iGeneral] , (*lstInZ)[iGeneral], iBack, size2,size, distMin);
918                         
919                         if (iBack!=0)
920                         {
921                                 LstTmpX.clear();
922                                 LstTmpY.clear();
923                                 LstTmpZ.clear();
924                                 for (i=0 ; i<size2 ; i++) 
925                                 {
926                                         ii = (i+iBack)%size2;
927                                         if (ii<(size2-1)) // Skip the last item
928                                         {
929                                                 LstTmpX.push_back( (*lstInX)[iGeneral+size+ii] );
930                                                 LstTmpY.push_back( (*lstInY)[iGeneral+size+ii] );
931                                                 LstTmpZ.push_back( (*lstInZ)[iGeneral+size+ii] );
932                                         }
933                                 } // for i
934                                 
935                                 //Repeat the first item at the end to close the contour
936                                 LstTmpX.push_back( LstTmpX[0] );
937                                 LstTmpY.push_back( LstTmpY[0] );
938                                 LstTmpZ.push_back( LstTmpZ[0] );
939
940                                 for (i=0 ; i<size2 ; i++) 
941                                 {
942                                         (*lstInX)[iGeneral+size+i] = LstTmpX[i];
943                                         (*lstInY)[iGeneral+size+i] = LstTmpY[i];
944                                         (*lstInZ)[iGeneral+size+i] = LstTmpZ[i];
945                                 } // for i                              
946                         }
947                         iGeneral=iGeneral+size;
948                 } // for iLstIndexIn
949                 
950                 
951         } // if sizeLstIndexIn
952         
953 }
954
955
956
957
958
959
960 void ManualContourModel_Box::Process()
961 {
962 // THE MAIN PROCESSING METHOD BODY
963 //   Here we simply set the input 'In' value to the output 'Out'
964 //   And print out the output value
965 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
966 //    void bbSet{Input|Output}NAME(const TYPE&)
967 //    const TYPE& bbGet{Input|Output}NAME() const 
968 //    Where :
969 //    * NAME is the name of the input/output
970 //      (the one provided in the attribute 'name' of the tag 'input')
971 //    * TYPE is the C++ type of the input/output
972 //      (the one provided in the attribute 'type' of the tag 'input')
973
974 //    bbSetOutputOut( bbGetInputIn() );
975 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
976
977         // First Step  Spline Interpolation
978         std::vector<double> lstInX=bbGetInputLstControlPointsX();
979         std::vector<double> lstInY=bbGetInputLstControlPointsY();
980         std::vector<double> lstInZ=bbGetInputLstControlPointsZ();
981         if ( (lstInX.size()!=lstInY.size()) || (lstInY.size()!=lstInZ.size()) ) 
982         { 
983                 printf("Warnning !!  .. ManualContourModel_Box: The list X Y Z, no have the same number of elements \n");
984                 return;
985         }
986         std::vector<int>        lstIndexsIn=bbGetInputLstIndexsIn();
987         std::vector<int>        lstIndexsOut;
988         std::vector<double> lstOutX;
989         std::vector<double> lstOutY;
990         std::vector<double> lstOutZ;
991         if (bbGetInputLstIndexsIn().size()==0)
992         {
993                 lstIndexsIn.push_back( lstInX.size() );
994         }
995         
996 // Step 1.  All contours the same clockwise direction (Control Points)
997         if (bbGetInputDoubleContour()==1)
998         {
999                 ClockwisePoints( &lstInX , &lstInY , &lstInZ , &lstIndexsIn );
1000 //              ShiftValues( &lstInX , &lstInY , &lstInZ , &lstIndexsIn );
1001         } // DoubleContour
1002         int i,size=lstIndexsIn.size();
1003         int iGeneral=0;
1004         
1005 // Step 2.  Spline interpolation of control points      
1006         for (i=0;i<size;i++)
1007         {
1008                 ProcessBySegment(       bbGetInputType() , 
1009                                                         iGeneral,  lstIndexsIn[i] ,
1010                                                         &lstInX ,  &lstInY  , &lstInZ,
1011                                                         &lstOutX , &lstOutY , &lstOutZ,
1012                                                         &lstIndexsOut,bbGetInputOpenClose() );
1013         } // for
1014
1015         if (bbGetInputDoubleContour()==0)
1016         {
1017 // Finish if Simple contours
1018                 //////////////////// Set Out   DoubleContour = 0
1019                 bbSetOutputLstContourPointsX(lstOutX);  
1020                 bbSetOutputLstContourPointsY(lstOutY);  
1021                 bbSetOutputLstContourPointsZ(lstOutZ);
1022                 bbSetOutputLstIndexsOut(lstIndexsOut);  
1023         } else {
1024 // Step 3. Interpolation in the other direction
1025 // Step 3.1 Linear Normalice points around contours     
1026                 RedistributionPoints(&lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut);
1027 //EED 01/2021           
1028 // Step 3.2 Shift points to find minimun acumulate distance     
1029                 ShiftValues( &lstOutX, &lstOutY, &lstOutZ, &lstIndexsOut );
1030 // Step 3.3. SIN Normalice points around contours       
1031 //              RedistributionPoints_SIN_iContour(-1, &lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut,-1,-1);
1032
1033 if (bbGetInputParam()[0]==1)
1034 {
1035                 RedistributionPointsAllContours_SIN( &lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut);
1036 }
1037 // Step 3.4 Transpose the vectors   
1038                 lstInX.clear();
1039                 lstInY.clear();
1040                 lstInZ.clear();
1041                 lstIndexsIn.clear();
1042                 size  = bbGetInputNbPoints();
1043                 int j,size2 = lstIndexsOut.size();
1044                 for (i=0;i<size;i++)
1045                 {
1046                         for (j=0;j<size2;j++)
1047                         {
1048                                 lstInX.push_back( lstOutX[ j*lstIndexsOut[j] + i ] );
1049                                 lstInY.push_back( lstOutY[ j*lstIndexsOut[j] + i ] );
1050                                 lstInZ.push_back( lstOutZ[ j*lstIndexsOut[j] + i ] );
1051                         } // for j
1052                         lstIndexsIn.push_back( size2 );
1053                 } // for i
1054                 lstOutX.clear();
1055                 lstOutY.clear();
1056                 lstOutZ.clear();
1057                 lstIndexsOut.clear();
1058 // Step 3.5 Interponation 2
1059                 size=lstIndexsIn.size();
1060                 iGeneral=0;
1061                 for (i=0;i<size;i++)
1062                 {
1063                         ProcessBySegment(       bbGetInputType() , 
1064                                                                 iGeneral, lstIndexsIn[i] ,
1065                                                                 &lstInX,&lstInY,&lstInZ,
1066                                                                 &lstOutX,&lstOutY,&lstOutZ,
1067                                                                 &lstIndexsOut,bbGetInputOpenClose2());
1068                 } // for
1069                 RedistributionPoints(&lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut);
1070 // Step 3.6 Transpose the vectors   
1071                 lstInX.clear();
1072                 lstInY.clear();
1073                 lstInZ.clear();
1074                 lstIndexsIn.clear();
1075                 size  = bbGetInputNbPoints();
1076                 size2 = lstIndexsOut.size();
1077                 for (i=0;i<size;i++)
1078                 {
1079                         for (j=0;j<size2;j++)
1080                         {
1081                                 lstInX.push_back( lstOutX[ j*lstIndexsOut[j] + i ] );
1082                                 lstInY.push_back( lstOutY[ j*lstIndexsOut[j] + i ] );
1083                                 lstInZ.push_back( lstOutZ[ j*lstIndexsOut[j] + i ] );
1084                         } // for j
1085                         lstIndexsIn.push_back( size2 );
1086                 } // for i
1087                 lstOutX.clear();
1088                 lstOutY.clear();
1089                 lstOutZ.clear();
1090                 lstIndexsOut.clear();
1091                 //////////////////// Set Out   DoubleContour = 1
1092                 bbSetOutputLstContourPointsX(lstInX);   
1093                 bbSetOutputLstContourPointsY(lstInY);   
1094                 bbSetOutputLstContourPointsZ(lstInZ);
1095                 bbSetOutputLstIndexsOut(lstIndexsIn);   
1096
1097         } // if DoubleContour 
1098
1099 }
1100 //===== 
1101 // 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)
1102 //===== 
1103 void ManualContourModel_Box::bbUserSetDefaultValues()
1104 {
1105
1106 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
1107 //    Here we initialize the input 'In' to 0
1108    bbSetInputType(1);
1109    bbSetInputDoubleContour(0);
1110    bbSetInputOpenClose(false);
1111    bbSetInputOpenClose2(false);
1112    bbSetInputNbPoints(100);
1113   
1114 }
1115 //===== 
1116 // 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)
1117 //===== 
1118 void ManualContourModel_Box::bbUserInitializeProcessing()
1119 {
1120
1121 //  THE INITIALIZATION METHOD BODY :
1122 //    Here does nothing 
1123 //    but this is where you should allocate the internal/output pointers 
1124 //    if any 
1125
1126   
1127 }
1128 //===== 
1129 // 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)
1130 //===== 
1131 void ManualContourModel_Box::bbUserFinalizeProcessing()
1132 {
1133
1134 //  THE FINALIZATION METHOD BODY :
1135 //    Here does nothing 
1136 //    but this is where you should desallocate the internal/output pointers 
1137 //    if any
1138   
1139 }
1140 }
1141 // EO namespace bbcreaMaracasVisu
1142
1143