]> Creatis software - creaVtk.git/blobdiff - bbtk_creaVtk_PKG/src/bbcreaVtkVectorsExtraction.cxx
#2671 creaVtk Feature New Normal - VectorsExtraction
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkVectorsExtraction.cxx
index e410bb9179b652085c52f432fe6d43ab55aacc2d..eae8d6767875548d4c35c5c1bc5f99e049598359 100644 (file)
@@ -5,6 +5,7 @@
 #include "bbcreaVtkPackage.h"
 #include "vtkDoubleArray.h"
 
+
 namespace bbcreaVtk
 {
 
@@ -31,44 +32,50 @@ void VectorsExtraction::Process()
 
     if(bbGetInputVectorsFieldImage() != NULL )
        {
-               vtkImageData* m_VectorImage = bbGetInputVectorsFieldImage();
-
-               std::vector<double> coord = bbGetInputCoordinates();
-
-               /*double *vector = static_cast<double*>(m_VectorImage->GetScalarPointer(coord[0],coord[1],coord[2]));
+               vtkImageData         *m_VectorImage = bbGetInputVectorsFieldImage();
+               vtkIdType             m_idType;
+      vtkDoubleArray       *velocity      = vtkDoubleArray::New();
 
-               vtkDoubleArray* velocity = vtkDoubleArray::New();
-               velocity = vtkDoubleArray::SafeDownCast(this->m_VectorImage->GetPointData()->GetArray("velocity"));
+      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
 
+      //Find coordinate into the image      
+      m_idType = m_VectorImage->FindPoint(coord[0],coord[1],coord[2]);
+      std::cout << m_idType;
 
-               std::cout << "coord: "<< coord[0] << ","<< coord[1] << ","<<coord[2] << std::endl;
-               std::cout << "vector: "<< velocity[0] << ","<< velocity[1] << ","<<velocityvelocity[2] << std::endl;
+      //Recuperate vector of vectorFieldImage
+               velocity = vtkDoubleArray::SafeDownCast(m_VectorImage->GetPointData()->GetArray("velocity"));
+      //velocity->Print(std::cout);
 
-               double ang1 = 0;
-               double ang2 = 0;
+      std::cout<< "# components velocity: " << velocity->GetNumberOfComponents()<<std::endl;
+      std::cout<< "# tuples velocity: " << velocity->GetNumberOfTuples()<<std::endl;
 
-               ang1 = velocity[0] + velocity[1] + velocity[2];
-               ang2 = velocity[0] + velocity[1] - velocity[2];
-*/
-               m_VectorImage->Print(std::cout);
+      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 -----
 
+      ang1 = vec[0]*80;
+       ang2 = vec[1]*10;
+               //m_VectorImage->Print(std::cout);
 
-               //bbSetOutputAngle1(ang1);
-               //bbSetOutputAngle2(ang2);
+       bbSetOutputAngle1(ang1);
+       bbSetOutputAngle2(ang2);
+      bbSetOutputVector(vec);
 
        }// if image != NULL
     
-
-    
-
-
-
-
     std::cout<< "MLER VectorsExtraction Process END" << std::endl;
   
 }