From e608b1f48e18f9f781e480900885dc2676cc78ab Mon Sep 17 00:00:00 2001 From: "eduardo.davila@creatis.insa-lyon.fr" Date: Mon, 21 Oct 2024 11:29:10 +0200 Subject: [PATCH] #3524 DeepCoppy in vtkBinaryOperation box --- packages/vtk/src/bbvtkBinaryOperations.cxx | 102 +++++++++++++++------ packages/vtk/src/bbvtkBinaryOperations.h | 2 +- 2 files changed, 73 insertions(+), 31 deletions(-) diff --git a/packages/vtk/src/bbvtkBinaryOperations.cxx b/packages/vtk/src/bbvtkBinaryOperations.cxx index d6812ae..480534d 100644 --- a/packages/vtk/src/bbvtkBinaryOperations.cxx +++ b/packages/vtk/src/bbvtkBinaryOperations.cxx @@ -49,43 +49,47 @@ void BinaryOperations::Process() if (bbGetInputIn1() == NULL) { - printf( "EED Warning!!! (%s) BinaryOperations::Process Set In1 at least", bbGetFullName().c_str() ); + printf( "EED Warning!!! (%s) BinaryOperations::Process Set In1 at least \n", bbGetFullName().c_str() ); bbSetOutputOut(NULL); return; } - if (ope!=NULL) - { - ope->Delete(); - ope = NULL; - } // if - ope = vtkImageMathematics::New(); - - //EED 2017-01-01 Migration VTK7 -#if (VTK_MAJOR_VERSION <= 5) - ope->SetInput1((vtkDataObject*)bbGetInputIn1()); -#endif -#if (VTK_MAJOR_VERSION >= 6) - ope->SetInput1Data((vtkDataObject*)bbGetInputIn1()); -#endif - - if (bbGetInputIn2() != NULL) - { - //EED 2017-01-01 Migration VTK7 -#if (VTK_MAJOR_VERSION <= 5) - ope->SetInput2((vtkDataObject*)bbGetInputIn2()); -#endif -#if (VTK_MAJOR_VERSION >= 6) - ope->SetInput2Data((vtkDataObject*)bbGetInputIn2()); -#endif - } else { - printf( "EED Warning!!! (%s) BinaryOperations::Process Set In2 at least", bbGetFullName().c_str() ); - bbSetOutputOut(NULL); - return; - } if ( (bbGetInputOperation()>=0) && (bbGetInputOperation()<=5) ) { + + + if (ope!=NULL) + { + ope->Delete(); + ope = NULL; + } // if + ope = vtkImageMathematics::New(); + + //EED 2017-01-01 Migration VTK7 + #if (VTK_MAJOR_VERSION <= 5) + ope->SetInput1((vtkDataObject*)bbGetInputIn1()); + #endif + #if (VTK_MAJOR_VERSION >= 6) + ope->SetInput1Data((vtkDataObject*)bbGetInputIn1()); + #endif + + + if (bbGetInputIn2() != NULL) + { + //EED 2017-01-01 Migration VTK7 + #if (VTK_MAJOR_VERSION <= 5) + ope->SetInput2((vtkDataObject*)bbGetInputIn2()); + #endif + #if (VTK_MAJOR_VERSION >= 6) + ope->SetInput2Data((vtkDataObject*)bbGetInputIn2()); + #endif + } else { + printf( "EED Warning!!! (%s) BinaryOperations::Process Set In2 at least \n", bbGetFullName().c_str() ); + bbSetOutputOut(NULL); + return; + } + switch ( bbGetInputOperation() ) { case 0: @@ -124,6 +128,44 @@ void BinaryOperations::Process() { bbSetOutputOut( bbGetInputIn2() ); } + if ( bbGetInputOperation()==8 ) + { + if (bbGetInputIn1()!=NULL) + { + if (bbGetInputIn2()==NULL) + { + int ext[6]; + bbGetInputIn1()->GetExtent(ext); + int dimX = ext[1]-ext[0] + 1; + int dimY = ext[3]-ext[2] + 1; + int dimZ = ext[5]-ext[4] + 1; + int scalarSize = bbGetInputIn1()->GetScalarSize(); + long int size = dimX * dimY * dimZ *scalarSize; + memset ( bbGetInputIn1()->GetScalarPointer(), 0 , size ); + } else { + /* + int ext[6]; + bbGetInputIn1()->GetExtent(ext); + int dimX1 = ext[1]-ext[0] + 1; + int dimY1 = ext[3]-ext[2] + 1; + int dimZ1 = ext[5]-ext[4] + 1; + int scalarSize1 = bbGetInputIn1()->GetScalarSize(); + bbGetInputIn2()->GetExtent(ext); + int dimX2 = ext[1]-ext[0] + 1; + int dimY2 = ext[3]-ext[2] + 1; + int dimZ2 = ext[5]-ext[4] + 1; + int scalarSize2 = bbGetInputIn1()->GetScalarSize(); + long int size = dimX1 * dimY1 * dimZ1 * scalarSize1; + if ((dimX1==dimX2) && (dimY1==dimY2) && (dimZ1==dimZ2) && (scalarSize1==scalarSize2)) + { + memcpy( bbGetInputIn1()->GetScalarPointer(), bbGetInputIn2()->GetScalarPointer() , size ); + } // if dim size + */ + bbGetInputIn1()->DeepCopy( bbGetInputIn2() ); + } // if In2 + } // if In1 + bbSetOutputOut( bbGetInputIn1() ); + } // Operation 8 // bbSignalOutputModification(); } diff --git a/packages/vtk/src/bbvtkBinaryOperations.h b/packages/vtk/src/bbvtkBinaryOperations.h index 49db6b1..ca684be 100644 --- a/packages/vtk/src/bbvtkBinaryOperations.h +++ b/packages/vtk/src/bbvtkBinaryOperations.h @@ -73,7 +73,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(BinaryOperations,bbtk::AtomicBlackBox); BBTK_CATEGORY("filter"); BBTK_INPUT(BinaryOperations,In1,"first image to be operated",vtkImageData*,"NULL default"); BBTK_INPUT(BinaryOperations,In2,"second image to be operated",vtkImageData*,"NULL default"); - BBTK_INPUT(BinaryOperations,Operation,"0:Add (default) , 1:subtract, 2:multiply, 3:divide, 4=Max, 5=Min, 6=Replace with In1, 7=Replace with In2",int,""); + BBTK_INPUT(BinaryOperations,Operation,"0:Add (default) , 1:subtract, 2:multiply, 3:divide, 4=Max, 5=Min, 6=Replace with In1, 7=Replace with In2, 8=DeepCopy de In2 to In1 (output In1)",int,""); BBTK_OUTPUT(BinaryOperations,Out,"",vtkImageData*,""); BBTK_END_DESCRIBE_BLACK_BOX(BinaryOperations); } -- 2.46.2