From c59fcd1186b9358614afceee68e03424c95f5417 Mon Sep 17 00:00:00 2001 From: jgv Date: Thu, 5 May 2016 15:47:43 +0300 Subject: [PATCH] 0027468: Incorrect processing of some cases by HLR algorithm Incorrect work of HLR algorithm caused by usage of wrong tolerances, wrong sampling of 2d curve and some other bugs are fixed. Test cases for issue CR27341 --- src/HLRBRep/HLRBRep_CurveTool.cxx | 8 +- src/HLRBRep/HLRBRep_Data.cxx | 2 +- src/HLRBRep/HLRBRep_Intersector.cxx | 13 +++- src/HLRTopoBRep/HLRTopoBRep_DSFiller.cxx | 97 ------------------------ src/StdPrs/StdPrs_DeflectionCurve.cxx | 6 +- tests/bugs/modalg_5/bug23625_1 | 5 +- tests/bugs/modalg_5/bug23625_2 | 3 +- tests/bugs/modalg_5/bug23625_3 | 1 + tests/bugs/modalg_5/bug23625_4 | 1 + tests/bugs/modalg_5/bug23625_5 | 1 + tests/bugs/modalg_6/bug25908 | 6 +- tests/bugs/modalg_6/bug27341 | 17 +++++ 12 files changed, 45 insertions(+), 115 deletions(-) create mode 100644 tests/bugs/modalg_6/bug27341 diff --git a/src/HLRBRep/HLRBRep_CurveTool.cxx b/src/HLRBRep/HLRBRep_CurveTool.cxx index e8241b177c..49706e1cfc 100644 --- a/src/HLRBRep/HLRBRep_CurveTool.cxx +++ b/src/HLRBRep/HLRBRep_CurveTool.cxx @@ -60,8 +60,8 @@ HLRBRep_CurveTool::NbSamples (const Standard_Address C) Standard_Integer HLRBRep_CurveTool::NbSamples (const Standard_Address C, - const Standard_Real /*u1*/, - const Standard_Real /*u2*/) + const Standard_Real u1, + const Standard_Real u2) { GeomAbs_CurveType typC = ((HLRBRep_Curve *)C)->GetType(); static Standard_Real nbsOther = 10.0; @@ -72,7 +72,9 @@ HLRBRep_CurveTool::NbSamples (const Standard_Address C, else if(typC == GeomAbs_BezierCurve) nbs = 3 + ((HLRBRep_Curve *)C)->NbPoles(); else if(typC == GeomAbs_BSplineCurve) { - nbs = ((HLRBRep_Curve *)C)->NbKnots(); + Handle(Geom_Curve) aCurve = ((HLRBRep_Curve *)C)->Curve().Curve().Curve(); + GeomAdaptor_Curve GAcurve(aCurve, u1, u2); + nbs = GAcurve.NbIntervals(GeomAbs_CN) + 1; nbs*= ((HLRBRep_Curve *)C)->Degree(); if(nbs < 2.0) nbs=2; } diff --git a/src/HLRBRep/HLRBRep_Data.cxx b/src/HLRBRep/HLRBRep_Data.cxx index 8a4d2927bb..a895b812ae 100644 --- a/src/HLRBRep/HLRBRep_Data.cxx +++ b/src/HLRBRep/HLRBRep_Data.cxx @@ -774,7 +774,7 @@ void HLRBRep_Data::Update (const HLRAlgo_Projector& P) Standard_Boolean withOutL = Standard_False; for (myFaceItr1.InitEdge(*fd); - myFaceItr1.MoreEdge() && !cut && !withOutL; + myFaceItr1.MoreEdge(); myFaceItr1.NextEdge()) { if (myFaceItr1.Internal()) { withOutL = Standard_True; diff --git a/src/HLRBRep/HLRBRep_Intersector.cxx b/src/HLRBRep/HLRBRep_Intersector.cxx index 96a6621d5a..c1ce1a7147 100644 --- a/src/HLRBRep/HLRBRep_Intersector.cxx +++ b/src/HLRBRep/HLRBRep_Intersector.cxx @@ -118,7 +118,10 @@ void HLRBRep_Intersector::Perform (const Standard_Address A1, b = ((HLRBRep_Curve*)myC1)->Parameter2d(b); IntRes2d_Domain D1(pa,a,(Standard_Real)ta,pb,b,(Standard_Real)tb); - tol = (Standard_Real)(((HLRBRep_EdgeData*) A1)->Tolerance()); + //modified by jgv, 18.04.2016 for OCC27341 + //tol = (Standard_Real)(((HLRBRep_EdgeData*) A1)->Tolerance()); + tol = Precision::Confusion(); + ////////////////////////////////////////// myIntersector.Perform(myC1,D1,tol,tol); } @@ -155,8 +158,12 @@ void HLRBRep_Intersector::Perform (const Standard_Integer /*nA*/, Standard_Real a1,b1,a2,b2,d,dd,tol,tol1,tol2; Standard_ShortReal ta,tb; - tol1 = (Standard_Real)(((HLRBRep_EdgeData*) A1)->Tolerance()); - tol2 = (Standard_Real)(((HLRBRep_EdgeData*) A2)->Tolerance()); + //modified by jgv, 18.04.2016 for OCC27341 + //tol1 = (Standard_Real)(((HLRBRep_EdgeData*) A1)->Tolerance()); + //tol2 = (Standard_Real)(((HLRBRep_EdgeData*) A2)->Tolerance()); + tol1 = Precision::Confusion(); + tol2 = Precision::Confusion(); + ////////////////////////////////////////// if (tol1 > tol2) tol = tol1; else tol = tol2; diff --git a/src/HLRTopoBRep/HLRTopoBRep_DSFiller.cxx b/src/HLRTopoBRep/HLRTopoBRep_DSFiller.cxx index 44beb38403..3237d0e24e 100644 --- a/src/HLRTopoBRep/HLRTopoBRep_DSFiller.cxx +++ b/src/HLRTopoBRep/HLRTopoBRep_DSFiller.cxx @@ -68,59 +68,6 @@ #define APPROX 1 -static Standard_Boolean IntLineRisesFromRegularity(const TopoDS_Edge& anIntLine, - const TopoDS_Edge& anEdge, - const TopoDS_Face&, - const TopTools_ListOfShape& aList) -{ - TopoDS_Vertex Ver [2]; - TopExp::Vertices(anIntLine, Ver[0], Ver[1]); - - //find min param and max param - Standard_Real MinPar = RealLast(), MaxPar = RealFirst(); - TopTools_ListIteratorOfListOfShape itl(aList); - for (; itl.More(); itl.Next()) - { - const TopoDS_Edge& anOutLine = TopoDS::Edge(itl.Value()); - Standard_Real aFirst, aLast; - BRep_Tool::Range(anOutLine, aFirst, aLast); - if (aFirst < MinPar) - MinPar = aFirst; - if (aLast > MaxPar) - MaxPar = aLast; - } - - Standard_Real theTol = BRep_Tool::Tolerance(anEdge); - Standard_Real ParamTol = Precision::Confusion(); - - Standard_Integer i, j; - for (i = 0; i < 2; i++) - { - BRepExtrema_ExtPC anExtPC(Ver[i], anEdge); - if (!anExtPC.IsDone()) - continue; - Standard_Integer NbExt = anExtPC.NbExt(); - if (NbExt == 0) - continue; - Standard_Integer jmin = 1; - for (j = 2; j <= NbExt; j++) - if (anExtPC.SquareDistance(j) < anExtPC.SquareDistance(jmin)) - jmin = j; - Standard_Real aDist = anExtPC.SquareDistance(jmin); - aDist = Sqrt(aDist); - if (aDist > theTol) - continue; - - Standard_Real theParam = anExtPC.Parameter(jmin); - if (theParam > MinPar + ParamTol && - theParam < MaxPar - ParamTol) - return Standard_True; - } - - return Standard_False; -} - - //======================================================================= //function : Insert //purpose : explore the faces and insert them @@ -507,50 +454,6 @@ void HLRTopoBRep_DSFiller::InsertFace (const Standard_Integer /*FI*/, } } } - - //jgv: correction of internal outlines: remove those that rise from middle of boundary outlines - TopTools_ListIteratorOfListOfShape itl(IntL); - while (itl.More()) - { - TopoDS_Edge anIntLine = TopoDS::Edge(itl.Value()); - Standard_Real found = Standard_False; - TopExp_Explorer Explo(F, TopAbs_EDGE); - for (; Explo.More(); Explo.Next()) - { - TopoDS_Edge anEdge = TopoDS::Edge(Explo.Current()); - if (!BRep_Tool::HasContinuity(anEdge)) - continue; - - TopLoc_Location RegLoc; - Standard_Real fpar, lpar; - Handle(Geom_Curve) RegCurve = BRep_Tool::Curve(anEdge, RegLoc, fpar, lpar); - TopTools_ListOfShape thelist; - TopTools_ListIteratorOfListOfShape itoutl(OutL); - for (; itoutl.More(); itoutl.Next()) - { - TopoDS_Edge anOutLine = TopoDS::Edge(itoutl.Value()); - TopLoc_Location aLoc; - Standard_Real aFirst, aLast; - Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anOutLine, aLoc, aFirst, aLast); - if (aCurve == RegCurve && aLoc == RegLoc) - thelist.Append(anOutLine); - } - - if (thelist.IsEmpty()) - continue; - - if (IntLineRisesFromRegularity(anIntLine, anEdge, F, thelist)) - { - IntL.Remove(itl); - found = Standard_True; - break; - } - } - - if (!found) - itl.Next(); - } - /////////////////////////////////////////////////// } //======================================================================= diff --git a/src/StdPrs/StdPrs_DeflectionCurve.cxx b/src/StdPrs/StdPrs_DeflectionCurve.cxx index 82083dc184..aa60e72070 100644 --- a/src/StdPrs/StdPrs_DeflectionCurve.cxx +++ b/src/StdPrs/StdPrs_DeflectionCurve.cxx @@ -174,12 +174,8 @@ static void drawCurve (Adaptor3d_Curve& aCurve, NumberOfPoints = Algo.NbPoints(); if (NumberOfPoints > 0) { - for (i=1;i