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()
37 vtkImageData* original = bbGetInputIn();
41 std::cout << "Set In" << std::endl;
45 //if (lastId == bbGetInputZ())
48 int z = bbGetInputZ();
56 original->GetSpacing(space);
57 original->GetExtent(ext);
58 original->GetOrigin(origin);
59 original->GetDimensions(newDim);
63 int scalar_type = original->GetScalarType();
67 final = vtkImageData::New();
68 final->SetSpacing(space);
69 final->SetDimensions(newDim);
70 final->SetScalarType(scalar_type);
71 final->AllocateScalars();
77 bbSetOutputMax(max_z);
84 for (int i=0; i<newDim[0]; i++){
85 for (int j=0; j<newDim[1]; j++){
90 ap2 = (char *) final->GetScalarPointer(i,j,0);
91 *ap2 = *((char*) (original->GetScalarPointer(i,j,z)));
93 case VTK_UNSIGNED_CHAR:
95 ap3 = (unsigned char *) final->GetScalarPointer(i,j,0);
96 *ap3 = *((unsigned char *)(original->GetScalarPointer(i,j,z)));
100 ap4 = (short *) final->GetScalarPointer(i,j,0);
101 *ap4 = *((short *)(original->GetScalarPointer(i,j,z)));
103 case VTK_UNSIGNED_SHORT:
104 unsigned short * ap5;
105 ap5 = (unsigned short *) final->GetScalarPointer(i,j,0);
106 *ap5 = *((unsigned short *)(original->GetScalarPointer(i,j,z)));
110 ap6 = (int *) final->GetScalarPointer(i,j,0);
111 *ap6 = *((int *)(original->GetScalarPointer(i,j,z)));
113 case VTK_UNSIGNED_INT:
115 ap7 = (unsigned int *) final->GetScalarPointer(i,j,0);
116 *ap7 = *((unsigned int *)(original->GetScalarPointer(i,j,z)));
120 ap8 = (long *) final->GetScalarPointer(i,j,0);
121 *ap8 = *((long *)(original->GetScalarPointer(i,j,z)));
123 case VTK_UNSIGNED_LONG:
125 ap9 = (unsigned long *) final->GetScalarPointer(i,j,0);
126 *ap9 = *((unsigned long *)(original->GetScalarPointer(i,j,z)));
130 ap10 = (float *) final->GetScalarPointer(i,j,0);
131 *ap10 = *((float *)(original->GetScalarPointer(i,j,z)));
135 ap11 = (double *) final->GetScalarPointer(i,j,0);
136 *ap11 = *((double *)(original->GetScalarPointer(i,j,z)));
142 caster = vtkImageCast::New();
143 caster->SetInput(final);
144 caster->SetOutputScalarTypeToShort();
147 bbSetOutputOut(caster->GetOutput());
149 std::cout << "updated slice " << z << std::endl;
150 bbSignalOutputModification();
151 lastId = bbGetInputZ();
153 void SliceImage::bbUserSetDefaultValues()
156 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
157 // Here we initialize the input 'In' to 0
159 bbSetOutputOut(NULL);
163 void SliceImage::bbUserInitializeProcessing()
166 // THE INITIALIZATION METHOD BODY :
168 // but this is where you should allocate the internal/output pointers
173 void SliceImage::bbUserFinalizeProcessing()
176 // THE FINALIZATION METHOD BODY :
178 // but this is where you should desallocate the internal/output pointers
183 // EO namespace bbvtk