026464: BRepOffset_MakeOffset does not provide valid output
authoraml <aml@opencascade.com>
Wed, 29 Jul 2015 13:14:09 +0000 (16:14 +0300)
committerbugmaster <bugmaster@opencascade.com>
Wed, 29 Jul 2015 13:15:25 +0000 (16:15 +0300)
Handling of degenerated case improved.

Test-case for issue #26464

src/BRepOffset/BRepOffset_Offset.cxx
tests/bugs/modalg_6/bug26464 [new file with mode: 0644]

index db10445..05bf9b8 100644 (file)
@@ -537,11 +537,29 @@ void BRepOffset_Offset::Init(const TopoDS_Face&                  Face,
       TopTools_SequenceOfShape DegEdges;
       TopExp_Explorer Explo(Face, TopAbs_EDGE);
       for (; Explo.More(); Explo.Next())
-       {
-         const TopoDS_Edge& anEdge = TopoDS::Edge(Explo.Current());
-         if (BRep_Tool::Degenerated(anEdge))
-           DegEdges.Append(anEdge);
-       }
+      {
+        const TopoDS_Edge& anEdge = TopoDS::Edge(Explo.Current());
+
+        if (BRep_Tool::Degenerated(anEdge))
+        {
+          Standard_Real aF, aL;
+          Handle(Geom2d_Curve) c2d =  BRep_Tool::CurveOnSurface(anEdge, Face, aF, aL);
+
+          gp_Pnt2d aFPnt2d = c2d->Value(aF),
+                   aLPnt2d = c2d->Value(aL);
+
+          gp_Pnt aFPnt = S->Value(aFPnt2d.X(), aFPnt2d.Y()),
+                 aLPnt = S->Value(aLPnt2d.X(), aLPnt2d.Y());
+
+          //  aFPnt.SquareDistance(aLPnt) > Precision::SquareConfusion() -
+          // is a sufficient condition of troubles: non-singular case, but edge is degenerated.
+          // So, normal handling of degenerated edges is not applicable in case of non-singular point.
+          if (aFPnt.SquareDistance(aLPnt) < Precision::SquareConfusion())
+          {
+            DegEdges.Append(anEdge);
+          }
+        }
+      }
       if (!DegEdges.IsEmpty())
        {
          const Standard_Real TolApex = 1.e-5;
@@ -1640,6 +1658,3 @@ BRepOffset_Status BRepOffset_Offset::Status() const
 {
   return myStatus;
 }
-
-
-
diff --git a/tests/bugs/modalg_6/bug26464 b/tests/bugs/modalg_6/bug26464
new file mode 100644 (file)
index 0000000..86cfbea
--- /dev/null
@@ -0,0 +1,17 @@
+puts "========"
+puts "OCC26464"
+puts "========"
+puts ""
+#######################################################
+# BRepOffset_MakeOffset does not provide valid output
+#######################################################
+
+smallview
+
+restore [locate_data_file OCC26464-extracted_Plate5520contour.brep] sh
+offsetparameter 1e-7 p i
+offsetload sh 60
+offsetperform r
+fit
+
+set only_screen_axo 1