From 35fe3e927bed0595b78fd1d0bdb0d5f45fb974a7 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Mon, 25 Sep 2023 17:54:38 -0400 Subject: [PATCH] STLFileReader: Fix crash when all points are on a single plane. Signed-off-by: Michael Jackson (cherry picked from commit 734fc82df9060b31fae3d21dea8ae87ae326af61) --- .../Filters/Algorithms/StlFileReader.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Plugins/ComplexCore/src/ComplexCore/Filters/Algorithms/StlFileReader.cpp b/src/Plugins/ComplexCore/src/ComplexCore/Filters/Algorithms/StlFileReader.cpp index f976c394d7..3a373093b0 100644 --- a/src/Plugins/ComplexCore/src/ComplexCore/Filters/Algorithms/StlFileReader.cpp +++ b/src/Plugins/ComplexCore/src/ComplexCore/Filters/Algorithms/StlFileReader.cpp @@ -312,9 +312,18 @@ Result<> StlFileReader::eliminate_duplicate_nodes() int32_t bin = 0, xBin = 0, yBin = 0, zBin = 0; for(size_t i = 0; i < nNodes; i++) { - xBin = static_cast((vertices[i * 3] - m_MinMaxCoords[0]) / stepX); - yBin = static_cast((vertices[i * 3 + 1] - m_MinMaxCoords[2]) / stepY); - zBin = static_cast((vertices[i * 3 + 2] - m_MinMaxCoords[4]) / stepZ); + if(stepX != 0.0) + { + xBin = static_cast((vertices[i * 3] - m_MinMaxCoords[0]) / stepX); + } + if(stepY != 0.0) + { + yBin = static_cast((vertices[i * 3 + 1] - m_MinMaxCoords[2]) / stepY); + } + if(zBin != 0.0) + { + zBin = static_cast((vertices[i * 3 + 2] - m_MinMaxCoords[4]) / stepZ); + } if(xBin == 100) { xBin = 99;