]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/ModelShowNPoints.cxx
#3504 Integer to double ShowNpoints
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / ModelShowNPoints.cxx
index ea3616a7113830e4af1a7e5fff2bb0a3078b478f..a66c92d6be55c1fa9316a09aa42dfb007c4a72eb 100644 (file)
@@ -28,19 +28,19 @@ double ModelShowNPoints::GetRadio()
 }
 
 //------------------------------------------------------------------------
-std::vector<int> ModelShowNPoints::GetLstPointsX()
+std::vector<double> ModelShowNPoints::GetLstPointsX()
 {
        return lstPointsX;
 }
 
 //------------------------------------------------------------------------
-std::vector<int> ModelShowNPoints::GetLstPointsY()
+std::vector<double> ModelShowNPoints::GetLstPointsY()
 {
        return lstPointsY;
 }
 
 //------------------------------------------------------------------------
-std::vector<int> ModelShowNPoints::GetLstPointsZ()
+std::vector<double> ModelShowNPoints::GetLstPointsZ()
 {
        return lstPointsZ;
 }
@@ -65,13 +65,13 @@ std::vector<std::string> ModelShowNPoints::GetLstLabels()
 }
 
 //------------------------------------------------------------------------
-void ModelShowNPoints::SetReferencePoint(std::vector<int> ppoint)
+void ModelShowNPoints::SetReferencePoint(std::vector<double> ppoint)
 {
        mReferencePoint = ppoint;
 }
 
 //------------------------------------------------------------------------
-std::vector<int> ModelShowNPoints::GetReferencePoint()
+std::vector<double> ModelShowNPoints::GetReferencePoint()
 {
        return mReferencePoint;
 }
@@ -95,7 +95,7 @@ std::string ModelShowNPoints::CleanSpaces(std::string ss)
 }
 
 //------------------------------------------------------------------------
-void ModelShowNPoints::GetIdPoint(int id, int *x, int *y, int *z)
+void ModelShowNPoints::GetIdPoint(int id, double *x, double *y, double *z)
 {
        *x = lstPointsX[id];
        *y = lstPointsY[id];
@@ -115,7 +115,7 @@ vtkImageData *ModelShowNPoints::GetImage()
 }
 
 //------------------------------------------------------------------------
-void ModelShowNPoints::AddPoint(int x, int y, int z, std::string label)
+void ModelShowNPoints::AddPoint(double x, double y, double z, std::string label)
 {
        lstPointsX.push_back( x );
        lstPointsY.push_back( y );
@@ -132,11 +132,11 @@ double ModelShowNPoints::DistanceSQ(double dX0, double dY0, double dZ0, double d
 }
 
 //------------------------------------------------------------------------
-int ModelShowNPoints::InsertPoint(int x, int y, int z, std::string label)
+int ModelShowNPoints::InsertPoint(double x, double y, double z, std::string label)
 {
        if(lstPointsX.size()>1)
        {
-               std::vector<int> dTotal;
+               std::vector<double> dTotal;
                int pos = 1;
                double a,b,c,res;
         int i,j;
@@ -149,7 +149,7 @@ int ModelShowNPoints::InsertPoint(int x, int y, int z, std::string label)
                                dTotal.push_back (res);         
                }
                //Gets the smallest distance 
-               int smallTMP = dTotal[0];
+               double smallTMP = dTotal[0];
                for (j = 0; j < (int) dTotal.size(); j++)
                {
                          if(dTotal[j]<smallTMP)
@@ -209,7 +209,7 @@ int ModelShowNPoints::InsertPoint(int x, int y, int z, std::string label)
         //  *************** Open contour case End *******************
 
         
-               std::vector<int>::iterator it;
+               std::vector<double>::iterator it;
                //Insert the point in the list of points
                it = lstPointsX.begin();
                lstPointsX.insert( it+pos, x );
@@ -239,21 +239,21 @@ void ModelShowNPoints::SavePoints_(FILE* ff)
         int i , size = (int) (lstPointsX.size());
         fprintf(ff,"NumberOfPoints %d \n",size);
         fprintf(ff," X\tY\tZ\tvalue\tLabel\n");
-        int x, y, z;
+        double x, y, z;
         double value;
         for (i=0; i<size; i++)
         {
             x       = lstPointsX[i];
             y       = lstPointsY[i];
             z       = lstPointsZ[i];
-            value   = mimage->GetScalarComponentAsDouble(x,y,z,0);
+            value   = mimage->GetScalarComponentAsDouble(std::round(x),std::round(y),std::round(z),0);
             if (lstLabels[i]!="")
             {
                 tmpLabel=lstLabels[i];
             } else{
                 tmpLabel="<_VOID_>";
             }
-            fprintf(ff,"%d\t%d\t%d\t%f\t%s\n", x , y , z , value  , tmpLabel.c_str());
+            fprintf(ff,"%f\t%f\t%f\t%f\t%s\n", x , y , z , value  , tmpLabel.c_str());
         } // for
 }
 
@@ -279,11 +279,12 @@ int ModelShowNPoints::ReadPoints_(FILE* ff)
     fscanf(ff," %s %s %s %s %s",chartmp, chartmp,chartmp,chartmp,chartmp );
 
     float value;
-    int x,y,z;
+    double x,y,z;
     for (i=0; i<size; i++)
     {
-        fscanf(ff,"%d%d%d%f%s",&x,&y,&z,&value,chartmp );  // x,y,z,value,label
+        fscanf(ff,"%lf%lf%lf%f%s",&x,&y,&z,&value,chartmp );  // x,y,z,value,label
         if (strcmp(chartmp,"<_VOID_>")==0) { strcpy(chartmp,""); }
+        cout << x << " " << y << " " << z << " " << value << endl;
         AddPoint(x,y,z, chartmp );
     }
     return size;