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

index b3e434fbb473e7cfa7c6127ccc2cbaea2856a4e0..a6b2a7e3695b215215dd8c41e228e484af82b737 100644 (file)
@@ -63,7 +63,6 @@ void ManualContourModel_Box::RedistributionPoints(    std::vector<double> *lstOutX,
        int size;
        for (iLstIndexOut=0;  iLstIndexOut<sizeLstIndexOut; iLstIndexOut++)
        {
-//printf("EED ManualContourModel_Box::RedistributionPoints iLstIndexOut=%d   \n", iLstIndexOut);
                lstRstX.clear();
                lstRstY.clear();
                lstRstZ.clear();
@@ -86,7 +85,6 @@ void ManualContourModel_Box::RedistributionPoints(    std::vector<double> *lstOutX,
                        lstRstZ.push_back( (*lstOutZ)[iGeneral] );
                        for (i=iGeneral+1; i<iGeneral+size;i++)
                        {
-//printf("EED ManualContourModel_Box::RedistributionPointsi=%d \n", i-iGeneral );
                                dist2 = 0;
                                for (k=iGeneral+1; k<iGeneral+size;k++)
                                {
@@ -113,7 +111,6 @@ void ManualContourModel_Box::RedistributionPoints(  std::vector<double> *lstOutX,
                                                        lstRstX.push_back( (*lstOutX)[k-1] + dd*dx );
                                                        lstRstY.push_back( (*lstOutY)[k-1] + dd*dy );
                                                        lstRstZ.push_back( (*lstOutZ)[k-1] + dd*dz );
-//                                                     printf("EED ManualContourModel_Box::RedistributionPoints iLstIndexOut=%d    i=%d k=%d  dist2+distSeg=%f    ii*delta=%f   dif=%f \n", iLstIndexOut,i-iGeneral, k-iGeneral, dist2+distSeg , ii*delta ,  (dist2+distSeg) - ii*delta);
                                                }
                                        }// if dist2 
                                        dist2 = dist2+distSeg;
@@ -136,6 +133,382 @@ void ManualContourModel_Box::RedistributionPoints(        std::vector<double> *lstOutX,
 }
 
 
+//-------------------------------------------------------------------------------------------------------------
+
+
+void ManualContourModel_Box::ExtractContour(   std::vector<double> *lstX,
+                                                                                               std::vector<double> *lstY, 
+                                                                                               std::vector<double> *lstZ,
+                                                                                               std::vector<int>        *lstIndexs,
+                                                                                               int contour,
+                                                                                               std::vector<double> *lstOutX,
+                                                                                               std::vector<double> *lstOutY, 
+                                                                                               std::vector<double> *lstOutZ )
+{
+       int     i;
+       int     iLstIndex;
+       int     iContour;
+       int     sizeLstIndexslstIndexs;
+       int     iGeneral;
+       int     iGeneralPlusSize;
+       if ( (lstX!=NULL) &&  (lstY!=NULL) && (lstZ!=NULL) && (lstIndexs!=NULL) && (lstOutX!=NULL) && (lstOutY!=NULL) && (lstOutZ!=NULL) )
+       {
+               sizeLstIndexslstIndexs  = (*lstIndexs).size();
+               if  ( sizeLstIndexslstIndexs!=0 ) 
+               {
+                       (*lstOutX).clear();
+                       (*lstOutY).clear();
+                       (*lstOutZ).clear();
+                       iGeneral                                = 0;
+                       iGeneralPlusSize                = (*lstIndexs)[0];
+                       for ( iContour=1 ; iContour<=contour ; iContour++ )
+                       {
+                               iGeneral                        = iGeneral+(*lstIndexs)[iContour-1];
+                               iGeneralPlusSize        = iGeneral+(*lstIndexs)[iContour];
+                       } // for iContour
+                       for ( i=iGeneral ; i<iGeneralPlusSize ; i++ )
+                       {
+                               (*lstOutX).push_back( (*lstX)[i] );
+                               (*lstOutY).push_back( (*lstY)[i] );
+                               (*lstOutZ).push_back( (*lstZ)[i] );                             
+                       } //for
+               } // size
+       } // NULL
+}
+
+void ManualContourModel_Box::PutPointsInContour(std::vector<double> *lstTmpX,
+                                                                                               std::vector<double> *lstTmpY, 
+                                                                                               std::vector<double> *lstTmpZ,
+                                                                                               int contour,
+                                                                                               std::vector<double> *lstOutX,
+                                                                                               std::vector<double> *lstOutY, 
+                                                                                               std::vector<double> *lstOutZ,
+                                                                                               std::vector<int>        *lstOutIndexs )
+{
+       int     i;
+       int     iLstIndex;
+       int     iContour;
+       int     sizeLstIndexslstIndexs;
+       int     iGeneral;
+       int     iGeneralPlusSize;
+       int     iSize;
+       int     SizeContour;
+       if ( (lstTmpX!=NULL) &&  (lstTmpY!=NULL) && (lstTmpZ!=NULL)  && (lstOutX!=NULL) && (lstOutY!=NULL) && (lstOutZ!=NULL) && (lstOutIndexs!=NULL) )
+       {
+               sizeLstIndexslstIndexs  = (*lstOutIndexs).size();
+               if  ( sizeLstIndexslstIndexs!=0 ) 
+               {
+                       iGeneral                                = 0;
+                       iGeneralPlusSize                = (*lstOutIndexs)[0];
+                       for ( iContour=1 ; iContour<=contour ; iContour++ )
+                       {
+                               iGeneral                        = iGeneral + (*lstOutIndexs)[iContour-1];
+                               SizeContour             = (*lstOutIndexs)[iContour];
+                       } // for iContour
+                       iGeneralPlusSize        = iGeneral + SizeContour;
+                       
+                       if(SizeContour==(*lstTmpX).size() )
+                       {
+                               int iSize=0;
+                               for ( i=iGeneral ; i<iGeneralPlusSize ; i++ )
+                               {
+                                       (*lstOutX)[i] = (*lstTmpX)[iSize] ;
+                                       (*lstOutY)[i] = (*lstTmpY)[iSize] ;
+                                       (*lstOutZ)[i] = (*lstTmpZ)[iSize] ;
+                                       iSize++;                                        
+                               } //for                 
+                       } else {
+                               printf("EED Warnning!! ManualContourModel_Box::PutPointsInContour  the lstTmp vector is not of the correct size. \n");
+                               for ( i=iGeneral ; i<iGeneralPlusSize ; i++ )
+                               {
+                                       (*lstOutX)[i] = -9999 ;
+                                       (*lstOutY)[i] = -9999 ;
+                                       (*lstOutZ)[i] = -9999 ;
+                               } //for                 
+                       }
+               } // size
+       } // 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,
+                                                                                                       std::vector<double> *lstInX,
+                                                                                                       std::vector<double> *lstInY, 
+                                                                                                       std::vector<double> *lstInZ,
+                                                                                                       std::vector<double> *lstOutX,
+                                                                                                       std::vector<double> *lstOutY, 
+                                                                                                       std::vector<double> *lstOutZ )
+{
+       int i,sizeLstInX=(*lstInX).size();
+       (*lstOutX).clear();     
+       (*lstOutY).clear();     
+       (*lstOutZ).clear();     
+       for ( i=0 ; i<sizeLstInX ; i++ )
+       {
+               (*lstOutX).push_back( (*lstInX)[i] );
+               (*lstOutY).push_back( (*lstInY)[i] );
+               (*lstOutZ).push_back( (*lstInZ)[i] );
+       } // for i
+}
+
+void ManualContourModel_Box::CopyContour2InContour1(
+                                                                                                       std::vector<double> *lstInX,
+                                                                                                       std::vector<double> *lstInY, 
+                                                                                                       std::vector<double> *lstInZ,
+                                                                                                       std::vector<double> *lstOutX,
+                                                                                                       std::vector<double> *lstOutY, 
+                                                                                                       std::vector<double> *lstOutZ )
+{
+       int i,sizeLstInX=(*lstInX).size();
+       (*lstOutX).clear();     
+       (*lstOutY).clear();     
+       (*lstOutZ).clear();     
+       for ( i=0 ; i<sizeLstInX ; i++ )
+       {
+               (*lstOutX).push_back( (*lstInX)[i] );
+               (*lstOutY).push_back( (*lstInY)[i] );
+               (*lstOutZ).push_back( (*lstInZ)[i] );
+       } // for i
+}
+
+double ManualContourModel_Box::IntegralDistanceTwoContours(std::vector<double> *lstTmpAX,
+                                                                                                                       std::vector<double> *lstTmpAY, 
+                                                                                                                       std::vector<double> *lstTmpAZ,
+                                                                                                                       std::vector<double> *lstTmpBX,
+                                                                                                                       std::vector<double> *lstTmpBY, 
+                                                                                                                       std::vector<double> *lstTmpBZ )
+{
+       int     i;
+       double  dx;
+       double  dy;
+       double  dz;
+       double  dist            = 0;
+       int     iSize           = (*lstTmpAX).size();
+       for ( i=0 ; i<iSize ; i++ )
+       {
+               dx      = (*lstTmpAX)[i]-(*lstTmpBX)[i];
+               dy      = (*lstTmpAY)[i]-(*lstTmpBY)[i];
+               dz      = (*lstTmpAZ)[i]-(*lstTmpBZ)[i];
+               dist= dist+ sqrt( dx*dx + dy*dy + dz*dz );
+       } //for i
+       return dist;
+}
+
+
+void ManualContourModel_Box::RedistributionPointsAllContours_SIN(      std::vector<double> *lstOutX,
+                                                                                                                                       std::vector<double> *lstOutY, 
+                                                                                                                                       std::vector<double> *lstOutZ,
+                                                                                                                                       std::vector<int>        *lstIndexsOut )
+{
+       std::vector<double> lstTmp1X;
+       std::vector<double> lstTmp1Y;
+       std::vector<double> lstTmp1Z;
+       std::vector<double> lstTmp2X;
+       std::vector<double> lstTmp2Y;
+       std::vector<double> lstTmp2Z;
+       std::vector<double> lstTmp1aX;
+       std::vector<double> lstTmp1aY;
+       std::vector<double> lstTmp1aZ;
+       int     iContour;
+       double  nbContours              = (*lstIndexsOut).size()-1;
+       double  alpha,iAlpha;
+       double  beta,iBeta;
+       double  sizeContour1;
+       double  sizeContour2;
+       double  distAcum;
+       double minDistAcum;
+       
+       ExtractContour(lstOutX,lstOutY,lstOutZ,lstIndexsOut,0,&lstTmp1X,&lstTmp1Y,&lstTmp1Z);
+       sizeContour1    = SizeContour( &lstTmp1X, &lstTmp1Y, &lstTmp1Z );
+       
+// Increment   
+       for ( iContour=0; iContour<nbContours ; iContour++ )
+       {
+               beta    = 0.10;
+// find Alpha
+               ExtractContour( lstOutX,lstOutY,lstOutZ,lstIndexsOut, iContour+1 ,&lstTmp2X,&lstTmp2Y,&lstTmp2Z );              
+               sizeContour2    = SizeContour( &lstTmp2X, &lstTmp2Y, &lstTmp2Z );
+               if (sizeContour1<sizeContour2){
+                       alpha   = 0;
+                       minDistAcum=-999999999;
+                       for (iAlpha=0.1 ; iAlpha<1; iAlpha=iAlpha+0.1) 
+                       {
+                               Redistribution_SIN( alpha,beta, &lstTmp1X,&lstTmp1Y,&lstTmp1Z , &lstTmp1aX,&lstTmp1aY,&lstTmp1aZ );
+                               distAcum = IntegralDistanceTwoContours( &lstTmp1aX,&lstTmp1aY,&lstTmp1aZ , &lstTmp2X,&lstTmp2Y,&lstTmp2Z );
+                               if (distAcum<minDistAcum) 
+                               {
+                                       alpha           = iAlpha;
+                                       minDistAcum     = distAcum;
+                               } // if integerDist
+                       } // for alpha
+// find Beta
+                       for (iBeta=0.0 ; iBeta<0.2; iBeta=iBeta+0.01) 
+                       {
+                               minDistAcum=-999999999;
+                               Redistribution_SIN( alpha,beta, &lstTmp1X,&lstTmp1Y,&lstTmp1Z , &lstTmp1aX,&lstTmp1aY,&lstTmp1aZ );
+                               distAcum = IntegralDistanceTwoContours( &lstTmp1aX,&lstTmp1aY,&lstTmp1aZ , &lstTmp2X,&lstTmp2Y,&lstTmp2Z );
+                               if (distAcum<minDistAcum) 
+                               {
+                                       beta            = iBeta;
+                                       minDistAcum     = distAcum;
+                               } // if integerDist
+
+                       } // for beta
+               } //if sizeContour2<sizeContour1
+// Set Alpha y Beta
+               Redistribution_SIN( alpha,beta, &lstTmp1X,&lstTmp1Y,&lstTmp1Z , &lstTmp1aX,&lstTmp1aY,&lstTmp1aZ );
+               double nn       = SizeContour( &lstTmp1aX, &lstTmp1aY, &lstTmp1aZ );
+               PutPointsInContour(&lstTmp1aX,&lstTmp1aY,&lstTmp1aZ, iContour ,lstOutX,lstOutY,lstOutZ,lstIndexsOut);                           
+               sizeContour1 = sizeContour2;
+               CopyContour2InContour1( &lstTmp2X,&lstTmp2Y,&lstTmp2Z , &lstTmp1X,&lstTmp1Y,&lstTmp1Z );
+       } // for iContour 
+}
+
+
+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,
@@ -503,6 +876,8 @@ void ManualContourModel_Box::Process()
        {
                lstIndexsIn.push_back( lstInX.size() );
        }
+       
+// Step 1.  All contours the same clockwise direction (Control Points)
        if (bbGetInputDoubleContour()==1)
        {
                ClockwisePoints( &lstInX , &lstInY , &lstInZ , &lstIndexsIn );
@@ -510,6 +885,8 @@ void ManualContourModel_Box::Process()
        } // DoubleContour
        int i,size=lstIndexsIn.size();
        int iGeneral=0;
+       
+// Step 2.  Spline interpolation of control points     
        for (i=0;i<size;i++)
        {
                ProcessBySegment(       bbGetInputType() , 
@@ -521,16 +898,24 @@ void ManualContourModel_Box::Process()
 
        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 );
-               ///////////// Second Step Transpose the vectors   
+// Step 3.3. SIN Normalice points around contours      
+//             RedistributionPoints_SIN_iContour(-1, &lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut,-1,-1);
+               RedistributionPointsAllContours_SIN( &lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut);
+//             ShiftValues( &lstOutX, &lstOutY, &lstOutZ, &lstIndexsOut );
+// Step 3.4 Transpose the vectors   
                lstInX.clear();
                lstInY.clear();
                lstInZ.clear();
@@ -551,7 +936,7 @@ void ManualContourModel_Box::Process()
                lstOutY.clear();
                lstOutZ.clear();
                lstIndexsOut.clear();
-               ///////////////////// Third step Interponation 2
+// Step 3.5 Interponation 2
                size=lstIndexsIn.size();
                iGeneral=0;
                for (i=0;i<size;i++)
@@ -563,7 +948,7 @@ void ManualContourModel_Box::Process()
                                                                &lstIndexsOut,bbGetInputOpenClose2());
                } // for
                RedistributionPoints(&lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut);
-               //////////////////// Forth step Transpose the vectors   
+// Step 3.6 Transpose the vectors   
                lstInX.clear();
                lstInY.clear();
                lstInZ.clear();
index 760f2b0c89f842d61cb3a0e63891e51254a6fb56..683ee71954e16add2997a547692863c09331087c 100644 (file)
@@ -23,12 +23,11 @@ class bbcreaMaracasVisu_EXPORT ManualContourModel_Box
   BBTK_DECLARE_INPUT(OpenClose,bool);
   BBTK_DECLARE_INPUT(OpenClose2,bool);
   BBTK_DECLARE_INPUT(NbPoints,int);
-
   BBTK_DECLARE_INPUT(LstIndexsIn,std::vector<int>);
-
   BBTK_DECLARE_INPUT(LstControlPointsX,std::vector<double>);
   BBTK_DECLARE_INPUT(LstControlPointsY,std::vector<double>);
   BBTK_DECLARE_INPUT(LstControlPointsZ,std::vector<double>);
+  BBTK_DECLARE_INPUT(Param,std::vector<double>);
 
 
   BBTK_DECLARE_OUTPUT(LstContourPointsX,std::vector<double>);
@@ -58,6 +57,8 @@ void ShiftValues(     std::vector<double> *lstInX,
                        std::vector<int>        *lstIndexsOut,
                        bool open );
 
+
+// Linear Distribution
 void RedistributionPoints(     std::vector<double> *lstOutX,
                                                        std::vector<double> *lstOutY, 
                                                        std::vector<double> *lstOutZ, 
@@ -65,6 +66,66 @@ void RedistributionPoints(   std::vector<double> *lstOutX,
 
 
 
+// sin distribution
+void 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 );
+// find best sin distribution
+void RedistributionPointsAllContours_SIN(      std::vector<double> *lstOutX,
+                                                                                       std::vector<double> *lstOutY, 
+                                                                                       std::vector<double> *lstOutZ, 
+                                                                                       std::vector<int> *lstIndexsOut );
+
+void Redistribution_SIN(       double alpha,
+                                                       double beta,
+                                                       std::vector<double> *lstC1X,
+                                                       std::vector<double> *lstC1Y, 
+                                                       std::vector<double> *lstC1Z,
+                                                       std::vector<double> *lstC2X,
+                                                       std::vector<double> *lstC2Y, 
+                                                       std::vector<double> *lstC2Z );
+
+double SizeContour(    std::vector<double> *lstX,
+                                       std::vector<double> *lstY, 
+                                       std::vector<double> *lstZ );
+
+void ExtractContour(std::vector<double> *lstX,
+                                       std::vector<double> *lstY, 
+                                       std::vector<double> *lstZ,
+                                       std::vector<int> *lstIndexs,
+                                       int contour,
+                                       std::vector<double> *lstOutX,
+                                       std::vector<double> *lstOutY, 
+                                       std::vector<double> *lstOutZ );
+
+void PutPointsInContour(       std::vector<double> *lstTmpX,
+                                                       std::vector<double> *lstTmpY, 
+                                                       std::vector<double> *lstTmpZ,
+                                                       int iContour,
+                                                       std::vector<double> *lstOutX,
+                                                       std::vector<double> *lstOutY, 
+                                                       std::vector<double> *lstOutZ,
+                                                       std::vector<int>        *lstOutIndexs );
+
+double IntegralDistanceTwoContours( std::vector<double> *lstTmpAX,
+                                                                       std::vector<double> *lstTmpAY, 
+                                                                       std::vector<double> *lstTmpAZ,
+                                                                       std::vector<double> *lstTmpBX,
+                                                                       std::vector<double> *lstTmpBY, 
+                                                                       std::vector<double> *lstTmpBZ );
+                                                                       
+void CopyContour2InContour1(   std::vector<double> *lstInX,
+                                                               std::vector<double> *lstInY, 
+                                                               std::vector<double> *lstInZ,
+                                                               std::vector<double> *lstOutX,
+                                                               std::vector<double> *lstOutY, 
+                                                               std::vector<double> *lstOutZ );
+                                                                       
+
+
+
 //===== 
 // 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)
 //===== 
@@ -82,11 +143,10 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ManualContourModel_Box,bbtk::AtomicBlackBox);
   BBTK_INPUT(ManualContourModel_Box,OpenClose2,"(false default) false=open, true=close.  Used with the DoubleContour option.",bool,"");
   BBTK_INPUT(ManualContourModel_Box,NbPoints,"(100 default) Number of points int the spline",int,"");
   BBTK_INPUT(ManualContourModel_Box,LstIndexsIn,"Lst number of points by segment",std::vector<int>,"");
-
   BBTK_INPUT(ManualContourModel_Box,LstControlPointsX,"List of control points",std::vector<double>,"");
   BBTK_INPUT(ManualContourModel_Box,LstControlPointsY,"List of control points",std::vector<double>,"");
   BBTK_INPUT(ManualContourModel_Box,LstControlPointsZ,"List of control points",std::vector<double>,"");
-
+  BBTK_INPUT(ManualContourModel_Box,Param,"Param",std::vector<double>,"");
   BBTK_OUTPUT(ManualContourModel_Box,LstContourPointsX,"List of points in the contour",std::vector<double>,"");
   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>,"");