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