#include "bbvtkTransform.h"
#include "bbvtkPackage.h"
+#include "vtkMath.h"
namespace bbvtk
{
BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,Transform);
vecSpacing.push_back(1); //spacing y
vecSpacing.push_back(1); //spacing z
bbSetInputSpacing(vecSpacing);
-
- result = NULL;
+
+ result = NULL;
}
// --------------------------------------------------------------
result->RotateWXYZ(bbGetInputRotateWXYZ()[0],bbGetInputRotateWXYZ()[1], bbGetInputRotateWXYZ()[2], bbGetInputRotateWXYZ()[3]);
} // if rotation size >=4
+ if (bbGetInputRotateToNormal().size()>=3)
+ {
+ double v1[3],v2[3],v3[3];
+ v1[0] = 0;
+ v1[1] = 0;
+ v1[2] = 1;
+ v2[0] = bbGetInputRotateToNormal()[0];
+ v2[1] = bbGetInputRotateToNormal()[1];
+ v2[2] = bbGetInputRotateToNormal()[2];
+ vtkMath *vtkmath = vtkMath::New();
+ double ang = acos ( vtkmath->Dot(v1,v2) );
+ ang = vtkmath->DegreesFromRadians( ang );
+ vtkmath->Cross( v1,v2,v3 );
+ vtkmath->Delete();
+ result->RotateWXYZ( ang , v3[0], v3[1], v3[2] );
+ } // if rotation size >=4
+
if (bbGetInputInverse()==false)
{
bbSetOutputOut(result);
BBTK_DECLARE_INPUT(RotateWXYZ,std::vector<double>);
BBTK_DECLARE_INPUT(Translate,std::vector<double>);
BBTK_DECLARE_INPUT(Spacing,std::vector<double>);
+ BBTK_DECLARE_INPUT(RotateToNormal,std::vector<double>);
BBTK_DECLARE_OUTPUT(Out,vtkLinearTransform *);
BBTK_PROCESS(Process);
void Process();
BBTK_INPUT(Transform,Translate,"vector with x y z",std::vector<double>,"");
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_OUTPUT(Transform,Out,"vtkTransform result",vtkLinearTransform *,"");