0030829: BRepExtrema_ShapeProximity crashes with shape from STL/WRL
authormsv <msv@opencascade.com>
Wed, 17 Jul 2019 13:50:43 +0000 (16:50 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 18 Jul 2019 08:09:08 +0000 (11:09 +0300)
The fix makes algorithm independent on geometrical data. Only triangulation is needed for its work.

src/BRepExtrema/BRepExtrema_TriangleSet.cxx
src/BRepExtrema/BRepExtrema_TriangleSet.hxx
tests/bugs/modalg_7/bug30829 [new file with mode: 0644]

index bf97180..0ca0483 100644 (file)
 #include <BRepExtrema_TriangleSet.hxx>
 
 #include <BRep_Tool.hxx>
-#include <BRepAdaptor_Surface.hxx>
 #include <BVH_LinearBuilder.hxx>
 #include <Poly_Triangulation.hxx>
-#include <TColgp_Array1OfPnt2d.hxx>
 
 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<Standard_Integer> (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)
index 1e843fb..3b0414c 100644 (file)
@@ -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 (file)
index 0000000..dcf37bf
--- /dev/null
@@ -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