]> OCCT Git - occt-copy.git/commitdiff
0027830: Infinite HLR looping
authormsv <msv@opencascade.com>
Thu, 8 Sep 2016 19:57:50 +0000 (22:57 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 15 Sep 2016 09:19:52 +0000 (12:19 +0300)
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

13 files changed:
src/HLRBRep/HLRBRep_Data.cxx
src/HLRBRep/HLRBRep_Data.hxx
src/HLRBRep/HLRBRep_Hider.cxx
tests/bugs/modalg_6/bug27341_301
tests/bugs/modalg_6/bug27341_306
tests/bugs/modalg_6/bug27341_307
tests/bugs/modalg_6/bug27341_308
tests/bugs/modalg_6/bug27341_313
tests/bugs/modalg_6/bug27341_317
tests/bugs/modalg_6/bug27341_320
tests/bugs/modalg_6/bug27341_324
tests/bugs/modalg_6/bug27341_328
tests/bugs/modalg_6/bug27830 [new file with mode: 0644]

index 63e7ee0ef481890f9d3a478c2570bf51d27fb769..0167524a046fc52980255f627bd94abab4d0f931 100644 (file)
@@ -20,6 +20,7 @@
 #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>
@@ -2093,39 +2094,24 @@ HLRBRep_Data::Classify (const Standard_Integer E,
       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;
+            }
+          }
        }
       }
     }
@@ -2444,3 +2430,34 @@ HLRBRep_Data::SameVertex (const Standard_Boolean h1,
   }
   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;
+}
index 72ee9995657d6b4f1dbf3f57f9a4b490dc62dd14..f5371143a8d58bf4874923b27d12e2044326f6dc 100644 (file)
@@ -173,7 +173,10 @@ public:
   
   //! 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()
 {
index 86b75137877f9a0956600e3ba9318165999468b1..6162996febec0e63e943803bd835be5c2d2c3eab 100644 (file)
@@ -103,6 +103,8 @@ void HLRBRep_Hider::Hide(const Standard_Integer FI,
   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();
 
index a278496272f31f0984523cec6565543965b0224d..e1634e72857666a93ff3712dd912a61f67e78ede 100644 (file)
@@ -23,6 +23,6 @@ build3d result
 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
index 7698f2a1fc0dc4cf33c67f2f9f7b74e913d07228..f673547bd5e897006ab41e0dbf3acaedfd5e6429 100644 (file)
@@ -23,6 +23,6 @@ build3d result
 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
index 1ca4fedeecd09c225d5efdc1154710cb7cc6afc9..7cb2f09310d8a16b5e0c340330f0df9a24cfab48 100644 (file)
@@ -23,6 +23,6 @@ build3d result
 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
index b8e0622a224a43dabd245134128fef73d216c89f..3bff8b873626b17f8f96642fd60b2cf0e51c9009 100644 (file)
@@ -22,7 +22,7 @@ build3d result
 
 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
index a947ba4138c58514342609e7d0f0b4cb1fa3caff..69f4eed1c3e388c6068aa1dbe56bb8baf9555c89 100644 (file)
@@ -23,6 +23,6 @@ build3d result
 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
index cfa5701fd73c4bba94011ae78aab83122e35a7a9..95e54f9cec963ddbc80150cdacac3f47e7a78c73 100644 (file)
@@ -22,7 +22,7 @@ build3d result
 
 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
index 01beeddc9446b4f05a97272d835719c9f7d955f7..ca1b1122276ff30a932130cfdcc0bc6782a34bb5 100644 (file)
@@ -23,6 +23,6 @@ build3d result
 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
index cfd3304ab56ebb8d7059e9defb94df89e58640c6..dad9044f348b1cdf07bf940f680988e86d3c4576 100644 (file)
@@ -23,6 +23,6 @@ build3d result
 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
index 383ea1aba9e0dc1c52cceb36dc67470348a22397..4aef17776487d2e28a898fd3ef29967ae12729f1 100644 (file)
@@ -23,6 +23,6 @@ build3d result
 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
diff --git a/tests/bugs/modalg_6/bug27830 b/tests/bugs/modalg_6/bug27830
new file mode 100644 (file)
index 0000000..66b2398
--- /dev/null
@@ -0,0 +1,17 @@
+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