]> OCCT Git - occt.git/commitdiff
0030094: Modeling Algorithms - Defeaturing does not work on the attached shape due...
authoremv <emv@opencascade.com>
Fri, 31 Aug 2018 07:17:47 +0000 (10:17 +0300)
committerbugmaster <bugmaster@opencascade.com>
Tue, 4 Sep 2018 16:24:43 +0000 (19:24 +0300)
BRepLib::ExtendFace method when working with analytical and periodic faces now takes into account the possible closeness of the result face.
Test cases for the issue.

src/BRepLib/BRepLib.cxx
tests/boolean/removefeatures/G3 [new file with mode: 0644]
tests/boolean/removefeatures/G4 [new file with mode: 0644]

index 60d0bbc92883d438a079915c7a1f12b4d806cfca..f07d7e659bda5f2126466941f428d5116affe3fc 100644 (file)
@@ -2706,18 +2706,23 @@ void BRepLib::ExtendFace(const TopoDS_Face& theF,
     Standard_Real aSUMin, aSUMax, aSVMin, aSVMax;
     aSurf->Bounds(aSUMin, aSUMax, aSVMin, aSVMax);
 
-    if (aBAS.IsUPeriodic())
+    Standard_Boolean isUPeriodic = aBAS.IsUPeriodic();
+    Standard_Real anUPeriod = isUPeriodic ? aBAS.UPeriod() : 0.0;
+    if (isUPeriodic)
     {
       // Adjust face bounds to first period
       Standard_Real aDelta = aFUMax - aFUMin;
-      aFUMin = Max(aSUMin, aFUMin + aBAS.UPeriod()*Ceiling((aSUMin - aFUMin)/aBAS.UPeriod()));
+      aFUMin = Max(aSUMin, aFUMin + anUPeriod*Ceiling((aSUMin - aFUMin) / anUPeriod));
       aFUMax = aFUMin + aDelta;
     }
-    if (aBAS.IsVPeriodic())
+
+    Standard_Boolean isVPeriodic = aBAS.IsVPeriodic();
+    Standard_Real aVPeriod = isVPeriodic ? aBAS.VPeriod() : 0.0;
+    if (isVPeriodic)
     {
       // Adjust face bounds to first period
       Standard_Real aDelta = aFVMax - aFVMin;
-      aFVMin = Max(aSVMin, aFVMin + aBAS.VPeriod()*Ceiling((aSVMin - aFVMin)/aBAS.VPeriod()));
+      aFVMin = Max(aSVMin, aFVMin + aVPeriod*Ceiling((aSVMin - aFVMin) / aVPeriod));
       aFVMax = aFVMin + aDelta;
     }
 
@@ -2729,9 +2734,23 @@ void BRepLib::ExtendFace(const TopoDS_Face& theF,
       aVRes = aBAS.VResolution(theExtVal);
 
     if (theExtUMin) aFUMin = Max(aSUMin, aFUMin - anURes);
-    if (theExtUMax) aFUMax = Min(aSUMax, aFUMax + anURes);
+    if (theExtUMax) aFUMax = Min(isUPeriodic ? aFUMin + anUPeriod : aSUMax, aFUMax + anURes);
     if (theExtVMin) aFVMin = Max(aSVMin, aFVMin - aVRes);
-    if (theExtVMax) aFVMax = Min(aSVMax, aFVMax + aVRes);
+    if (theExtVMax) aFVMax = Min(isVPeriodic ? aFVMin + aVPeriod : aSVMax, aFVMax + aVRes);
+
+    // Check if the periodic surface should become closed.
+    // In this case, use the basis surface with basis bounds.
+    const Standard_Real anEps = Precision::PConfusion();
+    if (isUPeriodic && Abs(aFUMax - aFUMin - anUPeriod) < anEps)
+    {
+      aFUMin = aSUMin;
+      aFUMax = aSUMax;
+    }
+    if (isVPeriodic && Abs(aFVMax - aFVMin - aVPeriod) < anEps)
+    {
+      aFVMin = aSVMin;
+      aFVMax = aSVMax;
+    }
 
     aS = aSurf;
   }
diff --git a/tests/boolean/removefeatures/G3 b/tests/boolean/removefeatures/G3
new file mode 100644 (file)
index 0000000..0813cc9
--- /dev/null
@@ -0,0 +1,30 @@
+puts "========"
+puts "0030094: Modeling Algorithms - Defeaturing does not work on the attached shape due to incorrect extension of the torus"
+puts "========"
+puts ""
+
+
+restore [locate_data_file bug30094.brep] a
+explode a f
+
+removefeatures r1 a a_1
+CheckIsFeatureRemoved a_1 {f}
+
+removefeatures r2 a a_6
+CheckIsFeatureRemoved a_6 {f}
+
+foreach r {r1 r2} {
+  checkshape $r
+  checknbshapes $r -wire 19 -face 17 -shell 1 -solid 1
+  checkprops $r -s 421523 -v 2.04083e+006 -deps 1.e-7
+}
+
+
+removefeatures result a a_1 a_8
+CheckIsFeatureRemoved a_1 {f}
+CheckIsFeatureRemoved a_8 {f}
+checkshape result
+checknbshapes result -wire 22 -face 20 -shell 1 -solid 1
+checkprops result -s 421862 -v 2.04152e+006 -deps 1.e-7
+
+checkview -display result -2d -path ${imagedir}/${test_image}.png
diff --git a/tests/boolean/removefeatures/G4 b/tests/boolean/removefeatures/G4
new file mode 100644 (file)
index 0000000..a689bd3
--- /dev/null
@@ -0,0 +1,30 @@
+puts "TODO OCC30099 ALL: Faulty shapes in variables faulty_1 to faulty_"
+puts "TODO OCC30099 ALL: Error : The area of result shape is"
+puts "TODO OCC30099 ALL: Error : The volume of result shape is"
+
+
+puts "========"
+puts "0030094: Modeling Algorithms - Defeaturing does not work on the attached shape due to incorrect extension of the torus"
+puts "========"
+puts ""
+
+
+restore [locate_data_file bug30094.brep] a
+explode a f
+
+removefeatures r1 a a_8
+CheckIsFeatureRemoved a_8 {f}
+checkshape r1
+checknbshapes r1 -wire 19 -face 17 -shell 1 -solid 1
+checkprops r1 -s 421523 -v 2.04083e+006 -deps 1.e-7
+
+removefeatures result a a_1 a_6 a_8
+CheckIsFeatureRemoved a_1 {f}
+CheckIsFeatureRemoved a_6 {f}
+CheckIsFeatureRemoved a_8 {f}
+
+checkshape result
+checknbshapes result -wire 25 -face 23 -shell 1 -solid 1
+checkprops result -s 422201 -v 2.042204e+006 -deps 1.e-7
+
+checkview -display result -2d -path ${imagedir}/${test_image}.png