]> Creatis software - creaMaracasVisu.git/blobdiff - bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx
#3277 creaMaracasVisu Feature New Normal - SegmentationConnectivityEED.bbg
[creaMaracasVisu.git] / bbtk / src / bbcreaMaracasVisuManualContourModel_Box.cxx
index 1aa1c53867598b4e53585e270f65168a9654a6fb..9a20b5f9946f5446ed7decb03e0cee07424f6f44 100644 (file)
@@ -27,9 +27,7 @@ void ManualContourModel_Box::ProcessBySegment(
        creaContoursFactory f;
        manualContourModel      *m;
        int i,size=iGeneral+sizeSegment;
-
        double x,y,z;
-
        m = (manualContourModel*)f.getContourModel( bbGetInputType() );
        m->SetNumberOfPointsSpline( bbGetInputNbPoints() );
        m->SetCloseContour( open );
@@ -57,24 +55,18 @@ void ManualContourModel_Box::RedistributionPoints(  std::vector<double> *lstOutX,
                                                                                                        std::vector<double> *lstOutZ,
                                                                                                        std::vector<int> *lstIndexsOut )
 {
-       printf("EED Warnning!   ManualContourModel_Box::RedistributionPoints  Start\n");
-
        std::vector<double> lstRstX;
        std::vector<double> lstRstY;
        std::vector<double> lstRstZ;
-
        int iLstIndexOut,sizeLstIndexOut=lstIndexsOut->size();
        int ii, iGeneral=0;
        int size;
-
        for (iLstIndexOut=0;  iLstIndexOut<sizeLstIndexOut; iLstIndexOut++)
        {
 //printf("EED ManualContourModel_Box::RedistributionPoints iLstIndexOut=%d   \n", iLstIndexOut);
-
                lstRstX.clear();
                lstRstY.clear();
                lstRstZ.clear();
-
                size=(*lstIndexsOut)[iLstIndexOut];
                if (size>2)
                {
@@ -89,7 +81,6 @@ void ManualContourModel_Box::RedistributionPoints(    std::vector<double> *lstOutX,
                                dist = dist+sqrt( dx*dx + dy*dy + dz*dz );
                        } //for
                        delta=dist/(size-1);
-                       
                        lstRstX.push_back( (*lstOutX)[iGeneral] );
                        lstRstY.push_back( (*lstOutY)[iGeneral] );
                        lstRstZ.push_back( (*lstOutZ)[iGeneral] );
@@ -129,13 +120,10 @@ void ManualContourModel_Box::RedistributionPoints(        std::vector<double> *lstOutX,
                                        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);
                        }
-
                        for (i=iGeneral; i<iGeneral+size;i++)
                        {
                                ii=i-iGeneral;
@@ -143,15 +131,9 @@ void ManualContourModel_Box::RedistributionPoints( std::vector<double> *lstOutX,
                                (*lstOutY)[i] = lstRstY[ii];
                                (*lstOutZ)[i] = lstRstZ[ii];
                        } // for i
-                                       
                } // if size>2
-               
                iGeneral=iGeneral+size;
-
        }// for iLstIndexOut
-
-       printf("EED Warnning!   ManualContourModel_Box::RedistributionPoints  End\n");
-
 }
 
 
@@ -167,18 +149,15 @@ void ManualContourModel_Box::ShiftValues( std::vector<double> *lstInX,
        double dist,distMin;
        int i,iBack;
        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;
@@ -194,8 +173,6 @@ void ManualContourModel_Box::ShiftValues(   std::vector<double> *lstInX,
                                        distMin = dist;
                                }
                        } // for dist
-
-
                        if (iBack!=0)
                        {
                                LstTmpX.clear();
@@ -215,7 +192,6 @@ void ManualContourModel_Box::ShiftValues(   std::vector<double> *lstInX,
                                        (*lstInZ)[iGeneral+size+i] = LstTmpZ[i];
                                } // for i                              
                        }
-
                        iGeneral=iGeneral+size;
                } // for iLstIndexIn
        } // sizeLstIndexIn
@@ -240,32 +216,28 @@ 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)
        {
                lstIndexsIn.push_back( lstInX.size() );
        }
-
-       ShiftValues( &lstInX , &lstInY , &lstInZ , &lstIndexsIn );
-
-
+       if (bbGetInputDoubleContour()==1)
+       {
+               ShiftValues( &lstInX , &lstInY , &lstInZ , &lstIndexsIn );
+       } // DoubleContour
        int i,size=lstIndexsIn.size();
        int iGeneral=0;
        for (i=0;i<size;i++)
@@ -277,93 +249,76 @@ void ManualContourModel_Box::Process()
                                                        &lstIndexsOut,bbGetInputOpenClose() );
        } // for
 
-       RedistributionPoints(&lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut);
-
-
-
-    // Second Step Transpose the vectors   
-       lstInX.clear();
-       lstInY.clear();
-       lstInZ.clear();
-       lstIndexsIn.clear();
-       size  = bbGetInputNbPoints();
-       int j,size2 = lstIndexsOut.size();
-       for (i=0;i<size;i++)
+       if (bbGetInputDoubleContour()==0)
        {
-               for (j=0;j<size2;j++)
+               //////////////////// Set Out   DoubleContour = 0
+               bbSetOutputLstContourPointsX(lstOutX);  
+               bbSetOutputLstContourPointsY(lstOutY);  
+               bbSetOutputLstContourPointsZ(lstOutZ);
+               bbSetOutputLstIndexsOut(lstIndexsOut);  
+       } else {
+               RedistributionPoints(&lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut);
+               ///////////// Second Step Transpose the vectors   
+               lstInX.clear();
+               lstInY.clear();
+               lstInZ.clear();
+               lstIndexsIn.clear();
+               size  = bbGetInputNbPoints();
+               int j,size2 = lstIndexsOut.size();
+               for (i=0;i<size;i++)
                {
-                       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();
-
-
-    // Third step 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,false);
-       } // for
-
-
-       RedistributionPoints(&lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut);
-
-
-    // Second Step 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++)
+                       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();
+               ///////////////////// Third step Interponation 2
+               size=lstIndexsIn.size();
+               iGeneral=0;
+               for (i=0;i<size;i++)
                {
-                       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();
-
-       bbSetOutputLstContourPointsX(lstInX);   
-       bbSetOutputLstContourPointsY(lstInY);   
-       bbSetOutputLstContourPointsZ(lstInZ);
-       bbSetOutputLstIndexsOut(lstIndexsIn);   
-
-
-printf("EED Warnning ..... ManualContourModel_Box::Process    Clean this ...............\n");
-printf("EED Warnning ..... ManualContourModel_Box::Process    Clean this ...............\n");
-printf("EED Warnning ..... ManualContourModel_Box::Process    Clean this ...............\n");
-printf("EED Warnning ..... ManualContourModel_Box::Process    Clean this ...............\n");
-printf("EED Warnning ..... ManualContourModel_Box::Process    Clean this ...............\n");
-printf("EED Warnning ..... ManualContourModel_Box::Process    Clean this ...............\n");
-printf("EED Warnning ..... ManualContourModel_Box::Process    Clean this ...............\n");
-printf("EED Warnning ..... ManualContourModel_Box::Process    Clean this ...............\n");
-printf("EED Warnning ..... ManualContourModel_Box::Process    Clean this ...............\n");
-
-/*
-       bbSetOutputLstContourPointsX(lstOutX);  
-       bbSetOutputLstContourPointsY(lstOutY);  
-       bbSetOutputLstContourPointsZ(lstOutZ);
-       bbSetOutputLstIndexsOut(lstIndexsOut);  
-*/
+                       ProcessBySegment(       bbGetInputType() , 
+                                                               iGeneral, lstIndexsIn[i] ,
+                                                               &lstInX,&lstInY,&lstInZ,
+                                                               &lstOutX,&lstOutY,&lstOutZ,
+                                                               &lstIndexsOut,bbGetInputOpenClose2());
+               } // for
+               RedistributionPoints(&lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut);
+               //////////////////// Forth step 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 
 
 }
 //===== 
@@ -375,7 +330,9 @@ void ManualContourModel_Box::bbUserSetDefaultValues()
 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
 //    Here we initialize the input 'In' to 0
    bbSetInputType(1);
+   bbSetInputDoubleContour(0);
    bbSetInputOpenClose(false);
+   bbSetInputOpenClose2(false);
    bbSetInputNbPoints(100);
   
 }