]> Creatis software - creaVtk.git/blobdiff - bbtk_creaVtk_PKG/src/bbcreaVtkVectorsExtraction.cxx
#3110 creaVtk Bug New Normal - branch vtk7itk4 compilation with vtk7
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkVectorsExtraction.cxx
index 38f2ffb1e9c8f34d1712daf04c3578bad6a550a8..33b2347ddf962cad47e285e157226befa185f0a8 100644 (file)
@@ -28,68 +28,79 @@ void VectorsExtraction::Process()
 //      (the one provided in the attribute 'name' of the tag 'input')
 //    * TYPE is the C++ type of the input/output
 //      (the one provided in the attribute 'type' of the tag 'input')
-    std::cout<< "MLER VectorsExtraction Process Start" << std::endl;
-
+std::cout<< "MLER VectorsExtraction Process Start" << std::endl;
     if(bbGetInputVectorsFieldImage() != NULL )
        {
-               vtkImageData         *m_VectorImage = bbGetInputVectorsFieldImage();
-               vtkIdType             m_idType;
-      vtkDoubleArray       *velocity      = vtkDoubleArray::New();
-
-      std::vector<double> coord           = bbGetInputCoordinates();
-      std::vector<double> vec;
-
-      vec.push_back(0);
-      vec.push_back(0);
-      vec.push_back(0);
-
-      double ang1 = 0;//Angle 1
-      double ang2 = 0;//ANgle 2
-      double comp = 0;//Component x + y
+               vtkImageData            *m_VectorImage = bbGetInputVectorsFieldImage();
+               vtkIdType               m_idType;
+       vtkDoubleArray          *velocity      = vtkDoubleArray::New();
+       std::vector<double>     coord          = bbGetInputCoordinates();
+       std::vector<double>     vec;
+       vec.push_back(0);
+       vec.push_back(0);
+       vec.push_back(0);
+       double ang1 = 0;//Angle 1
+       double ang2 = 0;//ANgle 2
+       double comp = 0;//Component x + y
+       //Find coordinate into the image      
+std::cout << "ups ." << std::endl;
+       m_idType = m_VectorImage->FindPoint(coord[0],coord[1],coord[2]);
+std::cout << "m_idType" << m_idType << std::endl;
+       //Recuperate vector of vectorFieldImage
+               m_VectorImage->Print(std::cout);
+
+
+               int sizeArrays= m_VectorImage->GetPointData()->GetNumberOfArrays();
+               for (int iArray=0; iArray<sizeArrays;iArray++)
+               {
+                       printf("%s\n", m_VectorImage->GetPointData()->GetArrayName(iArray) );
+               } // for iArrays
+
+vtkDataArray *dataArray = m_VectorImage->GetPointData()->GetArray("velocity");
+if (dataArray!=NULL)
+{
+       printf("DataArrya ok \n");      
+       double *vecData;
+       vecData=dataArray->GetTuple3(m_idType);
+       printf("info data: %f %f %f \n", vecData[0], vecData[1], vecData[2] );
+       vec[0]=vecData[0];
+       vec[1]=vecData[1];
+       vec[2]=vecData[2];
+       bbSetOutputVector(vec);
 
-      //Find coordinate into the image      
-      m_idType = m_VectorImage->FindPoint(coord[0],coord[1],coord[2]);
-      std::cout << m_idType;
+} // if dataArray
 
-      //Recuperate vector of vectorFieldImage
                velocity = vtkDoubleArray::SafeDownCast(m_VectorImage->GetPointData()->GetArray("velocity"));
-      //velocity->Print(std::cout);
-
-      std::cout<< "# components velocity: " << velocity->GetNumberOfComponents()<<std::endl;
-      std::cout<< "# tuples velocity: " << velocity->GetNumberOfTuples()<<std::endl;
-
-      vec[0] = velocity->GetComponent(m_idType,0);
-      vec[1] = velocity->GetComponent(m_idType,1);
-      vec[2] = velocity->GetComponent(m_idType,2);
-
-      std::cout << "velocity :" << vec[0] << "," <<vec[1] << ","<< vec[2] << std::endl;
-
-
-      //Miss calcule of angles -----
-      comp = sqrt((vec[0]*vec[0])+(vec[1]*vec[1]));
-      
-      ang1 = atan2(vec[2],comp) * 180 / PI;
-
-
-      ang2 = atan2(vec[1],vec[0]) * 180 / PI;
-
-      
-               //m_VectorImage->Print(std::cout);
-
-      std::cout << "ang1: " << ang1 << std::endl;
-      std::cout << "ang2: " << ang2 << std::endl;
-
-       bbSetOutputAngle1(ang1);
-       bbSetOutputAngle2(ang2);
-      bbSetOutputVector(vec);
-      bbSetOutputX(coord[0]);
-      bbSetOutputY(coord[1]);
-      bbSetOutputZ(coord[2]);
-
+       //velocity->Print(std::cout);
+               if (velocity!=NULL)
+               {
+       std::cout<< "# components velocity: " << velocity->GetNumberOfComponents()<<std::endl;
+       std::cout<< "# tuples velocity: " << velocity->GetNumberOfTuples()<<std::endl;
+                       vec[0] = velocity->GetComponent(m_idType,0);
+                       vec[1] = velocity->GetComponent(m_idType,1);
+                       vec[2] = velocity->GetComponent(m_idType,2);
+       std::cout << "velocity :" << vec[0] << "," <<vec[1] << ","<< vec[2] << std::endl;
+                       //Miss calcule of angles -----
+                       comp = sqrt((vec[0]*vec[0])+(vec[1]*vec[1]));
+                       ang1 = atan2(vec[2],comp) * 180 / PI;
+                       ang2 = atan2(vec[1],vec[0]) * 180 / PI;
+                       //m_VectorImage->Print(std::cout);
+       std::cout << "ang1: " << ang1 << std::endl;
+       std::cout << "ang2: " << ang2 << std::endl;
+                       bbSetOutputAngle1(ang1);
+                       bbSetOutputAngle2(ang2);
+                       bbSetOutputVector(vec);
+                       bbSetOutputX(coord[0]);
+                       bbSetOutputY(coord[1]);
+                       bbSetOutputZ(coord[2]);
+
+               } else {
+                       bbSetOutputAngle1(ang1);
+                       bbSetOutputAngle2(ang2);
+                       bbSetOutputVector(vec);
+               }// if velocity
        }// if image != NULL
-    
-    std::cout<< "MLER VectorsExtraction Process END" << std::endl;
-  
+std::cout<< "MLER VectorsExtraction Process END" << std::endl;  
 }
 //===== 
 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)