X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=bbtk_creaVtk_PKG%2Fsrc%2FbbcreaVtkVectorsExtraction.cxx;h=38f2ffb1e9c8f34d1712daf04c3578bad6a550a8;hb=c6fcc051556a7fb38185df53e9f45bfe005a9c92;hp=e410bb9179b652085c52f432fe6d43ab55aacc2d;hpb=4cad1b11d2325f89911b061915750ca20c7cfeaa;p=creaVtk.git diff --git a/bbtk_creaVtk_PKG/src/bbcreaVtkVectorsExtraction.cxx b/bbtk_creaVtk_PKG/src/bbcreaVtkVectorsExtraction.cxx index e410bb9..38f2ffb 100644 --- a/bbtk_creaVtk_PKG/src/bbcreaVtkVectorsExtraction.cxx +++ b/bbtk_creaVtk_PKG/src/bbcreaVtkVectorsExtraction.cxx @@ -5,6 +5,7 @@ #include "bbcreaVtkPackage.h" #include "vtkDoubleArray.h" + namespace bbcreaVtk { @@ -31,44 +32,62 @@ void VectorsExtraction::Process() if(bbGetInputVectorsFieldImage() != NULL ) { - vtkImageData* m_VectorImage = bbGetInputVectorsFieldImage(); + vtkImageData *m_VectorImage = bbGetInputVectorsFieldImage(); + vtkIdType m_idType; + vtkDoubleArray *velocity = vtkDoubleArray::New(); - std::vector coord = bbGetInputCoordinates(); + std::vector coord = bbGetInputCoordinates(); + std::vector vec; - /*double *vector = static_cast(m_VectorImage->GetScalarPointer(coord[0],coord[1],coord[2])); + vec.push_back(0); + vec.push_back(0); + vec.push_back(0); - vtkDoubleArray* velocity = vtkDoubleArray::New(); - velocity = vtkDoubleArray::SafeDownCast(this->m_VectorImage->GetPointData()->GetArray("velocity")); + double ang1 = 0;//Angle 1 + double ang2 = 0;//ANgle 2 + double comp = 0;//Component x + y + //Find coordinate into the image + m_idType = m_VectorImage->FindPoint(coord[0],coord[1],coord[2]); + std::cout << m_idType; + //Recuperate vector of vectorFieldImage + velocity = vtkDoubleArray::SafeDownCast(m_VectorImage->GetPointData()->GetArray("velocity")); + //velocity->Print(std::cout); + std::cout<< "# components velocity: " << velocity->GetNumberOfComponents()<GetNumberOfTuples()<GetComponent(m_idType,0); + vec[1] = velocity->GetComponent(m_idType,1); + vec[2] = velocity->GetComponent(m_idType,2); - double ang1 = 0; - double ang2 = 0; + std::cout << "velocity :" << vec[0] << "," <Print(std::cout); + //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); - //bbSetOutputAngle1(ang1); - //bbSetOutputAngle2(ang2); + std::cout << "ang1: " << ang1 << std::endl; + std::cout << "ang2: " << ang2 << std::endl; - }// if image != NULL - + bbSetOutputAngle1(ang1); + bbSetOutputAngle2(ang2); + bbSetOutputVector(vec); + bbSetOutputX(coord[0]); + bbSetOutputY(coord[1]); + bbSetOutputZ(coord[2]); + }// if image != NULL - - - - std::cout<< "MLER VectorsExtraction Process END" << std::endl; }