1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-04 13:13:25 +03:00

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
This commit is contained in:
jgv
2016-05-05 15:47:43 +03:00
committed by bugmaster
parent b7b2f85ac1
commit c59fcd1186
12 changed files with 45 additions and 115 deletions

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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();
}
///////////////////////////////////////////////////
}
//=======================================================================

View File

@@ -174,12 +174,8 @@ static void drawCurve (Adaptor3d_Curve& aCurve,
NumberOfPoints = Algo.NbPoints();
if (NumberOfPoints > 0) {
for (i=1;i<NumberOfPoints;i++) {
for (i = 1; i <= NumberOfPoints; i++)
SeqP.Append(Algo.Value(i));
}
if (j == nbinter) {
SeqP.Append(Algo.Value(NumberOfPoints));
}
}
}
}