]> Creatis software - bbtk.git/commitdiff
#3517 Transform box with manual matrix
authoreduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Wed, 8 May 2024 07:27:21 +0000 (09:27 +0200)
committereduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Wed, 8 May 2024 07:27:21 +0000 (09:27 +0200)
packages/std/src/bbstdMagicBox.h
packages/vtk/src/bbvtkTransform.cxx
packages/vtk/src/bbvtkTransform.h

index 99d27e872937bd25399a12388379f56eb1ead0e5..20c964f72f4178e5d8d5a8013aaffc3598bded2b 100644 (file)
@@ -117,7 +117,7 @@ namespace bbstd
     (&MagicBox::bbGetInputIn),
     new MagicBoxSetFunctor (&MagicBox::bbSetInputIn) ) );
 
-  BBTK_INPUT(MagicBox, Active, "Active True/False (default True)",bool,"");  
+  BBTK_INPUT(MagicBox, Active, "(default True) Active True/False",bool,"");  
 
 
   AddOutputDescriptor
index 8b71e0052137ffced07620883c868fcabab315e4..1b29f8b33f29ea910afc72bc93f180de6ad6f3ee 100644 (file)
 
 #include "bbvtkTransform.h"
 #include "bbvtkPackage.h"
+
 #include "vtkMath.h"
+#include "vtkMatrix4x4.h"
+
 namespace bbvtk
 {
   BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,Transform);
@@ -130,16 +133,48 @@ namespace bbvtk
           result->RotateWXYZ( ang  , v3[0], v3[1], v3[2] );
       } // if rotation size >=4
 
+      if (bbGetInputManualMatrixIn().size()==16)
+      {
+          std::vector<double> manaulMatrixIn = bbGetInputManualMatrixIn();
+          vtkMatrix4x4* m = result->GetMatrix();
+          int i,j,ii=0;
+          for (j=0;j<4;j++)
+          {
+              for (i=0;i<4;i++)
+              {
+                  m->SetElement(i,j,manaulMatrixIn[ii]);
+                  ii++;
+              }// for i
+          } // for j
+          m->Modified();
+          result->Update();
+      } // ManualMatrix
+      
+      vtkTransform * finalTransform;
          if (bbGetInputInverse()==false)
          {
-               bbSetOutputOut(result);
+        finalTransform = result;
          } else {
                vtkMatrix4x4 *matrix;
                matrix=vtkMatrix4x4::New();
                result->GetInverse(matrix);
                resultInverse->SetMatrix( matrix );
-               bbSetOutputOut(resultInverse);
+               finalTransform = resultInverse;
          }  // if Inverse
+      
+      bbSetOutputOut(finalTransform);
+
+      std::vector<double> manualMatrixOut;
+      vtkMatrix4x4* m = finalTransform->GetMatrix();
+      int i,j,ii=0;
+      for (j=0;j<4;j++)
+      {
+          for (i=0;i<4;i++)
+          {
+              manualMatrixOut.push_back( m->GetElement(i,j) );
+          }// for i
+      } // for j
+      bbSetOutputManualMatrixOut( manualMatrixOut );
   }
   
 }// EO namespace bbvtk
index 46e1c766c6c83da018be478fd8bf05f3bfa6bca8..2a8d0cd7886accf5438c5e6c5083e88630ad2a92 100644 (file)
@@ -48,7 +48,9 @@ namespace bbvtk
     BBTK_DECLARE_INPUT(Translate,std::vector<double>);
     BBTK_DECLARE_INPUT(Spacing,std::vector<double>);
     BBTK_DECLARE_INPUT(RotateToNormal,std::vector<double>);
+    BBTK_DECLARE_INPUT(ManualMatrixIn,std::vector<double>);
     BBTK_DECLARE_OUTPUT(Out,vtkLinearTransform *);
+    BBTK_DECLARE_OUTPUT(ManualMatrixOut,std::vector<double>);
     BBTK_PROCESS(Process);
     void Process();
     
@@ -73,8 +75,10 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(Transform,bbtk::AtomicBlackBox);
   BBTK_INPUT(Transform,Spacing,"vector with spacingX spacingY spacingZ",std::vector<double>,"");
   BBTK_INPUT(Transform,RotateWXYZ,"vector with Angle Vx Vy Vz",std::vector<double>,"");
   BBTK_INPUT(Transform,RotateToNormal,"(default is EMPTY) Normal vector [nx,ny,nz]",std::vector<double>,"");
+  BBTK_INPUT(Transform,ManualMatrixIn,"(default EMPTY) The 16 elements of a 4x4 matrix",std::vector<double>,"");
 
   BBTK_OUTPUT(Transform,Out,"vtkTransform result",vtkLinearTransform *,"");
+  BBTK_OUTPUT(Transform,ManualMatrixOut,"The 16 elements of the 4x4 matrix",std::vector<double>,"");
 
 BBTK_END_DESCRIBE_BLACK_BOX(Transform);
 }