0032942: Modeling Algorithms - Boolean operation Common has no result in specific... CR0-WEEK-18 IR-2022-05-06
authorifv <ifv@opencascade.com>
Mon, 25 Apr 2022 15:14:18 +0000 (18:14 +0300)
committersmoskvin <smoskvin@opencascade.com>
Thu, 5 May 2022 21:44:14 +0000 (00:44 +0300)
IntTools/IntTools_BeanFaceIntersector.cxx - calculation of deflection for surface bnd box is added
tests/bugs/modalg_8/bug32942,bug32943,bug32944,bug32945 - new test cases added

src/IntTools/IntTools_BeanFaceIntersector.cxx
tests/bugs/modalg_8/bug32942 [new file with mode: 0644]
tests/bugs/modalg_8/bug32943 [new file with mode: 0644]
tests/bugs/modalg_8/bug32944 [new file with mode: 0644]
tests/bugs/modalg_8/bug32945 [new file with mode: 0644]

index 0909c74..96b9c0c 100644 (file)
@@ -1813,7 +1813,6 @@ Standard_Boolean IntTools_BeanFaceIntersector::ComputeLocalized() {
       
       return Standard_False;
     }
-    
     IntTools_ListOfCurveRangeSample aListCurveRangeSort;
     IntTools_ListOfSurfaceRangeSample aListSurfaceRangeSort;
     
@@ -1860,7 +1859,7 @@ Standard_Boolean IntTools_BeanFaceIntersector::ComputeLocalized() {
       for(indIt = nMinIndex ; indIt <= nMaxIndex; indIt++) {
         if(myRangeManager.Flag(indIt) == 2) {
           bFound = Standard_True;
-  break;
+          break;
         }
       }
       
@@ -2179,88 +2178,96 @@ void ComputeGridPoints
   gp_Pnt        aPnt;
   Standard_Real aParU;
   Standard_Real aParV;
+  gp_Vec aDU, aDV;
+  Standard_Real du = 0, dv = 0;
+  Standard_Boolean isCalcDefl = aNbGridPnts[0] < 30 && aNbGridPnts[1] < 30;
+
+  Bnd_Box aGridBox, anExtBox;
   
   for (i = 1; i <= aNbGridPnts[0]; i++) {
     aParU = theSurfaceData.GetUParam(i);
+
+    if (isCalcDefl && i < aNbGridPnts[0])
+    {
+      du = 0.5 * (theSurfaceData.GetUParam(i + 1) - aParU);
+    }
     
     for (j = 1; j <= aNbGridPnts[1]; j++) {
       aParV = theSurfaceData.GetVParam(j);
+
+      if (isCalcDefl)
+      {
+        theSurf->D1(aParU, aParV, aPnt, aDU, aDV);
+      }
+      else
+      {
+        theSurf->D0(aParU, aParV, aPnt);
+      }
       
-      theSurf->D0(aParU, aParV, aPnt);
       theSurfaceData.SetGridPoint(i, j, aPnt);
+      //
+      if (isCalcDefl)
+      {
+        aGridBox.Add(aPnt);
+        if (i < aNbGridPnts[0] && j < aNbGridPnts[1])
+        {
+          dv = 0.5 * (theSurfaceData.GetVParam(j + 1) - aParV);
+          gp_Vec aShift = du * aDU + dv * aDV;
+          aPnt.Translate(aShift);
+          anExtBox.Add(aPnt);
+        }
+      }
     }
   }
 
   // Compute deflection.
   Standard_Real aDef = 0.;
-//   Standard_Real aDefLin;
-//   Standard_Real aParMid;
-//   Standard_Real aParConst;
-//   Standard_Real aDistPP;
-//   gp_Pnt        aPntMid;
-//   gp_Vec        aVec;
-//   gp_XYZ        aCoord;
-
-//   // Compute DU deflection.
-//   for (i = 1; i < aNbGridPnts[0]; i++) {
-//     aParMid = 0.5*(theSurfaceData.GetUParam(i + 1) +
-//        theSurfaceData.GetUParam(i));
-
-//     for (j = 1; j <= aNbGridPnts[1]; j++) {
-//       const gp_Pnt &thePnt1 = theSurfaceData.GetGridPoint(i,     j);
-//       const gp_Pnt &thePnt2 = theSurfaceData.GetGridPoint(i + 1, j);
-
-//       aVec.SetXYZ(thePnt2.XYZ().Subtracted(thePnt1.XYZ()));
-//       aDistPP = aVec.Magnitude();
-
-//       if (aDistPP > theTolerance) {
-//     // Computation of a distance of a middle point from the line P1 - P2.
-//     aParConst = theSurfaceData.GetVParam(j);
-//     theSurf->D0(aParMid, aParConst, aPntMid);
-//     aCoord = aPntMid.XYZ();
-//     aCoord.Subtract(thePnt1.XYZ());
-//     aCoord.Cross (aVec.XYZ());
-//     aCoord.Divide(aDistPP);
-//     aDefLin = aCoord.Modulus();
-
-//     if (aDefLin > aDef)
-//   aDef = aDefLin;
-//       }
-//     }
-//   }
-
-//   // Compute DV deflection.
-//   for (j = 1; j < aNbGridPnts[1]; j++) {
-//     aParMid = 0.5*(theSurfaceData.GetVParam(j + 1) +
-//        theSurfaceData.GetVParam(j));
-
-//     for (i = 1; i <= aNbGridPnts[0]; i++) {
-//       const gp_Pnt &thePnt1 = theSurfaceData.GetGridPoint(i, j);
-//       const gp_Pnt &thePnt2 = theSurfaceData.GetGridPoint(i, j + 1);
-
-//       aVec.SetXYZ(thePnt2.XYZ().Subtracted(thePnt1.XYZ()));
-//       aDistPP = aVec.Magnitude();
-
-//       if (aDistPP > theTolerance) {
-//     // Computation of a distance of a middle point from the line P1 - P2.
-//     aParConst = theSurfaceData.GetUParam(i);
-//     theSurf->D0(aParConst, aParMid, aPntMid);
-//     aCoord = aPntMid.XYZ();
-//     aCoord.Subtract(thePnt1.XYZ());
-//     aCoord.Cross (aVec.XYZ());
-//     aCoord.Divide(aDistPP);
-//     aDefLin = aCoord.Modulus();
-
-//     if (aDefLin > aDef)
-//   aDef = aDefLin;
-//       }
-//     }
-//   }
+  if (isCalcDefl)
+  {
+    Standard_Real xmin, ymin, zmin, xmax, ymax, zmax;
+    Standard_Real xmin1, ymin1, zmin1, xmax1, ymax1, zmax1;
+    aGridBox.Get(xmin, ymin, zmin, xmax, ymax, zmax);
+    anExtBox.Get(xmin1, ymin1, zmin1, xmax1, ymax1, zmax1);
+    Standard_Integer anExtCount = 0;
+    if (xmin1 < xmin)
+    {
+      aDef = Max(xmin - xmin1, aDef);
+      anExtCount++;
+    }
+    if (ymin1 < ymin)
+    {
+      aDef = Max(ymin - ymin1, aDef);
+      anExtCount++;
+    }
+    if (zmin1 < zmin)
+    {
+      aDef = Max(zmin - zmin1, aDef);
+      anExtCount++;
+    }
+    if (xmax1 > xmax)
+    {
+      aDef = Max(xmax1 - xmax, aDef);
+      anExtCount++;
+    }
+    if (ymax1 > ymax)
+    {
+      aDef = Max(ymax1 - ymax, aDef);
+      anExtCount++;
+    }
+    if (zmax1 > zmax)
+    {
+      aDef = Max(zmax1 - zmax, aDef);
+      anExtCount++;
+    }
+    if (anExtCount < 3)
+    {
+        aDef /= 2.;
+    }
+  }
 
   if (theTolerance > aDef)
-    aDef = theTolerance;
+    aDef = 2. * theTolerance;
 
-  aDef *= 2.;
   theSurfaceData.SetGridDeflection(aDef);
 }
 
diff --git a/tests/bugs/modalg_8/bug32942 b/tests/bugs/modalg_8/bug32942
new file mode 100644 (file)
index 0000000..ece1cba
--- /dev/null
@@ -0,0 +1,19 @@
+puts "========================================================================="
+puts "OCC32942: Modeling Algorithms - Boolean operation Common has no result in specific example"
+puts "========================================================================="
+puts ""
+
+restore [locate_data_file bug32942.brep] a
+explode a
+
+bcommon result a_1 a_2
+
+checkshape result
+
+checknbshapes result -vertex 8 -edge 12 -wire 6 -face 6 -shell 1 -solid 1
+
+checkmaxtol result -min_tol 1.e-5
+
+checkprops result -s 21746.8
+
+checkview -display result -2d -path ${imagedir}/${test_image}.png
diff --git a/tests/bugs/modalg_8/bug32943 b/tests/bugs/modalg_8/bug32943
new file mode 100644 (file)
index 0000000..b232df5
--- /dev/null
@@ -0,0 +1,19 @@
+puts "========================================================================="
+puts "OCC32943: Modeling Algorithms - Boolean operation Common has no result in specific example"
+puts "========================================================================="
+puts ""
+
+restore [locate_data_file bug32943.brep] a
+explode a
+
+bcommon result a_1 a_2
+
+checkshape result
+
+checknbshapes result -vertex 8 -edge 12 -wire 6 -face 6 -shell 1 -solid 1
+
+checkmaxtol result -min_tol 1.e-5
+
+checkprops result -s 17615.5
+
+checkview -display result -2d -path ${imagedir}/${test_image}.png
diff --git a/tests/bugs/modalg_8/bug32944 b/tests/bugs/modalg_8/bug32944
new file mode 100644 (file)
index 0000000..362791b
--- /dev/null
@@ -0,0 +1,19 @@
+puts "========================================================================="
+puts "OCC32944: Modeling Algorithms - Boolean operation Common has no result in specific example"
+puts "========================================================================="
+puts ""
+
+restore [locate_data_file bug32944.brep] a
+explode a
+
+bcommon result a_1 a_2
+
+checkshape result
+
+checknbshapes result -vertex 8 -edge 12 -wire 6 -face 6 -shell 1 -solid 1
+
+checkmaxtol result -min_tol 1.e-5
+
+checkprops result -s 36741.6
+
+checkview -display result -2d -path ${imagedir}/${test_image}.png
diff --git a/tests/bugs/modalg_8/bug32945 b/tests/bugs/modalg_8/bug32945
new file mode 100644 (file)
index 0000000..6b2fb69
--- /dev/null
@@ -0,0 +1,19 @@
+puts "========================================================================="
+puts "OCC32945: Modeling Algorithms - Boolean operation Common has no result in specific example"
+puts "========================================================================="
+puts ""
+
+restore [locate_data_file bug32945.brep] a
+explode a
+
+bcommon result a_1 a_2
+
+checkshape result
+
+checknbshapes result -vertex 8 -edge 12 -wire 6 -face 6 -shell 1 -solid 1
+
+checkmaxtol result -min_tol 1.e-5
+
+checkprops result -s 83754.8
+
+checkview -display result -2d -path ${imagedir}/${test_image}.png