]> Creatis software - creaMaracasVisu.git/commitdiff
Redistribution SIN
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Wed, 12 May 2021 16:26:45 +0000 (18:26 +0200)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Wed, 12 May 2021 16:26:45 +0000 (18:26 +0200)
bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx
bbtk/src/bbcreaMaracasVisuManualContourModel_Box.h

index 11806ac6db134bcf21dd54025fcf189ec650086d..9623d4c42448e9bfb84a9c395bc688b142dd0d91 100644 (file)
@@ -442,7 +442,6 @@ void ManualContourModel_Box::RedistributionPointsAllContours_SIN(   std::vector<do
                                                                                                                                        std::vector<double> *lstOutZ,
                                                                                                                                        std::vector<int>        *lstIndexsOut )
 {
-printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN start\n");
        std::vector<double> lstTmp1X;
        std::vector<double> lstTmp1Y;
        std::vector<double> lstTmp1Z;
@@ -472,7 +471,6 @@ printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN start\n");
        double  distAcum;
        double minDistAcum;
        
-       
        // ------------ Wave 1 -----------------
        
        ExtractContour(lstOutX,lstOutY,lstOutZ,lstIndexsOut,0,&lstTmp1X,&lstTmp1Y,&lstTmp1Z);
@@ -481,7 +479,6 @@ printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN start\n");
 // Increment   
        for ( iContour=0; iContour<nbContours-1 ; iContour++ )
        {
-printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN iContour=%d\n",iContour);
                beta    = 0;
                alpha   = 0;
 // find Alpha
@@ -530,16 +527,10 @@ printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN iContour=%d\
                        {
                                lstContourExeption.push_back( iContour+1 );
                        } // 
-                }
-                
+                }               
 // Set Alpha y Beta
-
-
                Redistribution_SIN( alpha,beta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
 
-// if(lstTmp2Y[0]==385) { alpha=bbGetInputParam()[1]; beta=bbGetInputParam()[2]; printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN ---385-- \n"); }
-printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN wve 1 alpha=%f  beta=%f  z=%f   sc1=%f   sc2=%f\n",alpha,beta,lstTmp2Y[0], sizeContour1,sizeContour2 );
-
                PutPointsInContour(&lstTmp2aX,&lstTmp2aY,&lstTmp2aZ, iContour+1 ,lstOutX,lstOutY,lstOutZ,lstIndexsOut);                         
                sizeContour1 = sizeContour2;
                CopyContour2InContour1( &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ , &lstTmp1X,&lstTmp1Y,&lstTmp1Z );
@@ -558,7 +549,6 @@ printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN wve 1 alpha=
 // Increment   
        for ( iContour=nbContours-1; iContour>=0 ; iContour-- )
        {
-printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN iContour=%d\n",iContour);
                beta    = 0;
                alpha   = 0;
 // find Alpha
@@ -607,9 +597,6 @@ printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN iContour=%d\
 
                Redistribution_SIN( alpha,beta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
 
-// if(lstTmp2Y[0]==385) { alpha=bbGetInputParam()[1]; beta=bbGetInputParam()[2]; printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN ---385-- \n"); }
-printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN wave 2 alpha=%f  beta=%f  z=%f   sc1=%f   sc2=%f\n",alpha,beta,lstTmp2Y[0], sizeContour1,sizeContour2 );
-
                PutPointsInContour(&lstTmp2aX,&lstTmp2aY,&lstTmp2aZ, iContour-1 ,lstOutX,lstOutY,lstOutZ,lstIndexsOut);                         
                sizeContour1 = sizeContour2;
                CopyContour2InContour1( &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ , &lstTmp1X,&lstTmp1Y,&lstTmp1Z );
@@ -620,11 +607,11 @@ printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN wave 2 alpha
        
        // ------------ Wave 3 -----------------
        
-       printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN  wave3 los que faltan");
+       double alpha1,alpha2;
+       double beta1,beta2;
        double iExtra,sizeExtra=lstContourExeption.size();
        for ( iExtra=0 ; iExtra<sizeExtra ; iExtra++ )
        {
-               printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN  wave3 los que faltan %d \n", lstContourExeption[iExtra] );
         
                ExtractContour(lstOutX,lstOutY,lstOutZ,lstIndexsOut, lstContourExeption[iExtra]-1       , &lstTmp1X,&lstTmp1Y,&lstTmp1Z);
                sizeContour1    = SizeContour( &lstTmp1X, &lstTmp1Y, &lstTmp1Z );
@@ -633,16 +620,19 @@ printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN wave 2 alpha
                ExtractContour(lstOutX,lstOutY,lstOutZ,lstIndexsOut, lstContourExeption[iExtra]+1       , &lstTmp3X,&lstTmp3Y,&lstTmp3Z);
                sizeContour3    = SizeContour( &lstTmp3X, &lstTmp3Y, &lstTmp3Z );
         
-               beta    = 0.05;
-               alpha   = 0;
+               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,beta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
+                       Redistribution_SIN( iAlpha,beta1, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
                        distAcum = IntegralDistanceTwoContours( &lstTmp1X,&lstTmp1Y,&lstTmp1Z , &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
                        if (distAcum<minDistAcum) 
                        {
-                               alpha           = iAlpha;
+                               alpha1          = iAlpha;
                                minDistAcum     = distAcum;
                        } // if integerDist
                } // for alpha
@@ -650,27 +640,27 @@ printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN wave 2 alpha
                minDistAcum = 999999999;
                for (iBeta=0.0 ; iBeta<0.2; iBeta=iBeta+0.01) 
                {
-                       Redistribution_SIN( alpha,iBeta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
+                       Redistribution_SIN( alpha1,iBeta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
                        distAcum = IntegralDistanceTwoContours( &lstTmp1X,&lstTmp1Y,&lstTmp1Z , &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
                        if (distAcum<minDistAcum) 
                        {
-                               beta            = iBeta;
+                               beta1           = iBeta;
                                minDistAcum     = distAcum;
                        } // if integerDist
                } // for beta    
-               Redistribution_SIN( alpha,beta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
 
  
-               beta    = 0.05;
-               alpha   = 0;
+// find Alpha
+               beta2   = 0.05;
+               alpha2  = 0;
                minDistAcum = 999999999;
                for (iAlpha=0 ; iAlpha<1; iAlpha=iAlpha+0.1 ) 
                {
-                       Redistribution_SIN( iAlpha,beta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2bX,&lstTmp2bY,&lstTmp2bZ );
+                       Redistribution_SIN( iAlpha,beta2, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2bX,&lstTmp2bY,&lstTmp2bZ );
                        distAcum = IntegralDistanceTwoContours( &lstTmp3X,&lstTmp3Y,&lstTmp3Z , &lstTmp2bX,&lstTmp2bY,&lstTmp2bZ );
                        if (distAcum<minDistAcum) 
                        {
-                               alpha           = iAlpha;
+                               alpha2          = iAlpha;
                                minDistAcum     = distAcum;
                        } // if integerDist
                } // for alpha
@@ -678,30 +668,129 @@ printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN wave 2 alpha
                minDistAcum = 999999999;
                for (iBeta=0.0 ; iBeta<0.2; iBeta=iBeta+0.01) 
                {
-                       Redistribution_SIN( alpha,iBeta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2bX,&lstTmp2bY,&lstTmp2bZ );
+                       Redistribution_SIN( alpha2,iBeta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2bX,&lstTmp2bY,&lstTmp2bZ );
                        distAcum = IntegralDistanceTwoContours( &lstTmp3X,&lstTmp3Y,&lstTmp3Z , &lstTmp2bX,&lstTmp2bY,&lstTmp2bZ );
                        if (distAcum<minDistAcum) 
                        {
-                               beta            = iBeta;
+                               beta2           = iBeta;
                                minDistAcum     = distAcum;
                        } // if integerDist
                } // for beta    
+
+               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);                               
-               
+//             PutPointsInContour(&lstTmp2cX,&lstTmp2cY,&lstTmp2cZ,  lstContourExeption[iExtra]  ,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()  );   
        
-       
-printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN End\n");
-
 }
+                                                                                                       
+
  
 
 
@@ -1235,6 +1324,7 @@ void ManualContourModel_Box::Process()
 if (bbGetInputParam()[0]==1)
 {
                RedistributionPointsAllContours_SIN( &lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut);
+               ShiftValues( &lstOutX, &lstOutY, &lstOutZ, &lstIndexsOut );
 }
 // Step 3.4 Transpose the vectors   
                lstInX.clear();
index c8a06761939e275a9ba9614c0ff6014e73da8744..b85478e6261e6f4856c775ce1c9460b8e02ce97f 100644 (file)
@@ -124,6 +124,16 @@ void CopyContour2InContour1(       std::vector<double> *lstInX,
                                                                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);
+