From 5a24b4aac106a02f1111f0ab1783fc004a05528a Mon Sep 17 00:00:00 2001 From: ptv Date: Fri, 24 Apr 2009 09:17:41 +0000 Subject: [PATCH] Debug FPE exception --- src/VTKViewer/VTKViewer_Trihedron.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/VTKViewer/VTKViewer_Trihedron.cxx b/src/VTKViewer/VTKViewer_Trihedron.cxx index 067dfecf6..90e832a70 100755 --- a/src/VTKViewer/VTKViewer_Trihedron.cxx +++ b/src/VTKViewer/VTKViewer_Trihedron.cxx @@ -82,13 +82,13 @@ void VTKViewer_UnScaledActor::Render(vtkRenderer *theRenderer) aDataSet->Update(); vtkFloatingPointType aLength = aDataSet->GetLength(); vtkFloatingPointType aPrecision = 1.0E-3; + vtkFloatingPointType aZeroTol = 1.0E-12; vtkFloatingPointType anOldScale = GetScale()[0]; - vtkFloatingPointType aScale; - if (aSize[1] > aSize[0]) - aScale = mySize*aWorldDiag/aWinDiag/aLength*sqrt(vtkFloatingPointType(aSize[0])/vtkFloatingPointType(aSize[1])); - else - aScale = mySize*aWorldDiag/aWinDiag/aLength*sqrt(vtkFloatingPointType(aSize[1])/vtkFloatingPointType(aSize[0])); - if(aScale != 0.0&& fabs(aScale - anOldScale)/aScale > aPrecision){ + vtkFloatingPointType aScale = anOldScale; + vtkFloatingPointType aMaxSize = (vtkFloatingPointType)fmax(aSize[1],aSize[0]); + if (fabs(aWinDiag) > aZeroTol && fabs(aLength) > aZeroTol && fabs(aMaxSize) > aZeroTol) + aScale = mySize*aWorldDiag/aWinDiag/aLength*sqrt(vtkFloatingPointType(fmin(aSize[1],aSize[0]))/aMaxSize); + if(fabs(aScale) > aZeroTol && fabs(aScale - anOldScale)/aScale > aPrecision){ SetScale(aScale); } } -- 2.39.2