From 7c08e3ac6e4b3476ed7b62bb7980481a059651a1 Mon Sep 17 00:00:00 2001 From: msv Date: Wed, 17 Jul 2019 16:50:43 +0300 Subject: [PATCH] 0030829: BRepExtrema_ShapeProximity crashes with shape from STL/WRL The fix makes algorithm independent on geometrical data. Only triangulation is needed for its work. --- src/BRepExtrema/BRepExtrema_TriangleSet.cxx | 12 ------------ src/BRepExtrema/BRepExtrema_TriangleSet.hxx | 3 --- tests/bugs/modalg_7/bug30829 | 20 ++++++++++++++++++++ 3 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 tests/bugs/modalg_7/bug30829 diff --git a/src/BRepExtrema/BRepExtrema_TriangleSet.cxx b/src/BRepExtrema/BRepExtrema_TriangleSet.cxx index bf971809b0..0ca048354f 100644 --- a/src/BRepExtrema/BRepExtrema_TriangleSet.cxx +++ b/src/BRepExtrema/BRepExtrema_TriangleSet.cxx @@ -16,10 +16,8 @@ #include #include -#include #include #include -#include IMPLEMENT_STANDARD_RTTIEXT(BRepExtrema_TriangleSet, BVH_PrimitiveSet3d) @@ -152,9 +150,6 @@ void BRepExtrema_TriangleSet::Clear() BVH_Array4i anEmptyTriangles; myTriangles.swap (anEmptyTriangles); - BVH_Array2d anEmptyVertUVArray; - myVertUVArray.swap (anEmptyVertUVArray); - BVH_Array3d anEmptyVertexArray; myVertexArray.swap (anEmptyVertexArray); } @@ -179,8 +174,6 @@ Standard_Boolean BRepExtrema_TriangleSet::Init (const BRepExtrema_ShapeList& the return Standard_False; } - BRepAdaptor_Surface aFaceAdaptor (theFaces (aFaceIdx), Standard_False); - const Standard_Integer aVertOffset = static_cast (myVertexArray.size()) - 1; @@ -193,11 +186,6 @@ Standard_Boolean BRepExtrema_TriangleSet::Init (const BRepExtrema_ShapeList& the myVertexArray.push_back (BVH_Vec3d (aVertex.X(), aVertex.Y(), aVertex.Z())); - - const Standard_Real aU = aTriangulation->UVNodes().Value (aVertIdx).X(); - const Standard_Real aV = aTriangulation->UVNodes().Value (aVertIdx).Y(); - - myVertUVArray.push_back (BVH_Vec2d (aU, aV)); } for (Standard_Integer aTriIdx = 1; aTriIdx <= aTriangulation->NbTriangles(); ++aTriIdx) diff --git a/src/BRepExtrema/BRepExtrema_TriangleSet.hxx b/src/BRepExtrema/BRepExtrema_TriangleSet.hxx index 1e843fbe9d..3b0414c75b 100644 --- a/src/BRepExtrema/BRepExtrema_TriangleSet.hxx +++ b/src/BRepExtrema/BRepExtrema_TriangleSet.hxx @@ -75,9 +75,6 @@ protected: //! Array of vertex indices. BVH_Array4i myTriangles; - //! Array of vertex UV params. - BVH_Array2d myVertUVArray; - //! Array of vertex coordinates. BVH_Array3d myVertexArray; diff --git a/tests/bugs/modalg_7/bug30829 b/tests/bugs/modalg_7/bug30829 new file mode 100644 index 0000000000..dcf37bf448 --- /dev/null +++ b/tests/bugs/modalg_7/bug30829 @@ -0,0 +1,20 @@ +puts "========" +puts "0030829: BRepExtrema_ShapeProximity crashes with shape from STL/WRL" +puts "========" +puts "" + +pload XSDRAW + +box b 10 10 10 +pcylinder c 5 10 +incmesh b 0.1 +incmesh c 0.1 + +writestl b ${imagedir}/${test_image}_b.stl +writestl c ${imagedir}/${test_image}_c.stl +readstl b ${imagedir}/${test_image}_b.stl +readstl c ${imagedir}/${test_image}_c.stl +file delete ${imagedir}/${test_image}_b.stl +file delete ${imagedir}/${test_image}_c.stl + +proximity b c