0027679: Wrong offset: overlapping edges
authorifv <ifv@opencascade.com>
Fri, 15 Jul 2016 07:42:09 +0000 (10:42 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 21 Jul 2016 08:20:34 +0000 (11:20 +0300)
Method BRepFill_OffsetWire::UpdateDetromp(...) is modified for correct treatment of closed bisectors.

Test case for issue #27679

src/BRepFill/BRepFill_OffsetWire.cxx
tests/bugs/modalg_6/bug27679 [new file with mode: 0644]

index 1de2334..5cc63bd 100644 (file)
@@ -1310,7 +1310,15 @@ void BRepFill_OffsetWire::UpdateDetromp (BRepFill_DataMapOfOrientedShapeListOfSh
     TopoDS_Vertex    V1,V2;
     
     const Handle(Geom2d_Curve)& Bis = Bisec.Value();
-    
+    Standard_Boolean ForceAdd = Standard_False;
+    Handle(Geom2d_TrimmedCurve) aTC = Handle(Geom2d_TrimmedCurve)::DownCast(Bis);
+    if(!aTC.IsNull() && aTC->BasisCurve()->IsPeriodic())
+    {
+      gp_Pnt2d Pf = Bis->Value(Bis->FirstParameter());
+      gp_Pnt2d Pl = Bis->Value(Bis->LastParameter());
+      ForceAdd = Pf.Distance(Pl) <= Precision::Confusion();
+    }
+
     U1 = Bis->FirstParameter();
     
     if (SOnE) { 
@@ -1324,7 +1332,7 @@ void BRepFill_OffsetWire::UpdateDetromp (BRepFill_DataMapOfOrientedShapeListOfSh
       V2 = TopoDS::Vertex(Vertices.Value(ii));
       
       gp_Pnt2d P = Bis->Value((U2 + U1)*0.5);
-      if (!Trim.IsInside(P)) {
+      if (!Trim.IsInside(P) || ForceAdd) {
         if (!V1.IsNull()) {
           Detromp(Shape1).Append(V1);
           Detromp(Shape2).Append(V1);
@@ -1342,7 +1350,7 @@ void BRepFill_OffsetWire::UpdateDetromp (BRepFill_DataMapOfOrientedShapeListOfSh
     if (!EOnE) {
       if (!Precision::IsInfinite(U2)) {
         gp_Pnt2d P = Bis->Value((U2 + U1)*0.5);
-        if (!Trim.IsInside(P)) {
+        if (!Trim.IsInside(P) || ForceAdd) {
           if (!V1.IsNull()) {
             Detromp(Shape1).Append(V1);
             Detromp(Shape2).Append(V1);
diff --git a/tests/bugs/modalg_6/bug27679 b/tests/bugs/modalg_6/bug27679
new file mode 100644 (file)
index 0000000..d1e4e97
--- /dev/null
@@ -0,0 +1,16 @@
+puts "========"
+puts "OCC27679"
+puts "========"
+puts ""
+###################################
+# Wrong offset: overlapping edges
+###################################
+
+restore [locate_data_file bug27679_w.brep] w
+
+mkoffset r w 1 20
+renamevar r_1 result
+
+checknbshapes result -edge 23
+
+checkview -display result -2d -path ${imagedir}/${test_image}.png