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