2 // 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)
4 #include "bbvtkAutoCrop.h"
5 #include "bbvtkPackage.h"
9 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,AutoCrop)
10 BBTK_BLACK_BOX_IMPLEMENTATION(AutoCrop,bbtk::AtomicBlackBox);
12 // 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)
14 void AutoCrop::Process()
17 printf("EED AutoCrop::Process Start\n");
19 // THE MAIN PROCESSING METHOD BODY
20 // Here we simply set the input 'In' value to the output 'Out'
21 // And print out the output value
22 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
23 // void bbSet{Input|Output}NAME(const TYPE&)
24 // const TYPE& bbGet{Input|Output}NAME() const
26 // * NAME is the name of the input/output
27 // (the one provided in the attribute 'name' of the tag 'input')
28 // * TYPE is the C++ type of the input/output
29 // (the one provided in the attribute 'type' of the tag 'input')
33 int sizeX,sizeY,sizeZ;
35 if (bbGetInputIn()!=NULL){
36 bbGetInputIn()->Update();
38 bbGetInputIn()->GetWholeExtent(ext);
39 sizeX=ext[1]-ext[0]+1;
40 sizeY=ext[3]-ext[2]+1;
41 sizeZ=ext[5]-ext[4]+1;
45 // if (_newImage==NULL)
47 _newImage = vtkImageData::New();
48 _newImage->Initialize();
49 _newImage->SetScalarType( bbGetInputIn()->GetScalarType() );
50 _newImage->SetSpacing( bbGetInputIn()->GetSpacing() );
51 _newImage->SetNumberOfScalarComponents( bbGetInputIn()->GetNumberOfScalarComponents() );
52 _newImage->SetDimensions( sizeX,sizeY,sizeZ );
53 _newImage->SetWholeExtent(0,sizeX-1,0,sizeY-1,0,sizeZ-1);
54 _newImage->AllocateScalars();
59 for (i=0; i<sizeX; i++)
61 for (j=0; j<sizeY; j++)
63 for (k=0; k<sizeZ; k++)
65 value = bbGetInputIn()->GetScalarComponentAsDouble(i,j,k, 0 );
66 _newImage->SetScalarComponentFromDouble(i,j,k, 0, value );
73 bbSetOutputOut(_newImage);
77 // 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)
79 void AutoCrop::bbUserSetDefaultValues()
82 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
83 // Here we initialize the input 'In' to 0
90 // 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)
92 void AutoCrop::bbUserInitializeProcessing()
95 // THE INITIALIZATION METHOD BODY :
97 // but this is where you should allocate the internal/output pointers
103 // 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)
105 void AutoCrop::bbUserFinalizeProcessing()
108 // THE FINALIZATION METHOD BODY :
110 // but this is where you should desallocate the internal/output pointers
115 // EO namespace bbvtk