From 526c506cb0a6a5c9c168ab5efd0a4e5211e30bf4 Mon Sep 17 00:00:00 2001 From: ifv Date: Thu, 8 Sep 2022 14:08:00 +0300 Subject: [PATCH] 0032859: Modeling Algorithms - BRepLib_FindSurface not return an expect plane BRepLib/BRepLib_FindSurface.cxx = removing very small values from coordinate of normal bug32859 - test case added --- src/BRepLib/BRepLib_FindSurface.cxx | 9 ++++++++- tests/bugs/modalg_8/bug32859 | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 tests/bugs/modalg_8/bug32859 diff --git a/src/BRepLib/BRepLib_FindSurface.cxx b/src/BRepLib/BRepLib_FindSurface.cxx index 15ae27de86..029abf4df3 100644 --- a/src/BRepLib/BRepLib_FindSurface.cxx +++ b/src/BRepLib/BRepLib_FindSurface.cxx @@ -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 index 0000000000..b0f435e82c --- /dev/null +++ b/tests/bugs/modalg_8/bug32859 @@ -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