From 1593d38b131206d6c25f6b8cd92c7e163370ec54 Mon Sep 17 00:00:00 2001 From: oan Date: Tue, 28 Jun 2022 11:43:49 +0300 Subject: [PATCH] 0032692: Mesh - In BRepMesh_ModelPreProcessor avoid crashes with problematic topology Improved the processing for the case where Failure flag for the meshing face is set. Specific tests added. Check triangulation consistency even for shapes with problematic topology given that they are suitable for keeping it. --- src/BRepMesh/BRepMesh_ModelPreProcessor.cxx | 9 +++++---- tests/bugs/mesh/bug32692_1 | 11 +++++++++++ tests/bugs/mesh/bug32692_2 | 11 +++++++++++ tests/bugs/mesh/bug32692_3 | 14 ++++++++++++++ 4 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 tests/bugs/mesh/bug32692_1 create mode 100644 tests/bugs/mesh/bug32692_2 create mode 100644 tests/bugs/mesh/bug32692_3 diff --git a/src/BRepMesh/BRepMesh_ModelPreProcessor.cxx b/src/BRepMesh/BRepMesh_ModelPreProcessor.cxx index 4eefa24287..e987376b2c 100644 --- a/src/BRepMesh/BRepMesh_ModelPreProcessor.cxx +++ b/src/BRepMesh/BRepMesh_ModelPreProcessor.cxx @@ -46,7 +46,8 @@ namespace void operator()(const Standard_Integer theFaceIndex) const { const IMeshData::IFaceHandle& aDFace = myModel->GetFace(theFaceIndex); - if (aDFace->IsSet(IMeshData_Outdated)) + if (aDFace->IsSet(IMeshData_Outdated) || + aDFace->GetFace().IsNull()) { return; } @@ -119,7 +120,7 @@ namespace void operator()(const Standard_Integer theFaceIndex) const { const IMeshData::IFaceHandle& aDFace = myModel->GetFace(theFaceIndex); - if (aDFace->GetSurface()->GetType() != GeomAbs_Cone) + if (aDFace->GetSurface()->GetType() != GeomAbs_Cone || aDFace->IsSet(IMeshData_Failure)) { return; } @@ -128,7 +129,7 @@ namespace for (Standard_Integer aEdgeIdx = 0; aEdgeIdx < aDWire->EdgesNb() - 1; ++aEdgeIdx) { const IMeshData::IEdgePtr& aDEdge = aDWire->GetEdge (aEdgeIdx); - + if (aDEdge->GetPCurve(aDFace.get(), TopAbs_FORWARD) != aDEdge->GetPCurve(aDFace.get(), TopAbs_REVERSED)) { if (aDEdge->GetCurve()->ParametersNb() == 2) @@ -146,7 +147,7 @@ namespace } } return; - } + } } } diff --git a/tests/bugs/mesh/bug32692_1 b/tests/bugs/mesh/bug32692_1 new file mode 100644 index 0000000000..db139cb93d --- /dev/null +++ b/tests/bugs/mesh/bug32692_1 @@ -0,0 +1,11 @@ +puts "=========" +puts "OCC32692: Crash when the input shape has some invalid topology" +puts "=========" +puts "" + +puts "REQUIRED ALL: Meshing statuses: SelfIntersectingWire Failure" + +restore [locate_data_file bug32692.brep] s +incmesh s 0.01 -parallel + +checktrinfo s -nod 7511 -tri 7625 -empty 9 -face 309 diff --git a/tests/bugs/mesh/bug32692_2 b/tests/bugs/mesh/bug32692_2 new file mode 100644 index 0000000000..3431ec9f61 --- /dev/null +++ b/tests/bugs/mesh/bug32692_2 @@ -0,0 +1,11 @@ +puts "=========" +puts "OCC32692: Crash when the input shape has some invalid topology" +puts "=========" +puts "" + +puts "REQUIRED ALL: Meshing statuses: Reused" + +restore [locate_data_file bug32692_broken_mesh.brep] s +incmesh s 0.01 -parallel + +checktrinfo s -nod 3 -tri 1 -face 1 diff --git a/tests/bugs/mesh/bug32692_3 b/tests/bugs/mesh/bug32692_3 new file mode 100644 index 0000000000..50d9334f43 --- /dev/null +++ b/tests/bugs/mesh/bug32692_3 @@ -0,0 +1,14 @@ +puts "=========" +puts "OCC32692: Crash when the input shape has some invalid topology" +puts "=========" +puts "" + +puts "REQUIRED ALL: Meshing statuses: OpenWire Failure Outdated" + +pload MODELING +cylinder c 0 0 0 10 +mkface f c + +incmesh f 0.01 -parallel + +checktrinfo f -nod 0 -tri 0 -face 1