From: jgv Date: Thu, 2 Jul 2015 12:19:50 +0000 (+0300) Subject: 0026296: Errors in BRepOffsetAPI_MakeOffset: failure because of wrong direction of... X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=696ca0a0fc4c16c79ebcd4ea855c4ec345014cde;p=occt-copy.git 0026296: Errors in BRepOffsetAPI_MakeOffset: failure because of wrong direction of bisector. --- diff --git a/src/BRepFill/BRepFill_OffsetWire.cxx b/src/BRepFill/BRepFill_OffsetWire.cxx index 98a48315e5..03dda88f6c 100755 --- a/src/BRepFill/BRepFill_OffsetWire.cxx +++ b/src/BRepFill/BRepFill_OffsetWire.cxx @@ -1146,7 +1146,8 @@ void BRepFill_OffsetWire::PerformWithBiLo TV2->UpdateTolerance( 1.5*dist2 ); } - FixHoles(); + if (!myIsOpenResult) + FixHoles(); myIsDone = Standard_True; } @@ -1399,6 +1400,17 @@ void BRepFill_OffsetWire::MakeWires() End = Standard_False; MVE.ChangeFromKey(CV).RemoveFirst(); + if (myIsOpenResult && MVE.FindFromKey(CV).IsEmpty()) + { + //MVE.UnBind(CV); + TopoDS_Shape LastShape = MVE.FindKey(MVE.Extent()); + TopTools_ListOfShape LastList; + LastList.Append(MVE(MVE.Extent())); + MVE.RemoveLast(); + if (MVE.FindIndex(CV) != 0) + MVE.Substitute(MVE.FindIndex(CV), LastShape, LastList); + } + // Modified by Sergey KHROMOV - Thu Mar 14 11:29:59 2002 Begin Standard_Boolean isClosed = Standard_False; // Modified by Sergey KHROMOV - Thu Mar 14 11:30:00 2002 End @@ -1440,6 +1452,9 @@ void BRepFill_OffsetWire::MakeWires() CE = TopoDS::Edge(MVE.FindFromKey(CV).First()); MVE.ChangeFromKey(CV).RemoveFirst(); } + else if (myIsOpenResult)//CV was a vertex with one edge + End = Standard_True; + if (MVE.FindFromKey(CV).IsEmpty()) { //MVE.UnBind(CV); diff --git a/src/Bisector/Bisector_BisecAna.cdl b/src/Bisector/Bisector_BisecAna.cdl index 11330ae703..b35a192574 100755 --- a/src/Bisector/Bisector_BisecAna.cdl +++ b/src/Bisector/Bisector_BisecAna.cdl @@ -127,7 +127,7 @@ is Bis : Bisec from GccInt ; V1 : Vec2d from gp ; V2 : Vec2d from gp ; - AreVectorsNotTangents : Boolean from Standard; + VecRef: Vec2d from gp ; Sense : Real from Standard ; U : out Real from Standard ; sense : out Boolean from Standard ; diff --git a/src/Bisector/Bisector_BisecAna.cxx b/src/Bisector/Bisector_BisecAna.cxx index 0dbc0496d0..f7b2c91570 100755 --- a/src/Bisector/Bisector_BisecAna.cxx +++ b/src/Bisector/Bisector_BisecAna.cxx @@ -78,7 +78,7 @@ Standard_Real Bisector_BisecAna::Distance ( const Handle(GccInt_Bisec)& abisector, const gp_Vec2d& afirstvector , const gp_Vec2d& asecondvector, - const Standard_Boolean AreVectorsNotTangents, + const gp_Vec2d& VecRef, const Standard_Real adirection, Standard_Real& aparameter, Standard_Boolean& asense, @@ -168,15 +168,18 @@ Standard_Real Bisector_BisecAna::Distance ( if ((afirstdir^secdirrev)*adirection < -0.1) { // input if((afirstdir^tangdir)*adirection < aTol && - (secdirrev^tangdir)*adirection < aTol) asense = Standard_False; + (secdirrev^tangdir)*adirection < aTol) + asense = Standard_False; } else if((afirstdir^secdirrev)*adirection > 0.1) { // output if((afirstdir^tangdir)*adirection < aTol || - (secdirrev^tangdir)*adirection < aTol) asense = Standard_False; + (secdirrev^tangdir)*adirection < aTol) + asense = Standard_False; } else { // flat if (afirstdir.Dot(secdirrev) > 0.) { // tangent - if ((afirstdir^tangdir)*adirection < 0.) asense = Standard_False; + if ((afirstdir^tangdir)*adirection < 0.) + asense = Standard_False; } else{ // turn back // Modified by Sergey KHROMOV - Thu Oct 31 14:16:53 2002 @@ -186,11 +189,12 @@ Standard_Real Bisector_BisecAna::Distance ( } } //jgv: for OCC26185 - if (AreVectorsNotTangents && - afirstdir * aseconddir > 0. && - afirstdir * tangdir < 0. && - aseconddir * tangdir < 0.) - asense = Standard_False; + if (VecRef.SquareMagnitude() != 0) + { + gp_Dir2d DirRef = VecRef; + if (tangdir * DirRef < 0.) + asense = Standard_False; + } /////////////////// // Modified by Sergey KHROMOV - Tue Oct 22 16:35:51 2002 End } @@ -233,8 +237,19 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve , Handle(Geom2d_Curve) CurveE; Handle(GccInt_Bisec) TheSol; - gp_Vec2d tan1 = afirstcurve->DN(afirstcurve->LastParameter (),1); - gp_Vec2d tan2 = asecondcurve->DN(asecondcurve->FirstParameter(),1); + //jgv: for OCC26296 + gp_Vec2d LineBisVec(0.,0.); + gp_Vec2d tan1, tan2; + gp_Pnt2d Pnt1, Pnt2; + afirstcurve->D1(afirstcurve->LastParameter(), Pnt1, tan1); + asecondcurve->D1(asecondcurve->FirstParameter(), Pnt2, tan2); + if (!oncurve) + { + LineBisVec = gp_Vec2d(Pnt1, Pnt2); + LineBisVec.Rotate(M_PI/2.); + } + /////////////////// + tan1.Reverse(); if (type1 == STANDARD_TYPE(Geom2d_TrimmedCurve)) @@ -347,11 +362,11 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve , // adirection,parameter,sense,ok); if (oncurve) distanceptsol = Distance(apoint,solution, - tan2,tan1,Standard_False, + tan2,tan1,LineBisVec, adirection,parameter,sense,ok); else distanceptsol = Distance(apoint,solution, - afirstvector,asecondvector,Standard_True, + afirstvector,asecondvector,LineBisVec, adirection,parameter,sense,ok); // Modified by skv - Tue Feb 15 17:51:29 2005 Integration End Handle(Geom2d_Curve) bisectorcurve = new Geom2d_Line(line); @@ -420,7 +435,7 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve , sense = Standard_True; if (oncurve) { distanceptsol = Distance(apoint,solution, - tan1,tan2,Standard_False, + tan1,tan2,LineBisVec, adirection,parameter,sense,ok); } else {ok = Standard_True;} @@ -434,11 +449,11 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve , // adirection,parameter,sense,ok); if (oncurve) distanceptsol = Distance(apoint,solution, - tan2,tan1,Standard_False, + tan2,tan1,LineBisVec, adirection,parameter,sense,ok); else distanceptsol = Distance(apoint,solution, - afirstvector,asecondvector,Standard_True, + afirstvector,asecondvector,LineBisVec, adirection,parameter,sense,ok); // Modified by skv - Tue Feb 15 17:51:29 2005 Integration End if (distanceptsol <= distancemini) { @@ -576,7 +591,7 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve , Handle(GccInt_Bisec) solution = Bisector.ThisSolution(i); Degenerate(solution,tolerance); sense = Standard_True; - distanceptsol = Distance(apoint,solution,tan1,tan2,Standard_False, + distanceptsol = Distance(apoint,solution,tan1,tan2,LineBisVec, adirection,parameter,sense,ok); theSense = sense; if (ok || !oncurve) { @@ -587,11 +602,11 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve , // adirection,parameter,sense,ok); if (oncurve) distanceptsol = Distance(apoint,solution, - tan2,tan1,Standard_False, + tan2,tan1,LineBisVec, adirection,parameter,sense,ok); else distanceptsol = Distance(apoint,solution, - afirstvector,asecondvector,Standard_True, + afirstvector,asecondvector,LineBisVec, adirection,parameter,sense,ok); // Modified by skv - Tue Feb 15 17:51:29 2005 Integration End if (distanceptsol <= distancemini) { @@ -645,12 +660,16 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve , } else if (type == GccInt_Par) { bisectorcurve = new Geom2d_Parabola(TheSol->Parabola()); - Standard_Real FocalLength = ((Handle(Geom2d_Parabola)&)bisectorcurve)->Focal(); + gp_Pnt2d apex = bisectorcurve->Value(0.); + gp_Pnt2d firstpnt = bisectorcurve->Value(firstparameter); + Standard_Real ChordLen = apex.Distance(firstpnt); + const Standard_Real TolPar = 1.e-5; Standard_Real secondparameter = Precision::Infinite(); if (!thesense) { if (ajointype == GeomAbs_Intersection && - 4.*FocalLength < firstparameter) //first parameter is too far from peak of parabola + TolPar < firstparameter && + ChordLen >= circle1.Radius()) //first parameter is too far from peak of parabola secondparameter = 0.; thebisector = new Geom2d_TrimmedCurve(bisectorcurve, firstparameter, @@ -659,7 +678,8 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve , else { if (ajointype == GeomAbs_Intersection && - firstparameter < -4.*FocalLength) //first parameter is too far from peak of parabola + firstparameter < -TolPar && + ChordLen >= circle1.Radius()) //first parameter is too far from peak of parabola secondparameter = 0.; thebisector = new Geom2d_TrimmedCurve(bisectorcurve, firstparameter, @@ -707,11 +727,11 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve , // adirection,parameter,sense,ok); if (oncurve) distanceptsol = Distance(apoint,solution, - tan2,tan1,Standard_False, + tan2,tan1,LineBisVec, adirection,parameter,sense,ok); else distanceptsol = Distance(apoint,solution, - afirstvector,asecondvector,Standard_True, + afirstvector,asecondvector,LineBisVec, adirection,parameter,sense,ok); // Modified by skv - Tue Feb 15 17:51:29 2005 Integration End // if (distanceptsol <= distancemini) { @@ -741,11 +761,11 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve , // adirection,parameter,sense,ok); if (oncurve) distanceptsol = Distance(apoint,solution, - tan2,tan1,Standard_False, + tan2,tan1,LineBisVec, adirection,parameter,sense,ok); else distanceptsol = Distance(apoint,solution, - afirstvector,asecondvector,Standard_True, + afirstvector,asecondvector,LineBisVec, adirection,parameter,sense,ok, Standard_True); // Modified by skv - Tue Feb 15 17:51:29 2005 Integration End if (ok || !oncurve) { @@ -796,6 +816,7 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve , Standard_Boolean ok; Standard_Boolean thesense = Standard_False,sense,theSense; Standard_Real distanceptsol,parameter,firstparameter =0.,secondparameter; + gp_Vec2d VecRef(0.,0.); Handle(Geom2d_Curve) curve; Handle(GccInt_Bisec) TheSol; @@ -849,7 +870,7 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve , Degenerate(solution,tolerance); sense = Standard_False; distanceptsol = Distance(apoint,solution, - afirstvector,asecondvector,Standard_True, + afirstvector,asecondvector,VecRef, adirection,parameter,sense,ok); if (distanceptsol <= distancemini) { @@ -966,7 +987,7 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Curve)& afirstcurve , } sense = Standard_False; distanceptsol = Distance(apoint,solution, - afirstvector,asecondvector,Standard_True, + afirstvector,asecondvector,VecRef, adirection,parameter,sense,ok); if (ok || !oncurve) { @@ -1053,6 +1074,7 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Point)& afirstpoint , { Standard_Boolean sense,ok; Standard_Real distanceptsol,parameter; + gp_Vec2d VecRef(0.,0.); GccAna_Pnt2dBisec bisector(afirstpoint->Pnt2d(),asecondpoint->Pnt2d()); gp_Lin2d line = bisector.ThisSolution(); @@ -1060,7 +1082,7 @@ void Bisector_BisecAna::Perform(const Handle(Geom2d_Point)& afirstpoint , sense = Standard_False; distanceptsol = Distance(apoint,solution, - afirstvector,asecondvector,Standard_True, + afirstvector,asecondvector,VecRef, adirection,parameter,sense,ok); if (ok || !oncurve) { Handle(Geom2d_Curve) bisectorcurve = new Geom2d_Line(line);