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
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;
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;
}
Standard_Boolean withOutL = Standard_False;
for (myFaceItr1.InitEdge(*fd);
- myFaceItr1.MoreEdge() && !cut && !withOutL;
+ myFaceItr1.MoreEdge();
myFaceItr1.NextEdge()) {
if (myFaceItr1.Internal()) {
withOutL = Standard_True;
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);
}
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;
#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
}
}
}
-
- //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();
- }
- ///////////////////////////////////////////////////
}
//=======================================================================
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));
- }
}
}
}
reflectlines result a 0 1 0
-checkprops result -l 3730.32
-checkshape result
+checkprops result -l 3882.71
+checkshape result
checksection result
+donly result
checkview -screenshot -2d -path ${imagedir}/${test_image}.png
reflectlines result a 0 1 0
-checkprops result -l 4022.72
+checkprops result -l 3905.95
checkshape result
checksection result
+donly result
checkview -screenshot -2d -path ${imagedir}/${test_image}.png
checkshape result
checksection result
+donly result
checkview -screenshot -2d -path ${imagedir}/${test_image}.png
checkshape result
checksection result
+donly result
checkview -screenshot -2d -path ${imagedir}/${test_image}.png
checkshape result
checksection result
+donly result
checkview -screenshot -2d -path ${imagedir}/${test_image}.png
set nbshapes_expected "
Number of shapes in shape
- VERTEX : 161
- EDGE : 81
+ VERTEX : 167
+ EDGE : 84
WIRE : 0
FACE : 0
SHELL : 0
SOLID : 0
COMPSOLID : 0
COMPOUND : 1
- SHAPE : 243
+ SHAPE : 252
"
checknbshapes result -ref ${nbshapes_expected} -t -m "HLRToShape"
--- /dev/null
+puts "============"
+puts "OCC27341"
+puts "============"
+puts ""
+######################################################
+# Incorrect exact HLR results
+######################################################
+
+restore [locate_data_file bug27341_hlrsave.brep] result
+
+vinit
+vdisplay result
+vfit
+vhlr on
+vhlrtype algo result
+
+checkview -screenshot -3d -path ${imagedir}/${test_image}.png