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 "bbcreaVtkImageCutByAxis.h"
5 #include "bbcreaVtkPackage.h"
9 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ImageCutByAxis)
10 BBTK_BLACK_BOX_IMPLEMENTATION(ImageCutByAxis,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 ImageCutByAxis::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 // bbSetOutputOut( bbGetInputIn() );
30 // std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
33 vtkImageData *newData=vtkImageData::New();
34 newData->DeepCopy( bbGetInputIn() );
37 bbGetInputIn()->GetWholeExtent(ext);
38 double dimX=ext[1]-ext[0]+1;
39 double dimY=ext[3]-ext[2]+1;
40 double dimZ=ext[5]-ext[4]+1;
42 int x=bbGetInputPoint()[0];
43 int y=bbGetInputPoint()[1];
44 int z=bbGetInputPoint()[2];
52 if ( bbGetInputType()=="x-y-z+" )
54 if (bbGetInputTypeOrientation()==0) { c1=false; c2=true; c3=true; c4=true; }
55 if (bbGetInputTypeOrientation()==1) { c1=true; c2=false; c3=true; c4=true; }
56 if (bbGetInputTypeOrientation()==2) { c1=true; c2=false; c3=true; c4=true; }
59 if (bbGetInputInsideVol()==true)
68 int xmin,xmax,ymin,ymax;
71 // imgPtr=bbGetInputIn()->GetScalarPointer(x,y,z,0);
72 // memset( bbGetInputIn()->GetScalarPointer() );
76 if (bbGetInputTypeOrientation()==0) { xmin=0; xmax=x; ymin=0; ymax=y; }
77 if (bbGetInputTypeOrientation()==1) { xmin=0; xmax=x; ymin=dimY-z; ymax=dimY; }
78 if (bbGetInputTypeOrientation()==2) { xmin=0; xmax=y; ymin=dimY-z; ymax=dimY; }
79 for (j=ymin;j<ymax;j++){
80 for (i=xmin;i<xmax;i++){newData->SetScalarComponentFromDouble(i,j,0,0,0);} // for i
86 if (bbGetInputTypeOrientation()==0) { xmin=0; xmax=x; ymin=y; ymax=dimY; }
87 if (bbGetInputTypeOrientation()==1) { xmin=0; xmax=x; ymin=0; ymax=dimY-z; }
88 if (bbGetInputTypeOrientation()==2) { xmin=0; xmax=y; ymin=0; ymax=dimY-z; }
89 for (j=ymin;j<ymax;j++){
90 for (i=xmin;i<xmax;i++){newData->SetScalarComponentFromDouble(i,j,0,0,0);} // for i
96 if (bbGetInputTypeOrientation()==0) { xmin=x; xmax=dimX; ymin=0; ymax=y; }
97 if (bbGetInputTypeOrientation()==1) { xmin=x; xmax=dimX; ymin=dimY-z; ymax=dimY; }
98 if (bbGetInputTypeOrientation()==2) { xmin=y; xmax=dimX; ymin=dimY-z; ymax=dimY; }
99 for (j=ymin;j<ymax;j++){
100 for (i=xmin;i<xmax;i++){newData->SetScalarComponentFromDouble(i,j,0,0,0);} // for i
106 if (bbGetInputTypeOrientation()==0) { xmin=x; xmax=dimX; ymin=y; ymax=dimY; }
107 if (bbGetInputTypeOrientation()==1) { xmin=x; xmax=dimX; ymin=0; ymax=dimY-z; }
108 if (bbGetInputTypeOrientation()==2) { xmin=y; xmax=dimX; ymin=0; ymax=dimY-z; }
109 for (j=ymin;j<ymax;j++){
110 for (i=xmin;i<xmax;i++){newData->SetScalarComponentFromDouble(i,j,0,0,0);} // for i
115 bbSetOutputOut( newData );
119 // 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)
121 void ImageCutByAxis::bbUserSetDefaultValues()
124 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
125 // Here we initialize the input 'In' to 0
127 bbSetInputType("x+y+z+");
128 bbSetInputInsideVol(true);
129 std::vector<int> point;
133 bbSetInputPoint(point);
136 // 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)
138 void ImageCutByAxis::bbUserInitializeProcessing()
141 // THE INITIALIZATION METHOD BODY :
143 // but this is where you should allocate the internal/output pointers
149 // 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)
151 void ImageCutByAxis::bbUserFinalizeProcessing()
154 // THE FINALIZATION METHOD BODY :
156 // but this is where you should desallocate the internal/output pointers
161 // EO namespace bbcreaVtk