Skip to content

Commit

Permalink
-fix bug with TrTin class where OptimizeTriangulation is called and t…
Browse files Browse the repository at this point in the history
…he 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().
  • Loading branch information
alemon-aquaveo authored and gagelarsen committed Aug 6, 2024
1 parent 472cf18 commit 23543d0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion xmsgrid/triangulate/TrTin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 23543d0

Please sign in to comment.