SCIInstitute / Cleaver

A MultiMaterial Tetrahedral Meshing Library and Application
https://cleaver.readthedocs.io
Other
40 stars 18 forks source link

Check directly for negative sqrt and divide by zero in SizingField #114

Closed aronhelser closed 2 years ago

aronhelser commented 2 years ago

Instead of relying on isNan(), check directly for conditions that could cause NaN. On Windows by default, a negative sqrt() will throw a floating point exception, halting the program. Changing this code is more convenient for consumers of the cleaver library.

I encounter this issue while developing the VTK filter wrapper for Cleaver2.

aronhelser commented 2 years ago

Note that there are several other places that check isNan() and then exit or indicate an error, which in practical terms is the same as throwing a floating point exception, but will look different to the end-user.

The spot changed above is encountered during normal, correct operation of the mesher.