From 3416dfd0b66b75b5d485aad38a95e39e9ea3baee Mon Sep 17 00:00:00 2001 From: Olivier Goury Date: Wed, 18 Oct 2023 10:17:18 +0200 Subject: [PATCH 1/2] Check that triangles index match the size of the triangleAroundVertexArray (Like it is done in EdgeSetTopologyContainer for EdgeAroundVertexArray) --- .../container/dynamic/TriangleSetTopologyContainer.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetTopologyContainer.cpp b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetTopologyContainer.cpp index 96b6d62727b..dad087a7084 100644 --- a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetTopologyContainer.cpp +++ b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetTopologyContainer.cpp @@ -125,6 +125,13 @@ void TriangleSetTopologyContainer::createTrianglesAroundVertexArray() m_trianglesAroundVertex.resize(getNbPoints()); for (size_t i = 0; i < m_triangle.size(); ++i) { + if (m_triangle[i][0] >= getNbPoints() || m_triangle[i][1] >= getNbPoints() || m_triangle[i][2] >= getNbPoints()) + { + msg_warning() << "trianglesAroundVertex creation failed, Triangle buffer is not concistent with number of points: Triangle: " << m_triangle[i] << " for: " << getNbPoints() << " points."; + continue; + } + + // adding edge i in the edge shell of both points for (unsigned int j=0; j<3; ++j) m_trianglesAroundVertex[ m_triangle[i][j] ].push_back( (TriangleID)i ); From 575c4c7805a1b143b8a885ae56b5b06c9a81219d Mon Sep 17 00:00:00 2001 From: Olivier Goury Date: Wed, 18 Oct 2023 10:51:04 +0200 Subject: [PATCH 2/2] Fix some typos --- .../topology/container/dynamic/EdgeSetTopologyContainer.cpp | 2 +- .../topology/container/dynamic/TriangleSetTopologyContainer.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/EdgeSetTopologyContainer.cpp b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/EdgeSetTopologyContainer.cpp index 791d760f0f9..26f90cca3ca 100644 --- a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/EdgeSetTopologyContainer.cpp +++ b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/EdgeSetTopologyContainer.cpp @@ -122,7 +122,7 @@ void EdgeSetTopologyContainer::createEdgesAroundVertexArray() if (edge[0] >= unsigned(nbPoints) || edge[1] >= unsigned(nbPoints)) { - msg_warning() << "EdgesAroundVertex creation failed, Edge buffer is not concistent with number of points: Edge: " << edge << " for: " << nbPoints << " points."; + msg_warning() << "EdgesAroundVertex creation failed, Edge buffer is not consistent with number of points, Edge: " << edge << " for: " << nbPoints << " points."; continue; } diff --git a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetTopologyContainer.cpp b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetTopologyContainer.cpp index dad087a7084..f7a81582eb8 100644 --- a/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetTopologyContainer.cpp +++ b/Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetTopologyContainer.cpp @@ -127,7 +127,7 @@ void TriangleSetTopologyContainer::createTrianglesAroundVertexArray() { if (m_triangle[i][0] >= getNbPoints() || m_triangle[i][1] >= getNbPoints() || m_triangle[i][2] >= getNbPoints()) { - msg_warning() << "trianglesAroundVertex creation failed, Triangle buffer is not concistent with number of points: Triangle: " << m_triangle[i] << " for: " << getNbPoints() << " points."; + msg_warning() << "trianglesAroundVertex creation failed, Triangle buffer is not consistent with number of points, Triangle: " << m_triangle[i] << " for: " << getNbPoints() << " points."; continue; }