]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkPlaneSource.cxx
#3466 ApplyTransformToPoint3D box
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkPlaneSource.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 "bbcreaVtkPlaneSource.h"
5 #include "bbcreaVtkPackage.h"
6 #include "vtkPlaneSource.h"
7 #include "vtkDataSet.h"
8 #include "iostream" 
9 namespace bbcreaVtk
10 {
11
12 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,PlaneSource)
13 BBTK_BLACK_BOX_IMPLEMENTATION(PlaneSource,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 PlaneSource::Process()
18 {
19         double c[3];
20         double p0[3];
21     double p1[3];
22         double p2[3];
23         vtkPlaneSource *plane;
24         plane   =       vtkPlaneSource::New();
25         c[0]    =       bbGetInputCenter()[0];
26         c[1]    =       bbGetInputCenter()[1];
27         c[2]    =       bbGetInputCenter()[2];
28         p0[0]   =       0;      
29         p0[1]   =       0;
30         p0[2]   =       0;
31
32
33         bool byNormal=true;     
34         double size=350;
35
36         // xy
37         if ((bbGetInputNormal()[0]==0) && (bbGetInputNormal()[1]==0) && (bbGetInputNormal()[2]==1)  ) 
38         {
39                 byNormal=       false;
40                 p1[0]   =       size;   
41                 p1[1]   =       0;
42                 p1[2]   =       0;    
43                 p2[0]   =       0;
44                 p2[1]   =       size;
45                 p2[2]   =       0;
46         }
47         
48         // xz
49         if ((bbGetInputNormal()[0]==0) && (bbGetInputNormal()[1]==1) && (bbGetInputNormal()[2]==0)  ) 
50         {
51                 byNormal=       false;
52                 p1[0]   =       size;   
53                 p1[1]   =       0;
54                 p1[2]   =       0;    
55                 p2[0]   =       0;
56                 p2[1]   =       0;
57                 p2[2]   =       size;
58         }
59
60         // yz
61         if ((bbGetInputNormal()[0]==1) && (bbGetInputNormal()[1]==0) && (bbGetInputNormal()[2]==0)  ) 
62         {
63                 byNormal=       false;
64                 p1[0]   =       0;      
65                 p1[1]   =       size;
66                 p1[2]   =       0;    
67                 p2[0]   =       0;
68                 p2[1]   =       0;
69                 p2[2]   =       size;
70         }
71
72                 plane->SetResolution( bbGetInputXResolution(), bbGetInputYResolution() );
73                 if (byNormal==false)
74                 {
75                         plane->SetOrigin( p0 );         
76                         plane->SetPoint1( p1 );
77                         plane->SetPoint2( p2 );
78                 } else {
79                         plane->SetNormal( bbGetInputNormal()[0], bbGetInputNormal()[1], bbGetInputNormal()[2] );
80                         printf("EED PlaneSource. Missing mechanism to define the size of the plane\n");
81                 }
82                         plane->SetCenter( c );
83
84                 plane->Update( );
85     bbSetOutputPlane( (vtkDataSet*)plane );
86     bbSetOutputPolyData( plane->GetOutput() );
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 PlaneSource::bbUserSetDefaultValues()
93 {
94    std::vector<double> c;
95    std::vector<double> n;
96         c.push_back(0);
97         c.push_back(0);
98         c.push_back(0);
99         n.push_back(1);
100         n.push_back(0);
101         n.push_back(0);
102    bbSetInputCenter(c);
103    bbSetInputNormal(n);
104    bbSetInputXResolution(100);
105    bbSetInputYResolution(100);
106 }
107 //===== 
108 // 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)
109 //===== 
110 void PlaneSource::bbUserInitializeProcessing()
111 {
112
113   
114 }
115 //===== 
116 // 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)
117 //===== 
118 void PlaneSource::bbUserFinalizeProcessing()
119 {
120
121   
122 }
123 }
124 // EO namespace bbcreaVtk
125
126