0031029: BRepLib::SameParameter regression in OCCT 7.4 from OCCT 7.3
authorifv <ifv@opencascade.com>
Mon, 14 Oct 2019 13:51:52 +0000 (16:51 +0300)
committerapn <apn@opencascade.com>
Tue, 22 Oct 2019 12:15:44 +0000 (15:15 +0300)
1. BRepLib.cxx: calculation of 2d tolerance is changed in method BRepLib::SameParameter(Edge..)
2. Geom2dConvert.cxx: incorrect comparing
"SquareDistance < tolerance"
is replaced by
"SquareDistance < tolerance*tolerance"
because tolerance is linear value.

src/BRepLib/BRepLib.cxx
src/Geom2dConvert/Geom2dConvert.cxx
tests/bugs/modalg_7/bug31029 [new file with mode: 0644]

index 3f7b47e..6a35e1f 100644 (file)
@@ -1347,15 +1347,13 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge,
       }
 
       // Eval tol2d to compute SameRange
-      Standard_Real UResol = Max(GAS.UResolution(theTolerance), Precision::PConfusion());
-      Standard_Real VResol = Max(GAS.VResolution(theTolerance), Precision::PConfusion());
-      Standard_Real Tol2d  = Min(UResol, VResol);
+      Standard_Real TolSameRange = Max(GAC.Resolution(theTolerance), Precision::PConfusion());
       for(Standard_Integer i = 0; i < 2; i++){
         Handle(Geom2d_Curve) curPC = PC[i];
         Standard_Boolean updatepc = 0;
         if(curPC.IsNull()) break;
         if(!SameRange){
-          GeomLib::SameRange(Tol2d,
+          GeomLib::SameRange(TolSameRange,
             PC[i],GCurve->First(),GCurve->Last(),
             f3d,l3d,curPC);
 
@@ -1375,13 +1373,17 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge,
 
         if(GAC2d.GetType() == GeomAbs_BSplineCurve && 
           GAC2d.Continuity() == GeomAbs_C0) {
+            Standard_Real UResol = GAS.UResolution(theTolerance);
+            Standard_Real VResol = GAS.VResolution(theTolerance);
+            Standard_Real TolConf2d = Min(UResol, VResol);
+            TolConf2d = Max(TolConf2d, Precision::PConfusion());
             Handle(Geom2d_BSplineCurve) bs2d = GAC2d.BSpline();
             Handle(Geom2d_BSplineCurve) bs2dsov = bs2d;
             Standard_Real fC0 = bs2d->FirstParameter(), lC0 = bs2d->LastParameter();
             Standard_Boolean repar = Standard_True;
             gp_Pnt2d OriginPoint;
             bs2d->D0(fC0, OriginPoint);
-            Geom2dConvert::C0BSplineToC1BSplineCurve(bs2d, Tol2d);
+            Geom2dConvert::C0BSplineToC1BSplineCurve(bs2d, TolConf2d);
             isBSP = Standard_True; 
 
             if(bs2d->IsPeriodic()) { // -------- IFV, Jan 2000
@@ -1425,7 +1427,7 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge,
                 }
                 d = sqrt(d)*.1;
 
-                Tol2dbail = Max(Min(Tol2dbail,d),Tol2d);
+                Tol2dbail = Max(Min(Tol2dbail,d), TolConf2d);
 
                 Geom2dConvert::C0BSplineToC1BSplineCurve(bs2d,Tol2dbail);
 
@@ -1531,8 +1533,8 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge,
                   GAC2d.Load(bs2d,f3d,l3d);
                   curPC = bs2d;
 
-                  if(Abs(bs2d->FirstParameter() - fC0) > Tol2d ||
-                    Abs(bs2d->LastParameter() - lC0) > Tol2d    ) {
+                  if(Abs(bs2d->FirstParameter() - fC0) > TolSameRange ||
+                    Abs(bs2d->LastParameter() - lC0) > TolSameRange) {
                       Standard_Integer NbKnots = bs2d->NbKnots();
                       TColStd_Array1OfReal Knots(1,NbKnots);
                       bs2d->Knots(Knots);
@@ -1585,7 +1587,7 @@ TopoDS_Edge BRepLib::SameParameter(const TopoDS_Edge& theEdge,
             //Approx_SameParameter has failed.
             //Consequently, the situation might be,
             //when 3D and 2D-curve do not have same-range.
-            GeomLib::SameRange( Tol2d, PC[i], 
+            GeomLib::SameRange( TolSameRange, PC[i],
                                 GCurve->First(), GCurve->Last(),
                                 f3d,l3d,curPC);
 
index 84bd040..295087f 100644 (file)
@@ -1480,7 +1480,7 @@ void Geom2dConvert::C0BSplineToC1BSplineCurve(Handle(Geom2d_BSplineCurve)& BS,
    BS->D1(BS->FirstParameter(),point1,V1);  //a verifier
    BS->D1(BS->LastParameter(),point2,V2);
 
-   if ((point1.SquareDistance(point2) < tolerance) &&
+   if ((point1.SquareDistance(point2) < tolerance * tolerance) &&
        (V1.IsParallel(V2, anAngularToler)))
    {
      closed_flag = Standard_True;
diff --git a/tests/bugs/modalg_7/bug31029 b/tests/bugs/modalg_7/bug31029
new file mode 100644 (file)
index 0000000..4c718a6
--- /dev/null
@@ -0,0 +1,11 @@
+puts "======================================================="
+puts "0031029: BRepLib::SameParameter regression in OCCT 7.4 from OCCT 7.3"
+puts "======================================================="
+puts ""
+
+restore [locate_data_file bug31029.brep] f
+
+sameparameter f 1.e-5
+
+checkshape f
+