]> Creatis software - bbtk.git/blob - packages/vtk/src/bbvtkImageVtkProperties.cxx
#3167 BBTK Feature New Normal - box vtk ImageProperties GetOrientation
[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<double> vspacing;
52         std::vector<double> vrange;
53         std::vector<double> vorigin;
54
55         if ( bbGetInputIn() )
56         {
57                 bbGetInputIn()->Modified();
58                 bbGetInputIn()->Update();
59                 bbGetInputIn()->GetWholeExtent(ext);
60                 vsize.push_back(ext[1]-ext[0]+1);
61                 vsize.push_back(ext[3]-ext[2]+1);
62                 vsize.push_back(ext[5]-ext[4]+1);
63                 dim = 0;
64                 if (vsize[0]>1) dim++;
65                 if (vsize[1]>1) dim++;
66                 if (vsize[2]>1) dim++;
67                 bbGetInputIn()->GetScalarRange(range);
68                 bbGetInputIn()->GetOrigin(origin);
69                 numberoOfComponents=bbGetInputIn()->GetNumberOfScalarComponents();
70                 bbGetInputIn()->GetSpacing(spc);
71                 for (unsigned int i=0;i<dim;++i) 
72                 {
73                         vspacing.push_back( (double)spc[i] );
74                         vorigin.push_back( (double)origin[i] );
75                 }
76                 vrange.push_back((double)range[0]);
77                 vrange.push_back((double)range[1]);
78                 if (bbGetInputIn()->GetScalarType()==VTK_BIT)                           nametype="VTK_BIT";                     // 1
79                 if (bbGetInputIn()->GetScalarType()==VTK_CHAR)                          nametype="VTK_CHAR";                    // 2
80                 if (bbGetInputIn()->GetScalarType()==VTK_SIGNED_CHAR)           nametype="VTK_SIGNED_CHAR";     // 15
81                 if (bbGetInputIn()->GetScalarType()==VTK_UNSIGNED_CHAR)         nametype="VTK_UNSIGNED_CHAR";   // 3
82                 if (bbGetInputIn()->GetScalarType()==VTK_SHORT)                         nametype="VTK_SHORT";                   // 4
83                 if (bbGetInputIn()->GetScalarType()==VTK_UNSIGNED_SHORT)        nametype="VTK_UNSIGNED_SHORT";  // 5
84                 if (bbGetInputIn()->GetScalarType()==VTK_INT)                           nametype="VTK_INT";             // 6
85                 if (bbGetInputIn()->GetScalarType()==VTK_UNSIGNED_INT)          nametype="VTK_UNSIGNED_INT";    // 7
86                 if (bbGetInputIn()->GetScalarType()==VTK_LONG)                          nametype="VTK_LONG";            // 8  
87                 if (bbGetInputIn()->GetScalarType()==VTK_UNSIGNED_LONG)         nametype="VTK_UNSIGNED_LONG";   // 9
88                 if (bbGetInputIn()->GetScalarType()==VTK_FLOAT)                         nametype="VTK_FLOAT";           // 10
89                 if (bbGetInputIn()->GetScalarType()==VTK_DOUBLE)                        nametype="VTK_DOUBLE";          // 11
90         } else {        
91                 dim                                     = 0;            
92                 numberoOfComponents     = 0;
93                 vsize.push_back(0);
94                 vsize.push_back(0);
95                 vsize.push_back(0);
96                 vspacing.push_back(0);
97                 vspacing.push_back(0);
98                 vspacing.push_back(0);
99                 vrange.push_back(0);
100                 vrange.push_back(0);
101                 nametype                        = "VOID";                               
102         }       
103         bbSetOutputDimension    ( dim );
104         bbSetOutputOrigin               ( vorigin );
105         bbSetOutputSize                 ( vsize );
106         bbSetOutputSpacing              ( vspacing );
107         bbSetOutputMinMax               ( vrange );
108         bbSetOutputTypeName             ( nametype );
109         bbSetOutputComponents   ( numberoOfComponents );
110 }
111 //===== 
112 // 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)
113 //===== 
114 void ImageVtkProperties::bbUserSetDefaultValues()
115 {
116
117 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
118 //    Here we initialize the input 'In' to 0
119 //   bbSetInputIn(0);
120   
121 }
122 //===== 
123 // 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)
124 //===== 
125 void ImageVtkProperties::bbUserInitializeProcessing()
126 {
127
128 //  THE INITIALIZATION METHOD BODY :
129 //    Here does nothing 
130 //    but this is where you should allocate the internal/output pointers 
131 //    if any 
132
133   
134 }
135 //===== 
136 // 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)
137 //===== 
138 void ImageVtkProperties::bbUserFinalizeProcessing()
139 {
140
141 //  THE FINALIZATION METHOD BODY :
142 //    Here does nothing 
143 //    but this is where you should desallocate the internal/output pointers 
144 //    if any
145   
146 }
147 }
148 // EO namespace bbvtk
149
150