2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
28 #include "bbtkStaticLecture.h"
32 int bbtkStaticLecture::GetTypeFormat( std::string formatStr , vtkImageData* image )
34 int outputformat = VTK_UNSIGNED_CHAR;
35 if (formatStr=="SAME")
37 if (image!=NULL) outputformat = image->GetScalarType();
39 else if (formatStr=="VTK_BIT") outputformat = VTK_BIT; // 1
40 else if (formatStr=="VTK_CHAR") outputformat = VTK_CHAR; // 2
41 else if (formatStr=="VTK_SIGNED_CHAR") outputformat = VTK_SIGNED_CHAR; // 15
42 else if (formatStr=="VTK_UNSIGNED_CHAR") outputformat = VTK_UNSIGNED_CHAR; // 3
43 else if (formatStr=="VTK_SHORT") outputformat = VTK_SHORT; // 4
44 else if (formatStr=="VTK_UNSIGNED_SHORT") outputformat = VTK_UNSIGNED_SHORT; // 5
45 else if (formatStr=="VTK_INT") outputformat = VTK_INT; // 6
46 else if (formatStr=="VTK_UNSIGNED_INT") outputformat = VTK_UNSIGNED_INT; // 7
47 else if (formatStr=="VTK_LONG") outputformat = VTK_LONG; // 8
48 else if (formatStr=="VTK_UNSIGNED_LONG") outputformat = VTK_UNSIGNED_LONG; // 9
49 else if (formatStr=="VTK_FLOAT") outputformat = VTK_FLOAT; // 10
50 else if (formatStr=="VTK_DOUBLE") outputformat = VTK_DOUBLE; // 11
51 else if (formatStr=="MET_CHAR") outputformat = VTK_CHAR; // 2
52 else if (formatStr=="MET_UCHAR") outputformat = VTK_UNSIGNED_CHAR; // 3
53 else if (formatStr=="MET_SHORT") outputformat = VTK_SHORT; // 4
54 else if (formatStr=="MET_USHORT") outputformat = VTK_UNSIGNED_SHORT; // 5
55 else if (formatStr=="MET_SHORT") outputformat = VTK_SHORT; // 4
56 else if (formatStr=="MET_FLOAT") outputformat = VTK_FLOAT; // 10
57 else if (formatStr=="MET_DOUBLE") outputformat = VTK_DOUBLE; // 11
64 void bbtkStaticLecture::setPixelValue(int i, int j, int k, vtkImageData* img, double value)
67 int scalar_type = img->GetScalarType();
68 int* ext = img->GetExtent();
88 ap2 = (char *) img->GetScalarPointer(i,j,k);
91 case VTK_UNSIGNED_CHAR:
93 ap3 = (unsigned char *) img->GetScalarPointer(i,j,k);
94 *ap3 = (unsigned char) value;
98 ap4 = (short *) img->GetScalarPointer(i,j,k);
101 case VTK_UNSIGNED_SHORT:
102 unsigned short * ap5;
103 ap5 = (unsigned short *) img->GetScalarPointer(i,j,k);
104 *ap5 = (unsigned short) value;
108 ap6 = (int *) img->GetScalarPointer(i,j,k);
111 case VTK_UNSIGNED_INT:
113 ap7 = (unsigned int *) img->GetScalarPointer(i,j,k);
114 *ap7 = (unsigned int) value;
118 ap8 = (long *) img->GetScalarPointer(i,j,k);
121 case VTK_UNSIGNED_LONG:
123 ap9 = (unsigned long *) img->GetScalarPointer(i,j,k);
124 *ap9 = (unsigned long) value;
128 ap10 = (float *) img->GetScalarPointer(i,j,k);
129 *ap10 = (float) value;
133 ap11 = (double *) img->GetScalarPointer(i,j,k);
134 *ap11 = (double) value;
138 double bbtkStaticLecture::getPixelValue(int i, int j, int k, vtkImageData* img)
141 int scalar_type = img->GetScalarType();
142 int* ext = img->GetExtent();
162 ap2 = (char *) img->GetScalarPointer(i,j,k);
165 case VTK_UNSIGNED_CHAR:
167 ap3 = (unsigned char *) img->GetScalarPointer(i,j,k);
172 ap4 = (short *) img->GetScalarPointer(i,j,k);
175 case VTK_UNSIGNED_SHORT:
176 unsigned short * ap5;
177 ap5 = (unsigned short *) img->GetScalarPointer(i,j,k);
182 ap6 = (int *) img->GetScalarPointer(i,j,k);
185 case VTK_UNSIGNED_INT:
187 ap7 = (unsigned int *) img->GetScalarPointer(i,j,k);
192 ap8 = (long *) img->GetScalarPointer(i,j,k);
195 case VTK_UNSIGNED_LONG:
197 ap9 = (unsigned long *) img->GetScalarPointer(i,j,k);
202 ap10 = (float *) img->GetScalarPointer(i,j,k);
203 rta = (double) *ap10;
207 ap11 = (double *) img->GetScalarPointer(i,j,k);
208 rta = (double) *ap11;