X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=packages%2Fvtk%2Fsrc%2FbbvtkInversCrop.cxx;h=29be94cabe1ed7bd18a5b9e3f2b6b89130773987;hb=19dda39fbfb4f8e1019c4f0dd37aa3afc8a3d1d6;hp=8581943820eb2e983ad2861975efcda79f2223cb;hpb=e269992d2d446784afc40073782311deaa25008f;p=bbtk.git diff --git a/packages/vtk/src/bbvtkInversCrop.cxx b/packages/vtk/src/bbvtkInversCrop.cxx index 8581943..29be94c 100644 --- a/packages/vtk/src/bbvtkInversCrop.cxx +++ b/packages/vtk/src/bbvtkInversCrop.cxx @@ -26,13 +26,15 @@ void InversCrop::Process() // * TYPE is the C++ type of the input/output // (the one provided in the attribute 'type' of the tag 'input') - if ((bbGetInputImageFix()!=NULL) && (bbGetInputImageMove()!=NULL) ) - { - if ( bbGetInputImageFix()->GetScalarType()==bbGetInputImageMove()->GetScalarType() ) - { - // Creating Image - int dim[3]; - int ext[6]; + if (bbGetInputActive()==true) + { + if ( (bbGetInputImageFix()!=NULL) && (bbGetInputImageMove()!=NULL) ) + { + if ( bbGetInputImageFix()->GetScalarType()==bbGetInputImageMove()->GetScalarType() ) + { + // Creating Image + int dim[3]; + int ext[6]; //EED 2017-01-01 Migration VTK7 #if (VTK_MAJOR_VERSION <= 5) @@ -111,21 +113,75 @@ void InversCrop::Process() (py>=0) && (pz>=0) && (sizeXM>0) ) { - memcpy( _imageoutput->GetScalarPointer(px,py,pz) , bbGetInputImageMove()->GetScalarPointer(spxM,j,k) , sizeXM ); + _imageoutput = vtkImageData::New(); + _imageoutput->Initialize(); + _imageoutput->SetScalarType( bbGetInputImageFix()->GetScalarType() ); + _imageoutput->SetSpacing( bbGetInputImageFix()->GetSpacing() ); + _imageoutput->SetDimensions( dim[0], dim[1], dim[2] ); + _imageoutput->AllocateScalars(); + // Duplicating Fix Image + long sizeimage = dim[0]*dim[1]*dim[2]*bbGetInputImageFix()->GetScalarSize(); + memcpy( _imageoutput->GetScalarPointer() , bbGetInputImageFix()->GetScalarPointer() , sizeimage); + } + if (bbGetInputType()==1) + { + _imageoutput=bbGetInputImageFix(); } - } // for j - } // for k - _imageoutput->Modified(); - } // If Image Fixe Move the same GetScalarType - else { - printf ("ERROR: InversCrop both ImageFixe and ImageMove need the same format.\n"); - } - } // If Image Fixe Move != NULL - else { - printf ("ERROR: InversCrop need ImageFixe and ImageMove to run.\n"); - } - bbSetOutputOut(_imageoutput); + + + // Copy the Move Image + int j,k; + int px,py,pz; + + bbGetInputImageMove()->GetWholeExtent(ext); + int dimMoveX = ext[1]-ext[0]+1; + int dimMoveY = ext[3]-ext[2]+1; + int dimMoveZ = ext[5]-ext[4]+1; + + int spxM = 0; // start px MoveImage + int sizeXM = 0; // sizeX MoveImage + + px = bbGetInputOrigin()[0]; + spxM = 0; + if (px<0) + { + spxM=px*(-1); + px=0; + } + sizeXM = dimMoveX-spxM; + if (px+sizeXM>=dim[0]) sizeXM=dim[0]-px; + sizeXM=sizeXM*bbGetInputImageFix()->GetScalarSize(); + for (k=0; k=0) && (pz>=0) && + (sizeXM>0) ) + { + memcpy( _imageoutput->GetScalarPointer(px,py,pz) , bbGetInputImageMove()->GetScalarPointer(spxM,j,k) , sizeXM ); + } + + } // for j + } // for k + _imageoutput->Modified(); + } // If Image Fixe Move the same GetScalarType + else { + printf ("ERROR: InversCrop both ImageFixe and ImageMove need the same format.\n"); + printf (" type ImageFix:%d type ImageMove:%d\n", bbGetInputImageFix()->GetScalarType(), bbGetInputImageMove()->GetScalarType() ); + + } + } // If Image Fixe Move != NULL + else { + printf ("ERROR: InversCrop need ImageFixe and ImageMove to run.\n"); + } + bbSetOutputOut(_imageoutput); + + } // if Active + } //===== @@ -133,19 +189,17 @@ void InversCrop::Process() //===== void InversCrop::bbUserSetDefaultValues() { - // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 + bbSetInputActive(true); bbSetInputType(0); bbSetInputImageFix(NULL); bbSetInputImageMove(NULL); - std::vector origin; origin.push_back(0); origin.push_back(0); origin.push_back(0); bbSetInputOrigin(origin); - _imageoutput=NULL; } //=====