]> Creatis software - bbtk.git/commitdiff
#3469 Transform box - Inverse option
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Wed, 7 Jul 2021 15:12:35 +0000 (17:12 +0200)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Wed, 7 Jul 2021 15:12:35 +0000 (17:12 +0200)
packages/vtk/src/bbvtkTransform.cxx
packages/vtk/src/bbvtkTransform.h

index fd0d369cde740fa8a3318d603806dec4422732cf..57c9c1fe45e3be75adeb69811b4815ccf3a4242e 100644 (file)
@@ -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
index 7bd2dd513440449c49cbf37437c11d345ba9368f..618b0d357235667f39c22af6316027a15aa3ca14 100644 (file)
@@ -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<double>);
     BBTK_DECLARE_INPUT(RotateWXYZ,std::vector<double>);
@@ -54,7 +55,8 @@ namespace bbvtk
     std::vector<double>                vecRotateWXYZ;
     std::vector<double>                vecTranslate;
     std::vector<double>                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<double>,"");
   BBTK_INPUT(Transform,Translate,"vector with x y z",std::vector<double>,"");