]> OCCT Git - occt-copy.git/commitdiff
Skip call of BRepLib_MakeFace for non-linear edges CR0_691_FixCMT
authorsnn <snn@opencascade.com>
Tue, 13 Jun 2017 06:48:24 +0000 (09:48 +0300)
committersnn <snn@opencascade.com>
Tue, 13 Jun 2017 06:48:24 +0000 (09:48 +0300)
src/BRepOffset/BRepOffset_MakeSimpleOffset.cxx

index 8617ee072fdd47a1b8af530bc38ed7439a070ede..43095cba00ee425f9d3048be76d8b753b13df184 100644 (file)
@@ -30,6 +30,7 @@
 #include <BRepOffset_SimpleOffset.hxx>
 #include <BRepTools_Modifier.hxx>
 #include <Geom_TrimmedCurve.hxx>
+#include <Geom_Line.hxx>
 #include <Geom2d_Line.hxx>
 #include <GeomFill_Generator.hxx>
 #include <Extrema_LocateExtPC.hxx>
@@ -421,6 +422,18 @@ Standard_Boolean BRepOffset_MakeSimpleOffset::BuildMissingWalls(const BRepTools_
   return Standard_True;
 }
 
+// used in BuildWallFace
+static Standard_Boolean isLinear(const TopoDS_Edge& theEdge)
+{
+  Standard_Real aU1, aU2;
+  Handle(Geom_Curve) aCurve = BRep_Tool::Curve(theEdge, aU1, aU2);
+  while (aCurve->IsKind(STANDARD_TYPE(Geom_TrimmedCurve)))
+  {
+    aCurve = Handle(Geom_TrimmedCurve)::DownCast(aCurve)->BasisCurve();
+  }
+  return !aCurve.IsNull() && aCurve->IsKind(STANDARD_TYPE(Geom_Line));
+}
+
 //=============================================================================
 //function : BuildWallFace
 //purpose  :
@@ -505,15 +518,18 @@ TopoDS_Face BRepOffset_MakeSimpleOffset::BuildWallFace(const BRepTools_Modifier&
 
   // Try to build using simple planar approach.
   TopoDS_Face aF;
-  try
-  {
-    // Call of face maker is wrapped by try/catch since it generates exceptions sometimes.
-    BRepLib_MakeFace aFM(aWire, Standard_True);
-    if (aFM.IsDone())
-      aF = aFM.Face();
-  }
-  catch(Standard_Failure)
+  if (isLinear(anOrigCopy) && isLinear(aWall1) && isLinear(aNewEdge) && isLinear(aWall2))
   {
+    try
+    {
+      // Call of face maker is wrapped by try/catch since it generates exceptions sometimes.
+      BRepLib_MakeFace aFM(aWire, Standard_True);
+      if (aFM.IsDone())
+        aF = aFM.Face();
+    }
+    catch (Standard_Failure)
+    {
+    }
   }
 
   if (aF.IsNull()) // Exception in face maker or result is not computed.