]> Creatis software - creaMaracasVisu.git/commitdiff
Redistribution SIN
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Mon, 10 May 2021 15:55:19 +0000 (17:55 +0200)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Mon, 10 May 2021 15:55:19 +0000 (17:55 +0200)
bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx
bbtk/src/bbcreaMaracasVisuManualContourModel_Box.h

index 0d9bffe24efffa6dc96ce1c15ace0afb12eb9c32..c8db827940c2755c35471f8d5d14fdfa3c85bdef 100644 (file)
@@ -204,8 +204,8 @@ void ManualContourModel_Box::PutPointsInContour(std::vector<double> *lstTmpX,
                        {
                                iGeneral                        = iGeneral + (*lstOutIndexs)[iContour-1];
                                SizeContour             = (*lstOutIndexs)[iContour];
+                               iGeneralPlusSize        = iGeneral + SizeContour;
                        } // for iContour
-                       iGeneralPlusSize        = iGeneral + SizeContour;
                        
                        if(SizeContour==(*lstTmpX).size() )
                        {
@@ -250,27 +250,144 @@ double ManualContourModel_Box::SizeContour(      std::vector<double> *lstX,
        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 )
+                                                                                                       std::vector<double> *lstC1X,
+                                                                                                       std::vector<double> *lstC1Y, 
+                                                                                                       std::vector<double> *lstC1Z,
+                                                                                                       double sizeOfContour,
+                                                                                                       std::vector<double> *lstC2X,
+                                                                                                       std::vector<double> *lstC2Y, 
+                                                                                                       std::vector<double> *lstC2Z )
 {
-       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
+printf("EED ManualContourModel_Box::Redistribution_SIN  Start \n");
+       std::vector<double> lstRstX;
+       std::vector<double> lstRstY;
+       std::vector<double> lstRstZ;
+       int ii,iGeneral;
+       double iiByDelta;
+       int size,iGeneralPlusSize;
+       double Alpha,Beta,t,tt, PI=3.14159265;
+       double TwoPI=2*PI;
+       double dist=sizeOfContour;
+       double 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];
+               size = (*lstInX).size();
+               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];
+                                       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)
+                                               {
+                                                       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==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  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 );
+                       }
+                       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
+               } // if size>2
+//             iGeneral=iGeneral+size;
+//     }// for iLstIndexOut
+printf("EED ManualContourModel_Box::Redistribution_SIN  End \n");      
 }
 
+
 void ManualContourModel_Box::CopyContour2InContour1(
                                                                                                        std::vector<double> *lstInX,
                                                                                                        std::vector<double> *lstInY, 
@@ -306,10 +423,10 @@ double ManualContourModel_Box::IntegralDistanceTwoContours(std::vector<double> *
        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 );
+               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;
 }
@@ -353,7 +470,7 @@ void ManualContourModel_Box::RedistributionPointsAllContours_SIN(   std::vector<do
                        minDistAcum=-999999999;
                        for (iAlpha=0.1 ; iAlpha<1; iAlpha=iAlpha+0.1) 
                        {
-                               Redistribution_SIN( alpha,beta, &lstTmp1X,&lstTmp1Y,&lstTmp1Z , &lstTmp1aX,&lstTmp1aY,&lstTmp1aZ );
+                               Redistribution_SIN( alpha,beta, &lstTmp1X,&lstTmp1Y,&lstTmp1Z ,sizeContour1, &lstTmp1aX,&lstTmp1aY,&lstTmp1aZ );
                                distAcum = IntegralDistanceTwoContours( &lstTmp1aX,&lstTmp1aY,&lstTmp1aZ , &lstTmp2X,&lstTmp2Y,&lstTmp2Z );
                                if (distAcum<minDistAcum) 
                                {
@@ -508,7 +625,6 @@ 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,
@@ -913,8 +1029,11 @@ void ManualContourModel_Box::Process()
                ShiftValues( &lstOutX, &lstOutY, &lstOutZ, &lstIndexsOut );
 // 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 );
+
+if (bbGetInputParam()[0]==1)
+{
+               RedistributionPointsAllContours_SIN( &lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut);
+}
 // Step 3.4 Transpose the vectors   
                lstInX.clear();
                lstInY.clear();
index 683ee71954e16add2997a547692863c09331087c..c8a06761939e275a9ba9614c0ff6014e73da8744 100644 (file)
@@ -83,6 +83,7 @@ void Redistribution_SIN(      double alpha,
                                                        std::vector<double> *lstC1X,
                                                        std::vector<double> *lstC1Y, 
                                                        std::vector<double> *lstC1Z,
+                                                       double sizeOfContour,
                                                        std::vector<double> *lstC2X,
                                                        std::vector<double> *lstC2Y, 
                                                        std::vector<double> *lstC2Z );