From 23543d0a36c7b9e6c7ffd52e6171d7e6f6baeabb Mon Sep 17 00:00:00 2001 From: Alan <37482427+alemon-aquaveo@users.noreply.github.com> Date: Fri, 2 Aug 2024 14:05:12 -0600 Subject: [PATCH] -fix bug with TrTin class where OptimizeTriangulation is called and the triangle adjacency info has not been computed. This would cause a crash. Added code to check if m_trisAdjToPts->empty() and if so then we call BuildTrisAdjToPts(). --- xmsgrid/triangulate/TrTin.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xmsgrid/triangulate/TrTin.cpp b/xmsgrid/triangulate/TrTin.cpp index 6791eeaa..e7661762 100644 --- a/xmsgrid/triangulate/TrTin.cpp +++ b/xmsgrid/triangulate/TrTin.cpp @@ -1112,6 +1112,9 @@ void TrTinImpl::DeletePoints(const SetInt& a_points) //------------------------------------------------------------------------------ bool TrTinImpl::OptimizeTriangulation() { + if (m_trisAdjToPts->empty()) // this method requires the adjacent triangle info + BuildTrisAdjToPts(); + bool modified = false; int nTri = NumTriangles(); VecInt no_propagate_flags(nTri, false); @@ -1997,7 +2000,12 @@ void TrTinUnitTests::testOptimizeTriangulation() tin->GetBoundaryPoints(boundaryPoints); TS_ASSERT_EQUALS((VecInt{0, 1, 2, 3, 5, 6, 7, 8}), boundaryPoints); -} // TrTinUnitTests::testOptimizeTriangulation + // fix crash where Optimize is called without adjacent triangles computed + *trisAdjToPts = VecInt2d(); + tin = TrTin::New(); + tin->SetGeometry(pts, tris, trisAdjToPts); + tin->OptimizeTriangulation(); + } // TrTinUnitTests::testOptimizeTriangulation //------------------------------------------------------------------------------ /// \brief /// \verbatim