From c0a5e4e1dd42160e0e69eb4f1081642c1a6913c6 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Wed, 7 Jul 2021 17:12:35 +0200 Subject: [PATCH] #3469 Transform box - Inverse option --- packages/vtk/src/bbvtkTransform.cxx | 20 +++++++++++++++++--- packages/vtk/src/bbvtkTransform.h | 5 ++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/packages/vtk/src/bbvtkTransform.cxx b/packages/vtk/src/bbvtkTransform.cxx index fd0d369..57c9c1f 100644 --- a/packages/vtk/src/bbvtkTransform.cxx +++ b/packages/vtk/src/bbvtkTransform.cxx @@ -68,6 +68,8 @@ namespace bbvtk bbUserFinalizeProcessing(); result = vtkTransform::New(); result->Update(); + resultInverse = vtkTransform::New(); + resultInverse->Update(); } // -------------------------------------------------------------- @@ -84,6 +86,8 @@ namespace bbvtk // -------------------------------------------------------------- void Transform::Process() { + printf("EED Transform::Process Start\n "); + bbUserInitializeProcessing(); if (bbGetInputIn()!=NULL) { @@ -108,7 +112,17 @@ namespace bbvtk result->RotateWXYZ(bbGetInputRotateWXYZ()[0],bbGetInputRotateWXYZ()[1], bbGetInputRotateWXYZ()[2], bbGetInputRotateWXYZ()[3]); } - bbSetOutputOut(result); + if (bbGetInputInverse()==false) + { + bbSetOutputOut(result); + } else { + vtkMatrix4x4 *matrix; + matrix=vtkMatrix4x4::New(); + result->GetInverse(matrix); + resultInverse->SetMatrix( matrix ); + bbSetOutputOut(resultInverse); + } // if Inverse + printf("EED Transform::Process End\n "); } -} -// EO namespace bbvtk + +}// EO namespace bbvtk diff --git a/packages/vtk/src/bbvtkTransform.h b/packages/vtk/src/bbvtkTransform.h index 7bd2dd5..618b0d3 100644 --- a/packages/vtk/src/bbvtkTransform.h +++ b/packages/vtk/src/bbvtkTransform.h @@ -41,6 +41,7 @@ namespace bbvtk public bbtk::AtomicBlackBox { BBTK_BLACK_BOX_INTERFACE(Transform,bbtk::AtomicBlackBox); + BBTK_DECLARE_INPUT(Inverse,bool); BBTK_DECLARE_INPUT(In,vtkLinearTransform *); BBTK_DECLARE_INPUT(Scale,std::vector); BBTK_DECLARE_INPUT(RotateWXYZ,std::vector); @@ -54,7 +55,8 @@ namespace bbvtk std::vector vecRotateWXYZ; std::vector vecTranslate; std::vector vecSpacing; - vtkTransform *result; + vtkTransform *result; + vtkTransform *resultInverse; }; BBTK_BEGIN_DESCRIBE_BLACK_BOX(Transform,bbtk::AtomicBlackBox); @@ -63,6 +65,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(Transform,bbtk::AtomicBlackBox); BBTK_DESCRIPTION("vtkTransform"); BBTK_CATEGORY("math"); + BBTK_INPUT(Transform,Inverse,"(default false) true/false",bool,""); BBTK_INPUT(Transform,In,"vtkTransform to be concatenate",vtkLinearTransform *,""); BBTK_INPUT(Transform,Scale,"vector with sx sy sz",std::vector,""); BBTK_INPUT(Transform,Translate,"vector with x y z",std::vector,""); -- 2.47.1