From: trillos Date: Fri, 20 Nov 2009 14:25:37 +0000 (+0000) Subject: Eliminated Vector Math X-Git-Tag: CREATOOLS.2-0-3~18 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=creaRigidRegistration.git;a=commitdiff_plain;h=ef1b2d78a9c08ea55e470608a6a8fe0fa1ad6099 Eliminated Vector Math --- diff --git a/lib/CheckBoard.cpp b/lib/CheckBoard.cpp index b766835..cb3bdc6 100644 --- a/lib/CheckBoard.cpp +++ b/lib/CheckBoard.cpp @@ -27,7 +27,6 @@ CheckBoard::~CheckBoard() //if (image1 != NULL ) { image1->Delete(); } //if (image2 != NULL ) { image2->Delete(); } if (newImage != NULL ) { newImage->Delete(); } - if (resample != NULL ) { resample->Delete(); } if (result != NULL ) { result->Delete(); } } diff --git a/lib/VectorMath.cxx b/lib/VectorMath.cxx deleted file mode 100644 index e9444c2..0000000 --- a/lib/VectorMath.cxx +++ /dev/null @@ -1,147 +0,0 @@ -#include "VectorMath.h" - - - -VectorMath::VectorMath() -{ - -} - -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]; - _pointx1b = pointsX1[1]; - - _pointx2a = pointsX2[0]; - _pointx2b = pointsX2[1]; - - _pointy1a = pointsY1[0]; - _pointy1b = pointsY1[1]; - - _pointy2a = pointsY2[0]; - _pointy2b = pointsY2[1]; - - _pointz1a = pointsZ1[0]; - _pointz1b = pointsZ1[1]; - - _pointz2a = pointsZ2[0]; - _pointz2b = pointsZ2[1]; -} - -/*Runs the calculations*/ -void VectorMath::Run() -{ - _origin.clear(); - _origin.push_back(_pointx2a); - _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); - _vectorA[2] =(double)(_pointz1b - _pointz1a); - - double normA = vtkMath::Norm(_vectorA); - - _vectorA[0] = _vectorA[0]/normA; - _vectorA[1] = _vectorA[1]/normA; - _vectorA[2] = _vectorA[2]/normA; - - double _vectorB[3]; - _vectorB[0] =(double)(_pointx2b - _pointx2a - _pointx1a); - _vectorB[1] =(double)(_pointy2b - _pointy2a - _pointy1a); - _vectorB[2] =(double)(_pointz2b - _pointz2a - _pointz1a); - - double normB = vtkMath::Norm(_vectorB); - - _vectorB[0] = _vectorB[0]/normB; - _vectorB[1] = _vectorB[1]/normB; - _vectorB[2] = _vectorB[2]/normB; - - vtkMath::Cross(_vectorA, _vectorB, _result); - - std::cout << "Data from vector A: X: " << _vectorA[0] << " Y: " << _vectorA[1] << " Z: " << _vectorA[2] << std::endl; - std::cout << "Data from vector B: X: " << _vectorB[0] << " Y: " << _vectorB[1] << " Z: " << _vectorB[2] << std::endl; - std::cout << "Data from result: X: " << _result[0] << " Y: " << _result[1] << " Z: " << _result[2] << std::endl; - - double _vectorOrigin[3] = {0,0,0}; - - double distanceA = vtkMath::Distance2BetweenPoints(_vectorOrigin, _vectorA); - 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)); - - _angle = vtkMath::DegreesFromRadians(_angle); - - std::cout << "Dot " << vtkMath::Dot(_vectorA, _vectorB) << std::endl; - 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 deleted file mode 100644 index a16e453..0000000 --- a/lib/VectorMath.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef _$PROJECT_NAME$SOURCE01_H_ -#define _$PROJECT_NAME$SOURCE01_H_ - -#include "vtkMath.h" -#include - -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; - int _pointx2b; - - int _pointy1a; - int _pointy1b; - int _pointy2a; - int _pointy2b; - - int _pointz1a; - int _pointz1b; - int _pointz2a; - int _pointz2b; - - ////////////////// - /* Results */ - ///////////////// - - std::vector _origin; - std::vector _originReslicer; - double _result[3]; - - double _scaleX; - double _scaleY; - double _scaleZ; - - double _angle; -}; - -#endif -