]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx
#3171 creaMaracasVisu Feature New Normal - creaVTK_MACROS
[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         if (bbGetInputImage()!=NULL)
38         {  
39                 manualpaintmodel->SetActive( bbGetInputActive() );
40                 manualpaintmodel->SetTool( bbGetInputTool() );
41                 manualpaintmodel->Set2D3D( bbGetInput2D3D() );
42                 manualpaintmodel->SetImages( bbGetInputImage(),bbGetInputImage2() );
43                 manualpaintmodel->SetGrayLevel( bbGetInputGrayLevel() );
44                 manualpaintmodel->SetDirection( bbGetInputDirection() );
45                 manualpaintmodel->SetBrushSize( bbGetInputBrushSize() );
46                 manualpaintmodel->SetBrushForm( bbGetInputBrushForm() );
47                 manualpaintmodel->SetToleranceFill( bbGetInputToleranceFill() );
48                 manualpaintmodel->SetDistanceFill( bbGetInputDistanceFill() );          
49                 manualpaintmodel->SetRangeMin( bbGetInputRange()[0] );
50                 manualpaintmodel->SetRangeMax( bbGetInputRange()[1] );
51                 if (bbGetInputPoint().size()==3)
52                 {
53                         manualpaintmodel->PaintImage( bbGetInputPoint()[0] , bbGetInputPoint()[1] , bbGetInputPoint()[2] );
54                 } // if Points
55
56                 if ( bbGetInputByLstPointsX().size()!=0 )
57                 {
58                         int i,size = bbGetInputByLstPointsX().size();
59                         for (i=0;i<size;i++)
60                         {
61                                 manualpaintmodel->PaintImage( bbGetInputByLstPointsX()[i] , bbGetInputByLstPointsY()[i] , bbGetInputByLstPointsZ()[i] );
62                         } // for
63                 }// if ByLstPointsX
64                 
65                 if (bbGetInputByImagePoints()!=NULL)
66                 {
67 //                      int ia,ja,ka;
68 //                      int ii,jj,kk;
69                         int ext[6];
70                         bbGetInputByImagePoints()->GetWholeExtent(ext);
71                         int dimX=ext[1]-ext[0]+1;
72                         int dimY=ext[3]-ext[2]+1;
73                         int dimZ=ext[5]-ext[4]+1;
74
75                         DEF_POINTER_IMAGE_VTK_CREA(vBIP,sSBIP,pBIP,sTBIP,bbGetInputByImagePoints());
76                         DEF_POINTER_IMAGE_VTK_CREA(vI2,sSI2,pI2,sTI2,bbGetInputImage2());
77
78 //#pragma omp parallel for
79
80                         int i,j,k;
81                         for (k=0;k<dimZ;k++) 
82                         {
83                                 if (k%50==0)
84                                 {
85                                         printf("ManualPaint_Model %d%\n", (int)(k*100.0/dimZ) );
86                                 }
87                                 for (j=0;j<dimY;j++) 
88                                 {
89                                         for (i=0;i<dimX;i++) 
90                                         {
91                                                 GETVALUE_VTK_CREA(vBIP,pBIP,sTBIP)
92                                                 if (vBIP>0)
93                                                 {
94                                                         GETVALUE_VTK_CREA(vI2,pI2,sTI2)
95                                                         if (vI2==0)
96                                                         {
97                                                                 manualpaintmodel->PaintImage(i,j,k);
98                                                         } // vI2                
99                                                 } // vBIP 
100                                                 pBIP = pBIP + sSBIP;                            
101                                                 pI2  = pI2  + sSI2;                             
102                                         }// for i
103                                 }// for j
104                         }// for k
105
106                         printf("ManualPaint_Model %d%\n", 100 );
107                 } // if ByImagePoints
108          } else {
109                 printf("EED Warning: Image not set. Box creaMaracasVisu::ManualPaint_Model (BBTK) \n");
110         } // if 
111
112         if (bbGetInputImage2()!=NULL)
113         { 
114                 bbSetOutputOut( bbGetInputImage2() );
115         } else if (bbGetInputImage()!=NULL) { 
116                 bbSetOutputOut( bbGetInputImage() );
117         } else { 
118                 bbSetOutputOut( NULL );
119         } 
120 }
121 //===== 
122 // 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)
123 //===== 
124 void ManualPaint_Model::bbUserSetDefaultValues()
125 {
126
127 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
128 //    Here we initialize the input 'In' to 0
129
130         bbSetInputActive(true);
131         bbSetInputTool(1);  // Paint
132         bbSetInput2D3D(1);  // 3D
133         bbSetInputImage(NULL);
134         bbSetInputImage2(NULL);
135         bbSetInputGrayLevel(100);
136         bbSetInputDirection(2); // XY
137         bbSetInputBrushSize(3);
138         bbSetInputBrushForm(1); // sphere
139         bbSetInputToleranceFill(50);
140         bbSetInputDistanceFill(25);
141
142         std::vector<int> point;
143         point.push_back(0);
144         point.push_back(0);
145         point.push_back(0);
146         bbSetInputPoint(point);
147
148         std::vector<double> range;
149         range.push_back(0);
150         range.push_back(200);
151         bbSetInputRange(range);
152
153         bbSetInputByImagePoints(NULL);
154   
155 }
156 //===== 
157 // 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)
158 //===== 
159 void ManualPaint_Model::bbUserInitializeProcessing()
160 {
161
162 //  THE INITIALIZATION METHOD BODY :
163 //    Here does nothing 
164 //    but this is where you should allocate the internal/output pointers 
165 //    if any 
166
167         manualpaintmodel=new ManualPaintModel();
168
169   
170 }
171 //===== 
172 // 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)
173 //===== 
174 void ManualPaint_Model::bbUserFinalizeProcessing()
175 {
176
177 //  THE FINALIZATION METHOD BODY :
178 //    Here does nothing 
179 //    but this is where you should desallocate the internal/output pointers 
180 //    if any
181         delete manualpaintmodel;
182   
183 }
184
185 }
186 // EO namespace bbcreaMaracasVisu
187
188