]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx
5ff2df72310c391dd2a8ea588ca2ab52a9f8b676
[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                         manualpaintmodel->SetUndoImage();
55                 } // if Points
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 //                      _manualPaintModel->SetUndoImage();     // Probably needed.   Here is ok.
63                         } // for
64                 }// if ByLstPointsX
65                 if ((bbGetInputByImagePoints()!=NULL) && (bbGetInputImage2()!=NULL) )
66                 {
67 //                      int ia,ja,ka;
68 //                      int ii,jj,kk;
69                         int ext[6];
70 //EED 2017-01-01 Migration VTK7
71 #if VTK_MAJOR_VERSION <= 5
72                         bbGetInputByImagePoints()->GetWholeExtent(ext);
73 #else
74                         bbGetInputByImagePoints()->GetExtent(ext);
75 #endif
76                         int dimX=ext[1]-ext[0]+1;
77                         int dimY=ext[3]-ext[2]+1;
78                         int dimZ=ext[5]-ext[4]+1;
79                         DEF_POINTER_IMAGE_VTK_CREA(vBIP,sSBIP,pBIP,sTBIP,bbGetInputByImagePoints());
80                         DEF_POINTER_IMAGE_VTK_CREA(vI2,sSI2,pI2,sTI2,bbGetInputImage2());
81 //#pragma omp parallel for
82                         int i,j,k;
83                         for (k=0;k<dimZ;k++) 
84                         {
85                                 if (k%50==0)
86                                 {
87                                         printf("ManualPaint_Model %d%\n", (int)(k*100.0/dimZ) );
88                                 }
89                                 for (j=0;j<dimY;j++) 
90                                 {
91                                         for (i=0;i<dimX;i++) 
92                                         {
93                                                 GETVALUE_VTK_CREA(vBIP,pBIP,sTBIP)
94                                                 if (vBIP>0)
95                                                 {
96                                                         GETVALUE_VTK_CREA(vI2,pI2,sTI2)
97                                                         if (vI2==0)
98                                                         {
99                                                                 manualpaintmodel->PaintImage(i,j,k);
100 //                                                              manualpaintmodel->SetUndoImage();     // Probably needed.   Here is ok.
101                                                         } // vI2                
102                                                 } // vBIP 
103                                                 pBIP = pBIP + sSBIP;                            
104                                                 pI2  = pI2  + sSI2;                             
105                                         }// for i
106                                 }// for j
107                         }// for k
108                         printf("ManualPaint_Model %d%\n", 100 );
109                 } // if ByImagePoints
110          } else {
111                 printf("EED Warning: ByImagePoints or Image2 not set.  Box creaMaracasVisu::ManualPaint_Model (BBTK) \n");
112         } // if ((bbGetInputByImagePoints()!=NULL) && (bbGetInputImage2()!=NULL) )
113
114         if (bbGetInputImage2()!=NULL)
115         { 
116                 bbSetOutputOut( bbGetInputImage2() );
117         } else if (bbGetInputImage()!=NULL) { 
118                 bbSetOutputOut( bbGetInputImage() );
119         } else { 
120                 bbSetOutputOut( NULL );
121         } 
122         bbSetOutputManualpaintmodel( manualpaintmodel );
123 }
124 //===== 
125 // 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)
126 //===== 
127 void ManualPaint_Model::bbUserSetDefaultValues()
128 {
129
130 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
131 //    Here we initialize the input 'In' to 0
132
133         bbSetInputActive(true);
134         bbSetInputTool(1);              // Paint
135         bbSetInput2D3D(1);              // 3D
136         bbSetInputImage(NULL);
137         bbSetInputImage2(NULL);
138         bbSetInputGrayLevel(100);
139         bbSetInputDirection(2);         // XY
140         bbSetInputBrushSize(3);
141         bbSetInputBrushForm(1);         // sphere
142         bbSetInputToleranceFill(50);
143         bbSetInputDistanceFill(25);
144         std::vector<int> point;
145         point.push_back(0);
146         point.push_back(0);
147         point.push_back(0);
148         bbSetInputPoint(point);
149         std::vector<double> range;
150         range.push_back(0);
151         range.push_back(200);
152         bbSetInputRange(range);
153         bbSetInputByImagePoints(NULL);
154 }
155 //===== 
156 // 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)
157 //===== 
158 void ManualPaint_Model::bbUserInitializeProcessing()
159 {
160
161 //  THE INITIALIZATION METHOD BODY :
162 //    Here does nothing 
163 //    but this is where you should allocate the internal/output pointers 
164 //    if any 
165
166         manualpaintmodel=new ManualPaintModel();
167
168   
169 }
170 //===== 
171 // 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)
172 //===== 
173 void ManualPaint_Model::bbUserFinalizeProcessing()
174 {
175
176 //  THE FINALIZATION METHOD BODY :
177 //    Here does nothing 
178 //    but this is where you should desallocate the internal/output pointers 
179 //    if any
180         delete manualpaintmodel;
181   
182 }
183
184 }
185 // EO namespace bbcreaMaracasVisu
186
187