]> Creatis software - bbtk.git/blob - packages/vtk/src/bbvtkImageVtkProperties.cxx
#3515 Add ext to ImagaVtkProperties box
[bbtk.git] / packages / vtk / src / bbvtkImageVtkProperties.cxx
1 /*
2  # ---------------------------------------------------------------------
3  #
4  # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5  #                        pour la SantÈ)
6  # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7  # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8  # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9  #
10  #  This software is governed by the CeCILL-B license under French law and
11  #  abiding by the rules of distribution of free software. You can  use,
12  #  modify and/ or redistribute the software under the terms of the CeCILL-B
13  #  license as circulated by CEA, CNRS and INRIA at the following URL
14  #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15  #  or in the file LICENSE.txt.
16  #
17  #  As a counterpart to the access to the source code and  rights to copy,
18  #  modify and redistribute granted by the license, users are provided only
19  #  with a limited warranty  and the software's author,  the holder of the
20  #  economic rights,  and the successive licensors  have only  limited
21  #  liability.
22  #
23  #  The fact that you are presently reading this means that you have had
24  #  knowledge of the CeCILL-B license and that you accept its terms.
25  # ------------------------------------------------------------------------ */
26
27
28 //=====
29 // 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)
30 //===== 
31 #include "bbvtkImageVtkProperties.h"
32 #include "bbvtkPackage.h"
33 namespace bbvtk
34 {
35
36 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,ImageVtkProperties)
37 BBTK_BLACK_BOX_IMPLEMENTATION(ImageVtkProperties,bbtk::AtomicBlackBox);
38 //===== 
39 // 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)
40 //===== 
41 void ImageVtkProperties::Process()
42 {
43         unsigned int            dim;
44         int                             ext[6];
45         double                          spc[3];
46         double                          range[2];
47         double                          origin[3];
48         std::string             nametype;
49         int                             numberoOfComponents;
50         std::vector<int>        vsize;
51     std::vector<int>    vextent;
52         std::vector<double> vspacing;
53         std::vector<double> vrange;
54         std::vector<double> vorigin;
55
56         if ( bbGetInputIn() )
57         {
58                 bbGetInputIn()->Modified();
59 //EED 2017-01-01 Migration VTK7
60 #if (VTK_MAJOR_VERSION <= 5) 
61                 bbGetInputIn()->Update();
62                 bbGetInputIn()->GetWholeExtent(ext);
63 #endif
64 #if (VTK_MAJOR_VERSION >= 6) 
65                 bbGetInputIn()->GetExtent(ext);
66 #endif
67
68                 vsize.push_back( ext[1]-ext[0]+1 );
69                 vsize.push_back( ext[3]-ext[2]+1 );
70                 vsize.push_back( ext[5]-ext[4]+1 );
71         vextent.push_back( ext[0] );
72         vextent.push_back( ext[1] );
73         vextent.push_back( ext[2] );
74         vextent.push_back( ext[3] );
75         vextent.push_back( ext[4] );
76         vextent.push_back( ext[5] );
77
78                 dim = 0;
79                 if (vsize[0]>1) dim++;
80                 if (vsize[1]>1) dim++;
81                 if (vsize[2]>1) dim++;
82                 bbGetInputIn()->GetScalarRange(range);
83                 bbGetInputIn()->GetOrigin(origin);
84                 numberoOfComponents=bbGetInputIn()->GetNumberOfScalarComponents();
85                 bbGetInputIn()->GetSpacing(spc);
86                 for (unsigned int i=0;i<dim;++i) 
87                 {
88                         vspacing.push_back( (double)spc[i] );
89                         vorigin.push_back( (double)origin[i] );
90                 }
91                 vrange.push_back((double)range[0]);
92                 vrange.push_back((double)range[1]);
93                 if (bbGetInputIn()->GetScalarType()==VTK_BIT)                           nametype="VTK_BIT";                     // 1
94                 if (bbGetInputIn()->GetScalarType()==VTK_CHAR)                          nametype="VTK_CHAR";                    // 2
95                 if (bbGetInputIn()->GetScalarType()==VTK_SIGNED_CHAR)           nametype="VTK_SIGNED_CHAR";     // 15
96                 if (bbGetInputIn()->GetScalarType()==VTK_UNSIGNED_CHAR)         nametype="VTK_UNSIGNED_CHAR";   // 3
97                 if (bbGetInputIn()->GetScalarType()==VTK_SHORT)                         nametype="VTK_SHORT";                   // 4
98                 if (bbGetInputIn()->GetScalarType()==VTK_UNSIGNED_SHORT)        nametype="VTK_UNSIGNED_SHORT";  // 5
99                 if (bbGetInputIn()->GetScalarType()==VTK_INT)                           nametype="VTK_INT";             // 6
100                 if (bbGetInputIn()->GetScalarType()==VTK_UNSIGNED_INT)          nametype="VTK_UNSIGNED_INT";    // 7
101                 if (bbGetInputIn()->GetScalarType()==VTK_LONG)                          nametype="VTK_LONG";            // 8  
102                 if (bbGetInputIn()->GetScalarType()==VTK_UNSIGNED_LONG)         nametype="VTK_UNSIGNED_LONG";   // 9
103                 if (bbGetInputIn()->GetScalarType()==VTK_FLOAT)                         nametype="VTK_FLOAT";           // 10
104                 if (bbGetInputIn()->GetScalarType()==VTK_DOUBLE)                        nametype="VTK_DOUBLE";          // 11
105         } else {        
106                 dim                                     = 0;            
107                 numberoOfComponents     = 0;
108                 vsize.push_back(0);
109                 vsize.push_back(0);
110                 vsize.push_back(0);
111         vextent.push_back(0);
112         vextent.push_back(0);
113         vextent.push_back(0);
114         vextent.push_back(0);
115         vextent.push_back(0);
116         vextent.push_back(0);
117                 vspacing.push_back(0);
118                 vspacing.push_back(0);
119                 vspacing.push_back(0);
120                 vrange.push_back(0);
121                 vrange.push_back(0);
122                 nametype                        = "VOID";                               
123         }       
124         bbSetOutputDimension    ( dim );
125         bbSetOutputOrigin               ( vorigin );
126         bbSetOutputSize                 ( vsize );
127     bbSetOutputExtent       ( vextent );
128         bbSetOutputSpacing              ( vspacing );
129         bbSetOutputMinMax               ( vrange );
130         bbSetOutputTypeName             ( nametype );
131         bbSetOutputComponents   ( numberoOfComponents );
132 }
133 //===== 
134 // 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)
135 //===== 
136 void ImageVtkProperties::bbUserSetDefaultValues()
137 {
138
139 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
140 //    Here we initialize the input 'In' to 0
141 //   bbSetInputIn(0);
142   
143 }
144 //===== 
145 // 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)
146 //===== 
147 void ImageVtkProperties::bbUserInitializeProcessing()
148 {
149
150 //  THE INITIALIZATION METHOD BODY :
151 //    Here does nothing 
152 //    but this is where you should allocate the internal/output pointers 
153 //    if any 
154
155   
156 }
157 //===== 
158 // 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)
159 //===== 
160 void ImageVtkProperties::bbUserFinalizeProcessing()
161 {
162
163 //  THE FINALIZATION METHOD BODY :
164 //    Here does nothing 
165 //    but this is where you should desallocate the internal/output pointers 
166 //    if any
167   
168 }
169 }
170 // EO namespace bbvtk
171
172