]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkApplyTransformToPoint3D.cxx
Clean code
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkApplyTransformToPoint3D.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 "bbcreaVtkApplyTransformToPoint3D.h"
5 #include "bbcreaVtkPackage.h"
6 #include "vtkTransform.h"
7
8 namespace bbcreaVtk
9 {
10
11 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ApplyTransformToPoint3D)
12 BBTK_BLACK_BOX_IMPLEMENTATION(ApplyTransformToPoint3D,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 ApplyTransformToPoint3D::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 //    bbSetOutputOut( bbGetInputIn() );
31 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
32
33
34         if ((bbGetInputPoint().size()==3) && (bbGetInputDirectionInPoint().size()==3) )
35         {
36                 double point[3] , newPoint[3];
37                 point[0] = bbGetInputPoint()[0];
38                 point[1] = bbGetInputPoint()[1];
39                 point[2] = bbGetInputPoint()[2];
40                 bbGetInputTransform()->TransformPoint( point,newPoint );
41                 std::vector<double> out;
42                 out.push_back( newPoint[0] );
43                 out.push_back( newPoint[1] );
44                 out.push_back( newPoint[2] );
45                 bbSetOutputOut( out );
46                 
47                 double pointDir[3] , newPointDir[3];
48                 pointDir[0] = bbGetInputPoint()[0]+bbGetInputDirectionInPoint()[0];
49                 pointDir[1] = bbGetInputPoint()[1]+bbGetInputDirectionInPoint()[1];
50                 pointDir[2] = bbGetInputPoint()[2]+bbGetInputDirectionInPoint()[2];
51                 bbGetInputTransform()->TransformPoint( pointDir,newPointDir );
52                 std::vector<double> outDir;
53                 outDir.push_back( newPointDir[0]-newPoint[0] );
54                 outDir.push_back( newPointDir[1]-newPoint[1] );
55                 outDir.push_back( newPointDir[2]-newPoint[2] );
56                 bbSetOutputOutDirection( outDir );
57         } else {
58                 printf("EED Warning!  ApplyTransformToPoint3D::Process  Incoherent sizes  Point(3)=%d  DirectionInPoint(3)=%d\n", bbGetInputPoint().size(),bbGetInputDirectionInPoint().size() );
59         }// if Point size
60 }
61
62 //===== 
63 // 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)
64 //===== 
65 void ApplyTransformToPoint3D::bbUserSetDefaultValues()
66 {
67 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
68 //    Here we initialize the input 'In' to 0
69
70    std::vector<double> point;
71    point.push_back(0);
72    point.push_back(0);
73    point.push_back(0);
74    bbSetInputPoint( point ); 
75    std::vector<double> dir;
76    dir.push_back(0);
77    dir.push_back(0);
78    dir.push_back(1);
79    bbSetInputDirectionInPoint( dir ); 
80    bbSetInputTransform(NULL); 
81 }
82
83 //===== 
84 // 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)
85 //===== 
86 void ApplyTransformToPoint3D::bbUserInitializeProcessing()
87 {
88 //  THE INITIALIZATION METHOD BODY :
89 //    Here does nothing 
90 //    but this is where you should allocate the internal/output pointers 
91 //    if any 
92 }
93
94 //===== 
95 // 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)
96 //===== 
97 void ApplyTransformToPoint3D::bbUserFinalizeProcessing()
98 {
99 //  THE FINALIZATION METHOD BODY :
100 //    Here does nothing 
101 //    but this is where you should desallocate the internal/output pointers 
102 //    if any 
103 }
104
105 } // EO namespace bbcreaVtk
106
107