]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkVectorsExtraction.cxx
#2671 creaVtk Feature New Normal - VectorsExtraction
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkVectorsExtraction.cxx
1 //===== 
2 // 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)
3 //===== 
4 #include "bbcreaVtkVectorsExtraction.h"
5 #include "bbcreaVtkPackage.h"
6 #include "vtkDoubleArray.h"
7
8
9 namespace bbcreaVtk
10 {
11
12 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,VectorsExtraction)
13 BBTK_BLACK_BOX_IMPLEMENTATION(VectorsExtraction,bbtk::AtomicBlackBox);
14 //===== 
15 // 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)
16 //===== 
17 void VectorsExtraction::Process()
18 {
19
20 // THE MAIN PROCESSING METHOD BODY
21 //   Here we simply set the input 'In' value to the output 'Out'
22 //   And print out the output value
23 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
24 //    void bbSet{Input|Output}NAME(const TYPE&)
25 //    const TYPE& bbGet{Input|Output}NAME() const 
26 //    Where :
27 //    * NAME is the name of the input/output
28 //      (the one provided in the attribute 'name' of the tag 'input')
29 //    * TYPE is the C++ type of the input/output
30 //      (the one provided in the attribute 'type' of the tag 'input')
31     std::cout<< "MLER VectorsExtraction Process Start" << std::endl;
32
33     if(bbGetInputVectorsFieldImage() != NULL )
34         {
35                 vtkImageData         *m_VectorImage = bbGetInputVectorsFieldImage();
36                 vtkIdType             m_idType;
37       vtkDoubleArray       *velocity      = vtkDoubleArray::New();
38
39       std::vector<double> coord           = bbGetInputCoordinates();
40       std::vector<double> vec;
41
42       double ang1 = 0;//Angle 1
43       double ang2 = 0;//ANgle 2
44
45      // double  *v = static_cast<double *> (m_VectorImage->GetScalarPointer(coord[0],coord[1],coord[2]));
46
47
48       //Find coordinate into the image      
49       m_idType = m_VectorImage->FindPoint(coord[0],coord[1],coord[2]);
50       std::cout << m_idType;
51
52       //Recuperate vector of vectorFieldImage
53                 velocity = vtkDoubleArray::SafeDownCast(m_VectorImage->GetPointData()->GetArray("velocity"));
54       velocity->Print(std::cout);
55
56       std::cout<< "# components velocity: " << velocity->GetNumberOfComponents()<<std::endl;
57       std::cout<< "# tuples velocity: " << velocity->GetNumberOfTuples()<<std::endl;
58
59       vec[0] = velocity->GetComponent(m_idType,0);
60       vec[1] = velocity->GetComponent(m_idType,1);
61       vec[2] = velocity->GetComponent(m_idType,2);
62
63       std::cout << "velocity :" << vec[0] << "," <<vec[1] << ","<< vec[2] << std::endl;
64
65
66       //Miss calcule of angles -----
67
68       ang1 = vec[0];
69                 ang2 = vec[1];
70                 m_VectorImage->Print(std::cout);
71
72                 bbSetOutputAngle1(ang1);
73                 bbSetOutputAngle2(ang2);
74       bbSetOutputVector(vec);
75
76         }// if image != NULL
77     
78     std::cout<< "MLER VectorsExtraction Process END" << std::endl;
79   
80 }
81 //===== 
82 // 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)
83 //===== 
84 void VectorsExtraction::bbUserSetDefaultValues()
85 {
86
87 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
88 //    Here we initialize the input 'In' to 0
89    bbSetInputVectorsFieldImage(NULL);
90   
91 }
92 //===== 
93 // 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)
94 //===== 
95 void VectorsExtraction::bbUserInitializeProcessing()
96 {
97
98 //  THE INITIALIZATION METHOD BODY :
99 //    Here does nothing 
100 //    but this is where you should allocate the internal/output pointers 
101 //    if any 
102
103   
104 }
105 //===== 
106 // 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)
107 //===== 
108 void VectorsExtraction::bbUserFinalizeProcessing()
109 {
110
111 //  THE FINALIZATION METHOD BODY :
112 //    Here does nothing 
113 //    but this is where you should desallocate the internal/output pointers 
114 //    if any
115   
116 }
117 }
118 // EO namespace bbcreaVtk
119
120