From 0c0807563f54ac3149d9bd23815c4ddacbc5b223 Mon Sep 17 00:00:00 2001 From: trillos Date: Thu, 5 Nov 2009 15:49:01 +0000 Subject: [PATCH] *** empty log message *** --- lib/Transformer.cxx | 7 ++++++- lib/VectorMath.cxx | 23 +++++++++++++++++++++-- lib/VectorMath.h | 28 ++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/lib/Transformer.cxx b/lib/Transformer.cxx index ed1b25b..3fa5507 100644 --- a/lib/Transformer.cxx +++ b/lib/Transformer.cxx @@ -103,10 +103,15 @@ void Transformer::Run(bool _3D) { _transform->Identity(); _transform->Translate(_centerPoint[0], _centerPoint[1], _centerPoint[2]); + + std::cout << "Transformer: Center points: X = " << _centerPoint[0] << " Y = " << _centerPoint[1] << " Z = " << _centerPoint[2] << std::endl; + std::cout << "Transformer Angle: " << _angle << std::endl; + _transform->Scale(_scaleX, _scaleY,_scaleZ); if(_3D) { - _transform->RotateWXYZ(_angle, _transformAxis[0], _transformAxis[1], _transformAxis[2]); + _transform->RotateWXYZ(_angle, _transformAxis[0], _transformAxis[1], _transformAxis[2]); + std::cout << "Transformer 3D Version" << std::endl; } else { diff --git a/lib/VectorMath.cxx b/lib/VectorMath.cxx index 56f4b1b..e9444c2 100644 --- a/lib/VectorMath.cxx +++ b/lib/VectorMath.cxx @@ -1,5 +1,7 @@ #include "VectorMath.h" + + VectorMath::VectorMath() { @@ -10,6 +12,7 @@ VectorMath::~VectorMath() } +/*Sets all the vector points*/ void VectorMath::SetData(std::vector pointsX1, std::vector pointsX2, std::vector pointsY1, std::vector pointsY2, std::vector pointsZ1, std::vector pointsZ2) { _pointx1a = pointsX1[0]; @@ -31,6 +34,7 @@ void VectorMath::SetData(std::vector pointsX1, std::vector pointsX2, s _pointz2b = pointsZ2[1]; } +/*Runs the calculations*/ void VectorMath::Run() { _origin.clear(); @@ -38,11 +42,15 @@ void VectorMath::Run() _origin.push_back(_pointy2a); _origin.push_back(_pointz2a); + std::cout << "Vector Math: Origin points: X = " << _pointx2a << " Y = " << _pointy2a << " Z = " << _pointz2a << std::endl; + _originReslicer.clear(); _originReslicer.push_back(_pointx1a); _originReslicer.push_back(_pointy1a); _originReslicer.push_back(_pointz1a); + std::cout << "Vector Math: Origin Reslicer points: X = " << _pointx1a << " Y = " << _pointy1a << " Z = " << _pointz1a << std::endl; + double _vectorA[3]; _vectorA[0] =(double)(_pointx1b - _pointx1a); _vectorA[1] =(double)(_pointy1b - _pointy1a); @@ -77,10 +85,15 @@ void VectorMath::Run() double distanceB = vtkMath::Distance2BetweenPoints(_vectorOrigin, _vectorA); double proportion = distanceA/distanceB; - + /* _scaleX = proportion; _scaleY = proportion; _scaleZ = proportion; + */ + + _scaleX = 1; + _scaleY = 1; + _scaleZ = 1; _angle = acos(vtkMath::Dot(_vectorA, _vectorB)); @@ -90,37 +103,43 @@ void VectorMath::Run() std::cout << "Angle " << (double)_angle << std::endl; } - +/*Returns the origin of the second vector*/ std::vector VectorMath::GetOrigin() { return _origin; } +/*Returns the origin of the first vector*/ std::vector VectorMath::GetOriginReslicer() { return _originReslicer; } +/*Returns the cross product of the two vectors*/ void VectorMath::GetResult(double result[3]) { result = _result; } +/*Scale in X*/ double VectorMath::GetScaleX() { return _scaleX; } +/*Scale in Y*/ double VectorMath::GetScaleY() { return _scaleY; } +/*Scale in Z*/ double VectorMath::GetScaleZ() { return _scaleZ; } +/*Rotation angle (dot product)*/ double VectorMath::GetAngle() { return _angle; diff --git a/lib/VectorMath.h b/lib/VectorMath.h index 9eafe8b..a16e453 100644 --- a/lib/VectorMath.h +++ b/lib/VectorMath.h @@ -8,17 +8,41 @@ class VectorMath{ public: VectorMath(); ~VectorMath(); + + /*Sets all the vector points*/ void SetData(std::vector pointsX1, std::vector pointsX2, std::vector pointsY1, std::vector pointsY2, std::vector pointsZ1, std::vector pointsZ2); + + /*Runs the calculations*/ void Run(); + + /*Returns the origin of the second vector*/ std::vector GetOrigin(); + + /*Returns the origin of the first vector*/ std::vector GetOriginReslicer(); + + /*Returns the cross product of the two vectors*/ void GetResult(double result[3]); + + /*Rotation angle (dot product)*/ double GetAngle(); + + /*Scale in X*/ double GetScaleX(); + + /*Scale in Y*/ double GetScaleY(); + + /*Scale in Z*/ double GetScaleZ(); private: + /////////////////// + /* Vector Points */ + /////////////////// + + /*The points are defined by the following naming pattern: _point[axis(x,y or z)][vector(1 {first image} or 2{second image})][a{starting piont} or b{end point}]*/ + int _pointx1a; int _pointx1b; int _pointx2a; @@ -33,6 +57,10 @@ private: int _pointz1b; int _pointz2a; int _pointz2b; + + ////////////////// + /* Results */ + ///////////////// std::vector _origin; std::vector _originReslicer; -- 2.47.1