]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkLineProfile.cxx
#3491 vtk9itk5wx3-macos
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkLineProfile.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 "bbcreaVtkLineProfile.h"
5 #include "bbcreaVtkPackage.h"
6 #include <math.h>
7
8 namespace bbcreaVtk
9 {
10
11 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,LineProfile)
12 BBTK_BLACK_BOX_IMPLEMENTATION(LineProfile,bbtk::AtomicBlackBox);
13 //===== 
14 // 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)
15 //===== 
16 void LineProfile::Process()
17 {
18
19 // THE MAIN PROCESSING METHOD BODY
20 //   Here we simply set the input 'In' value to the output 'Out'
21 //   And print out the output value
22 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
23 //    void bbSet{Input|Output}NAME(const TYPE&)
24 //    const TYPE& bbGet{Input|Output}NAME() const 
25 //    Where :
26 //    * NAME is the name of the input/output
27 //      (the one provided in the attribute 'name' of the tag 'input')
28 //    * TYPE is the C++ type of the input/output
29 //      (the one provided in the attribute 'type' of the tag 'input')
30
31
32 printf("EED LineProfile::Process Start\n");
33
34         std::vector<double> profileLst;
35         if ( (bbGetInputPoint1().size()==3) && (bbGetInputPoint2().size()==3) && (bbGetInputIn()!=NULL) ) 
36         {
37                 double x1 = bbGetInputPoint1()[0];
38                 double y1 = bbGetInputPoint1()[1];
39                 double z1 = bbGetInputPoint1()[2];
40                 double x2 = bbGetInputPoint2()[0];
41                 double y2 = bbGetInputPoint2()[1];
42                 double z2 = bbGetInputPoint2()[2];
43                 double dx = x1-x2;
44                 double dy = y1-y2;
45                 double dz = z1-z2;
46                 double dist = (int) sqrt( dx*dx + dy*dy  + dz*dz );
47
48 printf("EED LineProfile::Process point %f %f %f - %f %f %f\n", x1,y1,z1, x2,y2,z2);
49
50         
51                 int i;
52                 double ii,nx,ny,nz;
53                 for (i=0; i<dist;i++)
54                 {
55                         ii = i/dist;
56                         nx = x1 + dx*ii;                
57                         ny = y1 + dy*ii;                
58                         nz = z1 + dz*ii;
59                         profileLst.push_back( bbGetInputIn()->GetScalarComponentAsDouble(nx,ny,nz,0) );
60 printf("%f ", bbGetInputIn()->GetScalarComponentAsDouble(nx,ny,nz,0) );
61                 } // for i
62         } // if
63         bbSetOutputOut( profileLst );
64 printf("\n");
65 printf("EED LineProfile::Process End\n");
66
67 }
68 //===== 
69 // 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)
70 //===== 
71 void LineProfile::bbUserSetDefaultValues()
72 {
73
74 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
75 //    Here we initialize the input 'In' to 0
76    bbSetInputIn(NULL);
77   
78 }
79 //===== 
80 // 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)
81 //===== 
82 void LineProfile::bbUserInitializeProcessing()
83 {
84
85 //  THE INITIALIZATION METHOD BODY :
86 //    Here does nothing 
87 //    but this is where you should allocate the internal/output pointers 
88 //    if any 
89
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 LineProfile::bbUserFinalizeProcessing()
96 {
97
98 //  THE FINALIZATION METHOD BODY :
99 //    Here does nothing 
100 //    but this is where you should desallocate the internal/output pointers 
101 //    if any
102   
103 }
104 }
105 // EO namespace bbcreaVtk
106
107