0026384: Add explicit check for null magnitude instead of catching of exception in...
authoroan <oan@opencascade.com>
Wed, 17 Feb 2016 14:17:54 +0000 (17:17 +0300)
committerabv <abv@opencascade.com>
Sat, 20 Feb 2016 07:10:06 +0000 (10:10 +0300)
Check normal for null magnitude using gp::Resolution ()

src/BRepMesh/BRepMesh_FastDiscretFace.cxx

index dd1fe61..04400d1 100644 (file)
@@ -1227,29 +1227,24 @@ Standard_Real BRepMesh_FastDiscretFace::control(
       Standard_Real aSqDef = -1.;
       Standard_Boolean isSkipped = Standard_False;
       gp_XYZ normal(aLinkVec[0] ^ aLinkVec[1]);
-      try
-      {
-        OCC_CATCH_SIGNALS
+      if (normal.SquareModulus () < gp::Resolution())
+        continue;
 
-        normal.Normalize();
+      normal.Normalize();
 
-        // Check deflection on triangle
-        gp_XY mi2d = (xy[0] + xy[1] + xy[2]) / 3.0;
-        gFace->D0(mi2d.X(), mi2d.Y(), pDef);
-        aSqDef = Abs(normal * (pDef.XYZ() - p[0]));
-        aSqDef *= aSqDef;
+      // Check deflection at triangle centroid
+      gp_XY aCenter2d = (xy[0] + xy[1] + xy[2]) / 3.0;
+      gFace->D0(aCenter2d.X(), aCenter2d.Y(), pDef);
+      aSqDef = Abs(normal * (pDef.XYZ() - p[0]));
+      aSqDef *= aSqDef;
 
-        isSkipped = !checkDeflectionAndInsert(pDef, mi2d, theIsFirst, 
-          aSqDef, aSqDefFace, aCircles, theNewVertices, aMaxSqDef);
+      isSkipped = !checkDeflectionAndInsert(pDef, aCenter2d, theIsFirst, 
+        aSqDef, aSqDefFace, aCircles, theNewVertices, aMaxSqDef);
 
-        if (isSkipped)
-          break;
-      }
-      catch (Standard_Failure)
-      {
-        continue;
-      }
+      if (isSkipped)
+        break;
 
+      // Check deflection at triangle links
       for (Standard_Integer i = 0; i < 3 && !isSkipped; ++i)
       {
         if (m[i]) // is a boundary