From 9ce7b1159290d46aa6e38c4706d3fe5435d80508 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Tue, 27 Jun 2023 15:48:28 +0200 Subject: [PATCH] Clean code --- packages/vtk/src/bbvtkBinaryOperations.cxx | 72 +++++++++++++--------- packages/vtk/src/bbvtkBinaryOperations.h | 2 +- 2 files changed, 43 insertions(+), 31 deletions(-) diff --git a/packages/vtk/src/bbvtkBinaryOperations.cxx b/packages/vtk/src/bbvtkBinaryOperations.cxx index b308540..745b9c1 100644 --- a/packages/vtk/src/bbvtkBinaryOperations.cxx +++ b/packages/vtk/src/bbvtkBinaryOperations.cxx @@ -78,36 +78,48 @@ void BinaryOperations::Process() bbSetOutputOut(NULL); return; } - switch (bbGetInputOperation()) - { - case 0: - ope->SetOperationToAdd(); - break; - case 1: - ope->SetOperationToSubtract(); - - break; - case 2: - ope->SetOperationToMultiply(); - break; - case 3: - ope->SetOperationToDivide(); - break; - case 4: - ope->SetOperationToMax(); - break; - case 5: - ope->SetOperationToMin(); - break; - default: - std::cout << "Invalid Operation" << std::endl; - return; - break; - } - ope->Modified(); - ope->Update(); - vtkImageData* salida = ope->GetOutput(); - bbSetOutputOut(salida); + + if ( (bbGetInputOperation()>=0) && (bbGetInputOperation()<=5) ) + { + switch (bbGetInputOperation()) + { + case 0: + ope->SetOperationToAdd(); + break; + case 1: + ope->SetOperationToSubtract(); + break; + case 2: + ope->SetOperationToMultiply(); + break; + case 3: + ope->SetOperationToDivide(); + break; + case 4: + ope->SetOperationToMax(); + break; + case 5: + ope->SetOperationToMin(); + break; + default: + std::cout << "Invalid Operation" << std::endl; + return; + break; + } + ope->Modified(); + ope->Update(); + bbSetOutputOut( ope->GetOutput() ); + } // if operation 0..5 + + if ( bbGetInputOperation()==6 ) + { + bbSetOutputOut( bbGetInputIn1() ); + } + if ( bbGetInputOperation()==7 ) + { + bbSetOutputOut( bbGetInputIn2() ); + } + // bbSignalOutputModification(); } diff --git a/packages/vtk/src/bbvtkBinaryOperations.h b/packages/vtk/src/bbvtkBinaryOperations.h index 41f29e4..49db6b1 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",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",int,""); BBTK_OUTPUT(BinaryOperations,Out,"",vtkImageData*,""); BBTK_END_DESCRIBE_BLACK_BOX(BinaryOperations); } -- 2.47.1