]> OCCT Git - occt.git/commitdiff
0030781: Sweep algorithm creates non-planar edges (orig. BOPAlgo_MakerVolume fails... CR0-WEEK-49 IR-2022-12-11
authorifv <ifv@opencascade.com>
Fri, 2 Dec 2022 08:47:37 +0000 (11:47 +0300)
committerVadim Glukhikh <vadim.glukhikh@opencascade.com>
Sat, 10 Dec 2022 14:04:53 +0000 (14:04 +0000)
BRepFill/BRepFill_AdvancedEvolved.cxx - estimation of angular tolerance is added in method GetLids()

tests/evolved/voluved/bug30781 - new test added

src/BRepFill/BRepFill_AdvancedEvolved.cxx
tests/evolved/voluved/bug30781 [new file with mode: 0644]

index 2d5cdd19f534b52ba15787da6ed595f881aa1bf6..46c55743917ee350ea468ec041743572f60bd518 100644 (file)
@@ -44,6 +44,8 @@
 #include <BRepGProp_Face.hxx>
 #include <BRep_TEdge.hxx>
 #include <ShapeUpgrade_UnifySameDomain.hxx>
+#include <Bnd_Box.hxx>
+#include <BRepBndLib.hxx>
 
 #ifdef BRepFill_AdvancedEvolved_DEBUG
 #include <BinTools.hxx>
@@ -524,9 +526,14 @@ void BRepFill_AdvancedEvolved::GetLids()
     return;
   }
 
+  Standard_Real aTol = Max(aFS.Tolerance(), aFS.ToleranceReached());
+  aTol += myFuzzyValue;
+  Bnd_Box aProfBox;
+  BRepBndLib::Add(myProfile, aProfBox);
+  Standard_Real aSqDiag = aProfBox.SquareExtent();
   //Square of the default angular tolerance in
   //BOPAlgo_Tools::EdgesToWires(...) and BOPAlgo_Tools::WiresToFaces(...) methods
-  const Standard_Real aSqAnguarTol = 1.0e-16;
+  const Standard_Real aSqAnguarTol = aTol*aTol / aSqDiag;
   const gp_Dir &aNormal = aSurf->Position().Direction();
 
   // Obtain free-edges from myPipeShell. All edges must be planar
@@ -541,6 +548,7 @@ void BRepFill_AdvancedEvolved::GetLids()
   gp_Pnt aPtmp;
   gp_Vec aTan;
 
+  Standard_Real aDPMax = 0.;
   for (Standard_Integer i = 1; i <= aMapEF.Size(); i++)
   {
     TopTools_ListOfShape& aListF = aMapEF(i);
@@ -564,6 +572,8 @@ void BRepFill_AdvancedEvolved::GetLids()
       continue;
 
     const Standard_Real aDP = aTan.XYZ().Dot(aNormal.XYZ());
+    if (Abs(aDP) > aDPMax)
+      aDPMax = Abs(aDP);
     if (aDP*aDP>aSqModulus*aSqAnguarTol)
     {
       //Only planar edges are considered
@@ -594,8 +604,9 @@ void BRepFill_AdvancedEvolved::GetLids()
   aBB.MakeCompound(aCompW);
   aBB.MakeCompound(aCompF);
   aBB.MakeCompound(myTopBottom);
-  BOPAlgo_Tools::EdgesToWires(aFreeEdges, aCompW, Standard_True);
-  BOPAlgo_Tools::WiresToFaces(aCompW, aCompF);
+  Standard_Real anAngTol = Sqrt(aSqAnguarTol);
+  BOPAlgo_Tools::EdgesToWires(aFreeEdges, aCompW, Standard_True, anAngTol);
+  BOPAlgo_Tools::WiresToFaces(aCompW, aCompF, anAngTol);
 
   {
     // Check orientation
diff --git a/tests/evolved/voluved/bug30781 b/tests/evolved/voluved/bug30781
new file mode 100644 (file)
index 0000000..d4eccfe
--- /dev/null
@@ -0,0 +1,17 @@
+puts "##################################################"
+puts "0030781: Sweep algorithm creates non-planar edges (orig. BOPAlgo_MakerVolume fails to build a solid)"
+puts "##################################################"
+
+binrestore [locate_data_file bug30781.bin] s
+explode s
+evolved result -s s_1 -p s_2 -solid -a -v -t 1.e-6
+
+checkshape result
+checknbshapes result -vertex 24 -edge 38 -wire 14 -face 14
+checkprops result -s 41330.7
+
+smallview
+don result 
+fit
+
+checkview -screenshot -2d -path ${imagedir}/${test_image}.png
\ No newline at end of file