]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbcreaMaracasVisuManualPaint_Model.cxx
#2976 creaMaracasVisu Feature New Normal - ManualContourModel_Box
[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                         bbGetInputByImagePoints()->GetWholeExtent(ext);
66                         int dimX=ext[1]-ext[0]+1;
67                         int dimY=ext[3]-ext[2]+1;
68                         int dimZ=ext[5]-ext[4]+1;
69                         for (i=0;i<dimX;i++) 
70                         {
71                                 if (i%20==0)
72                                 {
73                                         printf("ManualPaint_Model %d%\n", (int)(i*100.0/dimX) );
74                                 }
75                                 for (j=0;j<dimY;j++) 
76                                 {
77                                         for (k=0;k<dimZ;k++) 
78                                         {
79                                                 if ( bbGetInputByImagePoints()->GetScalarComponentAsDouble(i,j,k, 0)>0)
80                                                 {
81                                                         if (bbGetInputImage2()->GetScalarComponentAsDouble(i,j,k, 0)==0)
82                                                         {
83                                                                 manualpaintmodel->PaintImage(i,j,k);
84                                                         } // bbGetInputImage2           
85                                                 } // GetScalarComponentAsDouble                                         
86                                         }// for k
87                                 }// for j
88                         }// for i
89                         printf("ManualPaint_Model %d%\n", 100 );
90                 } // if ByImagePoints
91          } else {
92                 printf("EED Warning: Image not set. Box creaMaracasVisu::ManualPaint_Model (BBTK) \n");
93         } // if 
94
95         if (bbGetInputImage2()!=NULL)
96         { 
97                 bbSetOutputOut( bbGetInputImage2() );
98         } else if (bbGetInputImage()!=NULL) { 
99                 bbSetOutputOut( bbGetInputImage() );
100         } else { 
101                 bbSetOutputOut( NULL );
102         } 
103 }
104 //===== 
105 // 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)
106 //===== 
107 void ManualPaint_Model::bbUserSetDefaultValues()
108 {
109
110 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
111 //    Here we initialize the input 'In' to 0
112
113         bbSetInputActive(true);
114         bbSetInputTool(1);  // Paint
115         bbSetInput2D3D(1);  // 3D
116         bbSetInputImage(NULL);
117         bbSetInputImage2(NULL);
118         bbSetInputGrayLevel(100);
119         bbSetInputDirection(2); // XY
120         bbSetInputBrushSize(3);
121         bbSetInputBrushForm(1); // sphere
122         bbSetInputToleranceFill(50);
123         bbSetInputDistanceFill(25);
124
125         std::vector<int> point;
126         point.push_back(0);
127         point.push_back(0);
128         point.push_back(0);
129         bbSetInputPoint(point);
130
131         std::vector<double> range;
132         range.push_back(0);
133         range.push_back(200);
134         bbSetInputRange(range);
135
136         bbSetInputByImagePoints(NULL);
137   
138 }
139 //===== 
140 // 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)
141 //===== 
142 void ManualPaint_Model::bbUserInitializeProcessing()
143 {
144
145 //  THE INITIALIZATION METHOD BODY :
146 //    Here does nothing 
147 //    but this is where you should allocate the internal/output pointers 
148 //    if any 
149
150         manualpaintmodel=new ManualPaintModel();
151
152   
153 }
154 //===== 
155 // 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)
156 //===== 
157 void ManualPaint_Model::bbUserFinalizeProcessing()
158 {
159
160 //  THE FINALIZATION METHOD BODY :
161 //    Here does nothing 
162 //    but this is where you should desallocate the internal/output pointers 
163 //    if any
164         delete manualpaintmodel;
165   
166 }
167
168 }
169 // EO namespace bbcreaMaracasVisu
170
171