]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkPlaneWidget.cxx
d7ae9a41285c7fd28f9737dad30e530e19594762
[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     SetNormalIn( normal );
16     double  delta   = 0.00000001;
17     bool    ok      = false;
18     
19     // 0 Center and Normal change
20     // 1 Center change
21     // 2 Normal change
22     if ( (_ReactiveType==0) ||  (_ReactiveType==1) )
23     {
24         if (abs(_cxBack-center[0])>delta ) ok=true;
25         if (abs(_cyBack-center[1])>delta ) ok=true;
26         if (abs(_czBack-center[2])>delta ) ok=true;
27     }// if ReacitivityType 1 3
28     if ( (_ReactiveType==0) ||  (_ReactiveType==2) )
29     {
30         if (abs(_nxBack-normal[0])>delta ) ok=true;
31         if (abs(_nyBack-normal[1])>delta ) ok=true;
32         if (abs(_nzBack-normal[2])>delta ) ok=true;
33     }// if ReacitivityType 2 3
34
35     if ( ok==true )
36     {
37         _cxBack = center[0];
38         _cyBack = center[1];
39         _czBack = center[2];
40         _nxBack = normal[0];
41         _nyBack = normal[1];
42         _nzBack = normal[2];
43         _box->bbSetOutputOut( _box->_boxcreavtkplanewidget.GetPlaneSource()->GetOutput()  );
44         _box->bbSetOutputCenter( center );
45         _box->bbSetOutputNormal( normal );
46 //EED 2022-01-08
47 //       _box->bbSignalOutputModification(std::string("Out"));
48 //       _box->bbSignalOutputModification(std::string("Center"));
49 //       _box->bbSignalOutputModification(std::string("Normal"));
50         _box->bbSignalOutputModification();
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         if ((bbGetInputIn()==NULL) || (bbGetInputRenderer()==NULL))
78         {
79                 bbSetOutputOut( NULL );
80                 std::vector<double> center;
81                 std::vector<double> normal;
82                 bbSetOutputCenter( center );
83                 bbSetOutputNormal( normal );
84         } else {
85                 _boxcreavtkplanewidget.SetActive( bbGetInputActive() );
86                 _boxcreavtkplanewidget.SetImage( bbGetInputIn() );
87                 _boxcreavtkplanewidget.SetResolution( bbGetInputResolution() );
88                 _boxcreavtkplanewidget.SetRenderer( bbGetInputRenderer() );
89                 _boxcreavtkplanewidget.SetRepresentation( bbGetInputRepresentation() );
90                 _boxcreavtkplanewidget.SetOrigin( bbGetInputOrigin() );
91         _boxcreavtkplanewidget.SetNormalIn( bbGetInputNormalIn() );
92         _boxcreavtkplanewidget._ReactiveType=bbGetInputReactiveType();
93                 _boxcreavtkplanewidget.Process();
94                 
95                 bbSetOutputOut( _boxcreavtkplanewidget.GetPlaneSource()->GetOutput() );
96                 bbSetOutputCenter( _boxcreavtkplanewidget.GetCenter() );
97                 bbSetOutputNormal( _boxcreavtkplanewidget.GetNormal() );
98         bbSetOutputBase( &_boxcreavtkplanewidget );
99         int sizeN = bbGetInputOrigin().size();
100         int sizeC = _boxcreavtkplanewidget.GetCenter().size();
101         if (sizeN==3)
102         {
103             double nx = bbGetInputOrigin()[0];
104             double ny = bbGetInputOrigin()[1];
105             double nz = bbGetInputOrigin()[2];
106         } // if sizeN
107         if (sizeC==3)
108         {
109             double cx =_boxcreavtkplanewidget.GetCenter()[0];
110             double cy =_boxcreavtkplanewidget.GetCenter()[1];
111             double cz =_boxcreavtkplanewidget.GetCenter()[2];
112         } // if sizeC
113         } // If In Renderer
114 }
115
116 //===== 
117 // 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)
118 //===== 
119 void PlaneWidget::bbUserSetDefaultValues()
120 {
121 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
122 //    Here we initialize the input 'In' to 0
123     _boxcreavtkplanewidget._box            = this;
124     _boxcreavtkplanewidget._cxBack         = -10000000;
125     _boxcreavtkplanewidget._cyBack         = -10000000;
126     _boxcreavtkplanewidget._czBack         = -10000000;
127     _boxcreavtkplanewidget._ReactiveType   = 0;
128     
129     bbSetInputActive(false);
130     bbSetInputIn(NULL);
131     bbSetInputResolution(60);
132     bbSetInputRepresentation(1);
133     bbSetInputRenderer(NULL);
134     bbSetInputReactiveType( _boxcreavtkplanewidget._ReactiveType );
135     bbSetOutputOut(NULL);
136     bbSetOutputBase(NULL);
137 }
138
139 //===== 
140 // 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)
141 //===== 
142 void PlaneWidget::bbUserInitializeProcessing()
143 {
144 //  THE INITIALIZATION METHOD BODY :
145 //    Here does nothing 
146 //    but this is where you should allocate the internal/output pointers 
147 //    if any
148 }
149
150 //===== 
151 // 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)
152 //===== 
153 void PlaneWidget::bbUserFinalizeProcessing()
154 {
155 //  THE FINALIZATION METHOD BODY :
156 //    Here does nothing 
157 //    but this is where you should desallocate the internal/output pointers 
158 //    if any
159 }
160
161 } // EO namespace bbcreaVtk
162
163