]> Creatis software - creaVtk.git/blobdiff - bbtk_creaVtk_PKG/src/bbcreaVtkVectorsExtraction.cxx
#2811 creaVtk Feature New Normal - ConcatTransform ImageAccumulate TransformVector
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkVectorsExtraction.cxx
index e753ae38515c463e790784035831ee3a2a574c84..38f2ffb1e9c8f34d1712daf04c3578bad6a550a8 100644 (file)
@@ -39,11 +39,13 @@ void VectorsExtraction::Process()
       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  *v = static_cast<double *> (m_VectorImage->GetScalarPointer(coord[0],coord[1],coord[2]));
-
+      double comp = 0;//Component x + y
 
       //Find coordinate into the image      
       m_idType = m_VectorImage->FindPoint(coord[0],coord[1],coord[2]);
@@ -51,7 +53,7 @@ void VectorsExtraction::Process()
 
       //Recuperate vector of vectorFieldImage
                velocity = vtkDoubleArray::SafeDownCast(m_VectorImage->GetPointData()->GetArray("velocity"));
-      velocity->Print(std::cout);
+      //velocity->Print(std::cout);
 
       std::cout<< "# components velocity: " << velocity->GetNumberOfComponents()<<std::endl;
       std::cout<< "# tuples velocity: " << velocity->GetNumberOfTuples()<<std::endl;
@@ -64,14 +66,25 @@ void VectorsExtraction::Process()
 
 
       //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);
 
-      ang1 = vec[0];
-               ang2 = vec[1];
-               m_VectorImage->Print(std::cout);
+      std::cout << "ang1: " << ang1 << std::endl;
+      std::cout << "ang2: " << ang2 << std::endl;
 
-               bbSetOutputAngle1(ang1);
-               bbSetOutputAngle2(ang2);
+       bbSetOutputAngle1(ang1);
+       bbSetOutputAngle2(ang2);
       bbSetOutputVector(vec);
+      bbSetOutputX(coord[0]);
+      bbSetOutputY(coord[1]);
+      bbSetOutputZ(coord[2]);
 
        }// if image != NULL