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 "bbvtkSliceImage.h"
29 #include "bbvtkPackage.h"
33 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,SliceImage)
34 BBTK_BLACK_BOX_IMPLEMENTATION(SliceImage,bbtk::AtomicBlackBox);
35 void SliceImage::Process()
38 printf("EED ********************************** bbtk-box vtk:SliceImage (Deprecated)\n");
39 printf("EED ********************************** >> use bbtk-box creaMaracasVisu:SliceImage \n");
40 vtkImageData* original = bbGetInputIn();
44 std::cout << "Set In" << std::endl;
48 //if (lastId == bbGetInputZ())
51 int z = bbGetInputZ();
59 original->GetSpacing(space);
60 original->GetExtent(ext);
61 original->GetOrigin(origin);
62 original->GetDimensions(newDim);
66 int scalar_type = original->GetScalarType();
70 final = vtkImageData::New();
71 final->SetSpacing(space);
72 final->SetDimensions(newDim);
74 //EED 2017-01-01 Migration VTK7
75 #if VTK_MAJOR_VERSION <= 5
76 final->SetScalarType(scalar_type);
77 final->AllocateScalars();
80 final->AllocateScalars(scalar_type,1);
85 bbSetOutputMax(max_z);
92 for (int i=0; i<newDim[0]; i++){
93 for (int j=0; j<newDim[1]; j++){
98 ap2 = (char *) final->GetScalarPointer(i,j,0);
99 *ap2 = *((char*) (original->GetScalarPointer(i,j,z)));
101 case VTK_UNSIGNED_CHAR:
103 ap3 = (unsigned char *) final->GetScalarPointer(i,j,0);
104 *ap3 = *((unsigned char *)(original->GetScalarPointer(i,j,z)));
108 ap4 = (short *) final->GetScalarPointer(i,j,0);
109 *ap4 = *((short *)(original->GetScalarPointer(i,j,z)));
111 case VTK_UNSIGNED_SHORT:
112 unsigned short * ap5;
113 ap5 = (unsigned short *) final->GetScalarPointer(i,j,0);
114 *ap5 = *((unsigned short *)(original->GetScalarPointer(i,j,z)));
118 ap6 = (int *) final->GetScalarPointer(i,j,0);
119 *ap6 = *((int *)(original->GetScalarPointer(i,j,z)));
121 case VTK_UNSIGNED_INT:
123 ap7 = (unsigned int *) final->GetScalarPointer(i,j,0);
124 *ap7 = *((unsigned int *)(original->GetScalarPointer(i,j,z)));
128 ap8 = (long *) final->GetScalarPointer(i,j,0);
129 *ap8 = *((long *)(original->GetScalarPointer(i,j,z)));
131 case VTK_UNSIGNED_LONG:
133 ap9 = (unsigned long *) final->GetScalarPointer(i,j,0);
134 *ap9 = *((unsigned long *)(original->GetScalarPointer(i,j,z)));
138 ap10 = (float *) final->GetScalarPointer(i,j,0);
139 *ap10 = *((float *)(original->GetScalarPointer(i,j,z)));
143 ap11 = (double *) final->GetScalarPointer(i,j,0);
144 *ap11 = *((double *)(original->GetScalarPointer(i,j,z)));
150 caster = vtkImageCast::New();
151 //EED 2017-01-01 Migration VTK7
152 #if VTK_MAJOR_VERSION <= 5
153 caster->SetInput(final);
155 caster->SetInputData(final);
158 caster->SetOutputScalarTypeToShort();
161 bbSetOutputOut(caster->GetOutput());
163 std::cout << "updated slice " << z << std::endl;
164 bbSignalOutputModification();
165 lastId = bbGetInputZ();
167 void SliceImage::bbUserSetDefaultValues()
170 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
171 // Here we initialize the input 'In' to 0
173 bbSetOutputOut(NULL);
177 void SliceImage::bbUserInitializeProcessing()
180 // THE INITIALIZATION METHOD BODY :
182 // but this is where you should allocate the internal/output pointers
187 void SliceImage::bbUserFinalizeProcessing()
190 // THE FINALIZATION METHOD BODY :
192 // but this is where you should desallocate the internal/output pointers
197 // EO namespace bbvtk