From 1deb1c3b7e574af47f59b1ad2030bc7140fded12 Mon Sep 17 00:00:00 2001 From: eap Date: Tue, 9 Jun 2020 13:58:21 +0300 Subject: [PATCH] #19232 [CEA] overal Mesh quality crash on imported MED Bug reason: the med file includes polygons based on none of nodes. Solution: forbid creating such polygons --- src/SMDS/SMDS_Mesh.cxx | 4 ++++ src/SMESH_I/SMESH_MeshEditor_i.cxx | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/SMDS/SMDS_Mesh.cxx b/src/SMDS/SMDS_Mesh.cxx index a5af798e5..353d07893 100644 --- a/src/SMDS/SMDS_Mesh.cxx +++ b/src/SMDS/SMDS_Mesh.cxx @@ -831,6 +831,8 @@ SMDS_Mesh::AddPolygonalFaceWithID (const std::vector & nod { if ( NbFaces() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); + if ( nodes.empty() ) + throw std::invalid_argument("Polygon without nodes is forbidden"); if ( SMDS_MeshCell* cell = myCellFactory->NewCell( ID )) { cell->init( SMDSEntity_Polygon, nodes ); @@ -874,6 +876,8 @@ SMDS_Mesh::AddQuadPolygonalFaceWithID (const std::vector & const int ID) { if ( NbFaces() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); + if ( nodes.empty() ) + throw std::invalid_argument("Polygon without nodes is forbidden"); if ( SMDS_MeshCell* cell = myCellFactory->NewCell( ID )) { cell->init( SMDSEntity_Quad_Polygon, nodes ); diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index 5ae3c6a6e..16cc20053 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -1069,6 +1069,12 @@ CORBA::Long SMESH_MeshEditor_i::AddPolygonalFace (const SMESH::long_array & IDsO if ( ! ( nodes[i] = getMeshDS()->FindNode( IDsOfNodes[i] ))) return 0; + if ( NbNodes == 0 ) + { + INFOS("Polygon without nodes is forbidden"); + return 0; + } + const SMDS_MeshElement* elem = getMeshDS()->AddPolygonalFace(nodes); // Update Python script @@ -1098,6 +1104,12 @@ CORBA::Long SMESH_MeshEditor_i::AddQuadPolygonalFace (const SMESH::long_array & for (int i = 0; i < NbNodes; i++) nodes[i] = getMeshDS()->FindNode(IDsOfNodes[i]); + if ( NbNodes == 0 ) + { + INFOS("Polygon without nodes is forbidden"); + return 0; + } + const SMDS_MeshElement* elem = getMeshDS()->AddQuadPolygonalFace(nodes); // Update Python script -- 2.39.2