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);
}
}