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 printf("EED bbtkStaticLecture::GetTypeFormat Start \n");
35 int outputformat = VTK_UNSIGNED_CHAR;
36 if (formatStr=="SAME")
38 printf("EED bbtkStaticLecture::GetTypeFormat 1 image=%p\n",image);
39 if (image!=NULL) outputformat = image->GetScalarType();
40 printf("EED bbtkStaticLecture::GetTypeFormat 2 \n");
42 else if (formatStr=="VTK_BIT") outputformat = VTK_BIT; // 1
43 else if (formatStr=="VTK_CHAR") outputformat = VTK_CHAR; // 2
44 else if (formatStr=="VTK_SIGNED_CHAR") outputformat = VTK_SIGNED_CHAR; // 15
45 else if (formatStr=="VTK_UNSIGNED_CHAR") outputformat = VTK_UNSIGNED_CHAR; // 3
46 else if (formatStr=="VTK_SHORT") outputformat = VTK_SHORT; // 4
47 else if (formatStr=="VTK_UNSIGNED_SHORT") outputformat = VTK_UNSIGNED_SHORT; // 5
48 else if (formatStr=="VTK_INT") outputformat = VTK_INT; // 6
49 else if (formatStr=="VTK_UNSIGNED_INT") outputformat = VTK_UNSIGNED_INT; // 7
50 else if (formatStr=="VTK_LONG") outputformat = VTK_LONG; // 8
51 else if (formatStr=="VTK_UNSIGNED_LONG") outputformat = VTK_UNSIGNED_LONG; // 9
52 else if (formatStr=="VTK_FLOAT") outputformat = VTK_FLOAT; // 10
53 else if (formatStr=="VTK_DOUBLE") outputformat = VTK_DOUBLE; // 11
54 else if (formatStr=="MET_CHAR") outputformat = VTK_CHAR; // 2
55 else if (formatStr=="MET_UCHAR") outputformat = VTK_UNSIGNED_CHAR; // 3
56 else if (formatStr=="MET_SHORT") outputformat = VTK_SHORT; // 4
57 else if (formatStr=="MET_USHORT") outputformat = VTK_UNSIGNED_SHORT; // 5
58 else if (formatStr=="MET_SHORT") outputformat = VTK_SHORT; // 4
59 else if (formatStr=="MET_FLOAT") outputformat = VTK_FLOAT; // 10
60 else if (formatStr=="MET_DOUBLE") outputformat = VTK_DOUBLE; // 11
62 printf("EED bbtkStaticLecture::GetTypeFormat outputformat=%d End\n", outputformat);
69 void bbtkStaticLecture::setPixelValue(int i, int j, int k, vtkImageData* img, double value)
72 int scalar_type = img->GetScalarType();
73 int* ext = img->GetExtent();
93 ap2 = (char *) img->GetScalarPointer(i,j,k);
96 case VTK_UNSIGNED_CHAR:
98 ap3 = (unsigned char *) img->GetScalarPointer(i,j,k);
99 *ap3 = (unsigned char) value;
103 ap4 = (short *) img->GetScalarPointer(i,j,k);
104 *ap4 = (short) value;
106 case VTK_UNSIGNED_SHORT:
107 unsigned short * ap5;
108 ap5 = (unsigned short *) img->GetScalarPointer(i,j,k);
109 *ap5 = (unsigned short) value;
113 ap6 = (int *) img->GetScalarPointer(i,j,k);
116 case VTK_UNSIGNED_INT:
118 ap7 = (unsigned int *) img->GetScalarPointer(i,j,k);
119 *ap7 = (unsigned int) value;
123 ap8 = (long *) img->GetScalarPointer(i,j,k);
126 case VTK_UNSIGNED_LONG:
128 ap9 = (unsigned long *) img->GetScalarPointer(i,j,k);
129 *ap9 = (unsigned long) value;
133 ap10 = (float *) img->GetScalarPointer(i,j,k);
134 *ap10 = (float) value;
138 ap11 = (double *) img->GetScalarPointer(i,j,k);
139 *ap11 = (double) value;
143 double bbtkStaticLecture::getPixelValue(int i, int j, int k, vtkImageData* img)
146 int scalar_type = img->GetScalarType();
147 int* ext = img->GetExtent();
167 ap2 = (char *) img->GetScalarPointer(i,j,k);
170 case VTK_UNSIGNED_CHAR:
172 ap3 = (unsigned char *) img->GetScalarPointer(i,j,k);
177 ap4 = (short *) img->GetScalarPointer(i,j,k);
180 case VTK_UNSIGNED_SHORT:
181 unsigned short * ap5;
182 ap5 = (unsigned short *) img->GetScalarPointer(i,j,k);
187 ap6 = (int *) img->GetScalarPointer(i,j,k);
190 case VTK_UNSIGNED_INT:
192 ap7 = (unsigned int *) img->GetScalarPointer(i,j,k);
197 ap8 = (long *) img->GetScalarPointer(i,j,k);
200 case VTK_UNSIGNED_LONG:
202 ap9 = (unsigned long *) img->GetScalarPointer(i,j,k);
207 ap10 = (float *) img->GetScalarPointer(i,j,k);
208 rta = (double) *ap10;
212 ap11 = (double *) img->GetScalarPointer(i,j,k);
213 rta = (double) *ap11;