#include "bbcreaVtkPackage.h"
#include "creaVtk_MACROS.h"
-
-#include <vtkImageReslice.h>
#include <vtkImageChangeInformation.h>
+#include <vtkImageReslice.h>
namespace bbcreaVtk
{
} // 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 } };
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 );
bbSetOutputOut( mchange->GetOutput() );
} else {
bbSetOutputOut( bbGetInputIn() );
- }// if Dir 1 or 2
-
+ }// if Dir -1..5
} else {
bbSetOutputOut(NULL);
}// if In!=NULL
//=====
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)
//=====
};
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*,"");