mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0025602: It is important for IGES and STEP file format to add check, if wrong data are read from the file
1. Functions Precision::IsIllegal(...) and Precision::IsInfinitesimal(...) were added. 2. Detection incorrect numbers read from *.stp and/or *.igs files was added.
This commit is contained in:
@@ -16,3 +16,47 @@
|
||||
|
||||
|
||||
#include <Precision.hxx>
|
||||
|
||||
//Binary representation of double numbers: expands it to MANTISSA, EXPONENT and SIGN-bit.
|
||||
struct stDBLType
|
||||
{
|
||||
unsigned int manl:32;
|
||||
unsigned int manh:20;
|
||||
unsigned int exp:11;
|
||||
unsigned int sign:1;
|
||||
};
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsIllegal
|
||||
//purpose : Returns True if R is infinite, NAN or another number
|
||||
// which is not supported by OCCT.
|
||||
// Fragment of fpclassify(...) function is used, which is taken
|
||||
// from here: http://www.jbox.dk/sanos/source/lib/math.c.html
|
||||
//=======================================================================
|
||||
Standard_Boolean Precision::IsIllegal (const Standard_Real R)
|
||||
{
|
||||
stDBLType* aDoubleBits = (struct stDBLType*) &R;
|
||||
if (aDoubleBits->exp == 0)
|
||||
{
|
||||
if (aDoubleBits->manh != 0 || aDoubleBits->manl != 0)
|
||||
{//_FPCLASS_ND (-DBL_MIN/2.0) or _FPCLASS_PD (+DBL_MIN/2.0)
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
|
||||
if (aDoubleBits->exp == 0x7ff)
|
||||
{//_FPCLASS_NINF (-1/0), _FPCLASS_PINF (+1/0), _FPCLASS_QNAN or _FPCLASS_SNAN
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
const Standard_Real anINf = 2.0*Infinite();
|
||||
|
||||
if(R >= anINf)
|
||||
return Standard_True;
|
||||
|
||||
if(R <= -anINf)
|
||||
return Standard_True;
|
||||
|
||||
return Standard_False;
|
||||
}
|
||||
|
Reference in New Issue
Block a user