]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkPlaneWidget.cxx
#3478 PointPickerNearest
[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         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         int sizeN=bbGetInputOrigin().size();
99         int sizeC=_boxcreavtkplanewidget.GetCenter().size();
100         printf("EED PlaneWidget::Process OriginIn.size=%d     CenterOut.size=%d \n", sizeN, sizeC);
101         if (sizeN==3) 
102         {
103             double nx = bbGetInputOrigin()[0];
104             double ny = bbGetInputOrigin()[1];
105             double nz = bbGetInputOrigin()[2];
106             printf("EED PlaneWidget::Process OriginIn=%f %f %f  \n", nx,ny,nz);
107         }
108         if (sizeC==3)
109         {
110             double cx =_boxcreavtkplanewidget.GetCenter()[0];
111             double cy =_boxcreavtkplanewidget.GetCenter()[1];
112             double cz =_boxcreavtkplanewidget.GetCenter()[2];
113             printf("EED PlaneWidget::Process CenterOut=%f %f %f \n", cx,cy,cz);
114         }
115         }
116 }
117
118 //===== 
119 // 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)
120 //===== 
121 void PlaneWidget::bbUserSetDefaultValues()
122 {
123 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
124 //    Here we initialize the input 'In' to 0
125     _boxcreavtkplanewidget._box            = this;
126     _boxcreavtkplanewidget._cxBack         = -10000000;
127     _boxcreavtkplanewidget._cyBack         = -10000000;
128     _boxcreavtkplanewidget._czBack         = -10000000;
129     _boxcreavtkplanewidget._ReactiveType   = 0;
130     
131     bbSetInputActive(false);
132     bbSetInputIn(NULL);
133     bbSetInputResolution(60);
134     bbSetInputRepresentation(1);
135     bbSetInputRenderer(NULL);
136     bbSetInputReactiveType( _boxcreavtkplanewidget._ReactiveType );
137     bbSetOutputOut(NULL);
138 }
139
140 //===== 
141 // 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)
142 //===== 
143 void PlaneWidget::bbUserInitializeProcessing()
144 {
145 //  THE INITIALIZATION METHOD BODY :
146 //    Here does nothing 
147 //    but this is where you should allocate the internal/output pointers 
148 //    if any
149 }
150
151 //===== 
152 // 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)
153 //===== 
154 void PlaneWidget::bbUserFinalizeProcessing()
155 {
156 //  THE FINALIZATION METHOD BODY :
157 //    Here does nothing 
158 //    but this is where you should desallocate the internal/output pointers 
159 //    if any
160 }
161
162 } // EO namespace bbcreaVtk
163
164