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 "bbvtkInversCrop.h"
5 #include "bbvtkPackage.h"
9 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,InversCrop)
10 BBTK_BLACK_BOX_IMPLEMENTATION(InversCrop,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 InversCrop::Process()
17 // THE MAIN PROCESSING METHOD BODY
18 // Here we simply set the input 'In' value to the output 'Out'
19 // And print out the output value
20 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
21 // void bbSet{Input|Output}NAME(const TYPE&)
22 // const TYPE& bbGet{Input|Output}NAME() const
24 // * NAME is the name of the input/output
25 // (the one provided in the attribute 'name' of the tag 'input')
26 // * TYPE is the C++ type of the input/output
27 // (the one provided in the attribute 'type' of the tag 'input')
29 if ((bbGetInputImageFix()!=NULL) && (bbGetInputImageMove()!=NULL) )
31 printf("EED InversCrop::Process ScalarType %d %d \n", bbGetInputImageFix()->GetScalarType(), bbGetInputImageMove()->GetScalarType() );
32 if ( bbGetInputImageFix()->GetScalarType()==bbGetInputImageMove()->GetScalarType() )
38 bbGetInputImageFix()->GetWholeExtent(ext);
39 dim[0]= ext[1]-ext[0]+1;
40 dim[1]= ext[3]-ext[2]+1;
41 dim[2]= ext[5]-ext[4]+1;
43 _imageoutput = vtkImageData::New();
44 _imageoutput->Initialize();
45 _imageoutput->SetScalarType( bbGetInputImageFix()->GetScalarType() );
46 _imageoutput->SetSpacing( bbGetInputImageFix()->GetSpacing() );
47 _imageoutput->SetDimensions( dim[0], dim[1], dim[2] );
48 _imageoutput->AllocateScalars();
50 // Duplicating Fix Image
51 long sizeimage = dim[0]*dim[1]*dim[2]*bbGetInputImageFix()->GetScalarSize();
52 memcpy( _imageoutput->GetScalarPointer() , bbGetInputImageFix()->GetScalarPointer() , sizeimage);
54 // Copy the Move Image
58 bbGetInputImageMove()->GetWholeExtent(ext);
59 int dimMoveX = ext[1]-ext[0]+1;
60 int dimMoveY = ext[3]-ext[2]+1;
61 int dimMoveZ = ext[5]-ext[4]+1;
63 int spxM=0; // start px MoveImage
64 int sizeXM=0; // sizeX MoveImage
66 px=bbGetInputOrigin()[0];
73 sizeXM = dimMoveX-spxM;
74 if (px+sizeXM>=dim[0]) sizeXM=dim[0]-px;
76 sizeXM=sizeXM*bbGetInputImageFix()->GetScalarSize();
77 for (k=0; k<dimMoveZ; k++)
79 for (j=0; j<dimMoveY; j++)
81 py=j+bbGetInputOrigin()[1];
82 pz=k+bbGetInputOrigin()[2];
84 if ( (py<dim[1]) && (pz<dim[2]) &&
88 memcpy( _imageoutput->GetScalarPointer(px,py,pz) , bbGetInputImageMove()->GetScalarPointer(spxM,j,k) , sizeXM );
93 _imageoutput->Modified();
94 } // If Image Fixe Move the same GetScalarType
96 printf ("ERROR: InversCrop both ImageFixe and ImageMove need the same format.\n");
98 } // If Image Fixe Move != NULL
100 printf ("ERROR: InversCrop need ImageFixe and ImageMove to run.\n");
102 bbSetOutputOut(_imageoutput);
106 // 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)
108 void InversCrop::bbUserSetDefaultValues()
111 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
112 // Here we initialize the input 'In' to 0
113 bbSetInputImageFix(NULL);
114 bbSetInputImageMove(NULL);
116 std::vector<int> origin;
120 bbSetInputOrigin(origin);
125 // 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)
127 void InversCrop::bbUserInitializeProcessing()
130 // THE INITIALIZATION METHOD BODY :
132 // but this is where you should allocate the internal/output pointers
138 // 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)
140 void InversCrop::bbUserFinalizeProcessing()
143 // THE FINALIZATION METHOD BODY :
145 // but this is where you should desallocate the internal/output pointers
150 // EO namespace bbvtk