]> Creatis software - bbtk.git/blob - packages/vtk/src/bbvtkImageVtkProperties.cxx
aac617bf0f529a487d787cbdbb558e66d2c3f822
[bbtk.git] / packages / vtk / src / bbvtkImageVtkProperties.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 "bbvtkImageVtkProperties.h"
5 #include "bbvtkPackage.h"
6 namespace bbvtk
7 {
8
9 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,ImageVtkProperties)
10 BBTK_BLACK_BOX_IMPLEMENTATION(ImageVtkProperties,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 ImageVtkProperties::Process()
15 {
16         unsigned int dim;
17         int ext[6];
18         double spc[3];
19         double range[2];
20         std::string nametype;
21         int numberoOfComponents;
22         std::vector<int> vsize;
23         std::vector<float> vspacing;
24         std::vector<float> vrange;
25
26         if ( bbGetInputIn() ){
27                 bbGetInputIn()->Update();
28                 
29                 bbGetInputIn()->GetWholeExtent(ext);
30                 vsize.push_back(ext[1]-ext[0]+1);
31                 vsize.push_back(ext[3]-ext[2]+1);
32                 vsize.push_back(ext[5]-ext[4]+1);
33                 
34                 dim = 0;
35                 if (vsize[0]>1) dim++;
36                 if (vsize[1]>1) dim++;
37                 if (vsize[2]>1) dim++;
38                 
39                 bbGetInputIn()->GetScalarRange(range);
40                 numberoOfComponents=bbGetInputIn()->GetNumberOfScalarComponents();
41         
42                 bbGetInputIn()->GetSpacing(spc);
43                 for (unsigned int i=0;i<dim;++i) 
44                         vspacing.push_back((float)spc[i]);
45
46                 vrange.push_back((float)range[0]);
47                 vrange.push_back((float)range[1]);
48         
49                 if (bbGetInputIn()->GetScalarType()==VTK_BIT)                           nametype="VTK_BIT";
50                 if (bbGetInputIn()->GetScalarType()==VTK_CHAR)                          nametype="VTK_CHAR";
51                 if (bbGetInputIn()->GetScalarType()==VTK_SIGNED_CHAR)           nametype="VTK_SIGNED_CHAR";
52                 if (bbGetInputIn()->GetScalarType()==VTK_UNSIGNED_CHAR)         nametype="VTK_UNSIGNED_CHAR";
53                 if (bbGetInputIn()->GetScalarType()==VTK_UNSIGNED_SHORT)        nametype="VTK_UNSIGNED_SHORT";
54                 if (bbGetInputIn()->GetScalarType()==VTK_UNSIGNED_INT)          nametype="VTK_UNSIGNED_INT";
55                 if (bbGetInputIn()->GetScalarType()==VTK_LONG)                          nametype="VTK_LONG";
56                 if (bbGetInputIn()->GetScalarType()==VTK_UNSIGNED_LONG)         nametype="VTK_UNSIGNED_LONG";
57                 if (bbGetInputIn()->GetScalarType()==VTK_FLOAT)                         nametype="VTK_FLOAT";
58                 if (bbGetInputIn()->GetScalarType()==VTK_DOUBLE)                        nametype="VTK_DOUBLE";
59         } else {        
60                 dim                                     = 0;            
61                 numberoOfComponents     = 0;
62                 vsize.push_back(0);
63                 vsize.push_back(0);
64                 vsize.push_back(0);
65                 vspacing.push_back(0);
66                 vspacing.push_back(0);
67                 vspacing.push_back(0);
68                 vrange.push_back(0);
69                 vrange.push_back(0);
70                 nametype                        = "VOID";                               
71         }       
72         bbSetOutputDimension( dim );
73         bbSetOutputSize( vsize );
74         bbSetOutputSpacing( vspacing );
75         bbSetOutputMinMax( vrange );
76         bbSetOutputTypeName( nametype );
77         bbSetOutputComponents( numberoOfComponents );
78         
79 }
80 //===== 
81 // 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)
82 //===== 
83 void ImageVtkProperties::bbUserSetDefaultValues()
84 {
85
86 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
87 //    Here we initialize the input 'In' to 0
88 //   bbSetInputIn(0);
89   
90 }
91 //===== 
92 // 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)
93 //===== 
94 void ImageVtkProperties::bbUserInitializeProcessing()
95 {
96
97 //  THE INITIALIZATION METHOD BODY :
98 //    Here does nothing 
99 //    but this is where you should allocate the internal/output pointers 
100 //    if any 
101
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 ImageVtkProperties::bbUserFinalizeProcessing()
108 {
109
110 //  THE FINALIZATION METHOD BODY :
111 //    Here does nothing 
112 //    but this is where you should desallocate the internal/output pointers 
113 //    if any
114   
115 }
116 }
117 // EO namespace bbvtk
118
119