From: El Hadi Moussi Date: Thu, 8 Aug 2024 16:10:29 +0000 (+0200) Subject: Add an exception if the mesh is not 2d and doesn't contains only triangles X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bbb68a0ca39687644544d64b1e4cc5712b4a4cb8;p=tools%2Fmedcoupling.git Add an exception if the mesh is not 2d and doesn't contains only triangles --- diff --git a/src/ShapeRecogn/NodesBuilder.cxx b/src/ShapeRecogn/NodesBuilder.cxx index 95183cbae..d8752f8f0 100644 --- a/src/ShapeRecogn/NodesBuilder.cxx +++ b/src/ShapeRecogn/NodesBuilder.cxx @@ -44,9 +44,10 @@ void NodesBuilder::computeNormals() DataArrayInt64 *revNodal = DataArrayInt64::New(); DataArrayInt64 *revNodalIdx = DataArrayInt64::New(); mesh->getReverseNodalConnectivity(revNodal, revNodalIdx); - for (mcIdType nodeId = 0; nodeId < nbNodes; nodeId++) + for (size_t nodeId = 0; nodeId < (size_t)nbNodes; nodeId++) { - int nbCells = revNodalIdx->getIJ(nodeId + 1, 0) - revNodalIdx->getIJ(nodeId, 0); + int nbCells = revNodalIdx->getIJ(nodeId + 1, 0) - + revNodalIdx->getIJ(nodeId, 0); std::vector cellIds(nbCells, 0); int start = revNodalIdx->getIJ(nodeId, 0); for (size_t i = 0; i < cellIds.size(); ++i) diff --git a/src/ShapeRecogn/ShapeRecognMesh.cxx b/src/ShapeRecogn/ShapeRecognMesh.cxx index 08c9a5618..c6e52afeb 100644 --- a/src/ShapeRecogn/ShapeRecognMesh.cxx +++ b/src/ShapeRecogn/ShapeRecognMesh.cxx @@ -10,7 +10,10 @@ using namespace MEDCoupling; ShapeRecognMesh::ShapeRecognMesh(const std::string &fileName) { mesh = ReadUMeshFromFile(fileName); - // TODO: check if the elements of the mesh are triangle ? + if (mesh->getMeshDimension() != 2) + throw INTERP_KERNEL::Exception("Expect a mesh with a dimension equal to 2"); + if (mesh->getNumberOfCellsWithType(INTERP_KERNEL::NORM_TRI3) != mesh->getNumberOfCells()) + throw INTERP_KERNEL::Exception("Expect a mesh containing exclusively triangular cells"); } ShapeRecognMesh::~ShapeRecognMesh()