Salome HOME
Fix for bug 10011: VISU: SIGFPE on RestoreViewParameters with scaling
authorjfa <jfa@opencascade.com>
Wed, 26 Oct 2005 14:02:02 +0000 (14:02 +0000)
committerjfa <jfa@opencascade.com>
Wed, 26 Oct 2005 14:02:02 +0000 (14:02 +0000)
src/VTKFilter/SALOME_Transform.cxx
src/VTKFilter/SALOME_Transform.h
src/VTKViewer/VTKViewer_ViewFrame.cxx

index 7700215d11c58fc684436c659a081e1dff0ade3a..9ded9f005f551713482dc8ee12606f34d6e79ebd 100644 (file)
 
 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);
 }
index fe9231a1313aa305f419c38459d9d9651f8f13c9..01bb4a1319ae6f9c05224e7cdf00720798f156f5 100644 (file)
@@ -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() {}
index 783b60bae2b44c8973c3683935457ff8dfce6365..1453121b79a910df7b26d7c65fe92a67bb433f1f 100644 (file)
@@ -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();
 }