]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkApplyTransformToPoint3D.cxx
ae0477251888541add8eb0eb6613bbd5c5e7adc8
[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         printf("EED ApplyTransformToPoint3D::Process Start\n ");
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         printf("EED ApplyTransformToPoint3D::Process End\n ");
63   
64 }
65
66 //===== 
67 // 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)
68 //===== 
69 void ApplyTransformToPoint3D::bbUserSetDefaultValues()
70 {
71 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
72 //    Here we initialize the input 'In' to 0
73
74    std::vector<double> point;
75    point.push_back(0);
76    point.push_back(0);
77    point.push_back(0);
78    bbSetInputPoint( point ); 
79    std::vector<double> dir;
80    dir.push_back(0);
81    dir.push_back(0);
82    dir.push_back(1);
83    bbSetInputDirectionInPoint( dir ); 
84    bbSetInputTransform(NULL); 
85 }
86
87 //===== 
88 // 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)
89 //===== 
90 void ApplyTransformToPoint3D::bbUserInitializeProcessing()
91 {
92 //  THE INITIALIZATION METHOD BODY :
93 //    Here does nothing 
94 //    but this is where you should allocate the internal/output pointers 
95 //    if any 
96 }
97
98 //===== 
99 // 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)
100 //===== 
101 void ApplyTransformToPoint3D::bbUserFinalizeProcessing()
102 {
103 //  THE FINALIZATION METHOD BODY :
104 //    Here does nothing 
105 //    but this is where you should desallocate the internal/output pointers 
106 //    if any 
107 }
108
109 } // EO namespace bbcreaVtk
110
111