]> Creatis software - creaMaracasVisu.git/commitdiff
#3463 box ManualContourModel optimisation of SIN() distribution by contour
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Sun, 16 May 2021 14:12:07 +0000 (16:12 +0200)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Sun, 16 May 2021 14:12:07 +0000 (16:12 +0200)
bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx
bbtk/src/bbcreaMaracasVisuManualContourModel_Box.h

index 9623d4c42448e9bfb84a9c395bc688b142dd0d91..b7cea8edd47ed328ec6d06ed6a48c2c62c2c569f 100644 (file)
@@ -146,7 +146,7 @@ void ManualContourModel_Box::ExtractContour(        std::vector<double> *lstX,
                                                                                                std::vector<double> *lstOutZ )
 {
        int     i;
-       int     iLstIndex;
+//     int     iLstIndex;
        int     iContour;
        int     sizeLstIndexslstIndexs;
        int     iGeneral;
@@ -186,7 +186,7 @@ void ManualContourModel_Box::PutPointsInContour(std::vector<double> *lstTmpX,
                                                                                                std::vector<int>        *lstOutIndexs )
 {
        int     i;
-       int     iLstIndex;
+//     int     iLstIndex;
        int     iContour;
        int     sizeLstIndexslstIndexs;
        int     iGeneral;
@@ -211,8 +211,10 @@ void ManualContourModel_Box::PutPointsInContour(std::vector<double> *lstTmpX,
                        if(SizeContour==(*lstTmpX).size() )
                        {
                                int iSize=0;
+printf("\n ManualContourModel_Box::PutPointsInContour y=%f\n", (*lstTmpY)[0] );
                                for ( i=iGeneral ; i<iGeneralPlusSize ; i++ )
                                {
+printf("x=%f  %f   y=%f %f  z=%f %f\n", (*lstOutX)[i], (*lstTmpX)[iSize],(*lstOutY)[i], (*lstTmpY)[iSize],(*lstOutZ)[i], (*lstTmpZ)[iSize]  );
                                        (*lstOutX)[i] = (*lstTmpX)[iSize] ;
                                        (*lstOutY)[i] = (*lstTmpY)[iSize] ;
                                        (*lstOutZ)[i] = (*lstTmpZ)[iSize] ;
@@ -232,26 +234,6 @@ void ManualContourModel_Box::PutPointsInContour(std::vector<double> *lstTmpX,
        } // NULL
 }
 
-double ManualContourModel_Box::SizeContour(    std::vector<double> *lstX,
-                                                                                       std::vector<double> *lstY, 
-                                                                                       std::vector<double> *lstZ)
-{
-       int     i;
-       double  dx;
-       double  dy;
-       double  dz;
-       double  dist            = 0;
-       int     iSize           = (*lstX).size()  - 1;
-       for ( i=0 ; i<iSize ; i++ )
-       {
-               dx      = (*lstX)[i+1]-(*lstX)[i];
-               dy      = (*lstY)[i+1]-(*lstY)[i];
-               dz      = (*lstZ)[i+1]-(*lstZ)[i];
-               dist= dist+sqrt( dx*dx + dy*dy + dz*dz );
-       } //for i
-       return dist;
-}
-
 
 void ManualContourModel_Box::Redistribution_SIN(       double alpha,
                                                                                                        double beta,
@@ -261,7 +243,7 @@ void ManualContourModel_Box::Redistribution_SIN(    double alpha,
                                                                                                        double sizeOfContour,
                                                                                                        std::vector<double> *lstC2X,
                                                                                                        std::vector<double> *lstC2Y, 
-                                                                                                       std::vector<double> *lstC2Z )
+                                                                                                       std::vector<double> *lstC2Z  )
 {
        std::vector<double> lstRstX;
        std::vector<double> lstRstY;
@@ -272,7 +254,6 @@ void ManualContourModel_Box::Redistribution_SIN(    double alpha,
        int     firstK;
        double  iiByDelta;
        double  dist2,distSeg;
-//     double  delta;
        double  dd,dx,dy,dz;
        double  t,tt, PI;
        double  TwoPI;
@@ -281,116 +262,88 @@ void ManualContourModel_Box::Redistribution_SIN( double alpha,
        PI                      = 3.14159265;
        TwoPI           = 2*PI;
        iGeneral        = 0;
-//     for (iLstIndexOut=0;  iLstIndexOut<sizeLstIndexOut; iLstIndexOut++)  // For each contour
-//     {
-//             lstRstX.clear();
-//             lstRstY.clear();
-//             lstRstZ.clear();
-//             size                            = (*lstIndexsOut)[iLstIndexOut];
-               size = (*lstC1X).size();
-               iGeneralPlusSize        = iGeneral+size;
-               if (size>2)
+
+       size = (*lstC1X).size();
+       iGeneralPlusSize        = iGeneral+size;
+       if (size>2)
+       {
+               firstK  = 0;                    
+               for (i=iGeneral; i<iGeneralPlusSize;i++)                                //  For each point of one contour
                {
-//                     dist=0;
-//                     for ( i=iGeneral ; i<iGeneralPlusSize-1 ; i++ )
-//                     {
-//                             dx      = (*lstOutX)[i]-(*lstOutX)[i+1];
-//                             dy      = (*lstOutY)[i]-(*lstOutY)[i+1];
-//                             dz      = (*lstOutZ)[i]-(*lstOutZ)[i+1];
-//                             dist= dist+sqrt( dx*dx + dy*dy + dz*dz );
-//                     } //for
+                       ii              = i-iGeneral;
+                       dist2   = 0;
+
+                       t               = ((double)ii) / ((double)(size-1));
+                       tt              = t + 0.70710678182*sin(t*TwoPI)*beta + alpha;
+                       if (tt>=1) { tt=tt-1; }
+                       if (tt<0) { tt=tt+1; }
+                       iiByDelta = tt * dist;
 
 
-//                     delta = dist/(size-1);
-                       firstK  = 0;                    
-                       for (i=iGeneral; i<iGeneralPlusSize;i++)                                //  For each point of one contour
+                       for (k=iGeneral; k<iGeneralPlusSize-1;k++)                      // Search inside
                        {
-                               ii = i-iGeneral;
-                               dist2   = 0;
-                               for (k=iGeneral; k<iGeneralPlusSize;k++)                        // Search inside
+                               dx              = (*lstC1X)[k+1]-(*lstC1X)[k];
+                               dy              = (*lstC1Y)[k+1]-(*lstC1Y)[k];
+                               dz              = (*lstC1Z)[k+1]-(*lstC1Z)[k];
+                               distSeg = sqrt( dx*dx + dy*dy + dz*dz );
+                               if ( dist2+distSeg >= iiByDelta )
                                {
-//if ( 385==(*lstOutY)[k]  )
-//{ 
-       t               =       ((double)ii) / ((double)(size-1));
-//     Beta    = 0.20; //  [0..1]
-//     Alpha   = 0.0;  // [0..1]
-//     Beta    = bbGetInputParam()[0];
-//     Alpha   = bbGetInputParam()[1];
-       tt              = t + 0.70710678182*sin(t*TwoPI)*beta + alpha;
-       if (tt>1) { tt=tt-1; }
-       if (tt<0) { tt=tt+1; }
-       iiByDelta = tt * dist;
-//} else {
-//  iiByDelta = ii*delta;
-//}
-
-//                                     dx = (*lstOutX)[k+1]-(*lstOutX)[k];
-//                                     dy = (*lstOutY)[k+1]-(*lstOutY)[k];
-//                                     dz = (*lstOutZ)[k+1]-(*lstOutZ)[k];
-                                       dx = (*lstC1X)[k+1]-(*lstC1X)[k];
-                                       dy = (*lstC1Y)[k+1]-(*lstC1Y)[k];
-                                       dz = (*lstC1Z)[k+1]-(*lstC1Z)[k];
-                                       distSeg = sqrt( dx*dx + dy*dy + dz*dz );
-                                       if ( dist2+distSeg >= iiByDelta )
+                                       if (distSeg==0)
                                        {
-                                               if (distSeg==0)
-                                               {
-                                                       dd = 0;
-                                               } else {
-                                                       dd=(iiByDelta-dist2)/distSeg;
-                                               }// if distSeg == 0
+                                               dd = 0;
+                                       } else {
+                                               dd=(iiByDelta-dist2)/distSeg;
+                                       }// if distSeg == 0
+                                       lstRstX.push_back( (*lstC1X)[k] + dd*dx );
+                                       lstRstY.push_back( (*lstC1Y)[k] + dd*dy );
+                                       lstRstZ.push_back( (*lstC1Z)[k] + dd*dz );
+                                       if (ii==0) { firstK=k; }
+                                       k = iGeneralPlusSize-1;
+                               } else {
+                                       if ( k==iGeneralPlusSize-1-1 )
+                                       {
+                                               dd = 1;
                                                lstRstX.push_back( (*lstC1X)[k] + dd*dx );
                                                lstRstY.push_back( (*lstC1Y)[k] + dd*dy );
                                                lstRstZ.push_back( (*lstC1Z)[k] + dd*dz );
-                                               if (ii==0) { firstK=k; }
-                                               k = iGeneralPlusSize-1;
-                                       } else {
-                                               if ( k==iGeneral+size-2 )
-                                               {
-                                                       dd = 1;
-                                                       lstRstX.push_back( (*lstC1X)[k] + dd*dx );
-                                                       lstRstY.push_back( (*lstC1Y)[k] + dd*dy );
-                                                       lstRstZ.push_back( (*lstC1Z)[k] + dd*dz );
-                                               }
-                                       }// if dist2 
-                                       dist2 = dist2 + distSeg;
-                               } // for k
-                       } //for i                       
-                       if (lstRstX.size()!=size) 
-                       {
-                               printf("EED Warnning!   ManualContourModel_Box::Redistribution_SIN  >> This list is not coherent lstRstX.size()=%d  size=%d\n", lstRstX.size(), size);
-                       }
-                       (*lstC2X).clear();
-                       (*lstC2Y).clear();
-                       (*lstC2Z).clear();
-                       for (i=iGeneral; i<iGeneralPlusSize;i++)
-                       {
-                               (*lstC2X).push_back(-1);        
-                               (*lstC2Y).push_back(-1);        
-                               (*lstC2Z).push_back(-1);        
-                       } // for i
-                       int iii;
-                       for (i=iGeneral; i<iGeneralPlusSize;i++)
-                       {
-                               ii                              = i-iGeneral;
-                               iii                             = iGeneral+ ( (i-iGeneral) + firstK) % size ;
-//                             (*lstOutX)[iii] = lstRstX[ii];
-//                             (*lstOutY)[iii] = lstRstY[ii];
-//                             (*lstOutZ)[iii] = lstRstZ[ii];
-                               (*lstC2X)[iii]  = lstRstX[ii];
-                               (*lstC2Y)[iii]  = lstRstY[ii];
-                               (*lstC2Z)[iii]  = lstRstZ[ii];
-                       } // for i
-               } else {
-                       for (i=0; i<size ; i++)
-                       {
-                               (*lstC2X)[i] = (*lstC1X)[i];
-                               (*lstC2Y)[i] = (*lstC1Y)[i];
-                               (*lstC2Z)[i] = (*lstC1Z)[i];
-                       } // for i
-               }// if size>2
-//             iGeneral=iGeneral+size;
-//     }// for iLstIndexOut
+                                       } // if k
+                               }// if dist2 
+                               dist2 = dist2 + distSeg;
+                       } // for k
+               } //for i                       
+               if (lstRstX.size()!=size) 
+               {
+                       printf("EED Warnning!   ManualContourModel_Box::Redistribution_SIN  >> This list is not coherent lstRstX.size()=%d  size=%d\n", lstRstX.size(), size);
+               }
+               (*lstC2X).clear();
+               (*lstC2Y).clear();
+               (*lstC2Z).clear();
+               for (i=iGeneral; i<iGeneralPlusSize;i++)
+               {
+                       (*lstC2X).push_back(-1);        
+                       (*lstC2Y).push_back(-1);        
+                       (*lstC2Z).push_back(-1);        
+               } // for i
+               int iii;
+               for (i=iGeneral; i<iGeneralPlusSize;i++)
+               {
+                       ii                              = i-iGeneral;
+                       iii                             = iGeneral+ ( (i-iGeneral) + firstK) % size ;
+                       (*lstC2X)[iii]  = lstRstX[ii];
+                       (*lstC2Y)[iii]  = lstRstY[ii];
+                       (*lstC2Z)[iii]  = lstRstZ[ii];
+               } // for i
+               (*lstC2X)[iGeneralPlusSize-1]=(*lstC2X)[iGeneral];
+               (*lstC2Y)[iGeneralPlusSize-1]=(*lstC2Y)[iGeneral];
+               (*lstC2Z)[iGeneralPlusSize-1]=(*lstC2Z)[iGeneral];
+       } else {
+               for (i=0; i<size ; i++)
+               {
+                       (*lstC2X)[i] = (*lstC1X)[i];
+                       (*lstC2Y)[i] = (*lstC1Y)[i];
+                       (*lstC2Z)[i] = (*lstC1Z)[i];
+               } // for i
+       }// if size>2
 }
 
 void ManualContourModel_Box::CopyContour2InContour1(
@@ -431,11 +384,123 @@ double ManualContourModel_Box::IntegralDistanceTwoContours(std::vector<double> *
                dx              = (*lstTmpAX)[i]-(*lstTmpBX)[i];
                dy              = (*lstTmpAY)[i]-(*lstTmpBY)[i];
                dz              = (*lstTmpAZ)[i]-(*lstTmpBZ)[i];
-               dist    = dist + sqrt( dx*dx + dy*dy + dz*dz );
+//             dist    = dist + sqrt( dx*dx + dy*dy + dz*dz );
+               dist    = dist +  (dx*dx + dy*dy + dz*dz) ;
        } //for i
        return dist;
 }
 
+void ManualContourModel_Box::findAlphaBetaSinDistribution(     std::vector<double> *ptrLstTmp2X,
+                                                                                                                       std::vector<double> *ptrLstTmp2Y,
+                                                                                                                       std::vector<double> *ptrLstTmp2Z ,
+                                                                                                                       int sizeContour,
+                                                                                                                       std::vector<double> *ptrLstTmp1X,
+                                                                                                                       std::vector<double> *ptrLstTmp1Y,
+                                                                                                                       std::vector<double> *ptrLstTmp1Z,  
+                                                                                                                       double *alphaOut,
+                                                                                                                       double *betaOut) 
+{
+       std::vector<double> lstTmp2aX;
+       std::vector<double> lstTmp2aY;
+       std::vector<double> lstTmp2aZ;
+       double  alpha,iAlpha,deltaAlpha;
+       double  beta,iBeta,deltaBeta;
+       double  distAcum;
+       double  minDistAcum;
+       deltaAlpha      = 0.1 / 2;      
+       deltaBeta       = 0.01 / 2;     
+       beta            = 0.05;
+       alpha           = 0;
+       minDistAcum = 999999999999;
+       for (iAlpha=0 ; iAlpha<1; iAlpha=iAlpha+deltaAlpha ) 
+       {
+               Redistribution_SIN( iAlpha,beta, ptrLstTmp2X,ptrLstTmp2Y,ptrLstTmp2Z ,sizeContour, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
+               distAcum = IntegralDistanceTwoContours( ptrLstTmp1X,ptrLstTmp1Y,ptrLstTmp1Z , &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
+               if (distAcum<minDistAcum) 
+               {
+                       alpha           = iAlpha;
+                       minDistAcum     = distAcum;
+               } // if integerDist
+       } // for alpha
+// find Beta
+       minDistAcum = 999999999999;
+       for (iBeta=0.0 ; iBeta<0.2; iBeta=iBeta+deltaBeta) 
+       {
+               Redistribution_SIN( alpha,iBeta, ptrLstTmp2X,ptrLstTmp2Y,ptrLstTmp2Z ,sizeContour, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
+               distAcum = IntegralDistanceTwoContours( ptrLstTmp1X,ptrLstTmp1Y,ptrLstTmp1Z , &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
+               if (distAcum<minDistAcum) 
+               {
+                       beta            = iBeta;
+                       minDistAcum     = distAcum;
+               } // if integerDist
+       } // for iBeta                  
+       *alphaOut       = alpha;
+       *betaOut        = beta;
+}
+
+
+
+double ManualContourModel_Box::SizeContour(    std::vector<double> *lstX,
+                                                                                       std::vector<double> *lstY, 
+                                                                                       std::vector<double> *lstZ)
+{
+       int     i;
+       double  dx;
+       double  dy;
+       double  dz;
+       double  dist            = 0;
+       int     iSize           = (*lstX).size()  - 1;
+       for ( i=0 ; i<iSize ; i++ )
+       {
+               dx      = (*lstX)[i+1]-(*lstX)[i];
+               dy      = (*lstY)[i+1]-(*lstY)[i];
+               dz      = (*lstZ)[i+1]-(*lstZ)[i];
+               dist= dist+sqrt( dx*dx + dy*dy + dz*dz );
+       } //for i
+       return dist;
+}
+
+
+
+void ManualContourModel_Box::CalculeLstSizeContours(   std::vector<double> *lstOutX,
+                                                                                                               std::vector<double> *lstOutY,
+                                                                                                               std::vector<double> *lstOutZ,
+                                                                                                               std::vector<int>        *lstIndexsOut,
+                                                                                                               std::vector<double> *lstSizeContours    )
+{
+       int     i;
+//     int     iLstIndex;
+       int     iContour;
+       int     sizeLstIndexs;
+       int     iGeneral;
+       int     iGeneralPlusSize;
+       double  dx,dy,dz;
+       double  dist;
+       (*lstSizeContours).clear();
+       if ( (lstOutX!=NULL) &&  (lstOutY!=NULL) && (lstOutZ!=NULL) && (lstIndexsOut!=NULL)  )
+       {
+               sizeLstIndexs   = (*lstIndexsOut).size();
+               if  ( sizeLstIndexs!=0 ) 
+               {       
+                       iGeneral                                = 0;
+                       for ( iContour=0 ; iContour<sizeLstIndexs ; iContour++ )
+                       {
+                               dist                            = 0;
+                               iGeneralPlusSize        = iGeneral + (*lstIndexsOut)[iContour];
+                               for ( i=iGeneral+1 ; i<iGeneralPlusSize ; i++ )
+                               {
+                                       dx      = (*lstOutX)[i]-(*lstOutX)[i-1] ;
+                                       dy      = (*lstOutY)[i]-(*lstOutY)[i-1] ;
+                                       dz      = (*lstOutZ)[i]-(*lstOutZ)[i-1] ;
+                                       dist= dist + sqrt( dx*dx +dy*dy + dz*dz );
+                               } // for iGeneral
+                               (*lstSizeContours).push_back( dist );
+                               iGeneral = iGeneralPlusSize;
+                       } // for iContour
+               } // sizeLstIndexs 
+       } // if lst NULL
+}
+
 
 void ManualContourModel_Box::RedistributionPointsAllContours_SIN(      std::vector<double> *lstOutX,
                                                                                                                                        std::vector<double> *lstOutY, 
@@ -451,471 +516,139 @@ void ManualContourModel_Box::RedistributionPointsAllContours_SIN(       std::vector<do
        std::vector<double> lstTmp2aX;
        std::vector<double> lstTmp2aY;
        std::vector<double> lstTmp2aZ;
-       std::vector<double> lstTmp2bX;
-       std::vector<double> lstTmp2bY;
-       std::vector<double> lstTmp2bZ;
-       std::vector<double> lstTmp2cX;
-       std::vector<double> lstTmp2cY;
-       std::vector<double> lstTmp2cZ;
        std::vector<double> lstTmp3X;
        std::vector<double> lstTmp3Y;
        std::vector<double> lstTmp3Z;
        std::vector<int>        lstContourExeption;
+       std::vector<double>     lstSizeContours;
        int     iContour;
        double  nbContours              = (*lstIndexsOut).size();
-       double  alpha,iAlpha;
-       double  beta,iBeta;
+       double  alpha,beta;
        double  sizeContour1;
        double  sizeContour2;
        double  sizeContour3;
-       double  distAcum;
-       double minDistAcum;
        
-       // ------------ Wave 1 -----------------
+       CalculeLstSizeContours(lstOutX,lstOutY,lstOutZ,lstIndexsOut, &lstSizeContours);
        
+// ------------ Wave 1    Back to Fordward (redistribution for the little one)-----------------        
        ExtractContour(lstOutX,lstOutY,lstOutZ,lstIndexsOut,0,&lstTmp1X,&lstTmp1Y,&lstTmp1Z);
-       sizeContour1    = SizeContour( &lstTmp1X, &lstTmp1Y, &lstTmp1Z );
+//     sizeContour1    = SizeContour( &lstTmp1X, &lstTmp1Y, &lstTmp1Z );
+       sizeContour1 = lstSizeContours[0];
        
 // Increment   
-       for ( iContour=0; iContour<nbContours-1 ; iContour++ )
+       for ( iContour=0; iContour<nbContours-1 ; iContour++ )   // Back to Fordward
        {
-               beta    = 0;
-               alpha   = 0;
-// find Alpha
                ExtractContour( lstOutX,lstOutY,lstOutZ,lstIndexsOut, iContour+1 ,&lstTmp2X,&lstTmp2Y,&lstTmp2Z );              
-               sizeContour2    = SizeContour( &lstTmp2X, &lstTmp2Y, &lstTmp2Z );
-
+//             sizeContour2    = SizeContour( &lstTmp2X, &lstTmp2Y, &lstTmp2Z );
+               sizeContour2 = lstSizeContours[ iContour+1 ];
+               
                if (iContour+2<nbContours)
                {
-                       ExtractContour( lstOutX,lstOutY,lstOutZ,lstIndexsOut, iContour+2 ,&lstTmp3X,&lstTmp3Y,&lstTmp3Z );              
-                       sizeContour3    = SizeContour( &lstTmp3X, &lstTmp3Y, &lstTmp3Z );
+//                     ExtractContour( lstOutX,lstOutY,lstOutZ,lstIndexsOut, iContour+2 ,&lstTmp3X,&lstTmp3Y,&lstTmp3Z );              
+//                     sizeContour3    = SizeContour( &lstTmp3X, &lstTmp3Y, &lstTmp3Z );
+                       sizeContour3 = lstSizeContours[ iContour+2 ];
                } else {
                        sizeContour3=-1;
                }
-               
                if ( (sizeContour1>sizeContour2) && (sizeContour2>sizeContour3) )
                {
-                       beta    = 0.05;
-                       alpha   = 0;
-                       minDistAcum = 999999999;
-                       for (iAlpha=0 ; iAlpha<1; iAlpha=iAlpha+0.1 ) 
-                       {
-                               Redistribution_SIN( iAlpha,beta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
-                               distAcum = IntegralDistanceTwoContours( &lstTmp1X,&lstTmp1Y,&lstTmp1Z , &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
-                               if (distAcum<minDistAcum) 
-                               {
-                                       alpha           = iAlpha;
-                                       minDistAcum     = distAcum;
-                               } // if integerDist
-                       } // for alpha
-// find Beta
-                       minDistAcum = 999999999;
-                       for (iBeta=0.0 ; iBeta<0.2; iBeta=iBeta+0.01) 
-                       {
-                               Redistribution_SIN( alpha,iBeta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
-                               distAcum = IntegralDistanceTwoContours( &lstTmp1X,&lstTmp1Y,&lstTmp1Z , &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
-                               if (distAcum<minDistAcum) 
-                               {
-                                       beta            = iBeta;
-                                       minDistAcum     = distAcum;
-                               } // if integerDist
-
-                       } // for beta
-               } //if sizeContour1>sizeContour2>sizeContour3
-                else  {
-                       if ( (sizeContour1>sizeContour2) && (sizeContour2<sizeContour3) )
+                       findAlphaBetaSinDistribution( &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2,  &lstTmp1X,&lstTmp1Y,&lstTmp1Z,  &alpha,&beta);
+                       Redistribution_SIN( alpha,beta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
+                         sizeContour2                                  = SizeContour( &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
+                         lstSizeContours[ iContour+1 ] = sizeContour2;
+                       PutPointsInContour(&lstTmp2aX,&lstTmp2aY,&lstTmp2aZ, iContour+1 ,lstOutX,lstOutY,lstOutZ,lstIndexsOut);                         
+                       CopyContour2InContour1( &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ , &lstTmp1X,&lstTmp1Y,&lstTmp1Z );
+               } else {
+                       if ( (sizeContour1>sizeContour2) && (sizeContour2<sizeContour3) )  // Warning for a minimum local
                        {
-                               lstContourExeption.push_back( iContour+1 );
-                       } // 
-                }               
-// Set Alpha y Beta
-               Redistribution_SIN( alpha,beta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
-
-               PutPointsInContour(&lstTmp2aX,&lstTmp2aY,&lstTmp2aZ, iContour+1 ,lstOutX,lstOutY,lstOutZ,lstIndexsOut);                         
+                               lstContourExeption.push_back( iContour-1 );
+                       } // if minimum local
+                       if ( (sizeContour1<sizeContour2) && (sizeContour2>sizeContour3) )  // Warning for a maximum local
+                       {
+                               lstInconsistentContourY.push_back( lstTmp2Y[0] );
+                               lstInconsistentContourID.push_back( iContour+1 );
+                       } // if maximum local
+                       CopyContour2InContour1( &lstTmp2aX,&lstTmp2Y,&lstTmp2Z , &lstTmp1X,&lstTmp1Y,&lstTmp1Z );
+                } //if sizeContour1>sizeContour2>sizeContour3           
                sizeContour1 = sizeContour2;
-               CopyContour2InContour1( &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ , &lstTmp1X,&lstTmp1Y,&lstTmp1Z );
-       
        } // for iContour 
+
        
-       
-       
-       
-       
-       // ------------ Wave 2 -----------------
-       
+// ------------ Wave 2  fordward  to back  (redistribute the litle one)-----------------
        ExtractContour(lstOutX,lstOutY,lstOutZ,lstIndexsOut,nbContours-1,&lstTmp1X,&lstTmp1Y,&lstTmp1Z);
-       sizeContour1    = SizeContour( &lstTmp1X, &lstTmp1Y, &lstTmp1Z );
-       
+//     sizeContour1    = SizeContour( &lstTmp1X, &lstTmp1Y, &lstTmp1Z );
+       sizeContour1    = lstSizeContours[ nbContours-1 ];
+
 // Increment   
-       for ( iContour=nbContours-1; iContour>=0 ; iContour-- )
+       for ( iContour=nbContours-1; iContour>0 ; iContour-- )  // Fordward to Back
        {
-               beta    = 0;
-               alpha   = 0;
-// find Alpha
                ExtractContour( lstOutX,lstOutY,lstOutZ,lstIndexsOut, iContour-1 ,&lstTmp2X,&lstTmp2Y,&lstTmp2Z );              
-               sizeContour2    = SizeContour( &lstTmp2X, &lstTmp2Y, &lstTmp2Z );
-               
-               
-               if (iContour-2<=0)
+//             sizeContour2    = SizeContour( &lstTmp2X, &lstTmp2Y, &lstTmp2Z );
+               sizeContour2    = lstSizeContours[ iContour-1 ];
+               if (iContour-2>=0)
                {
-                       ExtractContour( lstOutX,lstOutY,lstOutZ,lstIndexsOut, iContour-2 ,&lstTmp3X,&lstTmp3Y,&lstTmp3Z );              
-                       sizeContour3    = SizeContour( &lstTmp3X, &lstTmp3Y, &lstTmp3Z );
+//                     ExtractContour( lstOutX,lstOutY,lstOutZ,lstIndexsOut, iContour-2 ,&lstTmp3X,&lstTmp3Y,&lstTmp3Z );              
+//                     sizeContour3    = SizeContour( &lstTmp3X, &lstTmp3Y, &lstTmp3Z );
+                       sizeContour3    = lstSizeContours[ iContour-2 ];
                } else {
                        sizeContour3=-1;
                }
-               
-               if ( (sizeContour1>sizeContour2) && (sizeContour2>sizeContour3) ){
-                       beta    = 0.05;
-                       alpha   = 0;
-                       minDistAcum = 999999999;
-                       for (iAlpha=0 ; iAlpha<1; iAlpha=iAlpha+0.1 ) 
-                       {
-                               Redistribution_SIN( iAlpha,beta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
-                               distAcum = IntegralDistanceTwoContours( &lstTmp1X,&lstTmp1Y,&lstTmp1Z , &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
-                               if (distAcum<minDistAcum) 
-                               {
-                                       alpha           = iAlpha;
-                                       minDistAcum     = distAcum;
-                               } // if integerDist
-                       } // for alpha
-// find Beta
-                       minDistAcum = 999999999;
-                       for (iBeta=0.0 ; iBeta<0.2; iBeta=iBeta+0.01) 
-                       {
-                               Redistribution_SIN( alpha,iBeta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
-                               distAcum = IntegralDistanceTwoContours( &lstTmp1X,&lstTmp1Y,&lstTmp1Z , &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
-                               if (distAcum<minDistAcum) 
-                               {
-                                       beta            = iBeta;
-                                       minDistAcum     = distAcum;
-                               } // if integerDist
-
-                       } // for beta
+               if ( (sizeContour1>sizeContour2) && (sizeContour2>sizeContour3) )
+               {
+                       findAlphaBetaSinDistribution( &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2,  &lstTmp1X,&lstTmp1Y,&lstTmp1Z,  &alpha,&beta);
+                       Redistribution_SIN( alpha,beta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
+                         sizeContour2                                  = SizeContour( &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
+                         lstSizeContours[ iContour-1 ] = sizeContour2;
+                       PutPointsInContour(&lstTmp2aX,&lstTmp2aY,&lstTmp2aZ, iContour-1 ,lstOutX,lstOutY,lstOutZ,lstIndexsOut);                 
+                       CopyContour2InContour1( &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ , &lstTmp1X,&lstTmp1Y,&lstTmp1Z );
+               } else {
+                       if ( (sizeContour1>sizeContour2) && (sizeContour2<sizeContour3) )  // Warning for a minim local
+                       {
+                               lstContourExeption.push_back( iContour-1 );
+                       } // if minimum local
+                       if ( (sizeContour1<sizeContour2) && (sizeContour2>sizeContour3) )  // Warning for a maximum local
+                       {
+                               lstInconsistentContourY.push_back( lstTmp2Y[0] );
+                               lstInconsistentContourID.push_back( iContour-1 );
+                       } // if Maximum local
+                       CopyContour2InContour1( &lstTmp2X,&lstTmp2Y,&lstTmp2Z , &lstTmp1X,&lstTmp1Y,&lstTmp1Z );
                } //if  sizeContour1>sizeContour2>sizeContour3
-// Set Alpha y Beta
-
-
-               Redistribution_SIN( alpha,beta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
-
-               PutPointsInContour(&lstTmp2aX,&lstTmp2aY,&lstTmp2aZ, iContour-1 ,lstOutX,lstOutY,lstOutZ,lstIndexsOut);                         
                sizeContour1 = sizeContour2;
-               CopyContour2InContour1( &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ , &lstTmp1X,&lstTmp1Y,&lstTmp1Z );
-       
        } // for iContour 
-       
-       
-       
-       // ------------ Wave 3 -----------------
-       
+
+// ------------ Wave 3  redistribution for the minimun detected in Wave 1 -----------------
        double alpha1,alpha2;
        double beta1,beta2;
        double iExtra,sizeExtra=lstContourExeption.size();
        for ( iExtra=0 ; iExtra<sizeExtra ; iExtra++ )
-       {
-        
-               ExtractContour(lstOutX,lstOutY,lstOutZ,lstIndexsOut, lstContourExeption[iExtra]-1       , &lstTmp1X,&lstTmp1Y,&lstTmp1Z);
-               sizeContour1    = SizeContour( &lstTmp1X, &lstTmp1Y, &lstTmp1Z );
-               ExtractContour(lstOutX,lstOutY,lstOutZ,lstIndexsOut, lstContourExeption[iExtra]         , &lstTmp2X,&lstTmp2Y,&lstTmp2Z);
-               sizeContour2    = SizeContour( &lstTmp2X, &lstTmp2Y, &lstTmp2Z );
-               ExtractContour(lstOutX,lstOutY,lstOutZ,lstIndexsOut, lstContourExeption[iExtra]+1       , &lstTmp3X,&lstTmp3Y,&lstTmp3Z);
-               sizeContour3    = SizeContour( &lstTmp3X, &lstTmp3Y, &lstTmp3Z );
-        
-               printf("EED Warnning!  ManualContourModel_Box::RedistributionPointsAllContours_SIN  wave3 posible inconsistent contour y=%f\n", lstTmp2Y[0] );
-        
-// find Alpha
-               beta1   = 0.05;
-               alpha1  = 0;
-               minDistAcum = 999999999;
-               for (iAlpha=0 ; iAlpha<1; iAlpha=iAlpha+0.1 ) 
-               {
-                       Redistribution_SIN( iAlpha,beta1, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
-                       distAcum = IntegralDistanceTwoContours( &lstTmp1X,&lstTmp1Y,&lstTmp1Z , &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
-                       if (distAcum<minDistAcum) 
-                       {
-                               alpha1          = iAlpha;
-                               minDistAcum     = distAcum;
-                       } // if integerDist
-               } // for alpha
-// find Beta
-               minDistAcum = 999999999;
-               for (iBeta=0.0 ; iBeta<0.2; iBeta=iBeta+0.01) 
-               {
-                       Redistribution_SIN( alpha1,iBeta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
-                       distAcum = IntegralDistanceTwoContours( &lstTmp1X,&lstTmp1Y,&lstTmp1Z , &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
-                       if (distAcum<minDistAcum) 
-                       {
-                               beta1           = iBeta;
-                               minDistAcum     = distAcum;
-                       } // if integerDist
-               } // for beta    
-
-// find Alpha
-               beta2   = 0.05;
-               alpha2  = 0;
-               minDistAcum = 999999999;
-               for (iAlpha=0 ; iAlpha<1; iAlpha=iAlpha+0.1 ) 
-               {
-                       Redistribution_SIN( iAlpha,beta2, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2bX,&lstTmp2bY,&lstTmp2bZ );
-                       distAcum = IntegralDistanceTwoContours( &lstTmp3X,&lstTmp3Y,&lstTmp3Z , &lstTmp2bX,&lstTmp2bY,&lstTmp2bZ );
-                       if (distAcum<minDistAcum) 
-                       {
-                               alpha2          = iAlpha;
-                               minDistAcum     = distAcum;
-                       } // if integerDist
-               } // for alpha
-// find Beta
-               minDistAcum = 999999999;
-               for (iBeta=0.0 ; iBeta<0.2; iBeta=iBeta+0.01) 
-               {
-                       Redistribution_SIN( alpha2,iBeta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2bX,&lstTmp2bY,&lstTmp2bZ );
-                       distAcum = IntegralDistanceTwoContours( &lstTmp3X,&lstTmp3Y,&lstTmp3Z , &lstTmp2bX,&lstTmp2bY,&lstTmp2bZ );
-                       if (distAcum<minDistAcum) 
-                       {
-                               beta2           = iBeta;
-                               minDistAcum     = distAcum;
-                       } // if integerDist
-               } // for beta    
-
+       {        
+               iContour = lstContourExeption[iExtra];
+               ExtractContour(lstOutX,lstOutY,lstOutZ,lstIndexsOut, iContour-1 , &lstTmp1X,&lstTmp1Y,&lstTmp1Z);
+               ExtractContour(lstOutX,lstOutY,lstOutZ,lstIndexsOut, iContour   , &lstTmp2X,&lstTmp2Y,&lstTmp2Z);
+               ExtractContour(lstOutX,lstOutY,lstOutZ,lstIndexsOut, iContour+1 , &lstTmp3X,&lstTmp3Y,&lstTmp3Z);
+//             sizeContour2    = SizeContour( &lstTmp2X, &lstTmp2Y, &lstTmp2Z );
+               sizeContour2    = lstSizeContours[ iContour  ];
+               printf("EED Warnning!  ManualContourModel_Box::RedistributionPointsAllContours_SIN  wave3 posible inconsistent contour y=%f  iContour=%d\n", lstTmp2Y[0], iContour );
+               lstInconsistentContourY.push_back( lstTmp2Y[0] );
+               lstInconsistentContourID.push_back( iContour );
+               findAlphaBetaSinDistribution( &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2,  &lstTmp1X,&lstTmp1Y,&lstTmp1Z,  &alpha1,&beta1);
+               findAlphaBetaSinDistribution( &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2,  &lstTmp3X,&lstTmp3Y,&lstTmp3Z,  &alpha2,&beta2);
                if (beta2>beta1)
                {
                        alpha   = alpha2;
                } else {
                        alpha   = alpha1;
                }
-               beta    = ( beta1 + beta2 ) / 2;
-               Redistribution_SIN( alpha,beta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2bX,&lstTmp2bY,&lstTmp2bZ );
-               PutPointsInContour(&lstTmp2bX,&lstTmp2bY,&lstTmp2bZ,  lstContourExeption[iExtra]  ,lstOutX,lstOutY,lstOutZ,lstIndexsOut);
-
-//             Redistribution_SIN( alpha1,beta1, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
-//             Redistribution_SIN( alpha2,beta2, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2bX,&lstTmp2bY,&lstTmp2bZ );
-//             Mixing2DistributionVectors(&lstTmp2aX,&lstTmp2aY,&lstTmp2aZ,&lstTmp2bX,&lstTmp2bY,&lstTmp2bZ, &lstTmp2cX,&lstTmp2cY,&lstTmp2cZ );
-//             PutPointsInContour(&lstTmp2cX,&lstTmp2cY,&lstTmp2cZ,  lstContourExeption[iExtra]  ,lstOutX,lstOutY,lstOutZ,lstIndexsOut);                               
-
-
+               beta = ( beta1 + beta2 ) / 2;
+               Redistribution_SIN( alpha,beta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
+                         sizeContour2                                  = SizeContour( &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
+                         lstSizeContours[ iContour ]   = sizeContour2;
+               PutPointsInContour(&lstTmp2aX,&lstTmp2aY,&lstTmp2aZ,  iContour  ,lstOutX,lstOutY,lstOutZ,lstIndexsOut);
        } // for iExtra
-       
-}
-void ManualContourModel_Box::Mixing2DistributionVectors(       std::vector<double> *lstAX,
-                                                                                                                       std::vector<double> *lstAY, 
-                                                                                                                       std::vector<double> *lstAZ,
-                                                                                                                       std::vector<double> *lstBX,
-                                                                                                                       std::vector<double> *lstBY, 
-                                                                                                                       std::vector<double> *lstBZ,
-                                                                                                                       std::vector<double> *lstOutX,
-                                                                                                                       std::vector<double> *lstOutY, 
-                                                                                                                       std::vector<double> *lstOutZ)
-{
-       (*lstOutX).clear();
-       (*lstOutY).clear();
-       (*lstOutZ).clear();
-       
-       std::vector<double> lstTmpX;
-       std::vector<double> lstTmpY;
-       std::vector<double> lstTmpZ;
-       double  dx,dy,dz;
-       double  distA,distAT;
-       double  distB,distBT;
-       int     i,j,size;
-       int     ii,sizeTmpX;
-       bool    flagA,flagB;
 
-       distAT  = 0;
-       distBT  = 0;
-       i               = 1;
-       j               = 1;
-       size    = (*lstAX).size();      
-       
-       lstTmpX.push_back( (*lstAX)[0] );
-       lstTmpY.push_back( (*lstAY)[0] );
-       lstTmpZ.push_back( (*lstAZ)[0] );
-       lstTmpX.push_back( (*lstBX)[0] );
-       lstTmpY.push_back( (*lstBY)[0] );
-       lstTmpZ.push_back( (*lstBZ)[0] );
-       
-       while ((i<size )&& (j<size))
-       {
-               dx              = (*lstAX)[i]-(*lstAX)[i-1];
-               dy              = (*lstAY)[i]-(*lstAY)[i-1];
-               dz              = (*lstAZ)[i]-(*lstAZ)[i-1];
-               distA   = sqrt( dx*dx + dy*dy +dz*dz );
-               dx              = (*lstBX)[j]-(*lstBX)[j-1];
-               dy              = (*lstBY)[j]-(*lstBY)[j-1];
-               dz              = (*lstBZ)[j]-(*lstBZ)[j-1];
-               distB   = sqrt( dx*dx + dy*dy +dz*dz );
-               flagA   = false;
-               flagB   = false;
-               if ((distAT+distA)<(distBT+distB))
-               {
-                       flagA=true;
-               } else if ((distAT+distA)>(distBT+distB))
-               {
-                       flagB=true;
-               } else {
-                       flagA=true;
-                       flagB=true;
-               } // if  distAT+distA     distBT+distB
-               
-               if (flagA==true)
-               {
-                       lstTmpX.push_back( (*lstAX)[i] );
-                       lstTmpY.push_back( (*lstAY)[i] );
-                       lstTmpZ.push_back( (*lstAZ)[i] );
-                       distAT = distAT+distA;
-                       i++;
-               } // if flagA
 
-               if (flagB==true)
-               {
-                       lstTmpX.push_back( (*lstBX)[j] );
-                       lstTmpY.push_back( (*lstBY)[j] );
-                       lstTmpZ.push_back( (*lstBZ)[j] );
-                       distBT = distBT+distB;
-                       j++;
-               } // if flagA
-               
-       } // while i  j
-       
-       sizeTmpX = lstTmpX.size();
-       for (ii=0; ii<sizeTmpX; ii=ii+2)
-       {
-               (*lstOutX).push_back( lstTmpX[ii] );
-               (*lstOutY).push_back( lstTmpY[ii] );
-               (*lstOutZ).push_back( lstTmpZ[ii] );
-       } // for ii
-printf("EED ManualContourModel_Box::Mixing2DistributionVectors Y=%f   size=%d  sizeTmpX=%d   sizeOut=%d \n",lstTmpY[0], size,sizeTmpX, (*lstOutX).size()  );   
-       
 }
-                                                                                                       
-
  
-
-
-void ManualContourModel_Box::RedistributionPoints_SIN_iContour(int iContour,   std::vector<double> *lstOutX,
-                                                                                                       std::vector<double> *lstOutY, 
-                                                                                                       std::vector<double> *lstOutZ,
-                                                                                                       std::vector<int> *lstIndexsOut,double alpha, double beta )
-{
-printf("EED ManualContourModel_Box::RedistributionPoints_SIN_iContour  Start \n");
-       std::vector<double> lstRstX;
-       std::vector<double> lstRstY;
-       std::vector<double> lstRstZ;
-       int iLstIndexOut,sizeLstIndexOut = lstIndexsOut->size();
-       int ii,iGeneral;
-       double iiByDelta;
-       int size,iGeneralPlusSize;
-       double Alpha,Beta,t,tt, PI=3.14159265;
-       double TwoPI=2*PI;
-       double dist=0,dist2,distSeg,delta;
-       double dd,dx,dy,dz;
-       int i,k;
-       int firstK;
-       double tmpX,tmpY,tmpZ;
-       iGeneral=0;
-       for (iLstIndexOut=0;  iLstIndexOut<sizeLstIndexOut; iLstIndexOut++)  // For each contour
-       {
-               lstRstX.clear();
-               lstRstY.clear();
-               lstRstZ.clear();
-               size                            = (*lstIndexsOut)[iLstIndexOut];
-               iGeneralPlusSize        = iGeneral+size;
-               if (size>2)
-               {
-                       dist=0;
-                       for ( i=iGeneral ; i<iGeneralPlusSize-1 ; i++ )
-                       {
-                               dx      = (*lstOutX)[i]-(*lstOutX)[i+1];
-                               dy      = (*lstOutY)[i]-(*lstOutY)[i+1];
-                               dz      = (*lstOutZ)[i]-(*lstOutZ)[i+1];
-                               dist= dist+sqrt( dx*dx + dy*dy + dz*dz );
-                       } //for
-                       delta = dist/(size-1);
-
-                       firstK  = 0;                    
-                       for (i=iGeneral; i<iGeneralPlusSize;i++)                                //  For each point of one contour
-                       {
-                               ii = i-iGeneral;
-                               dist2   = 0;
-                               for (k=iGeneral; k<iGeneralPlusSize-1;k++)                      // Search inside
-                               {
-if ( 385==(*lstOutY)[k]  )
-{ 
-       t               =       ((double)ii) / ((double)(size-1));
-       Beta    = 0.20; //  [0..1]
-       Alpha   = 0.0;  // [0..1]
-       Beta    = bbGetInputParam()[0];
-       Alpha   = bbGetInputParam()[1];
-       tt              = t + 0.70710678182*sin(t*TwoPI)*Beta + Alpha;
-       if (tt>1) { tt=tt-1; }
-       if (tt<0) { tt=tt+1; }
-       iiByDelta = tt * dist;
-} else {
-  iiByDelta = ii*delta;
-}
-                                       dx = (*lstOutX)[k+1]-(*lstOutX)[k];
-                                       dy = (*lstOutY)[k+1]-(*lstOutY)[k];
-                                       dz = (*lstOutZ)[k+1]-(*lstOutZ)[k];
-                                       distSeg = sqrt( dx*dx + dy*dy + dz*dz );
-                                       if ( dist2+distSeg >= iiByDelta )
-                                       {
-                                               if (distSeg==0)
-                                               {
-                                                       dd = 0;
-                                               } else {
-                                                       dd=(iiByDelta-dist2)/distSeg;
-                                               }// if distSeg == 0
-                                               lstRstX.push_back( (*lstOutX)[k] + dd*dx );
-                                               lstRstY.push_back( (*lstOutY)[k] + dd*dy );
-                                               lstRstZ.push_back( (*lstOutZ)[k] + dd*dz );
-                                               if (ii==0) { firstK=k; }
-                                               k = iGeneralPlusSize-1;
-                                       } else {
-                                               if ( k==iGeneral+size-2 )
-                                               {
-                                                       dd = 1;
-                                                       lstRstX.push_back( (*lstOutX)[k] + dd*dx );
-                                                       lstRstY.push_back( (*lstOutY)[k] + dd*dy );
-                                                       lstRstZ.push_back( (*lstOutZ)[k] + dd*dz );
-                                               }
-                                       }// if dist2 
-                                       dist2 = dist2+distSeg;
-                               } // for k
-                       } //for i   
-                       
-                       
-                       if (lstRstX.size()!=size) 
-                       {
-                               printf("EED Warnning!   ManualContourModel_Box::RedistributionPoints  >> This list is not coherent  iLstIndexOut=%d  lstRstX.size()=%d  size=%d\n",iLstIndexOut, lstRstX.size(), size);
-                               tmpX    = lstRstX[iGeneral];
-                               tmpY    = lstRstY[iGeneral];
-                               tmpZ    = lstRstZ[iGeneral];
-                               lstRstX.push_back( tmpX );
-                               lstRstY.push_back( tmpY );
-                               lstRstZ.push_back( tmpZ );
-                       }
-                       int iii;
-                       for (i=iGeneral; i<iGeneralPlusSize;i++)
-                       {
-//                             ii=( (i-iGeneral) + firstK) % size ;
-                               ii= i-iGeneral ;
-                               iii=iGeneral+ ( (i-iGeneral) + firstK) % size ;
-                               (*lstOutX)[iii] = lstRstX[ii];
-                               (*lstOutY)[iii] = lstRstY[ii];
-                               (*lstOutZ)[iii] = lstRstZ[ii];
-                       } // for i
-               } // if size>2
-               iGeneral=iGeneral+size;
-       }// for iLstIndexOut
-       
-printf("EED ManualContourModel_Box::RedistributionPoints_SIN_iContour  End \n");
-       
-}
-
-
-
 void ManualContourModel_Box::ClockwisePoints(  std::vector<double> *lstInX,
                                                                                        std::vector<double> *lstInY, 
                                                                                        std::vector<double> *lstInZ,
@@ -1020,141 +753,6 @@ void ManualContourModel_Box::ClockwisePoints(    std::vector<double> *lstInX,
 }
 
 
-/*
-void ManualContourModel_Box::ShiftValues(      std::vector<double> *lstInX,
-                                                                                       std::vector<double> *lstInY, 
-                                                                                       std::vector<double> *lstInZ,
-                                                                                       std::vector<int> *lstIndexsIn )
-{
-       int iLstIndexIn,sizeLstIndexIn=lstIndexsIn->size();
-       int ii, iGeneral=0;
-       int size,size2;
-       double dist,distMin;
-       int i,iBack;
-       int ig;
-       double dx,dy,dz;
-       std::vector<double> LstTmpX;
-       std::vector<double> LstTmpY;
-       std::vector<double> LstTmpZ;
-       if (sizeLstIndexIn>=2)
-       {
-       
-               for (iLstIndexIn=0;  iLstIndexIn<sizeLstIndexIn-1; iLstIndexIn++)
-               {
-                       size  = (*lstIndexsIn)[iLstIndexIn];
-                       size2 = (*lstIndexsIn)[iLstIndexIn+1];
-                       //find min distance and  iBack
-                       distMin = 10000000;
-                       iBack   = 0;
-                       
-                       
-                       for (ig=0; ig<size; ig++)
-                       {
-                               for ( i=0 ; i<size2 ; i++ )
-                               {
-                                       dx      = (*lstInX)[iGeneral+ig]-(*lstInX)[iGeneral+size+i];
-                                       dy      = (*lstInY)[iGeneral+ig]-(*lstInY)[iGeneral+size+i];
-                                       dz      = (*lstInZ)[iGeneral+ig]-(*lstInZ)[iGeneral+size+i];
-                                       dist= sqrt( dx*dx + dy*dy + dz*dz );
-                                       if ( dist<distMin ) 
-                                       {
-                                               iBack   = i-ig;
-                                               distMin = dist;
-                                       }
-                               } // for i size2
-                       } // for ig size
-
-if (iBack<0) 
-{
-       printf("- "); 
-       iBack = iBack + size2; 
-}
-                       
-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);
-                       
-                       if (iBack!=0)
-                       {
-                               LstTmpX.clear();
-                               LstTmpY.clear();
-                               LstTmpZ.clear();
-                               for (i=0 ; i<size2 ; i++) 
-                               {
-                                       ii= (i+iBack)%size2;
-                                       LstTmpX.push_back( (*lstInX)[iGeneral+size+ii] );
-                                       LstTmpY.push_back( (*lstInY)[iGeneral+size+ii] );
-                                       LstTmpZ.push_back( (*lstInZ)[iGeneral+size+ii] );
-                               } // for i                              
-                               for (i=0 ; i<size2 ; i++) 
-                               {
-                                       (*lstInX)[iGeneral+size+i] = LstTmpX[i];
-                                       (*lstInY)[iGeneral+size+i] = LstTmpY[i];
-                                       (*lstInZ)[iGeneral+size+i] = LstTmpZ[i];
-                               } // for i                              
-                       }
-                       iGeneral=iGeneral+size;
-               } // for iLstIndexIn
-               
-//------------         
-               
-               iGeneral=0;
-
-               for (iLstIndexIn=0;  iLstIndexIn<sizeLstIndexIn-1; iLstIndexIn++)
-               {
-                       size  = (*lstIndexsIn)[iLstIndexIn];
-                       size2 = (*lstIndexsIn)[iLstIndexIn+1];
-                       //find min distance and  iBack
-                       distMin = 10000000;
-                       iBack   = 0;
-                       
-                       
-//                     for (ig=0; ig<size; ig++)
-//                     {
-                               for ( i=0 ; i<size2 ; i++ )
-                               {
-                                       dx      = (*lstInX)[iGeneral]-(*lstInX)[iGeneral+size+i];
-                                       dy      = (*lstInY)[iGeneral]-(*lstInY)[iGeneral+size+i];
-                                       dz      = (*lstInZ)[iGeneral]-(*lstInZ)[iGeneral+size+i];
-                                       dist= sqrt( dx*dx + dy*dy + dz*dz );
-                                       if ( dist<distMin ) 
-                                       {
-                                               iBack   = i;
-                                               distMin = dist;
-                                       }
-                               } // for i size2
-//                     } // for ig size
-
-                       
-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);
-                       
-                       if (iBack!=0)
-                       {
-                               LstTmpX.clear();
-                               LstTmpY.clear();
-                               LstTmpZ.clear();
-                               for (i=0 ; i<size2 ; i++) 
-                               {
-                                       ii= (i+iBack)%size2;
-                                       LstTmpX.push_back( (*lstInX)[iGeneral+size+ii] );
-                                       LstTmpY.push_back( (*lstInY)[iGeneral+size+ii] );
-                                       LstTmpZ.push_back( (*lstInZ)[iGeneral+size+ii] );
-                               } // for i                              
-                               for (i=0 ; i<size2 ; i++) 
-                               {
-                                       (*lstInX)[iGeneral+size+i] = LstTmpX[i];
-                                       (*lstInY)[iGeneral+size+i] = LstTmpY[i];
-                                       (*lstInZ)[iGeneral+size+i] = LstTmpZ[i];
-                               } // for i                              
-                       }
-                       iGeneral=iGeneral+size;
-               } // for iLstIndexIn
-               
-       } // if sizeLstIndexIn
-       
-}
-*/
-
-
-
 void ManualContourModel_Box::ShiftValues(      std::vector<double> *lstInX,
                                                                                        std::vector<double> *lstInY, 
                                                                                        std::vector<double> *lstInZ,
@@ -1171,10 +769,7 @@ void ManualContourModel_Box::ShiftValues( std::vector<double> *lstInX,
        std::vector<double> LstTmpY;
        std::vector<double> LstTmpZ;
        if (sizeLstIndexIn>=2)
-       {
-       
-         
-        
+       {        
                for (iLstIndexIn=0;  iLstIndexIn<sizeLstIndexIn-1; iLstIndexIn++)
                {
                        size  = (*lstIndexsIn)[iLstIndexIn];
@@ -1182,7 +777,6 @@ void ManualContourModel_Box::ShiftValues(  std::vector<double> *lstInX,
                        //find min distance and  iBack
                        distMin = 10000000;
                        iBack   = 0;
-                       
                    // Comparing distance between two contours  
                    // Both contours need the same size 
                        for (ig=0; ig<size; ig++)
@@ -1195,18 +789,12 @@ void ManualContourModel_Box::ShiftValues(        std::vector<double> *lstInX,
                                        dz      = (*lstInZ)[iGeneral+i]-(*lstInZ)[iGeneral+size+(i+ig)%size];
                                        dist= dist + sqrt( dx*dx + dy*dy + dz*dz );
                                } // for i size2
-
                                if ( dist<distMin ) 
                                {
                                        iBack   = ig+size;
                                        distMin = dist;
-                               }
-                               
-                       } // for ig size
-
-                       
-//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);
-                       
+                               }                       
+                       } // for ig size                        
                        if (iBack!=0)
                        {
                                LstTmpX.clear();
@@ -1222,12 +810,10 @@ void ManualContourModel_Box::ShiftValues(        std::vector<double> *lstInX,
                                                LstTmpZ.push_back( (*lstInZ)[iGeneral+size+ii] );
                                        }
                                } // for i
-                               
                                //Repeat the first item at the end to close the contour
                                LstTmpX.push_back( LstTmpX[0] );
                                LstTmpY.push_back( LstTmpY[0] );
                                LstTmpZ.push_back( LstTmpZ[0] );
-
                                for (i=0 ; i<size2 ; i++) 
                                {
                                        (*lstInX)[iGeneral+size+i] = LstTmpX[i];
@@ -1237,17 +823,11 @@ void ManualContourModel_Box::ShiftValues(        std::vector<double> *lstInX,
                        }
                        iGeneral=iGeneral+size;
                } // for iLstIndexIn
-               
-               
        } // if sizeLstIndexIn
-       
 }
 
 
 
-
-
-
 void ManualContourModel_Box::Process()
 {
 // THE MAIN PROCESSING METHOD BODY
@@ -1265,171 +845,171 @@ void ManualContourModel_Box::Process()
 //    bbSetOutputOut( bbGetInputIn() );
 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
 
-       // First Step  Spline Interpolation
-       std::vector<double> lstInX=bbGetInputLstControlPointsX();
-       std::vector<double> lstInY=bbGetInputLstControlPointsY();
-       std::vector<double> lstInZ=bbGetInputLstControlPointsZ();
-       if ( (lstInX.size()!=lstInY.size()) || (lstInY.size()!=lstInZ.size()) ) 
-       { 
-               printf("Warnning !!  .. ManualContourModel_Box: The list X Y Z, no have the same number of elements \n");
-               return;
-       }
-       std::vector<int>        lstIndexsIn=bbGetInputLstIndexsIn();
-       std::vector<int>        lstIndexsOut;
-       std::vector<double> lstOutX;
-       std::vector<double> lstOutY;
-       std::vector<double> lstOutZ;
-       if (bbGetInputLstIndexsIn().size()==0)
+       if (bbGetInputActive()==true)
        {
-               lstIndexsIn.push_back( lstInX.size() );
-       }
-       
-// Step 1.  All contours the same clockwise direction (Control Points)
-       if (bbGetInputDoubleContour()==1)
-       {
-               ClockwisePoints( &lstInX , &lstInY , &lstInZ , &lstIndexsIn );
-//             ShiftValues( &lstInX , &lstInY , &lstInZ , &lstIndexsIn );
-       } // DoubleContour
-       int i,size=lstIndexsIn.size();
-       int iGeneral=0;
-       
-// Step 2.  Spline interpolation of control points     
-       for (i=0;i<size;i++)
-       {
-               ProcessBySegment(       bbGetInputType() , 
-                                                       iGeneral,  lstIndexsIn[i] ,
-                                                       &lstInX ,  &lstInY  , &lstInZ,
-                                                       &lstOutX , &lstOutY , &lstOutZ,
-                                                       &lstIndexsOut,bbGetInputOpenClose() );
-       } // for
-
-       if (bbGetInputDoubleContour()==0)
-       {
-// Finish if Simple contours
-               //////////////////// Set Out   DoubleContour = 0
-               bbSetOutputLstContourPointsX(lstOutX);  
-               bbSetOutputLstContourPointsY(lstOutY);  
-               bbSetOutputLstContourPointsZ(lstOutZ);
-               bbSetOutputLstIndexsOut(lstIndexsOut);  
-       } else {
-// Step 3. Interpolation in the other direction
-// Step 3.1 Linear Normalice points around contours    
-               RedistributionPoints(&lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut);
-//EED 01/2021          
-// Step 3.2 Shift points to find minimun acumulate distance    
-               ShiftValues( &lstOutX, &lstOutY, &lstOutZ, &lstIndexsOut );
-// Step 3.3. SIN Normalice points around contours      
-//             RedistributionPoints_SIN_iContour(-1, &lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut,-1,-1);
-
-if (bbGetInputParam()[0]==1)
-{
-               RedistributionPointsAllContours_SIN( &lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut);
-               ShiftValues( &lstOutX, &lstOutY, &lstOutZ, &lstIndexsOut );
-}
-// Step 3.4 Transpose the vectors   
-               lstInX.clear();
-               lstInY.clear();
-               lstInZ.clear();
-               lstIndexsIn.clear();
-               size  = bbGetInputNbPoints();
-               int j,size2 = lstIndexsOut.size();
-               for (i=0;i<size;i++)
+               lstInconsistentContourY.clear();
+               lstInconsistentContourID.clear();
+
+               // First Step  Spline Interpolation
+               std::vector<double> lstInX=bbGetInputLstControlPointsX();
+               std::vector<double> lstInY=bbGetInputLstControlPointsY();
+               std::vector<double> lstInZ=bbGetInputLstControlPointsZ();
+               if ( (lstInX.size()!=lstInY.size()) || (lstInY.size()!=lstInZ.size()) ) 
+               { 
+                       printf("Warnning !!  .. ManualContourModel_Box: The list X Y Z, no have the same number of elements \n");
+                       return;
+               }
+               std::vector<int>        lstIndexsIn=bbGetInputLstIndexsIn();
+               std::vector<int>        lstIndexsOut;
+               std::vector<double> lstOutX;
+               std::vector<double> lstOutY;
+               std::vector<double> lstOutZ;
+               if (bbGetInputLstIndexsIn().size()==0)
                {
-                       for (j=0;j<size2;j++)
-                       {
-                               lstInX.push_back( lstOutX[ j*lstIndexsOut[j] + i ] );
-                               lstInY.push_back( lstOutY[ j*lstIndexsOut[j] + i ] );
-                               lstInZ.push_back( lstOutZ[ j*lstIndexsOut[j] + i ] );
-                       } // for j
-                       lstIndexsIn.push_back( size2 );
-               } // for i
-               lstOutX.clear();
-               lstOutY.clear();
-               lstOutZ.clear();
-               lstIndexsOut.clear();
-// Step 3.5 Interponation 2
-               size=lstIndexsIn.size();
-               iGeneral=0;
+                       lstIndexsIn.push_back( lstInX.size() );
+               }
+               
+       // Step 1.  All contours the same clockwise direction (Control Points)
+               if (bbGetInputDoubleContour()==1)
+               {
+                       ClockwisePoints( &lstInX , &lstInY , &lstInZ , &lstIndexsIn );
+       //              ShiftValues( &lstInX , &lstInY , &lstInZ , &lstIndexsIn );
+               } // DoubleContour
+               int i,size      = lstIndexsIn.size();
+               int iGeneral= 0;
+               
+       // Step 2.  Spline interpolation of control points      
                for (i=0;i<size;i++)
                {
                        ProcessBySegment(       bbGetInputType() , 
-                                                               iGeneral, lstIndexsIn[i] ,
-                                                               &lstInX,&lstInY,&lstInZ,
-                                                               &lstOutX,&lstOutY,&lstOutZ,
-                                                               &lstIndexsOut,bbGetInputOpenClose2());
+                                                               iGeneral,  lstIndexsIn[i] ,
+                                                               &lstInX ,  &lstInY  , &lstInZ,
+                                                               &lstOutX , &lstOutY , &lstOutZ,
+                                                               &lstIndexsOut,bbGetInputOpenClose() );
                } // for
-               RedistributionPoints(&lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut);
-// Step 3.6 Transpose the vectors   
-               lstInX.clear();
-               lstInY.clear();
-               lstInZ.clear();
-               lstIndexsIn.clear();
-               size  = bbGetInputNbPoints();
-               size2 = lstIndexsOut.size();
-               for (i=0;i<size;i++)
-               {
-                       for (j=0;j<size2;j++)
-                       {
-                               lstInX.push_back( lstOutX[ j*lstIndexsOut[j] + i ] );
-                               lstInY.push_back( lstOutY[ j*lstIndexsOut[j] + i ] );
-                               lstInZ.push_back( lstOutZ[ j*lstIndexsOut[j] + i ] );
-                       } // for j
-                       lstIndexsIn.push_back( size2 );
-               } // for i
-               lstOutX.clear();
-               lstOutY.clear();
-               lstOutZ.clear();
-               lstIndexsOut.clear();
-               //////////////////// Set Out   DoubleContour = 1
-               bbSetOutputLstContourPointsX(lstInX);   
-               bbSetOutputLstContourPointsY(lstInY);   
-               bbSetOutputLstContourPointsZ(lstInZ);
-               bbSetOutputLstIndexsOut(lstIndexsIn);   
-
-       } // if DoubleContour 
 
+               if (bbGetInputDoubleContour()==0)
+               {
+       // Finish if Simple contours
+                       //////////////////// Set Out   DoubleContour = 0
+                       bbSetOutputLstContourPointsX(lstOutX);  
+                       bbSetOutputLstContourPointsY(lstOutY);  
+                       bbSetOutputLstContourPointsZ(lstOutZ);
+                       bbSetOutputLstIndexsOut(lstIndexsOut);  
+               } else {
+       // Step 3. Interpolation in the other direction
+       // Step 3.1 Linear Normalice points around contours     
+                       RedistributionPoints(&lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut);
+       //EED 01/2021           
+       // Step 3.2 Shift points to find minimun acumulate distance     
+                       ShiftValues( &lstOutX, &lstOutY, &lstOutZ, &lstIndexsOut );
+       // Step 3.3. SIN Normalice points around contours       
+                       if (bbGetInputParam().size()>=1)
+                       {
+                               if (bbGetInputParam()[0]==1)
+                               {
+                                               RedistributionPointsAllContours_SIN( &lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut);
+                                               ShiftValues( &lstOutX, &lstOutY, &lstOutZ, &lstIndexsOut );
+                               } // if 1
+                       } // if size
+       // Step 3.4 Transpose the vectors   
+                       lstInX.clear();
+                       lstInY.clear();
+                       lstInZ.clear();
+                       lstIndexsIn.clear();
+                       size  = bbGetInputNbPoints();
+                       int j,size2 = lstIndexsOut.size();
+                       for (i=0;i<size;i++)
+                       {
+                               for (j=0;j<size2;j++)
+                               {
+                                       lstInX.push_back( lstOutX[ j*lstIndexsOut[j] + i ] );
+                                       lstInY.push_back( lstOutY[ j*lstIndexsOut[j] + i ] );
+                                       lstInZ.push_back( lstOutZ[ j*lstIndexsOut[j] + i ] );
+                               } // for j
+                               lstIndexsIn.push_back( size2 );
+                       } // for i
+                       lstOutX.clear();
+                       lstOutY.clear();
+                       lstOutZ.clear();
+                       lstIndexsOut.clear();
+       // Step 3.5 Interponation 2
+                       size=lstIndexsIn.size();
+                       iGeneral=0;
+                       for (i=0;i<size;i++)
+                       {
+                               ProcessBySegment(       bbGetInputType() , 
+                                                                       iGeneral, lstIndexsIn[i] ,
+                                                                       &lstInX,&lstInY,&lstInZ,
+                                                                       &lstOutX,&lstOutY,&lstOutZ,
+                                                                       &lstIndexsOut,bbGetInputOpenClose2());
+                       } // for
+                       RedistributionPoints(&lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut);
+       // Step 3.6 Transpose the vectors   
+                       lstInX.clear();
+                       lstInY.clear();
+                       lstInZ.clear();
+                       lstIndexsIn.clear();
+                       size  = bbGetInputNbPoints();
+                       size2 = lstIndexsOut.size();
+                       for (i=0;i<size;i++)
+                       {
+                               for (j=0;j<size2;j++)
+                               {
+                                       lstInX.push_back( lstOutX[ j*lstIndexsOut[j] + i ] );
+                                       lstInY.push_back( lstOutY[ j*lstIndexsOut[j] + i ] );
+                                       lstInZ.push_back( lstOutZ[ j*lstIndexsOut[j] + i ] );
+                               } // for j
+                               lstIndexsIn.push_back( size2 );
+                       } // for i
+                       lstOutX.clear();
+                       lstOutY.clear();
+                       lstOutZ.clear();
+                       lstIndexsOut.clear();
+                       //////////////////// Set Out   DoubleContour = 1
+                       bbSetOutputLstContourPointsX( lstInX ); 
+                       bbSetOutputLstContourPointsY( lstInY ); 
+                       bbSetOutputLstContourPointsZ( lstInZ );
+                       bbSetOutputLstIndexsOut( lstIndexsIn ); 
+                       bbSetOutputLstPssblIncnsnstntCntrY( lstInconsistentContourY );
+                       bbSetOutputLstPssblIncnsnstntCntrID( lstInconsistentContourID );
+               } // if DoubleContour 
+       } // if Active
 }
 //===== 
 // 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)
 //===== 
 void ManualContourModel_Box::bbUserSetDefaultValues()
 {
-
 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
 //    Here we initialize the input 'In' to 0
-   bbSetInputType(1);
+   bbSetInputActive(true);
+   bbSetInputType(1);   
    bbSetInputDoubleContour(0);
    bbSetInputOpenClose(false);
    bbSetInputOpenClose2(false);
-   bbSetInputNbPoints(100);
-  
+   bbSetInputNbPoints(100); 
 }
 //===== 
 // 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)
 //===== 
 void ManualContourModel_Box::bbUserInitializeProcessing()
 {
-
 //  THE INITIALIZATION METHOD BODY :
 //    Here does nothing 
 //    but this is where you should allocate the internal/output pointers 
 //    if any 
-
-  
 }
 //===== 
 // 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)
 //===== 
 void ManualContourModel_Box::bbUserFinalizeProcessing()
 {
-
 //  THE FINALIZATION METHOD BODY :
 //    Here does nothing 
 //    but this is where you should desallocate the internal/output pointers 
-//    if any
-  
-}
+//    if any 
 }
-// EO namespace bbcreaMaracasVisu
+// EO namespace bbcreaMaracasVisu
 
 
index b85478e6261e6f4856c775ce1c9460b8e02ce97f..1f25bd912d57f0c5fbaf042b22030d56e64c30cd 100644 (file)
@@ -18,6 +18,7 @@ class bbcreaMaracasVisu_EXPORT ManualContourModel_Box
 //===== 
 // 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)
 //===== 
+  BBTK_DECLARE_INPUT(Active,bool);
   BBTK_DECLARE_INPUT(Type,int);
   BBTK_DECLARE_INPUT(DoubleContour,int);
   BBTK_DECLARE_INPUT(OpenClose,bool);
@@ -34,6 +35,9 @@ class bbcreaMaracasVisu_EXPORT ManualContourModel_Box
   BBTK_DECLARE_OUTPUT(LstContourPointsY,std::vector<double>);
   BBTK_DECLARE_OUTPUT(LstContourPointsZ,std::vector<double>);
   BBTK_DECLARE_OUTPUT(LstIndexsOut,std::vector<int>);
+  BBTK_DECLARE_OUTPUT(LstPssblIncnsnstntCntrY,std::vector<double>);
+  BBTK_DECLARE_OUTPUT(LstPssblIncnsnstntCntrID,std::vector<int>);
+
   BBTK_PROCESS(Process);
   void Process();
 
@@ -78,6 +82,16 @@ void RedistributionPointsAllContours_SIN(    std::vector<double> *lstOutX,
                                                                                        std::vector<double> *lstOutZ, 
                                                                                        std::vector<int> *lstIndexsOut );
 
+void findAlphaBetaSinDistribution(     std::vector<double> *lstTmp2X,
+                                                                                                                       std::vector<double> *lstTmp2Y,
+                                                                                                                       std::vector<double> *lstTmp2Z ,
+                                                                                                                       int sizeContour,
+                                                                                                                       std::vector<double> *lstTmp1X,
+                                                                                                                       std::vector<double> *lstTmp1Y,
+                                                                                                                       std::vector<double> *lstTmp1Z,  
+                                                                                                                       double *alpha,
+                                                                                                                       double *beta); 
+
 void Redistribution_SIN(       double alpha,
                                                        double beta,
                                                        std::vector<double> *lstC1X,
@@ -92,6 +106,13 @@ double SizeContour( std::vector<double> *lstX,
                                        std::vector<double> *lstY, 
                                        std::vector<double> *lstZ );
 
+void CalculeLstSizeContours(   std::vector<double> *lstOutX,
+                                                               std::vector<double> *lstOutY,
+                                                               std::vector<double> *lstOutZ,
+                                                               std::vector<int>        *lstIndexsOut,
+                                                               std::vector<double>     *lstSizeContours        );
+
+
 void ExtractContour(std::vector<double> *lstX,
                                        std::vector<double> *lstY, 
                                        std::vector<double> *lstZ,
@@ -123,19 +144,9 @@ void CopyContour2InContour1(       std::vector<double> *lstInX,
                                                                std::vector<double> *lstOutX,
                                                                std::vector<double> *lstOutY, 
                                                                std::vector<double> *lstOutZ );
-                                                                       
-void Mixing2DistributionVectors(       std::vector<double> *lstAX,
-                                                                       std::vector<double> *lstAY, 
-                                                                       std::vector<double> *lstAZ,
-                                                                       std::vector<double> *lstBX,
-                                                                       std::vector<double> *lstBY, 
-                                                                       std::vector<double> *lstBZ,
-                                                                       std::vector<double> *lstOutX,
-                                                                       std::vector<double> *lstOutY, 
-                                                                       std::vector<double> *lstOutZ);
-
-
 
+std::vector<double> lstInconsistentContourY;
+std::vector<int>       lstInconsistentContourID;
 
 //===== 
 // 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)
@@ -148,6 +159,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ManualContourModel_Box,bbtk::AtomicBlackBox);
   BBTK_DESCRIPTION("No Description.");
   BBTK_CATEGORY("empty");
 
+  BBTK_INPUT(ManualContourModel_Box,Active,"(true default) Active true/false",bool,"");
   BBTK_INPUT(ManualContourModel_Box,Type,"(1 default) 1=spline, 2=rectangle, 3=circle, 4=bullEye, 6=Line, 7=points, 8=rotationTool, 10=polygon, 12=Spline3D",int,"");
   BBTK_INPUT(ManualContourModel_Box,DoubleContour,"(0 default) 0=Simple, 1=Double (This is used to construct surface, use LstIndexesIn)",int,"");
   BBTK_INPUT(ManualContourModel_Box,OpenClose,"(false default) false=open, true=close",bool,"");
@@ -162,6 +174,10 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ManualContourModel_Box,bbtk::AtomicBlackBox);
   BBTK_OUTPUT(ManualContourModel_Box,LstContourPointsY,"List of points in the contour",std::vector<double>,"");
   BBTK_OUTPUT(ManualContourModel_Box,LstContourPointsZ,"List of points in the contour",std::vector<double>,"");
   BBTK_OUTPUT(ManualContourModel_Box,LstIndexsOut,"Lst number of points by segment",std::vector<int>,"");
+  BBTK_OUTPUT(ManualContourModel_Box,LstPssblIncnsnstntCntrY,"Lst of possible Inconsinstent Contour Y, little contour between two big contour, Difficult for the SIN distribution (DoubleContour 1)",std::vector<double>,"");
+  BBTK_OUTPUT(ManualContourModel_Box,LstPssblIncnsnstntCntrID,"Lst of possible Inconsinstent Contour ID, little contour between two big contour, Difficult for the SIN distribution (DoubleContour 1)",std::vector<int>,"");
+
+
 
 BBTK_END_DESCRIBE_BLACK_BOX(ManualContourModel_Box);
 //=====