From: ifv Date: Wed, 25 Dec 2019 09:47:09 +0000 (+0300) Subject: Some modifications according to remarks X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=0e07189cb23d526e75b89013bd5d092d54a87aeb;p=occt-copy.git Some modifications according to remarks --- diff --git a/src/BRepBuilderAPI/BRepBuilderAPI_Sewing.cxx b/src/BRepBuilderAPI/BRepBuilderAPI_Sewing.cxx index 07639cec0b..507e6a4fea 100644 --- a/src/BRepBuilderAPI/BRepBuilderAPI_Sewing.cxx +++ b/src/BRepBuilderAPI/BRepBuilderAPI_Sewing.cxx @@ -622,6 +622,7 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge(const TopoDS_Edge& edgeFirs whichSec = 1; } } + // Standard_Real first, last; BRep_Tool::Range(edge1, first, last); @@ -957,8 +958,20 @@ TopoDS_Edge BRepBuilderAPI_Sewing::SameParameterEdge(const TopoDS_Edge& edgeFirs static_cast(aV1edge.TShape().get())->Tolerance(aTolV1); static_cast(aV2edge.TShape().get())->Tolerance(aTolV2); - BRepLib::SetPCurve(edge, c2d2edge, fac2, myTolerance, - aTolReached_3, aProjCurve); + Standard_Real aLimTol = myTolerance; + aLimTol = Max(aLimTol, BRep_Tool::Tolerance(edgeFirst)); + aLimTol = Max(aLimTol, BRep_Tool::Tolerance(edgeLast)); + + if (whichSec == 1) itf2.Initialize(listFacesLast); + else itf2.Initialize(listFacesFirst); + for (; itf2.More(); itf2.Next()) { + Handle(Geom2d_Curve) c2d2, c2d21; + Standard_Real firstOld, lastOld; + fac2 = TopoDS::Face(itf2.Value()); + c2d2 = BRep_Tool::CurveOnSurface(edge2, fac2, firstOld, lastOld); + BRepLib::SetPCurve(edge, c2d2, fac2, aLimTol, Standard_True, + aTolReached_3, aProjCurve); + } } else { diff --git a/src/BRepLib/BRepLib.hxx b/src/BRepLib/BRepLib.hxx index b8039cf702..5fd1401590 100644 --- a/src/BRepLib/BRepLib.hxx +++ b/src/BRepLib/BRepLib.hxx @@ -124,7 +124,7 @@ public: //! Algorithm sets in theTolReached tolerance of edge after setting pcurve. Standard_EXPORT static void SetPCurve(const TopoDS_Edge& theE, const Handle(Geom2d_Curve)& theC, - const TopoDS_Face& theF, const Standard_Real theMaxTol, + const TopoDS_Face& theF, const Standard_Real theMaxTol, const Standard_Boolean theForceProj, Standard_Real& theTolReached, Handle(Geom2d_Curve)& theProjCurve); //! Sets the pcurve theC1, theC2 for the edge theE on the closed face theF. @@ -137,7 +137,7 @@ public: //! Algorithm sets in theTolReached tolerance of edge after setting pcurve. Standard_EXPORT static void SetPCurve(const TopoDS_Edge& theE, const Handle(Geom2d_Curve)& theC1, const Handle(Geom2d_Curve)& theC2, - const TopoDS_Face& theF, const Standard_Real theMaxTol, + const TopoDS_Face& theF, const Standard_Real theMaxTol, const Standard_Boolean theForceProj, Standard_Real& theTolReached, Handle(Geom2d_Curve)& theProjCurve1, Handle(Geom2d_Curve)& theProjCurve2); diff --git a/src/BRepLib/BRepLib_1.cxx b/src/BRepLib/BRepLib_1.cxx index af3ebc36ca..411dc3f522 100644 --- a/src/BRepLib/BRepLib_1.cxx +++ b/src/BRepLib/BRepLib_1.cxx @@ -363,55 +363,71 @@ static void UpdateTol(const TopoDS_Edge& theE, const Standard_Real theTol) void BRepLib::SetPCurve(const TopoDS_Edge& theE, const Handle(Geom2d_Curve)& theC, const TopoDS_Face& theF, - const Standard_Real theMaxTol, + const Standard_Real theMaxTol, const Standard_Boolean theForceProj, Standard_Real& theTolReached, Handle(Geom2d_Curve)& theProjCurve) { + Standard_Real aNewTol = -1; Standard_Real aSMTol = Precision::PConfusion(); - Standard_Real aTol = BRep_Tool::Tolerance(theE); - BRep_Builder aBB; Standard_Real fr, lr, f, l; - BRep_Tool::Range(theE, fr, lr); - Handle(Geom2d_Curve) aC = theC; - f = theC->FirstParameter(); - l = theC->LastParameter(); - if (!(Precision::IsInfinite(f) || Precision::IsInfinite(l))) - { - GeomLib::SameRange(aSMTol, theC, f, l, fr, lr, aC); - } - aBB.UpdateEdge(theE, aC, theF, aTol); - Handle(Geom_Surface) anS = BRep_Tool::Surface(theF); Handle(Geom_Curve) aC3D = BRep_Tool::Curve(theE, f, l); - Standard_Real aTol1 = CompTol(aC3D, aC, anS, fr, lr); - if (aTol1 <= aTol) - { - theTolReached = aTol1; - aBB.SameParameter(theE, Standard_True); - return; - } - else if (theMaxTol < aTol && aTol1 < 2.*aTol) - { - theTolReached = aTol1; - UpdateTol(theE, theTolReached); - return; - } - aBB.SameParameter(theE, Standard_False); - Standard_Real aNewTol = -1; - BRepLib::SameParameter(theE, aTol, aNewTol, Standard_True); - if (aNewTol > 0) - { - //Set old tolerance for edge, which has been changed by sameparameter - static_cast(theE.TShape().get())->Tolerance(aTol); - } - if (aNewTol > 0.) + Handle(Geom_Surface) anS = BRep_Tool::Surface(theF); + Handle(Geom2d_Curve) aC = theC; + BRep_Builder aBB; + Standard_Real aTol1 = RealLast(); + BRep_Tool::Range(theE, fr, lr); + if (!theForceProj) { - aC = BRep_Tool::CurveOnSurface(theE, theF, f, l); - aNewTol = CompTol(aC3D, aC, anS, fr, lr); - if (aNewTol < theMaxTol) + Standard_Real aTol = BRep_Tool::Tolerance(theE); + f = theC->FirstParameter(); + l = theC->LastParameter(); + if (!(Precision::IsInfinite(f) || Precision::IsInfinite(l))) + { + GeomLib::SameRange(aSMTol, theC, f, l, fr, lr, aC); + } + // + if (anS.IsNull()) + { + return; + } + // + if (aC3D.IsNull()) + { + return; + } + // + aBB.UpdateEdge(theE, aC, theF, aTol); + // + aTol1 = CompTol(aC3D, aC, anS, fr, lr); + if (aTol1 <= aTol) { + theTolReached = aTol1; aBB.SameParameter(theE, Standard_True); - theTolReached = aNewTol; + return; + } + else if (theMaxTol < aTol && aTol1 < 2.*aTol) + { + theTolReached = aTol1; UpdateTol(theE, theTolReached); - return ; + return; + } + aBB.SameParameter(theE, Standard_False); + BRepLib::SameParameter(theE, aTol, aNewTol, Standard_True); + if (aNewTol < 0) + { + //Set old tolerance for edge, which has been changed by sameparameter + static_cast(theE.TShape().get())->Tolerance(aTol); + } + if (aNewTol > 0.) + { + aC = BRep_Tool::CurveOnSurface(theE, theF, f, l); + aNewTol = CompTol(aC3D, aC, anS, fr, lr); + if (aNewTol < theMaxTol) + { + aBB.SameParameter(theE, Standard_True); + theTolReached = aNewTol; + UpdateTol(theE, theTolReached); + return; + } } } //Projection @@ -508,7 +524,7 @@ void BRepLib::SetPCurve(const TopoDS_Edge& theE, void BRepLib::SetPCurve(const TopoDS_Edge& theE, const Handle(Geom2d_Curve)& theC1, const Handle(Geom2d_Curve)& theC2, const TopoDS_Face& theF, - const Standard_Real theMaxTol, + const Standard_Real theMaxTol, const Standard_Boolean theForceProj, Standard_Real& theTolReached, Handle(Geom2d_Curve)& theProjCurve1, Handle(Geom2d_Curve)& theProjCurve2) @@ -521,49 +537,64 @@ void BRepLib::SetPCurve(const TopoDS_Edge& theE, Handle(Geom2d_Curve) aC1 = theC1, aC2 = theC2; f = theC1->FirstParameter(); l = theC1->LastParameter(); - if (!(Precision::IsInfinite(f) || Precision::IsInfinite(l))) - { - GeomLib::SameRange(aSMTol, theC1, f, l, fr, lr, aC1); - } - f = theC2->FirstParameter(); - l = theC2->LastParameter(); - if (!(Precision::IsInfinite(f) || Precision::IsInfinite(l))) - { - GeomLib::SameRange(aSMTol, theC2, f, l, fr, lr, aC2); - } - aBB.UpdateEdge(theE, aC1, aC2, theF, aTol); + Standard_Real aTol1 = RealLast(); + Standard_Real aNewTol = -1.; Handle(Geom_Surface) anS = BRep_Tool::Surface(theF); Handle(Geom_Curve) aC3D = BRep_Tool::Curve(theE, f, l); - Standard_Real aTol1 = CompTol(aC3D, aC1, anS, fr, lr); - aTol1 = Max(aTol1, CompTol(aC3D, aC2, anS, fr, lr)); - if (aTol1 <= aTol) - { - theTolReached = aTol1; - aBB.SameParameter(theE, Standard_True); - return; - } - aBB.SameParameter(theE, Standard_False); - Standard_Real aNewTol = -1; - BRepLib::SameParameter(theE, aTol, aNewTol, Standard_False); - if (aNewTol > 0) + if (!theForceProj) { - //Set old tolerance for edge, which has been changed by sameparameter - static_cast(theE.TShape().get())->Tolerance(aTol); - } - if (aNewTol > 0. && aNewTol < theMaxTol) - { - TopoDS_Vertex aV1, aV2; - TopExp::Vertices(theE, aV1, aV2); - if (!aV1.IsNull()) + if (!(Precision::IsInfinite(f) || Precision::IsInfinite(l))) { - aBB.UpdateVertex(aV1, aNewTol); + GeomLib::SameRange(aSMTol, theC1, f, l, fr, lr, aC1); } - if (!aV2.IsNull()) + f = theC2->FirstParameter(); + l = theC2->LastParameter(); + if (!(Precision::IsInfinite(f) || Precision::IsInfinite(l))) { - aBB.UpdateVertex(aV2, aNewTol); + GeomLib::SameRange(aSMTol, theC2, f, l, fr, lr, aC2); + } + aBB.UpdateEdge(theE, aC1, aC2, theF, aTol); + // + if (anS.IsNull()) + { + return; + } + // + if (aC3D.IsNull()) + { + return; + } + // + aTol1 = CompTol(aC3D, aC1, anS, fr, lr); + aTol1 = Max(aTol1, CompTol(aC3D, aC2, anS, fr, lr)); + if (aTol1 <= aTol) + { + theTolReached = aTol1; + aBB.SameParameter(theE, Standard_True); + return; + } + aBB.SameParameter(theE, Standard_False); + BRepLib::SameParameter(theE, aTol, aNewTol, Standard_False); + if (aNewTol > 0) + { + //Set old tolerance for edge, which has been changed by sameparameter + static_cast(theE.TShape().get())->Tolerance(aTol); + } + if (aNewTol > 0. && aNewTol < theMaxTol) + { + TopoDS_Vertex aV1, aV2; + TopExp::Vertices(theE, aV1, aV2); + if (!aV1.IsNull()) + { + aBB.UpdateVertex(aV1, aNewTol); + } + if (!aV2.IsNull()) + { + aBB.UpdateVertex(aV2, aNewTol); + } + theTolReached = aNewTol; + return; } - theTolReached = aNewTol; - return; } //Projection Handle(BRepAdaptor_HSurface) aBAHS = new BRepAdaptor_HSurface(theF); diff --git a/src/BRepTest/BRepTest_BasicCommands.cxx b/src/BRepTest/BRepTest_BasicCommands.cxx index f07940b722..2a038bb14a 100644 --- a/src/BRepTest/BRepTest_BasicCommands.cxx +++ b/src/BRepTest/BRepTest_BasicCommands.cxx @@ -125,11 +125,17 @@ static Standard_Integer setpcurve(Draw_Interpretor&, Standard_Integer n, const c if (n > 4) { tol = Draw::Atof(a[4]); } + Standard_Boolean ForceProj = Standard_False; + if (n > 5) + { + Standard_Integer i = Draw::Atoi(a[5]); + if (i > 0) ForceProj = Standard_True; + } //BRep_Builder BB; //BB.UpdateEdge(TopoDS::Edge(E), PC, TopoDS::Face(F), tol); Standard_Real tolreached; Handle(Geom2d_Curve) ProjC; - BRepLib::SetPCurve(TopoDS::Edge(E), PC, TopoDS::Face(F), tol, + BRepLib::SetPCurve(TopoDS::Edge(E), PC, TopoDS::Face(F), tol, ForceProj, tolreached, ProjC); DBRep::Set(a[1], E); return 0; @@ -1427,7 +1433,7 @@ void BRepTest::BasicCommands(Draw_Interpretor& theCommands) __FILE__, addpcurve,g); theCommands.Add("setpcurve", - "addpcurve edge 2dcurve face [tol (default 1.e-4)]", + "setpcurve edge 2dcurve face [tol (default 1.e-4)] [proj]", __FILE__, setpcurve, g);