//===== // 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) //===== #include "bbcreaVtkImageCutByAxis.h" #include "bbcreaVtkPackage.h" namespace bbcreaVtk { BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ImageCutByAxis) BBTK_BLACK_BOX_IMPLEMENTATION(ImageCutByAxis,bbtk::AtomicBlackBox); //===== // 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) //===== void ImageCutByAxis::Process() { // THE MAIN PROCESSING METHOD BODY // Here we simply set the input 'In' value to the output 'Out' // And print out the output value // INPUT/OUTPUT ACCESSORS ARE OF THE FORM : // void bbSet{Input|Output}NAME(const TYPE&) // const TYPE& bbGet{Input|Output}NAME() const // Where : // * NAME is the name of the input/output // (the one provided in the attribute 'name' of the tag 'input') // * TYPE is the C++ type of the input/output // (the one provided in the attribute 'type' of the tag 'input') // bbSetOutputOut( bbGetInputIn() ); // std::cout << "Output value = " <DeepCopy( bbGetInputIn() ); int ext[6]; //EED 2017-01-01 Migration VTK7 #if VTK_MAJOR_VERSION <= 5 bbGetInputIn()->GetWholeExtent(ext); #else bbGetInputIn()->GetExtent(ext); #endif double dimX = ext[1]-ext[0]+1; double dimY = ext[3]-ext[2]+1; double dimZ = ext[5]-ext[4]+1; int x = bbGetInputPoint()[0]; int y = bbGetInputPoint()[1]; int z = bbGetInputPoint()[2]; int i,j,k; bool c1=false; bool c2=false; bool c3=false; bool c4=false; bool c5=false; bool c6=false; bool c7=false; bool c8=false; if ( bbGetInputType()=="x-y-z+" ) { if (bbGetInputTypeOrientation()==0) { c1=false; c2=true; c3=true; c4=true; } if (bbGetInputTypeOrientation()==1) { c1=true; c2=false; c3=true; c4=true; } if (bbGetInputTypeOrientation()==2) { c1=true; c2=false; c3=true; c4=true; } if (bbGetInputTypeOrientation()==3) { c1=false; c2=true; c3=true; c4=true; } } if ( bbGetInputType()=="x+y+z+" ) { if (bbGetInputTypeOrientation()==3) { c1=false; c2=false; c3=false; c4=false; c5=true; c6=false; c7=false; c8=false; } } if (bbGetInputInsideVol()==true) { c1=!c1; c2=!c2; c3=!c3; c4=!c4; } // IndideVol printf("EED ImageCutByAxis::Process\n"); if (c1==true) printf("EED ImageCutByAxis::Process flag 1\n"); if (c2==true) printf("EED ImageCutByAxis::Process flag 2\n"); if (c3==true) printf("EED ImageCutByAxis::Process flag 3\n"); if (c4==true) printf("EED ImageCutByAxis::Process flag 4\n"); int xmin,xmax,ymin,ymax,zmin,zmax; // void *imgPtr; // imgPtr=bbGetInputIn()->GetScalarPointer(x,y,z,0); // memset( bbGetInputIn()->GetScalarPointer() ); if (c1==true) { if (bbGetInputTypeOrientation()==0) { xmin=0; xmax=x; ymin=0; ymax=y; zmin=0; zmax=1; } if (bbGetInputTypeOrientation()==1) { xmin=0; xmax=x; ymin=dimY-z; ymax=dimY; zmin=0; zmax=1; } if (bbGetInputTypeOrientation()==2) { xmin=0; xmax=y; ymin=dimY-z; ymax=dimY; zmin=0; zmax=1; } if (bbGetInputTypeOrientation()==3) { xmin=0; xmax=x; ymin=0; ymax=y; zmin=0; zmax=z; } // xyz printf("EED ImageCutByAxis::Process x=%d %d y= %d %d z=%d %d\n", xmin,xmax , ymin,ymax, zmin,zmax ); for (k=zmin;kSetScalarComponentFromDouble(i,j,k,0,0);} // for i } // for j } // for k } // c1 if (c2==true) { if (bbGetInputTypeOrientation()==0) { xmin=0; xmax=x; ymin=y; ymax=dimY; } if (bbGetInputTypeOrientation()==1) { xmin=0; xmax=x; ymin=0; ymax=dimY-z; } if (bbGetInputTypeOrientation()==2) { xmin=0; xmax=y; ymin=0; ymax=dimY-z; } if (bbGetInputTypeOrientation()==3) { xmin=0; xmax=x; ymin=y; ymax=dimY; } for (j=ymin;jSetScalarComponentFromDouble(i,j,0,0,0);} // for i } // for j } //c2 if (c3==true) { if (bbGetInputTypeOrientation()==0) { xmin=x; xmax=dimX; ymin=0; ymax=y; } if (bbGetInputTypeOrientation()==1) { xmin=x; xmax=dimX; ymin=dimY-z; ymax=dimY; } if (bbGetInputTypeOrientation()==2) { xmin=y; xmax=dimX; ymin=dimY-z; ymax=dimY; } if (bbGetInputTypeOrientation()==3) { xmin=x; xmax=dimX; ymin=0; ymax=y; } for (j=ymin;jSetScalarComponentFromDouble(i,j,0,0,0);} // for i } // for j } //c3 if (c4==true) { if (bbGetInputTypeOrientation()==0) { xmin=x; xmax=dimX; ymin=y; ymax=dimY; } if (bbGetInputTypeOrientation()==1) { xmin=x; xmax=dimX; ymin=0; ymax=dimY-z; } if (bbGetInputTypeOrientation()==2) { xmin=y; xmax=dimX; ymin=0; ymax=dimY-z; } if (bbGetInputTypeOrientation()==3) { xmin=x; xmax=dimX; ymin=y; ymax=dimY; } for (j=ymin;jSetScalarComponentFromDouble(i,j,0,0,0);} // for i } // for j } //c4 if (c5==true) { if (bbGetInputTypeOrientation()==0) { xmin=0; xmax=x; ymin=0; ymax=y; zmin=0; zmax=1; } if (bbGetInputTypeOrientation()==1) { xmin=0; xmax=x; ymin=dimY-z; ymax=dimY; zmin=0; zmax=1; } if (bbGetInputTypeOrientation()==2) { xmin=0; xmax=y; ymin=dimY-z; ymax=dimY; zmin=0; zmax=1; } if (bbGetInputTypeOrientation()==3) { xmin=x; xmax=dimX; ymin=y; ymax=dimY; zmin=z; zmax=dimZ; } // xyz printf("EED ImageCutByAxis::Process x=%d %d y= %d %d z=%d %d\n", xmin,xmax , ymin,ymax, zmin,zmax ); for (k=zmin;kSetScalarComponentFromDouble(i,j,k,0,0);} // for i } // for j } // for k } // c1 newData->Modified(); bbSetOutputOut( newData ); } //===== // 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) //===== void ImageCutByAxis::bbUserSetDefaultValues() { // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 bbSetInputIn(NULL); bbSetInputType("x-y-z+"); bbSetInputInsideVol(true); std::vector point; point.push_back(0); point.push_back(0); point.push_back(0); bbSetInputPoint(point); } //===== // 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) //===== void ImageCutByAxis::bbUserInitializeProcessing() { // THE INITIALIZATION METHOD BODY : // Here does nothing // but this is where you should allocate the internal/output pointers // if any } //===== // 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) //===== void ImageCutByAxis::bbUserFinalizeProcessing() { // THE FINALIZATION METHOD BODY : // Here does nothing // but this is where you should desallocate the internal/output pointers // if any } } // EO namespace bbcreaVtk