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);
71 //EED 2017-01-01 Migration VTK7
72 #if VTK_MAJOR_VERSION <= 5
73 final->SetScalarType(scalar_type);
74 final->AllocateScalars();
77 final->AllocateScalars(scalar_type,1);
82 bbSetOutputMax(max_z);
89 for (int i=0; i<newDim[0]; i++){
90 for (int j=0; j<newDim[1]; j++){
95 ap2 = (char *) final->GetScalarPointer(i,j,0);
96 *ap2 = *((char*) (original->GetScalarPointer(i,j,z)));
98 case VTK_UNSIGNED_CHAR:
100 ap3 = (unsigned char *) final->GetScalarPointer(i,j,0);
101 *ap3 = *((unsigned char *)(original->GetScalarPointer(i,j,z)));
105 ap4 = (short *) final->GetScalarPointer(i,j,0);
106 *ap4 = *((short *)(original->GetScalarPointer(i,j,z)));
108 case VTK_UNSIGNED_SHORT:
109 unsigned short * ap5;
110 ap5 = (unsigned short *) final->GetScalarPointer(i,j,0);
111 *ap5 = *((unsigned short *)(original->GetScalarPointer(i,j,z)));
115 ap6 = (int *) final->GetScalarPointer(i,j,0);
116 *ap6 = *((int *)(original->GetScalarPointer(i,j,z)));
118 case VTK_UNSIGNED_INT:
120 ap7 = (unsigned int *) final->GetScalarPointer(i,j,0);
121 *ap7 = *((unsigned int *)(original->GetScalarPointer(i,j,z)));
125 ap8 = (long *) final->GetScalarPointer(i,j,0);
126 *ap8 = *((long *)(original->GetScalarPointer(i,j,z)));
128 case VTK_UNSIGNED_LONG:
130 ap9 = (unsigned long *) final->GetScalarPointer(i,j,0);
131 *ap9 = *((unsigned long *)(original->GetScalarPointer(i,j,z)));
135 ap10 = (float *) final->GetScalarPointer(i,j,0);
136 *ap10 = *((float *)(original->GetScalarPointer(i,j,z)));
140 ap11 = (double *) final->GetScalarPointer(i,j,0);
141 *ap11 = *((double *)(original->GetScalarPointer(i,j,z)));
147 caster = vtkImageCast::New();
148 //EED 2017-01-01 Migration VTK7
149 #if VTK_MAJOR_VERSION <= 5
150 caster->SetInput(final);
152 caster->SetInputData(final);
155 caster->SetOutputScalarTypeToShort();
158 bbSetOutputOut(caster->GetOutput());
160 std::cout << "updated slice " << z << std::endl;
161 bbSignalOutputModification();
162 lastId = bbGetInputZ();
164 void SliceImage::bbUserSetDefaultValues()
167 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
168 // Here we initialize the input 'In' to 0
170 bbSetOutputOut(NULL);
174 void SliceImage::bbUserInitializeProcessing()
177 // THE INITIALIZATION METHOD BODY :
179 // but this is where you should allocate the internal/output pointers
184 void SliceImage::bbUserFinalizeProcessing()
187 // THE FINALIZATION METHOD BODY :
189 // but this is where you should desallocate the internal/output pointers
194 // EO namespace bbvtk