]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbcreaMaracasVisuContourExtractDataBox.cxx
#3478 ContourExtractData
[creaMaracasVisu.git] / bbtk / src / bbcreaMaracasVisuContourExtractDataBox.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 "bbcreaMaracasVisuContourExtractDataBox.h"
5 #include "bbcreaMaracasVisuPackage.h"
6
7 #include "ContourExtractData.h"
8
9
10
11
12 namespace bbcreaMaracasVisu
13 {
14
15 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ContourExtractDataBox)
16 BBTK_BLACK_BOX_IMPLEMENTATION(ContourExtractDataBox,bbtk::AtomicBlackBox);
17 //===== 
18 // 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)
19 //===== 
20 void ContourExtractDataBox::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         ContourExtractData *contourextractdata = new ContourExtractData(true);
38         contourextractdata->SetImage( bbGetInputReferenceImage() );
39         if (bbGetInputRange().size()==2)
40         {
41             contourextractdata->SetScalarRange( bbGetInputRange()[0] , bbGetInputRange()[1] );
42         } // if Range
43     
44      //   _contourextractdata ->SetTypeOperation( typeContourGroup % 3 );
45         contourextractdata->InitVolumeStatistics();
46         std::vector<manualBaseModel*> lstManConMod;
47         lstManConMod.push_back( bbGetInputManualBaseModel() );
48         contourextractdata->SetLstManualContourModel( lstManConMod );
49
50         contourextractdata->ResetImageResult( bbGetInputZ() );
51     //    for ( z=minZ ; z<=maxZ ; z++ )
52     //    {
53             contourextractdata->SetZtoBeAnalys( bbGetInputZ() );
54             contourextractdata->CalculateImageResult();
55     //    } // for
56         
57         
58         std::vector<double> LstValue;
59         std::vector<double> LstValuePosX;
60         std::vector<double> LstValuePosY;
61         std::vector<double> LstValuePosZ;
62         int numberOfPixels=0;
63         LstValue.clear();
64         LstValuePosX.clear();
65         LstValuePosY.clear();
66         LstValuePosZ.clear();
67
68         contourextractdata->GetValuesInsideCrown(  &numberOfPixels,
69                                                     &LstValue,
70                                                     &LstValuePosX,
71                                                     &LstValuePosY,
72                                                     &LstValuePosZ);
73
74     //    int grayRangeMin;
75     //    int grayRangeMax;
76         
77         int        resultSize;
78         int        resultGrayRangeCount;
79         double    resultMin;
80         double    resultMax;
81         double    resultAverage;
82         double    resultStandarDeviation;
83
84     //    resultSize=numberOfPixels;
85     
86     if (bbGetInputRange().size()==2)
87     {
88         // Statistics of each slice.
89         contourextractdata->Statistics( &LstValue,
90                                        bbGetInputRange()[0],
91                                        bbGetInputRange()[1],
92                                        &resultGrayRangeCount,
93                                        &resultSize,
94                                        &resultMin,
95                                        &resultMax,
96                                        &resultAverage,
97                                        &resultStandarDeviation);
98         bbSetOutputResultGrayRangeCount( (double)resultGrayRangeCount );
99         bbSetOutputResultSize( (double)resultSize );
100         bbSetOutputResultMin( resultMin );
101         bbSetOutputResultMax( resultMax );
102         bbSetOutputResultAverage( resultAverage );
103         bbSetOutputResultStandarDeviation( resultStandarDeviation );
104     } // if Range
105     
106     vtkImageData *imageValues   = contourextractdata->GetVtkImageValueResult();
107     vtkImageData *imageMask     = contourextractdata->GetVtkImageMaskResult();
108     bbSetOutputValues( imageValues );
109     bbSetOutputMask( imageMask );
110     bbSetOutputNumberOfPixels( (double)numberOfPixels );
111     bbSetOutputLstValue( LstValue );
112     bbSetOutputLstValuePosX( LstValuePosX );
113     bbSetOutputLstValuePosX( LstValuePosY );
114     bbSetOutputLstValuePosX( LstValuePosZ );
115
116     //    int        vol_rCountRange;
117     //    int        vol_rsize;
118     //    double    vol_minValue;
119     //    double    vol_maxValue;
120     //    double    vol_average;
121     //    double    vol_standardeviation;
122
123     //        _contourextractdata->GetVolumeStatistics(&vol_rCountRange, &vol_rsize,
124     //                                                 &vol_minValue, &vol_maxValue,
125     //                                                 &vol_average, &vol_standardeviation);
126 }
127
128 //===== 
129 // 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)
130 //===== 
131 void ContourExtractDataBox::bbUserSetDefaultValues()
132 {
133 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
134 //    Here we initialize the input 'In' to 0
135     bbSetInputManualBaseModel(NULL);
136     bbSetInputReferenceImage(NULL);
137     bbSetInputZ(0);
138     std::vector<double> rangeMinMax;
139     rangeMinMax.push_back(-10000);
140     rangeMinMax.push_back(10000);
141     bbSetInputRange(rangeMinMax);
142     bbSetOutputMask(NULL);
143     bbSetOutputValues(NULL);
144     
145     bbSetOutputResultGrayRangeCount( -1 );
146     bbSetOutputResultSize( -1 );
147     bbSetOutputResultMin( -1 );
148     bbSetOutputResultMax( -1 );
149     bbSetOutputResultAverage( -1 );
150     bbSetOutputResultStandarDeviation( -1 );
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 ContourExtractDataBox::bbUserInitializeProcessing()
158 {
159 //  THE INITIALIZATION METHOD BODY :
160 //    Here does nothing 
161 //    but this is where you should allocate the internal/output pointers 
162 //    if any
163 }
164
165 //===== 
166 // 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)
167 //===== 
168 void ContourExtractDataBox::bbUserFinalizeProcessing()
169 {
170 //  THE FINALIZATION METHOD BODY :
171 //    Here does nothing 
172 //    but this is where you should desallocate the internal/output pointers 
173 //    if any
174 }
175
176 }// EO namespace bbcreaMaracasVisu
177
178