From ff1479f34aa78998642b65d7024db5b206c022b9 Mon Sep 17 00:00:00 2001 From: apo Date: Fri, 2 Dec 2005 15:19:57 +0000 Subject: [PATCH] To avoid devision by zero --- src/PIPELINE/VISU_DeformedShapePL.cxx | 8 +++++++- src/PIPELINE/VISU_GaussPointsPL.cxx | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/PIPELINE/VISU_DeformedShapePL.cxx b/src/PIPELINE/VISU_DeformedShapePL.cxx index 12847fa9..af4bf8bd 100644 --- a/src/PIPELINE/VISU_DeformedShapePL.cxx +++ b/src/PIPELINE/VISU_DeformedShapePL.cxx @@ -86,7 +86,13 @@ void VISU_DeformedShapePL::Init(){ VISU_ScalarMapPL::Init(); float aScalarRange[2]; GetSourceRange(aScalarRange); - SetScale(GetScaleFactor(GetInput2())/aScalarRange[1]); + + vtkDataSet* aDataSet = GetInput2(); + float aScaleFactor = VISU_DeformedShapePL::GetScaleFactor( aDataSet ); + + static double EPS = 1.0 / VTK_LARGE_FLOAT; + if(std::abs(aScalarRange[1]) > EPS) + SetScale(aScaleFactor / aScalarRange[1]); } VISU_ScalarMapPL::THook* VISU_DeformedShapePL::DoHook(){ diff --git a/src/PIPELINE/VISU_GaussPointsPL.cxx b/src/PIPELINE/VISU_GaussPointsPL.cxx index 0ec6d3a9..dfa140a9 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.cxx +++ b/src/PIPELINE/VISU_GaussPointsPL.cxx @@ -184,7 +184,12 @@ VISU_GaussPointsPL GetSourceRange(aScalarRange); vtkDataSet* aDataSet = GetParentMesh(); float aScaleFactor = VISU_DeformedShapePL::GetScaleFactor( aDataSet ); - SetScale( aScaleFactor / aScalarRange[1] ); + + static double EPS = 1.0 / VTK_LARGE_FLOAT; + if(std::abs(aScalarRange[1]) > EPS) + SetScale( aScaleFactor / aScalarRange[1] ); + else + SetScale(0.0); // Deformed Shape myPassFilter[0]->SetInput(myCellDataToPointData->GetUnstructuredGridOutput()); -- 2.39.2