From 79c2db16fed4560c62c91127e2ea4a882d162cd7 Mon Sep 17 00:00:00 2001 From: trillos Date: Mon, 16 Nov 2009 09:02:18 +0000 Subject: [PATCH] Added transform3D library classes --- lib/Transformer3D.cxx | 68 +++++++++++++++++++++++++++++++++++++++++++ lib/Transformer3D.h | 23 +++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 lib/Transformer3D.cxx create mode 100644 lib/Transformer3D.h diff --git a/lib/Transformer3D.cxx b/lib/Transformer3D.cxx new file mode 100644 index 0000000..2cdbabb --- /dev/null +++ b/lib/Transformer3D.cxx @@ -0,0 +1,68 @@ + +#include "Transformer3D.h" +#include "vtkMatrix4x4.h" + +/* + CONSTRUCTOR: Initializes the two points with empty vectors, the angle in 0. +*/ +Transformer3D::Transformer3D() +{ + std::vector empty (3,0); + _centerPoint=empty; + //If the transform already exists, we delete it before we create a new transform + //and set the matrix with the identity matrix + _transform= vtkTransform::New(); + vtkMatrix4x4 *_matrix = vtkMatrix4x4::New(); + _matrix->Identity(); + _transform->SetMatrix(_matrix); + +} + +/* + DESTRUCTOR +*/ +Transformer3D::~Transformer3D() +{ + //We delete the existing transform + if (_transform != NULL ) { _transform->Delete(); } +} + +/* + SETS A NEW TRANSFORM +*/ +void Transformer3D::SetTransform(vtkTransform *transform) +{ + _transform=transform; +} + +/* + SETS CENTER POINT +*/ +void Transformer3D::SetCenterPoint(std::vector point) +{ + _centerPoint=point; +} + + +/* + GETS THE RESULTANT TRANSFORM +*/ +vtkTransform *Transformer3D::GetResult() +{ + return _transform; +} + +/* + MAKES THE TRANSFORMATIONS +*/ +void Transformer3D::Run() +{ + _transform->Identity(); + std::cout << "Center points transform 3D: " << "X: " << _centerPoint[0] << "Y: " << _centerPoint[1] << "Z: " << _centerPoint[2] << std::endl; + _transform->Translate(_centerPoint[0], _centerPoint[1], _centerPoint[2]); + + //_transform->Scale(_scaleX, _scaleY,_scaleZ); + //_transform->RotateWXYZ(_angle, 0, 0, 1); + + _transform->Update(); +} diff --git a/lib/Transformer3D.h b/lib/Transformer3D.h new file mode 100644 index 0000000..7f84d53 --- /dev/null +++ b/lib/Transformer3D.h @@ -0,0 +1,23 @@ + +#ifndef Transformer3D_h +#define Transformer3D_h + +#include "vtkTransform.h" +#include + +class Transformer3D{ +public: + Transformer3D(); + ~Transformer3D(); + void SetTransform(vtkTransform *transform); + void SetCenterPoint(std::vector point); + void Run(); + + vtkTransform *GetResult(); +private: + std::vector _centerPoint; + + vtkTransform *_transform; +}; + +#endif -- 2.47.1