]> OCCT Git - occt-copy.git/commitdiff
0025602: It is important for IGES and STEP file format to add check, if wrong data... CR25602
authornbv <nbv@opencascade.com>
Wed, 29 Jul 2015 11:06:07 +0000 (14:06 +0300)
committernbv <nbv@opencascade.com>
Wed, 29 Jul 2015 13:12:42 +0000 (16:12 +0300)
1. Functions Precision::IsIllegal(...) and Precision::IsInfinitesimal(...) were added.
2. Detection incorrect numbers read from *.stp and/or *.igs files was added.

src/IGESData/IGESData_GlobalSection.cxx
src/IGESData/IGESData_ParamReader.cxx
src/Precision/FILES
src/Precision/Precision.cxx
src/Precision/Precision.hxx
src/Precision/Precision.lxx [deleted file]
src/StepData/StepData_StepReaderData.cxx
tests/de/iges_2/H9
tests/de/step_1/E6

index 87211099ac3cfb05f88d1e9985e4d90de03d3eba..611e485af1d376d7122308daf1d84fc3f6d87ff8 100644 (file)
@@ -29,7 +29,9 @@
 #include <Interface_Static.hxx>
 #include <Message_Msg.hxx>
 #include <OSD_Process.hxx>
+#include <Precision.hxx>
 #include <Quantity_Date.hxx>
+#include <Standard_NumericError.hxx>
 #include <TCollection_HAsciiString.hxx>
 #include <UnitsMethods.hxx>
 
@@ -148,7 +150,20 @@ void IGESData_GlobalSection::Init(const Handle(Interface_ParamSet)& params,
     if (fpt == Interface_ParamInteger) {
        // but a real is expected 
       if ( i == 13 || i == 17 || i == 19 || i == 20)
-       realval = Atof(val);
+      {
+        realval = Atof(val);
+
+        if(Precision::IsIllegal(realval))
+        {
+          Standard_NumericError::Raise();
+        }
+
+        if(Precision::IsInfinitesimal(realval))
+        {
+          realval = 0.0;
+        }
+      }
+
       intval  = atoi(val);
     }
 
@@ -164,6 +179,16 @@ void IGESData_GlobalSection::Init(const Handle(Interface_ParamSet)& params,
         if (val[k] == '\0') break;
       }
       realval = Atof(text);
+
+      if(Precision::IsIllegal(realval))
+      {
+        Standard_NumericError::Raise();
+      }
+
+      if(Precision::IsInfinitesimal(realval))
+      {
+        realval  = 0.0;
+      }
     }
 
     // if the param is a text
index 15ee7c79c4f07bceac7e4b30591da93f33b922a0..ca4d8cfee54db176c738837cd6b425ecbda4430d 100644 (file)
@@ -30,6 +30,8 @@
 #include <Interface_ParamList.hxx>
 #include <Interface_Static.hxx>
 #include <Message_Msg.hxx>
+#include <Precision.hxx>
+#include <Standard_NumericError.hxx>
 #include <TCollection_HAsciiString.hxx>
 
 #include <stdio.h>
@@ -1255,8 +1257,19 @@ Standard_Boolean IGESData_ParamReader::ReadingReal (const Standard_Integer num,
       text[j++] = orig[i];  
     if (orig[i] == '\0') break;
   }
-  if (FP.ParamType() == Interface_ParamReal) 
+  if (FP.ParamType() == Interface_ParamReal)
+  {
     val = Atof(text);
+    if(Precision::IsIllegal(val))
+    {
+      Standard_NumericError::Raise();
+    }
+
+    if(Precision::IsInfinitesimal(val))
+    {
+      val  = 0.0;
+    }
+  }
   else if (FP.ParamType() == Interface_ParamEnum) {  // convention
     if (!pbrealform) {
       if (testconv < 0) testconv = 0; //Interface_Static::IVal("iges.convert.read");
@@ -1273,6 +1286,15 @@ Standard_Boolean IGESData_ParamReader::ReadingReal (const Standard_Integer num,
     // -> un message avertissement + on ajoute le point puis on convertit
     
     val = Atof(text);
+    if(Precision::IsIllegal(val))
+    {
+      Standard_NumericError::Raise();
+    }
+
+    if(Precision::IsInfinitesimal(val))
+    {
+      val  = 0.0;
+    }
   } else if (FP.ParamType() == Interface_ParamVoid) {
     val = 0.0;    // DEFAULT
   } else {
@@ -1323,8 +1345,19 @@ Standard_Boolean IGESData_ParamReader::ReadingReal
       text[j++] = orig[i];  
     if (orig[i] == '\0') break;
   }
-  if (FP.ParamType() == Interface_ParamReal) 
+  if (FP.ParamType() == Interface_ParamReal)
+  {
     val = Atof(text);
+    if(Precision::IsIllegal(val))
+    {
+      Standard_NumericError::Raise();
+    }
+
+    if(Precision::IsInfinitesimal(val))
+    {
+      val  = 0.0;
+    }
+  }
   else if (FP.ParamType() == Interface_ParamEnum) {  // convention
     if (!pbrealform) {
       if (testconv < 0) testconv = 0; //Interface_Static::IVal("iges.convert.read");
@@ -1341,6 +1374,15 @@ Standard_Boolean IGESData_ParamReader::ReadingReal
     // -> un message avertissement + on ajoute le point puis on convertit
     
     val = Atof(text);
+    if(Precision::IsIllegal(val))
+    {
+      Standard_NumericError::Raise();
+    }
+
+    if(Precision::IsInfinitesimal(val))
+    {
+      val  = 0.0;
+    }
   } else if (FP.ParamType() == Interface_ParamVoid) {
     val = 0.0;    // DEFAULT
   } else {
index 5b8f799ca3e8331d5d1818e4bd7715d919719649..a10391e697dc06ce866a6a61a420f716b77b5205 100644 (file)
@@ -1,3 +1,2 @@
 Precision.cxx
 Precision.hxx
-Precision.lxx
index 700794b38b82575586c48a410bf5e304fced51c0..de12ee2472a986e3e8e23e8b0411c26b8fceb1a1 100644 (file)
 
 
 #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;
+}
index b3c0e34a09231e4fe3b5e01943425ea1dd3b25ae..d64b89a1301c9f2dea458662e3c115e1f63dd342 100644 (file)
 class Precision 
 {
 public:
-
-  DEFINE_STANDARD_ALLOC
-
-  
   //! Returns the recommended precision value
   //! when checking the equality of two angles (given in radians).
   //! Standard_Real Angle1 = ... , Angle2 = ... ;
@@ -123,8 +119,10 @@ public:
   //! you can use :
   //! If ( Abs( D1.D2 ) < Precision::Angular() ) ...
   //! (although the function IsNormal does exist).
-  Standard_EXPORT static Standard_Real Angular();
-  
+  static Standard_Real Angular()
+  {
+    return 1.e-12;
+  }
 
   //! Returns the recommended precision value when
   //! checking coincidence of two points in real space.
@@ -166,13 +164,18 @@ public:
   //! distance (1 / 10 millimeter). This distance
   //! becomes easily measurable, but only within a restricted
   //! space which contains some small objects of the complete scene.
-  Standard_EXPORT static Standard_Real Confusion();
-  
+  static Standard_Real Confusion()
+  {
+    return 1.e-7;
+  }
 
   //! Returns square of Confusion.
   //! Created for speed and convenience.
-  Standard_EXPORT static Standard_Real SquareConfusion();
-  
+  static Standard_Real SquareConfusion()
+  {
+    return Confusion() * Confusion();
+  }
+
   //! Returns the precision value in real space, frequently
   //! used by intersection algorithms to decide that a solution is reached.
   //! This function provides an acceptable level of precision
@@ -195,8 +198,11 @@ public:
   //! The tolerance of intersection is equal to :
   //! Precision::Confusion() / 100.
   //! (that is, 1.e-9).
-  Standard_EXPORT static Standard_Real Intersection();
-  
+  static Standard_Real Intersection()
+  {
+    return Confusion() * 0.01;
+  }
+
   //! Returns the precision value in real space, frequently used
   //! by approximation algorithms.
   //! This function provides an acceptable level of precision for
@@ -210,15 +216,19 @@ public:
   //! (that is, 1.e-6).
   //! You may use a smaller tolerance in an approximation
   //! algorithm, but this option might be costly.
-  Standard_EXPORT static Standard_Real Approximation();
-  
+  static Standard_Real Approximation()
+  {
+    return Confusion() * 10.;
+  }
+
   //! Convert a real  space precision  to  a  parametric
   //! space precision.   <T>  is the mean  value  of the
   //! length of the tangent of the curve or the surface.
-  //!
   //! Value is P / T
-    static Standard_Real Parametric (const Standard_Real P, const Standard_Real T);
-  
+  static Standard_Real Parametric (const Standard_Real P, const Standard_Real T)
+  {
+    return P / T;
+  }
 
   //! Returns a precision value in parametric space, which may be used :
   //! -   to test the coincidence of two points in the real space,
@@ -264,8 +274,10 @@ public:
   //! 2.Pi without impacting on the resulting point.
   //! Therefore, take great care when adjusting a parametric
   //! tolerance to your own algorithm.
-  Standard_EXPORT static Standard_Real PConfusion (const Standard_Real T);
-  
+  static Standard_Real PConfusion (const Standard_Real T)
+  {
+    return Parametric(Confusion(),T);
+  }
 
   //! Returns a precision value in parametric space, which
   //! may be used by intersection algorithms, to decide that
@@ -280,8 +292,11 @@ public:
   //! segment whose length is equal to 100. (default value), or T.
   //! The parametric tolerance of intersection is equal to :
   //! -   Precision::Intersection() / 100., or Precision::Intersection() / T.
-  Standard_EXPORT static Standard_Real PIntersection (const Standard_Real T);
-  
+  static Standard_Real PIntersection (const Standard_Real T)
+  {
+    return Parametric(Intersection(),T);
+  }
+
   //! Returns a precision value in parametric space, which may
   //! be used by approximation algorithms. The purpose of this
   //! function is to provide an acceptable level of precision in
@@ -295,50 +310,87 @@ public:
   //! segment whose length is equal to 100. (default value), or T.
   //! The parametric tolerance of intersection is equal to :
   //! -   Precision::Approximation() / 100., or Precision::Approximation() / T.
-  Standard_EXPORT static Standard_Real PApproximation (const Standard_Real T);
-  
+  static Standard_Real PApproximation (const Standard_Real T)
+  {
+    return Parametric(Approximation(),T);
+  }
+
   //! Convert a real  space precision  to  a  parametric
   //! space precision on a default curve.
-  //!
   //! Value is Parametric(P,1.e+2)
-  Standard_EXPORT static Standard_Real Parametric (const Standard_Real P);
-  
+  static Standard_Real Parametric (const Standard_Real P)
+  {
+    return Parametric(P, 100.);
+  }
+
   //! Used  to test distances  in parametric  space on a
   //! default curve.
-  //!
   //! This is Precision::Parametric(Precision::Confusion())
-    static Standard_Real PConfusion();
-  
+  static Standard_Real PConfusion()
+  {
+    return Parametric(Confusion());
+  }
+
   //! Used for Intersections  in parametric  space  on a
   //! default curve.
-  //!
   //! This is Precision::Parametric(Precision::Intersection())
-    static Standard_Real PIntersection();
-  
+  static Standard_Real PIntersection()
+  {
+    return Parametric(Intersection());
+  }
+
   //! Used for  Approximations  in parametric space on a
   //! default curve.
-  //!
   //! This is Precision::Parametric(Precision::Approximation())
-    static Standard_Real PApproximation();
-  
+  static Standard_Real PApproximation()
+  {
+    return Parametric(Approximation());
+  }
+
   //! Returns True if R may be considered as an infinite
   //! number. Currently Abs(R) > 1e100
-  Standard_EXPORT static Standard_Boolean IsInfinite (const Standard_Real R);
-  
+  static Standard_Boolean IsInfinite (const Standard_Real R)
+  {
+    return Abs(R) >= (0.5*Precision::Infinite());
+  }
+
   //! Returns True if R may be considered as  a positive
   //! infinite number. Currently R > 1e100
-  Standard_EXPORT static Standard_Boolean IsPositiveInfinite (const Standard_Real R);
-  
+  static Standard_Boolean IsPositiveInfinite (const Standard_Real R)
+  {
+    return R >= (0.5*Precision::Infinite());
+  }
+
   //! Returns True if R may  be considered as a negative
   //! infinite number. Currently R < -1e100
-  Standard_EXPORT static Standard_Boolean IsNegativeInfinite (const Standard_Real R);
-  
+  static Standard_Boolean IsNegativeInfinite (const Standard_Real R)
+  {
+    return R <= -(0.5*Precision::Infinite());
+  }
+
   //! Returns a  big number that  can  be  considered as
   //! infinite. Use -Infinite() for a negative big number.
-  Standard_EXPORT static Standard_Real Infinite();
-
-
-
+  static Standard_Real Infinite()
+  {
+    return 2.e+100;
+  }
+
+  //! Returns True if R is infinite, NAN or another number
+  //! which is not supported by OCCT.
+  Standard_EXPORT static Standard_Boolean IsIllegal (const Standard_Real R);
+
+  //! Returns True if R is in epsilon-neighborhood of 0.
+  //! The value of epsilon is defined in OCCT and can be returned by
+  //! Precision::Infinite() method.
+  //! Therefore, epsilon-value is chosen to be equal 1/Infinite().
+  //! Some examples of numbers, which this function will return TRUE for:
+  //! R = 0, 3.0e-120, -5.0e-116 etc.
+  static Standard_Boolean IsInfinitesimal (const Standard_Real R)
+  {
+    const Standard_Real aNull = 1/Infinite();
+
+    return (Abs(R) < aNull);
+  }
 
 protected:
 
@@ -354,11 +406,4 @@ private:
 
 };
 
-
-#include <Precision.lxx>
-
-
-
-
-
 #endif // _Precision_HeaderFile
diff --git a/src/Precision/Precision.lxx b/src/Precision/Precision.lxx
deleted file mode 100644 (file)
index d5b698c..0000000
+++ /dev/null
@@ -1,229 +0,0 @@
-// Created on: 1993-03-08
-// Created by: Remi LEQUETTE
-// Copyright (c) 1993-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-//=======================================================================
-//function : Angular
-//purpose  : 
-//=======================================================================
-
-inline Standard_Real  Precision::Angular()
-{
-#ifdef PRECISION_OBSOLETE
-  static const Standard_Real Precision_Angular        = 1.e-12;
-  return Precision_Angular;
-#else
-  return 1.e-12;
-#endif
-}
-
-
-//=======================================================================
-//function : Confusion
-//purpose  : 
-//=======================================================================
-
-inline Standard_Real  Precision::Confusion()
-{
-#ifdef PRECISION_OBSOLETE
-  static const Standard_Real Precision_Confusion      = 1.e-7;
-  return Precision_Confusion;
-#else
-  return 1.e-7;
-#endif
-}
-
-
-//=======================================================================
-//function : SquareConfusion
-//purpose  : 
-//=======================================================================
-inline Standard_Real Precision::SquareConfusion()
-{
-  return Confusion() * Confusion();
-}
-
-
-//=======================================================================
-//function : Intersection
-//purpose  : 
-//=======================================================================
-
-inline Standard_Real  Precision::Intersection()
-{
-#ifdef PRECISION_OBSOLETE
-  static const Standard_Real Precision_Intersection   = Precision::Confusion() / 100.;
-  return Precision_Intersection;
-#else
-  return Confusion() * 0.01;
-#endif
-}
-
-
-//=======================================================================
-//function : Approximation
-//purpose  : 
-//=======================================================================
-
-inline Standard_Real  Precision::Approximation()
-{
-#ifdef PRECISION_OBSOLETE
-  static const Standard_Real Precision_Approximation  = Precision::Confusion() * 10.;
-  return Precision_Approximation;
-#else
-  return Confusion() * 10.;
-#endif
-}
-
-
-//=======================================================================
-//function : Parametric
-//purpose  : 
-//=======================================================================
-
-inline Standard_Real  Precision::Parametric(const Standard_Real P,
-                                           const Standard_Real T)
-{
-  return P / T;
-}
-
-
-//=======================================================================
-//function : PConfusion
-//purpose  : 
-//=======================================================================
-
-inline Standard_Real  Precision::PConfusion(const Standard_Real T)
-{
-  return Parametric(Confusion(),T);
-}
-
-
-//=======================================================================
-//function : PIntersection
-//purpose  : 
-//=======================================================================
-
-inline Standard_Real  Precision::PIntersection(const Standard_Real T)
-{
-  return Parametric(Intersection(),T);
-}
-
-
-//=======================================================================
-//function : PApproximation
-//purpose  : 
-//=======================================================================
-
-inline Standard_Real  Precision::PApproximation(const Standard_Real T)
-{
-  return Parametric(Approximation(),T);
-}
-
-//=======================================================================
-//function : Parametric
-//purpose  : 
-//=======================================================================
-
-inline Standard_Real  Precision::Parametric(const Standard_Real P)
-{
-#ifdef PRECISION_OBSOLETE
-  static const Standard_Real Precision_DefTangent     = 1.e+2;
-  return Parametric(P,Precision_DefTangent);
-#else
-  return Parametric(P, 100.);
-#endif
-}
-
-
-//=======================================================================
-//function : PConfusion
-//purpose  : 
-//=======================================================================
-
-inline Standard_Real  Precision::PConfusion()
-{
-  return Parametric(Confusion());
-}
-
-
-//=======================================================================
-//function : PIntersection
-//purpose  : 
-//=======================================================================
-
-inline Standard_Real  Precision::PIntersection()
-{
-  return Parametric(Intersection());
-}
-
-
-//=======================================================================
-//function : PApproximation
-//purpose  : 
-//=======================================================================
-
-inline Standard_Real  Precision::PApproximation()
-{
-  return Parametric(Approximation());
-}
-
-//=======================================================================
-//function : IsInfinite
-//purpose  : 
-//=======================================================================
-
-inline Standard_Boolean  Precision::IsInfinite(const Standard_Real R)
-{
-  return Abs(R) >= (0.5*Precision::Infinite());
-}
-
-//=======================================================================
-//function : IsPositiveInfinite
-//purpose  : 
-//=======================================================================
-
-inline Standard_Boolean  Precision::IsPositiveInfinite(const Standard_Real R)
-{
-  return R >= (0.5*Precision::Infinite());
-}
-
-//=======================================================================
-//function : IsNegativeInfinite
-//purpose  : 
-//=======================================================================
-
-inline Standard_Boolean  Precision::IsNegativeInfinite(const Standard_Real R)
-{
-  return R <= -(0.5*Precision::Infinite());
-}
-
-
-//=======================================================================
-//function : Infinite
-//purpose  : 
-//=======================================================================
-
-inline Standard_Real  Precision::Infinite()
-{
-#ifdef PRECISION_OBSOLETE
-  static const Standard_Real Precision_Infinite       = 1.e+100;
-  static const Standard_Real Precision_InfiniteValue  = 2 * Precision_Infinite;
-  return Precision_InfiniteValue;
-#else
-  return 2.e+100;
-#endif
-}
-
index d2ee28cea127d04a4b9603d015085ac033b246d0..9801ca42138a61d002b32f0ef49d2a8833bec974 100644 (file)
@@ -22,6 +22,8 @@
 #include <Interface_Static.hxx>
 #include <Message.hxx>
 #include <Message_Messenger.hxx>
+#include <Precision.hxx>
+#include <Standard_NumericError.hxx>
 #include <Standard_Transient.hxx>
 #include <Standard_Type.hxx>
 #include <StepData_EnumTool.hxx>
@@ -489,145 +491,299 @@ Standard_Integer StepData_StepReaderData::ReadSub(const Standard_Integer numsub,
   Handle(TColStd_HArray1OfReal)      hre;
   Handle(Interface_HArray1OfHAsciiString)  hst;
   Standard_Integer kod = 0;
-  switch (FT0) {
-    case Interface_ParamMisc    : return -1;
-    case Interface_ParamInteger : kod = 1;  break;
-    case Interface_ParamReal    : kod = 5;  break;
-    case Interface_ParamIdent   : kod = 7;  break;
-    case Interface_ParamVoid    : kod = 0;  break;
-    case Interface_ParamText    : kod = 6;  break;
-    case Interface_ParamEnum    : kod = 4;  break;  // a confirmer(logical)
-      /*      kod = 4;
-             if ( str[0] == '.' && str[2] == '.' && str[3] == '\0' &&
-             (str[1] == 'T' || str[1] == 'F' || str[1] == 'U') ) kod = 3;
-             break; */ // svv #2
-    case Interface_ParamLogical : return -1;
-    case Interface_ParamSub     : kod = 0;  break;
-    case Interface_ParamHexa    : return -1;
-    case Interface_ParamBinary  : return -1;
-    default :  return -1;
+  switch (FT0)
+  {
+  case Interface_ParamMisc:
+    return -1;
+  case Interface_ParamInteger:
+    kod = 1;
+    break;
+  case Interface_ParamReal:
+    kod = 5;
+    break;
+  case Interface_ParamIdent:
+    kod = 7;
+    break;
+  case Interface_ParamVoid:
+    kod = 0;
+    break;
+  case Interface_ParamText:
+    kod = 6;
+    break;
+  case Interface_ParamEnum:
+    kod = 4;
+    break;  // a confirmer(logical)
+    /*      kod = 4;
+    if ( str[0] == '.' && str[2] == '.' && str[3] == '\0' &&
+    (str[1] == 'T' || str[1] == 'F' || str[1] == 'U') ) kod = 3;
+    break; */ // svv #2
+  case Interface_ParamLogical:
+    return -1;
+  case Interface_ParamSub:
+    kod = 0;
+    break;
+  case Interface_ParamHexa:
+    return -1;
+  case Interface_ParamBinary:
+    return -1;
+  default:
+    return -1;
+  }
+  if (kod == 1 || kod == 3)
+  {
+    hin = new TColStd_HArray1OfInteger (1,nbp); val = hin;
+  }
+  else if (kod == 5)
+  {
+    hre = new TColStd_HArray1OfReal(1,nbp);
+    val = hre;
+  }
+  else if (kod == 6)
+  {
+    hst = new Interface_HArray1OfHAsciiString(1,nbp);
+    val = hst;
+  }
+  else
+  {
+    htr = new TColStd_HArray1OfTransient(1,nbp);
+    val = htr;
   }
-  if (kod == 1 || kod == 3) { hin = new TColStd_HArray1OfInteger (1,nbp); val = hin; }
-  else if (kod == 5) { hre = new TColStd_HArray1OfReal   (1,nbp); val = hre; }
-  else if (kod == 6) { hst = new Interface_HArray1OfHAsciiString (1,nbp); val = hst; }
-  else            { htr = new TColStd_HArray1OfTransient (1,nbp); val = htr; }
 //  Attention : si type variable, faudra changer son fusil d epaule -> htr
 
-  for (Standard_Integer ip = 1; ip <= nbp; ip ++) {
+  for (Standard_Integer ip = 1; ip <= nbp; ip ++)
+  {
     const Interface_FileParameter& FP = Param(numsub,ip);
     str = FP.CValue();
     FT  = FP.ParamType();
-    switch (kod) {
-      case 1 : {
-       if (FT != Interface_ParamInteger) { kod = 0; break; }
-       hin->SetValue (ip,atoi(str));   break;
+    switch (kod)
+    {
+    case 1:
+      {
+        if (FT != Interface_ParamInteger)
+        {
+          kod = 0;
+          break;
+        }
+
+        hin->SetValue (ip,atoi(str));  break;
       }
-      case 2 :
-      case 3 : {
-       if (FT != Interface_ParamEnum)    { kod = 0; break; }
-       if      (!strcmp(str,".F.")) hin->SetValue (ip,0);
-       else if (!strcmp(str,".T.")) hin->SetValue (ip,1);
-       else if (!strcmp(str,".U.")) hin->SetValue (ip,2);
-       else    kod = 0;
-       break;
+    case 2:
+    case 3:
+      {
+        if (FT != Interface_ParamEnum)
+        {
+          kod = 0;
+          break;
+        }
+
+        if(!strcmp(str,".F."))
+          hin->SetValue (ip,0);
+        else if(!strcmp(str,".T."))
+          hin->SetValue (ip,1);
+        else if (!strcmp(str,".U."))
+          hin->SetValue (ip,2);
+        else
+          kod = 0;
+        break;
       }
-      case 4 : {
-       if (FT != Interface_ParamEnum)    { kod = 0; break; }
-       Handle(StepData_SelectNamed) sn = new StepData_SelectNamed;
-       sn->SetEnum (-1,str);
-       htr->SetValue (ip,sn);  break;
+    case 4:
+      {
+        if (FT != Interface_ParamEnum)
+        {
+          kod = 0;
+          break;
+        }
+
+        Handle(StepData_SelectNamed) sn = new StepData_SelectNamed;
+        sn->SetEnum (-1,str);
+        htr->SetValue (ip,sn);
+        break;
       }
-      case 5 : {
-       if (FT != Interface_ParamReal)    { kod = 0; break; }
-       hre->SetValue (ip,Interface_FileReaderData::Fastof(str));   break;
+    case 5:
+      {
+        if (FT != Interface_ParamReal)
+        {
+          kod = 0;
+          break;
+        }
+
+        Standard_Real aValue = Interface_FileReaderData::Fastof(str);
+        if(Precision::IsIllegal(aValue))
+        {
+          Standard_NumericError::Raise();
+        }
+
+        if(Precision::IsInfinitesimal(aValue))
+        {
+          aValue = 0.0;
+        }
+
+        hre->SetValue (ip,aValue);
+        break;
       }
-      case 6 : {
-       if (FT != Interface_ParamText)    { kod = 0; break; }
-       Handle(TCollection_HAsciiString) txt = new TCollection_HAsciiString(str);
-       CleanText (txt);  hst->SetValue (ip,txt);  break;
+    case 6:
+      {
+        if (FT != Interface_ParamText)
+        {
+          kod = 0;
+          break;
+        }
+
+        Handle(TCollection_HAsciiString) txt = new TCollection_HAsciiString(str);
+        CleanText (txt);
+        hst->SetValue (ip,txt);
+        break;
       }
-      case 7 : {
-       Handle(Standard_Transient) ent = BoundEntity (FP.EntityNumber());
-       htr->SetValue (ip,ent);  break;
+    case 7:
+      {
+        Handle(Standard_Transient) ent = BoundEntity (FP.EntityNumber());
+        htr->SetValue (ip,ent);
+        break;
       }
-      default : break;
+    default:
+      break;
     }
-//    Restent les autres cas ... tout est possible. cf le type du Param
-    if (kod > 0) continue;
-//    Il faut passer au transient ...
-    if (htr.IsNull()) {
+    //    Restent les autres cas ... tout est possible. cf le type du Param
+    if (kod > 0)
+      continue;
+    //    Il faut passer au transient ...
+    if (htr.IsNull())
+    {
       htr = new TColStd_HArray1OfTransient (1,nbp);  val = htr;
       Standard_Integer jp;     
-      if (!hin.IsNull()) {
-       for (jp = 1; jp < ip; jp ++) {
-         Handle(StepData_SelectInt) sin = new StepData_SelectInt;
-         sin->SetInt (hin->Value(jp));
-         htr->SetValue (jp,sin);
-       }
+      if (!hin.IsNull())
+      {
+        for (jp = 1; jp < ip; jp ++)
+        {
+          Handle(StepData_SelectInt) sin = new StepData_SelectInt;
+          sin->SetInt (hin->Value(jp));
+          htr->SetValue (jp,sin);
+        }
       }
-      if (!hre.IsNull()) {
-       for (jp = 1; jp < ip; jp ++) {
-         Handle(StepData_SelectReal) sre = new StepData_SelectReal;
-         sre->SetReal (hre->Value(jp));
-         htr->SetValue (jp,sre);
-       }
+      if (!hre.IsNull())
+      {
+        for (jp = 1; jp < ip; jp ++)
+        {
+          Handle(StepData_SelectReal) sre = new StepData_SelectReal;
+          sre->SetReal (hre->Value(jp));
+          htr->SetValue (jp,sre);
+        }
       }
-      if (!hst.IsNull()) {
-       for (jp = 1; jp < ip; jp ++) {
-         htr->SetValue (jp,hst->Value(jp));
-       }
+      if (!hst.IsNull())
+      {
+        for (jp = 1; jp < ip; jp ++)
+        {
+          htr->SetValue (jp,hst->Value(jp));
+        }
       }
     }
-//    A present, faut y aller : lire le champ et le mettre en place
-//    Ce qui suit ressemble fortement a ReadAny ...
+    //    A present, faut y aller : lire le champ et le mettre en place
+    //    Ce qui suit ressemble fortement a ReadAny ...
 
-    switch (FT) {
-    case Interface_ParamMisc : break;
-    case Interface_ParamInteger : {
-      Handle(StepData_SelectInt) sin = new StepData_SelectInt;
-      sin->SetInteger (atoi(str));
-      htr->SetValue (ip,sin); break;
-    }
-    case Interface_ParamReal : {
-      Handle(StepData_SelectReal) sre = new StepData_SelectReal;
-      sre->SetReal (Interface_FileReaderData::Fastof(str));   break;
-      //htr->SetValue (ip,sre); break; svv #2: unreachable
-    }
-    case Interface_ParamIdent : htr->SetValue (ip,BoundEntity (FP.EntityNumber()));  break;
-    case Interface_ParamVoid : break;
-    case Interface_ParamEnum : {
-      Handle(StepData_SelectInt)   sin;
-      Handle(StepData_SelectNamed) sna;
-      Standard_Integer logic = -1;
-// PTV 16.09.2000
-// set the default value of StepData_Logical
-      StepData_Logical slog = StepData_LUnknown;
-      if ( str[0] == '.' && str[2] == '.' && str[3] == '\0') {
-       if (str[1] == 'F')       {  slog = StepData_LFalse;    logic = 0;  }
-       else if (str[1] == 'T')  {  slog = StepData_LTrue;     logic = 1;  }
-       else if (str[1] == 'U')  {  slog = StepData_LUnknown;  logic = 2;  }
+    switch (FT)
+    {
+    case Interface_ParamMisc:
+      break;
+    case Interface_ParamInteger:
+      {
+        Handle(StepData_SelectInt) sin = new StepData_SelectInt;
+        sin->SetInteger (atoi(str));
+        htr->SetValue (ip,sin);
+        break;
+      }
+    case Interface_ParamReal:
+      {
+        Handle(StepData_SelectReal) sre = new StepData_SelectReal;
+
+        Standard_Real aValue = Interface_FileReaderData::Fastof(str);
+        if(Precision::IsIllegal(aValue))
+        {
+          Standard_NumericError::Raise();
+        }
+
+        if(Precision::IsInfinitesimal(aValue))
+        {
+          aValue = 0.0;
+        }
+
+        sre->SetReal (aValue);
+        break;
+        //htr->SetValue (ip,sre); break; svv #2: unreachable
       }
-      if (logic >= 0)
-       { sin = new StepData_SelectInt; sin->SetLogical(slog); htr->SetValue(ip,sin); }
-      else { sna = new StepData_SelectNamed;
-            sna->SetEnum (logic,str); htr->SetValue (ip,sna);  }
+    case Interface_ParamIdent:
+      htr->SetValue (ip,BoundEntity (FP.EntityNumber()));
+      break;
+    case Interface_ParamVoid:
+      break;
+    case Interface_ParamEnum:
+      {
+        Handle(StepData_SelectInt)   sin;
+        Handle(StepData_SelectNamed) sna;
+        Standard_Integer logic = -1;
+
+        // PTV 16.09.2000
+        // set the default value of StepData_Logical
+
+        StepData_Logical slog = StepData_LUnknown;
+
+        if ( str[0] == '.' && str[2] == '.' && str[3] == '\0')
+        {
+          if (str[1] == 'F')
+          {
+            slog = StepData_LFalse;
+            logic = 0;
+          }
+          else if (str[1] == 'T')
+          {
+            slog = StepData_LTrue;
+            logic = 1;
+          }
+          else if (str[1] == 'U')
+          {
+            slog = StepData_LUnknown;
+            logic = 2;
+          }
+        }
+
+        if (logic >= 0)
+        {
+          sin = new StepData_SelectInt; sin->SetLogical(slog); htr->SetValue(ip,sin);
+        }
+        else
+        {
+          sna = new StepData_SelectNamed;
+          sna->SetEnum (logic,str); htr->SetValue (ip,sna);
+        }
+        break;
+      }
+    case Interface_ParamLogical:
+      break;
+    case Interface_ParamText:
+      {
+        Handle(TCollection_HAsciiString) txt = new TCollection_HAsciiString(str);
+        CleanText (txt);
+        htr->SetValue (ip,txt);
+        break;
+      }
+    case Interface_ParamSub:
+      {
+        Handle(Standard_Transient) sub;
+        Standard_Integer nent = FP.EntityNumber();
+        Standard_Integer kind = ReadSub (nent,mess,ach,descr,sub);
+        if (kind < 0)
+          break;
+
+        htr->SetValue(ip,sub);  break;
+      }
+
+    case Interface_ParamHexa:
+      break;
+    case Interface_ParamBinary:
+      break;
+    default:
       break;
     }
-    case Interface_ParamLogical : break;
-    case Interface_ParamText : {
-      Handle(TCollection_HAsciiString) txt = new TCollection_HAsciiString(str);
-      CleanText (txt);  htr->SetValue (ip,txt);  break;
-    }
-    case Interface_ParamSub  : {
-      Handle(Standard_Transient) sub;
-      Standard_Integer nent = FP.EntityNumber();
-      Standard_Integer kind = ReadSub (nent,mess,ach,descr,sub);   if (kind < 0) break;
-      htr->SetValue(ip,sub);  break;
-    }
-    case Interface_ParamHexa : break;
-    case Interface_ParamBinary  : break;
-    default                  : break;
-    }
+
     return -1;
   }
   return 8;  // pour Any
@@ -682,7 +838,20 @@ Standard_Boolean StepData_StepReaderData::ReadField(const Standard_Integer num,
     case Interface_ParamMisc    : OK = Standard_False;  break;
     case Interface_ParamInteger : fild.SetInteger (atoi(str)); break;
     case Interface_ParamReal    :
-      fild.SetReal (Interface_FileReaderData::Fastof(str));   break;
+      {
+        Standard_Real aValue = Interface_FileReaderData::Fastof(str);
+        if(Precision::IsIllegal(aValue))
+        {
+          Standard_NumericError::Raise();
+        }
+
+        if(Precision::IsInfinitesimal(aValue))
+        {
+          aValue = 0.0;
+        }
+
+        fild.SetReal (aValue);   break;
+      }
     case Interface_ParamIdent   :
       nent = FP.EntityNumber();
       if (nent > 0) fild.SetEntity (BoundEntity(nent));
@@ -768,12 +937,33 @@ Standard_Boolean StepData_StepReaderData::ReadAny(const Standard_Integer num,
     }
     case Interface_ParamReal : {
       if (!val.IsNull()) {
-       DeclareAndCast(StepData_SelectMember,sm,val);
-       sm->SetReal (Interface_FileReaderData::Fastof(str));
-       return Standard_True;
+        DeclareAndCast(StepData_SelectMember,sm,val);
+        Standard_Real aValue = Interface_FileReaderData::Fastof(str);
+        if(Precision::IsIllegal(aValue))
+        {
+          Standard_NumericError::Raise();
+        }
+        if(Precision::IsInfinitesimal(aValue))
+        {
+          aValue = 0.0;
+        }
+
+        sm->SetReal (aValue);
+        return Standard_True;
       }
       Handle(StepData_SelectReal) sre = new StepData_SelectReal;
-      sre->SetReal (Interface_FileReaderData::Fastof(str));
+      Standard_Real aValue = Interface_FileReaderData::Fastof(str);
+      if(Precision::IsIllegal(aValue))
+      {
+        Standard_NumericError::Raise();
+      }
+
+      if(Precision::IsInfinitesimal(aValue))
+      {
+        aValue = 0.0;
+      }
+
+      sre->SetReal (aValue);
       val = sre;
       return Standard_True;
     }
@@ -894,13 +1084,35 @@ Standard_Boolean StepData_StepReaderData::ReadXY(const Standard_Integer num,
   if (numsub != 0) {
     if (NbParams(numsub) == 2) {
       const Interface_FileParameter& FPX = Param(numsub,1);
-      if (FPX.ParamType() == Interface_ParamReal)  X =
-       Interface_FileReaderData::Fastof(FPX.CValue());
+      if (FPX.ParamType() == Interface_ParamReal)
+      {
+        X = Interface_FileReaderData::Fastof(FPX.CValue());
+        if(Precision::IsIllegal(X))
+        {
+          Standard_NumericError::Raise();
+        }
+
+        if(Precision::IsInfinitesimal(X))
+        {
+          X = 0.0;
+        }
+      }
       else errmess = new String("Parameter n0.%d (%s) : (X,Y) X not a Real");
 
       const Interface_FileParameter& FPY = Param(numsub,2);
-      if (FPY.ParamType() == Interface_ParamReal)  Y = 
-       Interface_FileReaderData::Fastof( FPY.CValue());
+      if (FPY.ParamType() == Interface_ParamReal)
+      {
+        Y = Interface_FileReaderData::Fastof( FPY.CValue());
+        if(Precision::IsIllegal(Y))
+        {
+          Standard_NumericError::Raise();
+        }
+
+        if(Precision::IsInfinitesimal(Y))
+        {
+          Y = 0.0;
+        }
+      }
       else errmess = new String("Parameter n0.%d (%s) : (X,Y) Y not a Real");
 
     }
@@ -932,18 +1144,51 @@ Standard_Boolean StepData_StepReaderData::ReadXYZ(const Standard_Integer num,
   if (numsub != 0) {
     if (NbParams(numsub) == 3) {
       const Interface_FileParameter& FPX = Param(numsub,1);
-      if (FPX.ParamType() == Interface_ParamReal)  X =
-       Interface_FileReaderData::Fastof(FPX.CValue());
+      if (FPX.ParamType() == Interface_ParamReal)
+      {
+        X = Interface_FileReaderData::Fastof(FPX.CValue());
+        if(Precision::IsIllegal(X))
+        {
+          Standard_NumericError::Raise();
+        }
+
+        if(Precision::IsInfinitesimal(X))
+        {
+          X = 0.0;
+        }
+      }
       else errmess = new String("Parameter n0.%d (%s) : (X,Y,Z) X not a Real");
 
       const Interface_FileParameter& FPY = Param(numsub,2);
-      if (FPY.ParamType() == Interface_ParamReal)  Y =
-       Interface_FileReaderData::Fastof(FPY.CValue());
+      if (FPY.ParamType() == Interface_ParamReal)
+      {
+        Y = Interface_FileReaderData::Fastof(FPY.CValue());
+        if(Precision::IsIllegal(Y))
+        {
+          Standard_NumericError::Raise();
+        }
+
+        if(Precision::IsInfinitesimal(Y))
+        {
+          Y = 0.0;
+        }
+      }
       else errmess = new String("Parameter n0.%d (%s) : (X,Y,Z) Y not a Real");
 
       const Interface_FileParameter& FPZ = Param(numsub,3);
-      if (FPZ.ParamType() == Interface_ParamReal)  Z =
-       Interface_FileReaderData::Fastof(FPZ.CValue());
+      if (FPZ.ParamType() == Interface_ParamReal)
+      {
+        Z = Interface_FileReaderData::Fastof(FPZ.CValue());
+        if(Precision::IsIllegal(Z))
+        {
+          Standard_NumericError::Raise();
+        }
+
+        if(Precision::IsInfinitesimal(Z))
+        {
+          Z = 0.0;
+        }
+      }
       else errmess = new String("Parameter n0.%d (%s) : (X,Y,Z) Z not a Real");
 
     }
@@ -972,8 +1217,19 @@ Standard_Boolean StepData_StepReaderData::ReadReal(const Standard_Integer num,
   Handle(String) errmess;  // Null si pas d erreur
   if (nump > 0 && nump <= NbParams(num)) {
     const Interface_FileParameter& FP = Param(num,nump);
-    if (FP.ParamType() == Interface_ParamReal)  val =
-      Interface_FileReaderData::Fastof(FP.CValue());
+    if (FP.ParamType() == Interface_ParamReal)
+    {
+      val = Interface_FileReaderData::Fastof(FP.CValue());
+      if(Precision::IsIllegal(val))
+      {
+        Standard_NumericError::Raise();
+      }
+
+      if(Precision::IsInfinitesimal(val))
+      {
+        val = 0.0;
+      }
+    }
     else errmess = new String("Parameter n0.%d (%s) not a Real");
   }
   else errmess = new String("Parameter n0.%d (%s) absent");
index 8c0e68f860dc5d1bb8aed9875844def177be7fab..72650688d2a2ba0d0f6c46396ebf545e7b7608af 100755 (executable)
@@ -1,22 +1,19 @@
 # !!!! This file is generated automatically, do not edit manually! See end script
 puts "TODO CR23096 ALL: NBSHAPES : Faulty" 
-puts "TODO CR23096 ALL: TOLERANCE : Faulty" 
 puts "TODO CR23096 ALL: LABELS : Faulty" 
 puts "TODO CR23096 ALL: COLORS : Faulty" 
-puts "TODO CR25013 ALL: Error : 3 differences with reference data found
+puts "TODO CR23096 ALL: CHECKSHAPE : Faulty
 
-set LinuxDiff 4
-set LinuxFaulties {STATSHAPE}
 set filename coque-sup.igs
 
 set ref_data {
 DATA        : Faulties = 0  ( 0 )  Warnings = 0  ( 0 )  Summary  = 0  ( 0 )
-TPSTAT      : Faulties = 0  ( 3 )  Warnings = 274  ( 4465 )  Summary  = 274  ( 4468 )
-CHECKSHAPE  : Wires    = 2  ( 2 )  Faces    = 3  ( 3 )  Shells   = 0  ( 0 )   Solids   = 0 ( 0 )
-NBSHAPES    : Solid    = 0  ( 0 )  Shell    = 0  ( 0 )  Face     = 1628  ( 1628 )   Summary  = 39231  ( 39275 )
-STATSHAPE   : Solid    = 0  ( 0 )  Shell    = 0  ( 0 )  Face     = 1628  ( 1628 )   FreeWire = 22  ( 26 )   FreeEdge  = 135 ( 135 )   SharedEdge = 17934  ( 17947 )
-TOLERANCE   : MaxTol   =   4.337400808e+088  (    8.082392835e+086 )  AvgTol   =  2.040579288e+085  (    5.099401401e+083 )
-LABELS      : N0Labels = 6  ( 6 )  N1Labels = 1643  ( 9621 )  N2Labels = 0  ( 0 )   TotalLabels = 1649  ( 9627 )   NameLabels = 1649  ( 2891 )   ColorLabels = 1645  ( 9626 )   LayerLabels = 489  ( 3997 )
+TPSTAT      : Faulties = 0  ( 6 )  Warnings = 274  ( 4459 )  Summary  = 274  ( 4465 )
+CHECKSHAPE  : Wires    = 1  ( 1 )  Faces    = 3  ( 2 )  Shells   = 0  ( 0 )   Solids   = 0 ( 0 )
+NBSHAPES    : Solid    = 0  ( 0 )  Shell    = 0  ( 0 )  Face     = 1626  ( 1626 )   Summary  = 39233  ( 39240 )
+STATSHAPE   : Solid    = 0  ( 0 )  Shell    = 0  ( 0 )  Face     = 1626  ( 1626 )   FreeWire = 22  ( 26 )   FreeEdge  = 135 ( 135 )   SharedEdge = 17927  ( 17928 )
+TOLERANCE   : MaxTol   =   0.1961320506  (    992.8187669 )  AvgTol   =  0.0003489506144  (    0.2649133106 )
+LABELS      : N0Labels = 6  ( 6 )  N1Labels = 1641  ( 9630 )  N2Labels = 0  ( 0 )   TotalLabels = 1647  ( 9636 )   NameLabels = 1647  ( 2887 )   ColorLabels = 1643  ( 9635 )   LayerLabels = 487  ( 3989 )
 PROPS       : Centroid = 0  ( 0 )  Volume   = 0  ( 0 )  Area     = 0  ( 0 )
 NCOLORS     : NColors  = 4  ( 5 )
 COLORS      : Colors   = BLUE1 CYAN1 GOLD3 GREEN  ( BLUE1 CYAN1 GOLD3 GREEN YELLOW )
index 8b628a77772ed9c53ea944998a94598e5ffe3daf..a009f7d56a566e0765ea8944475b74c2ff12a3a1 100755 (executable)
@@ -2,14 +2,14 @@
 set filename trj4_s1-ai-214.stp
 
 set ref_data {
-DATA        : Faulties = 0  ( 54 )  Warnings = 0  ( 0 )  Summary  = 0  ( 54 )
+DATA        : Faulties = 0  ( 0 )  Warnings = 0  ( 0 )  Summary  = 0  ( 0 )
 TPSTAT      : Faulties = 0  ( 0 )  Warnings = 2  ( 51 )  Summary  = 2  ( 51 )
 CHECKSHAPE  : Wires    = 0  ( 0 )  Faces    = 0  ( 0 )  Shells   = 0  ( 0 )   Solids   = 0 ( 0 )
 NBSHAPES    : Solid    = 8  ( 8 )  Shell    = 10  ( 10 )  Face     = 108  ( 108 )   Summary  = 603  ( 603 )
 STATSHAPE   : Solid    = 8  ( 8 )  Shell    = 10  ( 10 )  Face     = 108  ( 108 )   FreeWire = 0  ( 0 )   FreeEdge  = 0 ( 0 )   SharedEdge = 212  ( 212 )
 TOLERANCE   : MaxTol   = 0.0007308879226  ( 0.002238579085 )  AvgTol   =  1.588313862e-05  (  3.376786703e-05 )
 LABELS      : N0Labels = 9  ( 9 )  N1Labels = 8  ( 8 )  N2Labels = 0  ( 0 )   TotalLabels = 17  ( 17 )   NameLabels = 17  ( 17 )   ColorLabels = 0  ( 0 )   LayerLabels = 0  ( 0 )
-PROPS       : Centroid = 1  ( 1 )  Volume   = 1  ( 1 )  Area     = 1  ( 1 )
+PROPS       : Centroid = 0  ( 0 )  Volume   = 1  ( 1 )  Area     = 1  ( 1 )
 NCOLORS     : NColors  = 0  ( 0 )
 COLORS      : Colors   =   (  )
 NLAYERS     : NLayers  = 0  ( 0 )