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