X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=packages%2Fvtk%2Fsrc%2FbbvtkInversCrop.cxx;h=68b2b1c4797895febcef1449f6f40a6a74030f32;hb=879c32e4e9dab882f99c737dc8ec1d82327a36e9;hp=29be94cabe1ed7bd18a5b9e3f2b6b89130773987;hpb=19dda39fbfb4f8e1019c4f0dd37aa3afc8a3d1d6;p=bbtk.git diff --git a/packages/vtk/src/bbvtkInversCrop.cxx b/packages/vtk/src/bbvtkInversCrop.cxx index 29be94c..68b2b1c 100644 --- a/packages/vtk/src/bbvtkInversCrop.cxx +++ b/packages/vtk/src/bbvtkInversCrop.cxx @@ -26,6 +26,8 @@ void InversCrop::Process() // * TYPE is the C++ type of the input/output // (the one provided in the attribute 'type' of the tag 'input') +printf("\n\n EED InversCrop::Process Start \n" ); + if (bbGetInputActive()==true) { if ( (bbGetInputImageFix()!=NULL) && (bbGetInputImageMove()!=NULL) ) @@ -43,82 +45,32 @@ void InversCrop::Process() #if (VTK_MAJOR_VERSION >= 6) bbGetInputImageFix()->GetExtent(ext); #endif - dim[0]= ext[1]-ext[0]+1; - dim[1]= ext[3]-ext[2]+1; - dim[2]= ext[5]-ext[4]+1; - - if (bbGetInputType()==0) - { - _imageoutput = vtkImageData::New(); - _imageoutput->Initialize(); - _imageoutput->SetSpacing( bbGetInputImageFix()->GetSpacing() ); - _imageoutput->SetDimensions( dim[0], dim[1], dim[2] ); -//EED 2017-01-01 Migration VTK7 -#if (VTK_MAJOR_VERSION <= 5) - _imageoutput->SetScalarType( bbGetInputImageFix()->GetScalarType() ); - _imageoutput->AllocateScalars(); -#endif -#if (VTK_MAJOR_VERSION >= 6) - _imageoutput->AllocateScalars(bbGetInputImageFix()->GetScalarType() , 1); -#endif - } - if (bbGetInputType()==1) - { - _imageoutput=bbGetInputImageFix(); - } - - - // Duplicating Fix Image - long sizeimage = dim[0]*dim[1]*dim[2]*bbGetInputImageFix()->GetScalarSize(); - memcpy( _imageoutput->GetScalarPointer() , bbGetInputImageFix()->GetScalarPointer() , sizeimage); - - // Copy the Move Image - int j,k; - int px,py,pz; - -//EED 2017-01-01 Migration VTK7 -#if (VTK_MAJOR_VERSION <= 5) - bbGetInputImageMove()->GetWholeExtent(ext); -#endif -#if (VTK_MAJOR_VERSION >= 6) - bbGetInputImageMove()->GetExtent(ext); -#endif - - 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; kGetDataDimension()==3) + { + dim[2] = ext[5]-ext[4]+1; + } - if ( (py=0) && (pz>=0) && - (sizeXM>0) ) +printf("EED InversCrop::Process 1 %d\n", bbGetInputImageFix()->GetDataDimension() ); +printf("EED InversCrop::Process 2 %d %d %d \n",dim[0],dim[1],dim[2] ); + + if (bbGetInputType()==0) { _imageoutput = vtkImageData::New(); _imageoutput->Initialize(); - _imageoutput->SetScalarType( bbGetInputImageFix()->GetScalarType() ); _imageoutput->SetSpacing( bbGetInputImageFix()->GetSpacing() ); - _imageoutput->SetDimensions( dim[0], dim[1], dim[2] ); + _imageoutput->SetDimensions( dim[0], dim[1], dim[2] ); +//EED 2017-01-01 Migration VTK7 +#if (VTK_MAJOR_VERSION <= 5) + _imageoutput->SetScalarType( bbGetInputImageFix()->GetScalarType() ); _imageoutput->AllocateScalars(); +#endif +#if (VTK_MAJOR_VERSION >= 6) + _imageoutput->AllocateScalars(bbGetInputImageFix()->GetScalarType() , 1); +#endif + // Duplicating Fix Image long sizeimage = dim[0]*dim[1]*dim[2]*bbGetInputImageFix()->GetScalarSize(); memcpy( _imageoutput->GetScalarPointer() , bbGetInputImageFix()->GetScalarPointer() , sizeimage); @@ -128,36 +80,48 @@ void InversCrop::Process() _imageoutput=bbGetInputImageFix(); } - - // Copy the Move Image int j,k; int px,py,pz; +//EED 2017-01-01 Migration VTK7 +#if (VTK_MAJOR_VERSION <= 5) bbGetInputImageMove()->GetWholeExtent(ext); +#endif +#if (VTK_MAJOR_VERSION >= 6) + bbGetInputImageMove()->GetExtent(ext); +#endif int dimMoveX = ext[1]-ext[0]+1; int dimMoveY = ext[3]-ext[2]+1; - int dimMoveZ = ext[5]-ext[4]+1; + int dimMoveZ = 1; + if (bbGetInputImageMove()->GetDataDimension()==3) + { + dimMoveZ = ext[5]-ext[4]+1; + } + + printf("EED InversCrop::Process 3 %d %d %d \n",dimMoveX,dimMoveY,dimMoveZ ); + + + int spxM = 0; // start px MoveImage int sizeXM = 0; // sizeX MoveImage - px = bbGetInputOrigin()[0]; spxM = 0; if (px<0) { - spxM=px*(-1); - px=0; + spxM = px*(-1); + px = 0; } sizeXM = dimMoveX-spxM; if (px+sizeXM>=dim[0]) sizeXM=dim[0]-px; - sizeXM=sizeXM*bbGetInputImageFix()->GetScalarSize(); + sizeXM = sizeXM * bbGetInputImageFix()->GetScalarSize(); for (k=0; k=0) && (pz>=0) && (sizeXM>0) ) @@ -168,19 +132,18 @@ void InversCrop::Process() } // for j } // for k _imageoutput->Modified(); - } // If Image Fixe Move the same GetScalarType - else { + } else { // If Image Fixe Move the same GetScalarType 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); + } else { // If Image Fixe Move != NULL + printf ("ERROR: InversCrop need ImageFixe and ImageMove to run.\n"); + } + bbSetOutputOut(_imageoutput); } // if Active +printf("EED InversCrop::Process End \n" ); }