]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx
#3253 creaMaracasVisu Bug New Normal - manual paint refresh
[creaMaracasVisu.git] / bbtk / src / bbcreaMaracasVisuManualPaint_Model.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
5 #include "creaVtk_MACROS.h"
6 #include "bbcreaMaracasVisuManualPaint_Model.h"
7 #include "bbcreaMaracasVisuPackage.h"
8
9
10 namespace bbcreaMaracasVisu
11 {
12
13 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ManualPaint_Model)
14 BBTK_BLACK_BOX_IMPLEMENTATION(ManualPaint_Model,bbtk::AtomicBlackBox);
15 //===== 
16 // 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)
17 //===== 
18
19
20 void ManualPaint_Model::Process()
21 {
22
23 // THE MAIN PROCESSING METHOD BODY
24 //   Here we simply set the input 'In' value to the output 'Out'
25 //   And print out the output value
26 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
27 //    void bbSet{Input|Output}NAME(const TYPE&)
28 //    const TYPE& bbGet{Input|Output}NAME() const 
29 //    Where :
30 //    * NAME is the name of the input/output
31 //      (the one provided in the attribute 'name' of the tag 'input')
32 //    * TYPE is the C++ type of the input/output
33 //      (the one provided in the attribute 'type' of the tag 'input')
34 //    bbSetOutputOut( bbGetInputIn() );
35 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
36
37
38         if (bbGetInputImage()!=NULL)
39         {  
40
41                 manualpaintmodel->SetActive( bbGetInputActive() );
42                 manualpaintmodel->SetTool( bbGetInputTool() );
43                 manualpaintmodel->Set2D3D( bbGetInput2D3D() );
44                 manualpaintmodel->SetImages( bbGetInputImage(),bbGetInputImage2() );
45                 manualpaintmodel->SetGrayLevel( bbGetInputGrayLevel() );
46                 manualpaintmodel->SetDirection( bbGetInputDirection() );
47                 manualpaintmodel->SetBrushSize( bbGetInputBrushSize() );
48                 manualpaintmodel->SetBrushForm( bbGetInputBrushForm() );
49                 manualpaintmodel->SetToleranceFill( bbGetInputToleranceFill() );
50                 manualpaintmodel->SetDistanceFill( bbGetInputDistanceFill() );          
51                 manualpaintmodel->SetRangeMin( bbGetInputRange()[0] );
52                 manualpaintmodel->SetRangeMax( bbGetInputRange()[1] );
53
54                 if (bbGetInputPoint().size()==3)
55                 {
56                         manualpaintmodel->PaintImage( bbGetInputPoint()[0] , bbGetInputPoint()[1] , bbGetInputPoint()[2] );
57                 } // if Points
58
59
60
61                 if ( bbGetInputByLstPointsX().size()!=0 )
62                 {
63                         int i,size = bbGetInputByLstPointsX().size();
64                         for (i=0;i<size;i++)
65                         {
66                                 manualpaintmodel->PaintImage( bbGetInputByLstPointsX()[i] , bbGetInputByLstPointsY()[i] , bbGetInputByLstPointsZ()[i] );
67                         } // for
68                 }// if ByLstPointsX
69                 
70                 if (bbGetInputByImagePoints()!=NULL)
71                 {
72 //                      int ia,ja,ka;
73 //                      int ii,jj,kk;
74                         int ext[6];
75 //EED 2017-01-01 Migration VTK7
76 #if VTK_MAJOR_VERSION <= 5
77                         bbGetInputByImagePoints()->GetWholeExtent(ext);
78 #else
79                         bbGetInputByImagePoints()->GetExtent(ext);
80 #endif
81
82                         int dimX=ext[1]-ext[0]+1;
83                         int dimY=ext[3]-ext[2]+1;
84                         int dimZ=ext[5]-ext[4]+1;
85
86                         DEF_POINTER_IMAGE_VTK_CREA(vBIP,sSBIP,pBIP,sTBIP,bbGetInputByImagePoints());
87                         DEF_POINTER_IMAGE_VTK_CREA(vI2,sSI2,pI2,sTI2,bbGetInputImage2());
88
89 //#pragma omp parallel for
90
91                         int i,j,k;
92                         for (k=0;k<dimZ;k++) 
93                         {
94                                 if (k%50==0)
95                                 {
96                                         printf("ManualPaint_Model %d%\n", (int)(k*100.0/dimZ) );
97                                 }
98                                 for (j=0;j<dimY;j++) 
99                                 {
100                                         for (i=0;i<dimX;i++) 
101                                         {
102                                                 GETVALUE_VTK_CREA(vBIP,pBIP,sTBIP)
103                                                 if (vBIP>0)
104                                                 {
105                                                         GETVALUE_VTK_CREA(vI2,pI2,sTI2)
106                                                         if (vI2==0)
107                                                         {
108                                                                 manualpaintmodel->PaintImage(i,j,k);
109                                                         } // vI2                
110                                                 } // vBIP 
111                                                 pBIP = pBIP + sSBIP;                            
112                                                 pI2  = pI2  + sSI2;                             
113                                         }// for i
114                                 }// for j
115                         }// for k
116
117                         printf("ManualPaint_Model %d%\n", 100 );
118                 } // if ByImagePoints
119
120
121
122          } else {
123                 printf("EED Warning: Image not set. Box creaMaracasVisu::ManualPaint_Model (BBTK) \n");
124         } // if bbGetInputImage()
125
126
127         if (bbGetInputImage2()!=NULL)
128         { 
129                 bbSetOutputOut( bbGetInputImage2() );
130         } else if (bbGetInputImage()!=NULL) { 
131                 bbSetOutputOut( bbGetInputImage() );
132         } else { 
133                 bbSetOutputOut( NULL );
134         } 
135
136 }
137 //===== 
138 // 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)
139 //===== 
140 void ManualPaint_Model::bbUserSetDefaultValues()
141 {
142
143 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
144 //    Here we initialize the input 'In' to 0
145
146         bbSetInputActive(true);
147         bbSetInputTool(1);  // Paint
148         bbSetInput2D3D(1);  // 3D
149         bbSetInputImage(NULL);
150         bbSetInputImage2(NULL);
151         bbSetInputGrayLevel(100);
152         bbSetInputDirection(2); // XY
153         bbSetInputBrushSize(3);
154         bbSetInputBrushForm(1); // sphere
155         bbSetInputToleranceFill(50);
156         bbSetInputDistanceFill(25);
157
158         std::vector<int> point;
159         point.push_back(0);
160         point.push_back(0);
161         point.push_back(0);
162         bbSetInputPoint(point);
163
164         std::vector<double> range;
165         range.push_back(0);
166         range.push_back(200);
167         bbSetInputRange(range);
168
169         bbSetInputByImagePoints(NULL);
170   
171 }
172 //===== 
173 // 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)
174 //===== 
175 void ManualPaint_Model::bbUserInitializeProcessing()
176 {
177
178 //  THE INITIALIZATION METHOD BODY :
179 //    Here does nothing 
180 //    but this is where you should allocate the internal/output pointers 
181 //    if any 
182
183         manualpaintmodel=new ManualPaintModel();
184
185   
186 }
187 //===== 
188 // 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)
189 //===== 
190 void ManualPaint_Model::bbUserFinalizeProcessing()
191 {
192
193 //  THE FINALIZATION METHOD BODY :
194 //    Here does nothing 
195 //    but this is where you should desallocate the internal/output pointers 
196 //    if any
197         delete manualpaintmodel;
198   
199 }
200
201 }
202 // EO namespace bbcreaMaracasVisu
203
204