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