Make protection of HLR algo against garbage data in faces. In particular case, there are faces built on a periodical surfaces, which U bounds exceed period thousands times. Such faces are excluded from the process of edges hiding.
In addition, while fitting the intersection point in period for periodical faces, replace looping with the single call to AdjustPeriodic method.
- Add new test case.
- Update tests of HLR according to new numbers of subshapes.
Update of test cases according to the new behavior
#include <BRepTopAdaptor_TopolTool.hxx>
#include <ElCLib.hxx>
#include <Geom2d_Curve.hxx>
+#include <GeomInt.hxx>
#include <gp.hxx>
#include <gp_Dir.hxx>
#include <gp_Dir2d.hxx>
IntCurveSurface_TransitionOnCurve Tr;
for (i = 1; i <= nbPoints; i++) {
- Standard_Boolean InsideRestriction = Standard_False;
myIntersector.CSPoint(i).Values(PInter,u,v,w,Tr);
if (w < wLim) {
- if (PeriodU)
- while (u > UMin)
- u -= PeriodU;
- if (PeriodV)
- while (v > VMin)
- v -= PeriodV;
-// Standard_Real UInit = u;
- Standard_Real VInit = v;
+ Standard_Real aDummyShift;
+ if (PeriodU > 0.)
+ GeomInt::AdjustPeriodic(u, UMin, UMax, PeriodU, u, aDummyShift);
+ if (PeriodV > 0.)
+ GeomInt::AdjustPeriodic(v, VMin, VMax, PeriodV, v, aDummyShift);
- do {
- v = VInit;
-
- do {
- gp_Pnt2d pnt2d(u,v);
- if (myClassifier->Classify(pnt2d,Precision::PConfusion())
- != TopAbs_OUT)
- {
- InsideRestriction = Standard_True;
- state = TopAbs_IN;
- Level++;
- if (!LevelFlag) {
- return state;
- }
- }
- v += PeriodV;
- }
- while (PeriodV && v < VMax && !InsideRestriction);
- u += PeriodU;
- }
- while (PeriodU && u < UMax && !InsideRestriction);
+ gp_Pnt2d pnt2d(u, v);
+ if (myClassifier->Classify(pnt2d, Precision::PConfusion())
+ != TopAbs_OUT)
+ {
+ state = TopAbs_IN;
+ Level++;
+ if (!LevelFlag) {
+ return state;
+ }
+ }
}
}
}
}
return SameV;
}
+
+//=======================================================================
+//function : IsBadFace
+//purpose :
+//=======================================================================
+
+Standard_Boolean HLRBRep_Data::IsBadFace() const
+{
+ if (iFaceGeom)
+ {
+ // check for garbage data - if periodic then bounds must not exceed period
+ HLRBRep_Surface *pGeom = (HLRBRep_Surface*)iFaceGeom;
+ if (pGeom->IsUPeriodic())
+ {
+ Standard_Real aPeriod = pGeom->UPeriod();
+ Standard_Real aMin = pGeom->FirstUParameter();
+ Standard_Real aMax = pGeom->LastUParameter();
+ if (aPeriod * 2 < aMax - aMin)
+ return Standard_True;
+ }
+ if (pGeom->IsVPeriodic())
+ {
+ Standard_Real aPeriod = pGeom->VPeriod();
+ Standard_Real aMin = pGeom->FirstVParameter();
+ Standard_Real aMax = pGeom->LastVParameter();
+ if (aPeriod * 2 < aMax - aMin)
+ return Standard_True;
+ }
+ }
+ return Standard_False;
+}
//! Classification of an edge.
Standard_EXPORT TopAbs_State Classify (const Standard_Integer E, const HLRBRep_EdgeData& ED, const Standard_Boolean LevelFlag, Standard_Integer& Level, const Standard_Real param);
-
+
+ //! Returns true if the current face is bad.
+ Standard_EXPORT Standard_Boolean IsBadFace() const;
+
Standard_EXPORT void Destroy();
~HLRBRep_Data()
{
myDS->InitEdge(FI,MST);
if (!myDS->MoreEdge()) // there is nothing to do
return; // **********************
+ if (myDS->IsBadFace())
+ return;
HLRBRep_EdgeInterferenceTool EIT(myDS); // List of Intersections
HLRBRep_Array1OfEData& myEData = myDS->EDataArray();
fit
checkprops result -l 1030.62
-checknbshapes result -vertex 258 -edge 130
+checknbshapes result -vertex 256 -edge 129
checkview -screenshot -2d -path ${imagedir}/${test_image}.png
fit
checkprops result -l 2893.98
-checknbshapes result -vertex 705 -edge 353
+checknbshapes result -vertex 699 -edge 350
checkview -screenshot -2d -path ${imagedir}/${test_image}.png
fit
checkprops result -l 2282.11
-checknbshapes result -vertex 947 -edge 476
+checknbshapes result -vertex 945 -edge 475
checkview -screenshot -2d -path ${imagedir}/${test_image}.png
fit
-checkprops result -l 1249.94
-checknbshapes result -vertex 490 -edge 245
+checkprops result -l 1170.46
+checknbshapes result -vertex 486 -edge 243
checkview -screenshot -2d -path ${imagedir}/${test_image}.png
fit
checkprops result -l 9662.5
-checknbshapes result -vertex 4429 -edge 2221
+checknbshapes result -vertex 4423 -edge 2218
checkview -screenshot -2d -path ${imagedir}/${test_image}.png
fit
-checkprops result -l 2774.53
-checknbshapes result -vertex 614 -edge 307
+checkprops result -l 2704.1
+checknbshapes result -vertex 594 -edge 297
checkview -screenshot -2d -path ${imagedir}/${test_image}.png
fit
checkprops result -l 1726.77
-checknbshapes result -vertex 811 -edge 406
+checknbshapes result -vertex 803 -edge 402
checkview -screenshot -2d -path ${imagedir}/${test_image}.png
fit
checkprops result -l 211.007
-checknbshapes result -vertex 106 -edge 53
+checknbshapes result -vertex 102 -edge 51
checkview -screenshot -2d -path ${imagedir}/${test_image}.png
fit
checkprops result -l 40.3211
-checknbshapes result -vertex 62 -edge 31
+checknbshapes result -vertex 60 -edge 30
checkview -screenshot -2d -path ${imagedir}/${test_image}.png
--- /dev/null
+puts "============"
+puts "OCC27830"
+puts "============"
+puts ""
+######################################################
+# Infinite HLR looping
+######################################################
+
+restore [locate_data_file bug27830_body1.brep] result
+
+vinit
+vdisplay result
+vfit
+vhlr on
+vhlrtype algo result
+
+# no screenshot since the shape is a garbage, the test is just to check performance