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 # ------------------------------------------------------------------------ */
29 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
31 #include "bbvtkCleanExternalPlane.h"
32 #include "bbvtkPackage.h"
36 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,CleanExternalPlane)
37 BBTK_BLACK_BOX_IMPLEMENTATION(CleanExternalPlane,bbtk::AtomicBlackBox);
39 //----------------------------------------------------------------------
40 void CleanExternalPlane::CleanTypeA(vtkImageData* image)
42 if ( bbGetInputIn()!=NULL )
48 //EED 2017-01-01 Migration VTK7
49 #if (VTK_MAJOR_VERSION <= 5)
50 image->GetWholeExtent(ext);
52 #if (VTK_MAJOR_VERSION >= 6)
53 image->GetExtent(ext);
56 dim[0]=ext[1]-ext[0]+1;
57 dim[1]=ext[3]-ext[2]+1;
58 dim[2]=ext[5]-ext[4]+1;
61 for (i=0 ; i<dim[0] ; i++)
63 for (j=0 ; j<dim[1] ; j++)
65 image->SetScalarComponentFromDouble (ext[0]+i, ext[2]+j, ext[4]+0 , 0, 0.0);
66 image->SetScalarComponentFromDouble (ext[0]+i, ext[2]+j, ext[4]+dim[2]-1, 0, 0.0);
71 for (i=0 ; i<dim[1] ; i++)
73 for (j=0 ; j<dim[2] ; j++)
75 image->SetScalarComponentFromDouble (ext[0]+0 , ext[2]+i, ext[4]+j, 0, 0.0);
76 image->SetScalarComponentFromDouble (ext[0]+dim[0]-1 , ext[2]+i, ext[4]+j, 0, 0.0);
81 for (i=0 ; i<dim[0] ; i++)
83 for (j=0 ; j<dim[2] ; j++)
85 image->SetScalarComponentFromDouble (ext[0]+i, ext[2]+0 , ext[4]+j, 0, 0.0);
86 image->SetScalarComponentFromDouble (ext[0]+i, ext[2]+dim[1]-1 , ext[4]+j, 0, 0.0);
92 //----------------------------------------------------------------------
93 void CleanExternalPlane::CleanTypeB()
99 //EED 2017-01-01 Migration VTK7
100 #if (VTK_MAJOR_VERSION <= 5)
101 bbGetInputIn()->GetWholeExtent(ext);
103 #if (VTK_MAJOR_VERSION >= 6)
104 bbGetInputIn()->GetExtent(ext);
107 dimA[0] = ext[1]-ext[0]+1;
108 dimA[1] = ext[3]-ext[2]+1;
109 dimA[2] = ext[5]-ext[4]+1;
111 dimB[0] = dimA[0] + 2;
112 dimB[1] = dimA[1] + 2;
113 dimB[2] = dimA[2] + 2;
116 imageoutput->Initialize();
117 imageoutput->SetSpacing( bbGetInputIn()->GetSpacing() );
118 imageoutput->SetDimensions( dimB[0], dimB[1], dimB[2] );
120 //EED 2017-01-01 Migration VTK7
121 #if (VTK_MAJOR_VERSION <= 5)
122 imageoutput->SetScalarType( bbGetInputIn()->GetScalarType() );
123 imageoutput->AllocateScalars();
125 #if (VTK_MAJOR_VERSION >= 6)
126 imageoutput->AllocateScalars( bbGetInputIn()->GetScalarType() , 1);
131 long sizeBlock= dimA[0] * bbGetInputIn()->GetScalarSize();
133 for (j=0;j<dimA[1];j++)
135 for (k=0;k<dimA[2];k++)
137 memcpy( imageoutput->GetScalarPointer(1,j+1,k+1) , bbGetInputIn()->GetScalarPointer(0,j,k) , sizeBlock );
142 //EED 2017-01-01 Migration VTK7
143 #if (VTK_MAJOR_VERSION <= 5)
144 imageoutput->Update();
146 #if (VTK_MAJOR_VERSION >= 6)
150 imageoutput->Modified();
155 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
157 void CleanExternalPlane::Process()
160 // THE MAIN PROCESSING METHOD BODY
161 // Here we simply set the input 'In' value to the output 'Out'
162 // And print out the output value
163 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
164 // void bbSet{Input|Output}NAME(const TYPE&)
165 // const TYPE& bbGet{Input|Output}NAME() const
167 // * NAME is the name of the input/output
168 // (the one provided in the attribute 'name' of the tag 'input')
169 // * TYPE is the C++ type of the input/output
170 // (the one provided in the attribute 'type' of the tag 'input')
173 if (bbGetInputType()==-1)
175 bbSetOutputOut( bbGetInputIn() );
178 // Clean external planes
179 if (bbGetInputType()==0)
181 CleanTypeA( bbGetInputIn() );
182 bbSetOutputOut( bbGetInputIn() );
185 // Add new faces and clean the external planes
186 if (bbGetInputType()==1)
189 CleanTypeA(imageoutput);
190 bbSetOutputOut( imageoutput );
198 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
200 void CleanExternalPlane::bbUserSetDefaultValues()
203 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
204 // Here we initialize the input 'In' to 0
210 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
212 void CleanExternalPlane::bbUserInitializeProcessing()
215 // THE INITIALIZATION METHOD BODY :
217 // but this is where you should allocate the internal/output pointers
220 imageoutput = vtkImageData::New();
224 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
226 void CleanExternalPlane::bbUserFinalizeProcessing()
229 // THE FINALIZATION METHOD BODY :
231 // but this is where you should desallocate the internal/output pointers
233 imageoutput->Delete();
236 } // EO namespace bbvtk