]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkPlaneWidget.cxx
1698e7115dcce0b5b9404034545e8c4b01843a87
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkPlaneWidget.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 "bbcreaVtkPlaneWidget.h"
5 #include "bbcreaVtkPackage.h"
6 namespace bbcreaVtk
7 {
8
9
10
11 void boxcreaVtkPlaneWidget::Execute()  // virutal
12 {
13     std::vector<double> center = _box->_boxcreavtkplanewidget.GetCenter();
14     std::vector<double> normal = _box->_boxcreavtkplanewidget.GetNormal();
15     double  delta   = 0.00000001;
16     bool    ok      = false;
17     
18     // 0 Center and Normal change
19     // 1 Center change
20     // 2 Normal change
21     if ( (_ReactiveType==0) ||  (_ReactiveType==1) )
22     {
23         if (abs(_cxBack-center[0])>delta ) ok=true;
24         if (abs(_cyBack-center[1])>delta ) ok=true;
25         if (abs(_czBack-center[2])>delta ) ok=true;
26     }// if ReacitivityType 1 3
27     if ( (_ReactiveType==0) ||  (_ReactiveType==2) )
28     {
29         if (abs(_nxBack-normal[0])>delta ) ok=true;
30         if (abs(_nyBack-normal[1])>delta ) ok=true;
31         if (abs(_nzBack-normal[2])>delta ) ok=true;
32     }// if ReacitivityType 2 3
33
34     if ( ok==true )
35     {
36         _cxBack = center[0];
37         _cyBack = center[1];
38         _czBack = center[2];
39         _nxBack = normal[0];
40         _nyBack = normal[1];
41         _nzBack = normal[2];
42         _box->bbSetOutputOut( _box->_boxcreavtkplanewidget.GetPlaneSource()->GetOutput()  );
43         _box->bbSetOutputCenter( center );
44         _box->bbSetOutputNormal( normal );
45 //EED 2022-01-08
46 //       _box->bbSignalOutputModification(std::string("Out"));
47 //       _box->bbSignalOutputModification(std::string("Center"));
48 //       _box->bbSignalOutputModification(std::string("Normal"));
49         _box->bbSignalOutputModification();
50
51     }
52 }
53
54 //----------------------------------------------------------------------------------------------
55 //----------------------------------------------------------------------------------------------
56 //----------------------------------------------------------------------------------------------
57 //----------------------------------------------------------------------------------------------
58
59 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,PlaneWidget)
60 BBTK_BLACK_BOX_IMPLEMENTATION(PlaneWidget,bbtk::AtomicBlackBox);
61 //===== 
62 // 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)
63 //===== 
64 void PlaneWidget::Process()
65 {
66 // THE MAIN PROCESSING METHOD BODY
67 //   Here we simply set the input 'In' value to the output 'Out'
68 //   And print out the output value
69 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
70 //    void bbSet{Input|Output}NAME(const TYPE&)
71 //    const TYPE& bbGet{Input|Output}NAME() const 
72 //    Where :
73 //    * NAME is the name of the input/output
74 //      (the one provided in the attribute 'name' of the tag 'input')
75 //    * TYPE is the C++ type of the input/output
76 //      (the one provided in the attribute 'type' of the tag 'input')
77     printf("EED PlaneWidget::Process 1 \n");
78         if ((bbGetInputIn()==NULL) || (bbGetInputRenderer()==NULL))
79         {
80         printf("EED PlaneWidget::Process 2 \n");
81                 bbSetOutputOut( NULL );
82                 std::vector<double> center;
83                 std::vector<double> normal;
84                 bbSetOutputCenter( center );
85                 bbSetOutputNormal( normal );
86         } else {
87         if (bbGetInputOrigin().size()==3) printf("EED PlaneWidget::Process 3  Origin  %f, %f, %f \n",  bbGetInputOrigin()[0], bbGetInputOrigin()[1], bbGetInputOrigin()[2] );
88         else printf("EED PlaneWidget::Process 3  Origin -1 \n" );
89                 _boxcreavtkplanewidget.SetActive( bbGetInputActive() );
90                 _boxcreavtkplanewidget.SetImage( bbGetInputIn() );
91                 _boxcreavtkplanewidget.SetResolution( bbGetInputResolution() );
92                 _boxcreavtkplanewidget.SetRenderer( bbGetInputRenderer() );
93                 _boxcreavtkplanewidget.SetRepresentation( bbGetInputRepresentation() );
94                 _boxcreavtkplanewidget.SetOrigin( bbGetInputOrigin() );
95         _boxcreavtkplanewidget.SetNormalIn( bbGetInputNormalIn() );
96         _boxcreavtkplanewidget._ReactiveType=bbGetInputReactiveType();
97                 _boxcreavtkplanewidget.Process();
98                 
99                 bbSetOutputOut( _boxcreavtkplanewidget.GetPlaneSource()->GetOutput() );
100                 bbSetOutputCenter( _boxcreavtkplanewidget.GetCenter() );
101                 bbSetOutputNormal( _boxcreavtkplanewidget.GetNormal() );
102         bbSetOutputBase( &_boxcreavtkplanewidget );
103         int sizeN = bbGetInputOrigin().size();
104         int sizeC = _boxcreavtkplanewidget.GetCenter().size();
105         if (sizeN==3)
106         {
107             double nx = bbGetInputOrigin()[0];
108             double ny = bbGetInputOrigin()[1];
109             double nz = bbGetInputOrigin()[2];
110         } // if sizeN
111         if (sizeC==3)
112         {
113             double cx =_boxcreavtkplanewidget.GetCenter()[0];
114             double cy =_boxcreavtkplanewidget.GetCenter()[1];
115             double cz =_boxcreavtkplanewidget.GetCenter()[2];
116         } // if sizeC
117         } // If In Renderer
118 }
119
120 //===== 
121 // 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)
122 //===== 
123 void PlaneWidget::bbUserSetDefaultValues()
124 {
125 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
126 //    Here we initialize the input 'In' to 0
127     _boxcreavtkplanewidget._box            = this;
128     _boxcreavtkplanewidget._cxBack         = -10000000;
129     _boxcreavtkplanewidget._cyBack         = -10000000;
130     _boxcreavtkplanewidget._czBack         = -10000000;
131     _boxcreavtkplanewidget._ReactiveType   = 0;
132     
133     bbSetInputActive(false);
134     bbSetInputIn(NULL);
135     bbSetInputResolution(60);
136     bbSetInputRepresentation(1);
137     bbSetInputRenderer(NULL);
138     bbSetInputReactiveType( _boxcreavtkplanewidget._ReactiveType );
139     bbSetOutputOut(NULL);
140     bbSetOutputBase(NULL);
141 }
142
143 //===== 
144 // 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)
145 //===== 
146 void PlaneWidget::bbUserInitializeProcessing()
147 {
148 //  THE INITIALIZATION METHOD BODY :
149 //    Here does nothing 
150 //    but this is where you should allocate the internal/output pointers 
151 //    if any
152 }
153
154 //===== 
155 // 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)
156 //===== 
157 void PlaneWidget::bbUserFinalizeProcessing()
158 {
159 //  THE FINALIZATION METHOD BODY :
160 //    Here does nothing 
161 //    but this is where you should desallocate the internal/output pointers 
162 //    if any
163 }
164
165 } // EO namespace bbcreaVtk
166
167