]> OCCT Git - occt-copy.git/commitdiff
0029159: Sewing fail when using a maximum tolerance
authormsv <msv@opencascade.com>
Fri, 29 Sep 2017 07:43:52 +0000 (10:43 +0300)
committermsv <msv@opencascade.com>
Fri, 13 Oct 2017 12:12:53 +0000 (15:12 +0300)
Force setting truly computed tolerance of the edge if BRepLib::SameParameter has put too large tolerance.

src/BRepBuilderAPI/BRepBuilderAPI_Sewing.cxx
tests/bugs/modalg_7/bug29159 [new file with mode: 0644]

index ffe71aad900a2448a0a61b878dfecf78148cce6f..ce5039ff8c2bb20f1e61708176b4981f19e87c7c 100644 (file)
 #include <Geom_OffsetSurface.hxx>
 #include <BRep_PointOnCurve.hxx>
 #include <BRep_ListOfPointRepresentation.hxx>
+#include <BRep_TEdge.hxx>
 #include <BRep_TVertex.hxx>
 #include <Message_ProgressSentry.hxx>
 #include <BRepBuilderAPI_VertexInspector.hxx>
@@ -951,11 +952,22 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge(const TopoDS_Edge& edgeFirs
             if (dist > dist2) 
               dist2 = dist;
           }
-          maxTol = Max(sqrt(dist2), Precision::Confusion());
+          maxTol = Max(sqrt(dist2) * (1. + 1e-7), Precision::Confusion());
         }
       }
       if(maxTol >= 0. && maxTol < tolReached)
+      {
+        if (tolReached > MaxTolerance())
+        {
+          // Set tolerance directly to overwrite too large tolerance
+          static_cast<BRep_TEdge*>(edge.TShape().operator->())->Tolerance(maxTol);
+        }
+        else
+        {
+          // just update tolerance with computed distance
         aBuilder.UpdateEdge(edge, maxTol);
+        }
+      }
       aBuilder.SameParameter(edge,Standard_True);
     }
   }
diff --git a/tests/bugs/modalg_7/bug29159 b/tests/bugs/modalg_7/bug29159
new file mode 100644 (file)
index 0000000..21397f9
--- /dev/null
@@ -0,0 +1,29 @@
+puts "========"
+puts "OCC29159"
+puts "========"
+puts ""
+#################################################
+# Sewing fail when using a maximum tolerance
+#################################################
+
+set MaxTol 5e-4
+set ExpLength 97.234
+
+restore [locate_data_file bug29159_F.brep] f
+sewing result 5e-4 f +mint 1e-8 +maxt $MaxTol
+
+regexp {EDGE *: MAX=([-0-9.+eE]+)} [tolerance result] full toler
+
+if {$toler > $MaxTol} {
+  puts "Error: Tolerance after sewing is greater than max allowed tolerance"
+}
+
+if {![regexp "seems to be OK" [bopcheck result 2]]} {
+  puts "Error: result of sewing is self-interfering"
+}
+
+checknbshapes result -m "Sewing result" -edge 8 -face 2
+
+smallview +X+Y
+don result
+fit