hyperbola radii are -1.#IND000000

I have moved all my projects to VS8.0 from VS6.0 which are based on opencascade6.3. I found that one of my 2D IGES file which I import using sample ImportExport throws stack overflow error. I tracked the problem and came to know that this 2D drawing has few hyperbola whose major and minor diameters are not number. In VS6.0 following code used to detect this and log the error which i never noticed till now. I do not mind if these hyperbola are missed and final drawing is sufficient for my project.

inline gp_Hypr::gp_Hypr (const gp_Ax2& A2,
const Standard_Real MajorRadius,
const Standard_Real MinorRadius):
pos(A2),
majorRadius(MajorRadius),
minorRadius(MinorRadius)
{
Standard_ConstructionError_Raise_if
(MinorRadius }

But VS8.0 does not detect it and throws stack overflow after sometime.

To check same scenario, I compiled following sample code in VS6.0 and VS8.0 and found that VS6.0 sets l_bIsNum as true whereas VS8.0 sets it as false.

double l_dX = -10;
double l_dSq = sqrt(l_dX);
bool l_bIsNum = l_dSq

There may be many such lines of code which would fail due to change in IDE. Has anyone faced this problem? Could someone suggest if there is any project setting which needs to be changed?

TIA,

Ashish

Pawel's picture

Hi Ashish,

well, VCb6.0 is quite fault-tolerant so you will probably have to eliminate such cases manually.

I was porting an OCC-based app some time ago and there were really quite a lot of issues that had to be solved manually (not necessarily OCC-originated ones).

Good luck
Pawel

ashish.negi's picture

Hi Pawel,

Thanks for replying.

I have added one function in Standard_Real.hxx to check if number is NaN
inline Standard_Boolean IsNaN(const Standard_Real value)
{
return (value!=value);
}

For now, I have made these checks only in IGESToBRep_BasicCurve which was throwing stack overflow error.

I compared project setting in VS6.0 and VS8.0 but could not find anything which can be changed so that NaN checks work like VS6.0

Ashish

UweM's picture

Hello,

you know the function '_isnan'? A other solution is, you set the mask for the fpu new
(throw a exception)

_clearfp();
unsigned save = _controlfp(0,0);
save = save & ~(_EM_INVALID | _EM_DENORMAL | _EM_ZERODIVIDE | _EM_OVERFLOW | _EM_UNDERFLOW);
_controlfp( save, _MCW_EM );

I you will catch the exception, set the project option under C/C++ -> code generation ->
activate c++ execptions -> SEH-exception (/EHa) (i have only the german version).

uwe

Roman Lygin's picture

OSD::SetSignal (Standard_True) will convert FPE (floating point exceptions) into Open CASCADE's exceptions (subclasses of Standard_Failure). With that you will have more chances to notice them instead of silently missing.

Hope this helps.
Roman

ashish.negi's picture

Hi Roman,

It really helped.

Thanks a bunch!