]> Creatis software - creaVtk.git/commitdiff
box TurnImage manual matrix type -1
authoreduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Mon, 14 Apr 2025 08:30:05 +0000 (10:30 +0200)
committereduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Mon, 14 Apr 2025 08:30:05 +0000 (10:30 +0200)
bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.cxx
bbtk_creaVtk_PKG/src/bbcreaVtkTurnImage.h

index 7afd2e9f9bb4bc5b84c8d13061b2e76588406a93..2c3a8eca21f30b086301dbf05eb26990289e9389 100644 (file)
@@ -5,9 +5,8 @@
 #include "bbcreaVtkPackage.h"
 
 #include "creaVtk_MACROS.h"
-
-#include <vtkImageReslice.h>
 #include <vtkImageChangeInformation.h>
+#include <vtkImageReslice.h>
 
 namespace bbcreaVtk
 {
@@ -106,11 +105,26 @@ void TurnImage::Process()
          } // for k
          bbSetOutputOut(newImage);
         */
-        if ( (bbGetInputDir()==1) || (bbGetInputDir()==2) )
+        if ( (bbGetInputDir()>=-1) && (bbGetInputDir()<=5) )
         {
             vtkImageReslice             *reslice = vtkImageReslice::New();
             vtkImageChangeInformation   *mchange = vtkImageChangeInformation::New();
             // Reslice does all of the work.
+            if (  bbGetInputDir()==-1 )   // manual matrix
+            {
+
+                if (bbGetInputAxesDirectionCosines().size()==9)
+                {
+                    std::vector<double> v =bbGetInputAxesDirectionCosines();
+                     double axes[3][3] = { { v[0], v[1], v[2] }, { v[3], v[4], v[5] }, { v[6], v[7], v[8] } };
+                    reslice->SetResliceAxesDirectionCosines(axes[0], axes[1], axes[2]);
+                }
+            } // dir -1
+            if (  bbGetInputDir()==0 )   // nothing
+            {
+                static double axes[3][3] = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };
+                reslice->SetResliceAxesDirectionCosines(axes[0], axes[1], axes[2]);
+            } // dir 0
             if (  bbGetInputDir()==1 )
             {
                 static double axes[3][3] = { { 0, 1, 0 }, { 0, 0, -1 }, { 1, 0, 0 } };
@@ -121,10 +135,27 @@ void TurnImage::Process()
                 static double axes[3][3] = { { 1, 0, 0 }, { 0, 0, -1 }, { 0, 1, 0 } };
                 reslice->SetResliceAxesDirectionCosines(axes[0], axes[1], axes[2]);
             } // dir 2
+            if (  bbGetInputDir()==3 )
+            {
+                static double axes[3][3] = { { 0, 1, 0 }, { 1, 0, 0 }, { 0, 0, 1 } };
+                reslice->SetResliceAxesDirectionCosines(axes[0], axes[1], axes[2]);
+            } // dir 3
+            if (  bbGetInputDir()==4 ) // RY90
+            {
+                static double axes[3][3] = { { 0, 0, 1 }, { 0, 1, 0 }, { -1, 0, 0 } };
+                reslice->SetResliceAxesDirectionCosines(axes[0], axes[1], axes[2]);
+            } // dir 4
+            if (  bbGetInputDir()==5 ) // RY-90
+            {
+                static double axes[3][3] = { { 0, 0, -1 }, { 0, 1, 0 }, { 1, 0, 0 } };
+                reslice->SetResliceAxesDirectionCosines(axes[0], axes[1], axes[2]);
+            } // dir 5
             //         reslice->SetOutputOrigin(0,0,0);
+            bbGetInputIn()->Modified();
             reslice->SetInputData( bbGetInputIn() );
             reslice->SetResliceAxesOrigin( 0,0,0 );
             reslice->SetInterpolationModeToNearestNeighbor();
+            reslice->Modified();
             reslice->Update();
             mchange->SetInputData( reslice->GetOutput() );
             mchange->SetOutputOrigin( 0,0,0 );
@@ -132,8 +163,7 @@ void TurnImage::Process()
             bbSetOutputOut( mchange->GetOutput() );
         } else {
             bbSetOutputOut( bbGetInputIn() );
-        }// if Dir 1 or 2
-
+        }// if Dir -1..5
     } else {
         bbSetOutputOut(NULL);
     }// if In!=NULL
index 1f6d0f47bb5b2a8bca9ee493ebfe150f792fabf1..98eb49c8f97ec66a426e84b9c2265f329796c294 100644 (file)
@@ -24,10 +24,11 @@ class bbcreaVtk_EXPORT TurnImage
 //===== 
   BBTK_DECLARE_INPUT(In,vtkImageData*);
   BBTK_DECLARE_INPUT(Dir,int);
+  BBTK_DECLARE_INPUT(AxesDirectionCosines,std::vector<double>);
   BBTK_DECLARE_OUTPUT(Out,vtkImageData*);
   BBTK_PROCESS(Process);
   void Process();
-//===== 
+//=====
 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
 //===== 
 };
@@ -39,7 +40,8 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(TurnImage,bbtk::AtomicBlackBox);
   BBTK_CATEGORY("empty");
 
   BBTK_INPUT(TurnImage,In,"Input Image",vtkImageData*,"");
-  BBTK_INPUT(TurnImage,Dir,"(default 0) 0:XY(original)  1:YZ  2:XZ",int,"");
+  BBTK_INPUT(TurnImage,Dir,"(default 0) -1:Manual matrix  0:XY(original)  1:YZ  2:XZ 3:R180Z 4:RY90 5:RY-90",int,"");
+  BBTK_INPUT(TurnImage,AxesDirectionCosines,"AxesDirectionCosines  9 elements of a matrix3x3", std::vector<double> ,"");
 
   BBTK_OUTPUT(TurnImage,Out,"Output image",vtkImageData*,"");