0032859: Modeling Algorithms - BRepLib_FindSurface not return an expect plane IR-2022-09-09
authorifv <ifv@opencascade.com>
Thu, 8 Sep 2022 11:08:00 +0000 (14:08 +0300)
committersmoskvin <smoskvin@opencascade.com>
Sat, 10 Sep 2022 14:14:05 +0000 (17:14 +0300)
BRepLib/BRepLib_FindSurface.cxx = removing very small values from coordinate of normal
bug32859 - test case added

src/BRepLib/BRepLib_FindSurface.cxx
tests/bugs/modalg_8/bug32859 [new file with mode: 0644]

index 15ae27de86affe478f8fead62da429e2a0b814a2..029abf4df33c2fa5393477aa8ebb214501cf55d7 100644 (file)
@@ -506,7 +506,14 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape&    S,
 
   if (!isSolved)
     return;
-
+  //Removing very small values
+  Standard_Real aMaxV = Max(Abs(aVec(1)), Max(Abs(aVec(2)), Abs(aVec(3))));
+  Standard_Real eps = Epsilon(aMaxV);
+  for (i = 1; i <= 3; ++i)
+  {
+    if (Abs(aVec(i)) <= eps)
+      aVec(i) = 0.;
+  }
   gp_Vec aN (aVec (1), aVec (2), aVec (3));
   Handle(Geom_Plane) aPlane = new Geom_Plane (aBaryCenter, aN);
   myTolReached = Controle (aPoints, aPlane);
diff --git a/tests/bugs/modalg_8/bug32859 b/tests/bugs/modalg_8/bug32859
new file mode 100644 (file)
index 0000000..b0f435e
--- /dev/null
@@ -0,0 +1,21 @@
+puts "============================================================================================="
+puts "0032859: Modeling Algorithms - BRepLib_FindSurface not return an expect plane"
+puts "============================================================================================="
+puts ""
+
+vertex v1 -500  25 -6
+vertex v2 -450 -25 -6
+vertex v3  450 -25 -6
+vertex v4  500  25 -6
+edge e1 v1 v2
+edge e2 v2 v3
+edge e3 v3 v4
+edge e4 v4 v1
+
+wire w e1 e2 e3 e4
+mkplane p w
+mksurface s p
+set log [eval dump s]
+if {[regexp "Axis   :0, 0, 1" ${log}] != 1} {
+    puts "Error: BRepLib_FindSurface algorithm does not return valid result" 
+}                                                           
\ No newline at end of file