diff --git a/src/BRepLib/BRepLib.cxx b/src/BRepLib/BRepLib.cxx index 3f7b47e2f7..6a35e1fdf5 100644 --- a/src/BRepLib/BRepLib.cxx +++ b/src/BRepLib/BRepLib.cxx @@ -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); diff --git a/src/Geom2dConvert/Geom2dConvert.cxx b/src/Geom2dConvert/Geom2dConvert.cxx index 84bd040e18..295087f665 100644 --- a/src/Geom2dConvert/Geom2dConvert.cxx +++ b/src/Geom2dConvert/Geom2dConvert.cxx @@ -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 index 0000000000..4c718a6636 --- /dev/null +++ b/tests/bugs/modalg_7/bug31029 @@ -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 +