From fc8d3aa7d0272f6d43453fb3b7ecd0c5f4ccdf02 Mon Sep 17 00:00:00 2001 From: jfa Date: Wed, 26 Oct 2005 14:02:02 +0000 Subject: [PATCH] Fix for bug 10011: VISU: SIGFPE on RestoreViewParameters with scaling --- src/VTKFilter/SALOME_Transform.cxx | 35 ++++++++++++++++++++++++--- src/VTKFilter/SALOME_Transform.h | 4 ++- src/VTKViewer/VTKViewer_ViewFrame.cxx | 4 +-- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/VTKFilter/SALOME_Transform.cxx b/src/VTKFilter/SALOME_Transform.cxx index 7700215d1..9ded9f005 100644 --- a/src/VTKFilter/SALOME_Transform.cxx +++ b/src/VTKFilter/SALOME_Transform.cxx @@ -33,17 +33,44 @@ using namespace std; +static double EPS = 10e-4; + vtkStandardNewMacro(SALOME_Transform); -void SALOME_Transform::SetScale(float theScaleX, float theScaleY, float theScaleZ){ +//void SALOME_Transform::SetScale(float theScaleX, float theScaleY, float theScaleZ){ +// double aMatrix[16] = {theScaleX,0,0,0, +// 0,theScaleY,0,0, +// 0,0,theScaleZ,0, +// 0,0,0,1.0000000}; +// vtkTransform::SetMatrix(aMatrix); +//} + +/*!Sets matrix scale.*/ +void SALOME_Transform::SetMatrixScale(double theScaleX, double theScaleY, double theScaleZ){ double aMatrix[16] = {theScaleX,0,0,0, 0,theScaleY,0,0, 0,0,theScaleZ,0, 0,0,0,1.0000000}; - vtkTransform::SetMatrix(aMatrix); + this->SetMatrix(aMatrix); +} + +/*!Gets matrix scale.*/ +void SALOME_Transform::GetMatrixScale(double theScale[3]){ + vtkMatrix4x4 *aTMatrix=this->GetMatrix(); + const double aScaleX = aTMatrix->GetElement(0,0); + const double aScaleY = aTMatrix->GetElement(1,1); + const double aScaleZ = aTMatrix->GetElement(2,2); + theScale[0] = aScaleX; + theScale[1] = aScaleY; + theScale[2] = aScaleZ; } int SALOME_Transform::IsIdentity(){ - float* aScale = GetScale(); - return (aScale[0] == 1.0 && aScale[1] == 1.0 && aScale[2] == 1.0); + //float* aScale = GetScale(); + //return (aScale[0] == 1.0 && aScale[1] == 1.0 && aScale[2] == 1.0); + double aScale[3]; + this->GetMatrixScale(aScale); + return (fabs(aScale[0] - 1.0) < EPS && + fabs(aScale[1] - 1.0) < EPS && + fabs(aScale[2] - 1.0) < EPS); } diff --git a/src/VTKFilter/SALOME_Transform.h b/src/VTKFilter/SALOME_Transform.h index fe9231a13..01bb4a131 100644 --- a/src/VTKFilter/SALOME_Transform.h +++ b/src/VTKFilter/SALOME_Transform.h @@ -36,8 +36,10 @@ class VTK_EXPORT SALOME_Transform : public vtkTransform{ static SALOME_Transform *New(); vtkTypeMacro(SALOME_Transform,vtkTransform); - void SetScale(float theScaleX, float theScaleY, float theScaleZ); + //void SetScale(float theScaleX, float theScaleY, float theScaleZ); int IsIdentity(); + void SetMatrixScale(double theScaleX, double theScaleY, double theScaleZ); + void GetMatrixScale(double theScale[3]); protected: SALOME_Transform() {} diff --git a/src/VTKViewer/VTKViewer_ViewFrame.cxx b/src/VTKViewer/VTKViewer_ViewFrame.cxx index 783b60bae..1453121b7 100644 --- a/src/VTKViewer/VTKViewer_ViewFrame.cxx +++ b/src/VTKViewer/VTKViewer_ViewFrame.cxx @@ -608,11 +608,11 @@ void VTKViewer_ViewFrame::Repaint(bool theUpdateTrihedron) } void VTKViewer_ViewFrame::GetScale(double theScale[3]){ - m_Transform->GetScale(theScale); + m_Transform->GetMatrixScale(theScale); } void VTKViewer_ViewFrame::SetScale(double theScale[3]){ - m_Transform->SetScale(theScale[0], theScale[1], theScale[2]); + m_Transform->SetMatrixScale(theScale[0], theScale[1], theScale[2]); m_RWInteractor->Render(); Repaint(); } -- 2.39.2