]> Creatis software - creaMaracasVisu.git/commitdiff
#
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Wed, 3 Feb 2021 17:58:32 +0000 (18:58 +0100)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Wed, 3 Feb 2021 17:58:32 +0000 (18:58 +0100)
bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx

index 2b2404271ff40b64634a7f62bccd6fbbaeb4e93f..e1717ca87466bbbabbf5bc22628d5cf99ba9d442 100644 (file)
@@ -242,6 +242,8 @@ printf("EED ManualContourModel_Box::ClockwisePoints cx=%f cy=%f cz=%f    flagAng
        } // for iLstIndexIn
 }
 
+
+/*
 void ManualContourModel_Box::ShiftValues(      std::vector<double> *lstInX,
                                                                                        std::vector<double> *lstInY, 
                                                                                        std::vector<double> *lstInZ,
@@ -372,6 +374,88 @@ printf("EED ManualContourModel_Box::ShiftValues px=%f py=%f pz=%f  iBack=%d/%d
        } // if sizeLstIndexIn
        
 }
+*/
+
+
+
+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++)
+                       {
+                               dist=0;
+                               for ( i=0 ; i<size2 ; i++ )
+                               {
+                                       dx      = (*lstInX)[iGeneral+i]-(*lstInX)[iGeneral+size+(i+ig)%size];
+                                       dy      = (*lstInY)[iGeneral+i]-(*lstInY)[iGeneral+size+(i+ig)%size];
+                                       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);
+                       
+                       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
+       
+}
+
+
+
 
 
 
@@ -413,7 +497,7 @@ void ManualContourModel_Box::Process()
        if (bbGetInputDoubleContour()==1)
        {
                ClockwisePoints( &lstInX , &lstInY , &lstInZ , &lstIndexsIn );
-               ShiftValues( &lstInX , &lstInY , &lstInZ , &lstIndexsIn );
+//             ShiftValues( &lstInX , &lstInY , &lstInZ , &lstIndexsIn );
        } // DoubleContour
        int i,size=lstIndexsIn.size();
        int iGeneral=0;
@@ -435,6 +519,7 @@ void ManualContourModel_Box::Process()
                bbSetOutputLstIndexsOut(lstIndexsOut);  
        } else {
                RedistributionPoints(&lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut);
+               ShiftValues( &lstOutX, &lstOutY, &lstOutZ, &lstIndexsOut );
                ///////////// Second Step Transpose the vectors   
                lstInX.clear();
                lstInY.clear();