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 )
47 image->GetWholeExtent(ext);
49 dim[0]=ext[1]-ext[0]+1;
50 dim[1]=ext[3]-ext[2]+1;
51 dim[2]=ext[5]-ext[4]+1;
54 for (i=0 ; i<dim[0] ; i++)
56 for (j=0 ; j<dim[1] ; j++)
58 image->SetScalarComponentFromDouble (ext[0]+i, ext[2]+j, ext[4]+0 , 0, 0.0);
59 image->SetScalarComponentFromDouble (ext[0]+i, ext[2]+j, ext[4]+dim[2]-1, 0, 0.0);
64 for (i=0 ; i<dim[1] ; i++)
66 for (j=0 ; j<dim[2] ; j++)
68 image->SetScalarComponentFromDouble (ext[0]+0 , ext[2]+i, ext[4]+j, 0, 0.0);
69 image->SetScalarComponentFromDouble (ext[0]+dim[0]-1 , ext[2]+i, ext[4]+j, 0, 0.0);
74 for (i=0 ; i<dim[0] ; i++)
76 for (j=0 ; j<dim[2] ; j++)
78 image->SetScalarComponentFromDouble (ext[0]+i, ext[2]+0 , ext[4]+j, 0, 0.0);
79 image->SetScalarComponentFromDouble (ext[0]+i, ext[2]+dim[1]-1 , ext[4]+j, 0, 0.0);
85 //----------------------------------------------------------------------
86 void CleanExternalPlane::CleanTypeB()
92 bbGetInputIn()->GetWholeExtent(ext);
94 dimA[0] = ext[1]-ext[0]+1;
95 dimA[1] = ext[3]-ext[2]+1;
96 dimA[2] = ext[5]-ext[4]+1;
98 dimB[0] = dimA[0] + 2;
99 dimB[1] = dimA[1] + 2;
100 dimB[2] = dimA[2] + 2;
103 imageoutput->Initialize();
104 imageoutput->SetScalarType( bbGetInputIn()->GetScalarType() );
105 imageoutput->SetSpacing( bbGetInputIn()->GetSpacing() );
106 imageoutput->SetDimensions( dimB[0], dimB[1], dimB[2] );
107 imageoutput->AllocateScalars();
111 long sizeBlock= dimA[0] * bbGetInputIn()->GetScalarSize();
113 for (j=0;j<dimA[1];j++)
115 for (k=0;k<dimA[2];k++)
117 memcpy( imageoutput->GetScalarPointer(1,j+1,k+1) , bbGetInputIn()->GetScalarPointer(0,j,k) , sizeBlock );
120 imageoutput->Update();
121 imageoutput->Modified();
126 // 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)
128 void CleanExternalPlane::Process()
131 // THE MAIN PROCESSING METHOD BODY
132 // Here we simply set the input 'In' value to the output 'Out'
133 // And print out the output value
134 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
135 // void bbSet{Input|Output}NAME(const TYPE&)
136 // const TYPE& bbGet{Input|Output}NAME() const
138 // * NAME is the name of the input/output
139 // (the one provided in the attribute 'name' of the tag 'input')
140 // * TYPE is the C++ type of the input/output
141 // (the one provided in the attribute 'type' of the tag 'input')
144 if (bbGetInputType()==-1)
146 bbSetOutputOut( bbGetInputIn() );
149 // Clean external planes
150 if (bbGetInputType()==0)
152 CleanTypeA( bbGetInputIn() );
153 bbSetOutputOut( bbGetInputIn() );
156 // Add new faces and clean the external planes
157 if (bbGetInputType()==1)
160 CleanTypeA(imageoutput);
161 bbSetOutputOut( imageoutput );
169 // 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)
171 void CleanExternalPlane::bbUserSetDefaultValues()
174 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
175 // Here we initialize the input 'In' to 0
181 // 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)
183 void CleanExternalPlane::bbUserInitializeProcessing()
186 // THE INITIALIZATION METHOD BODY :
188 // but this is where you should allocate the internal/output pointers
191 imageoutput = vtkImageData::New();
195 // 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)
197 void CleanExternalPlane::bbUserFinalizeProcessing()
200 // THE FINALIZATION METHOD BODY :
202 // but this is where you should desallocate the internal/output pointers
204 imageoutput->Delete();
207 } // EO namespace bbvtk