From 639bffa55ebf0dba494932d9bcb780d7ad5bb50f Mon Sep 17 00:00:00 2001 From: rinkk <karsten.rink@ufz.de> Date: Thu, 8 Oct 2020 11:37:01 +0200 Subject: [PATCH] [meshlib] fixing issue when creating TetGen PLC --- Applications/FileIO/TetGenInterface.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Applications/FileIO/TetGenInterface.cpp b/Applications/FileIO/TetGenInterface.cpp index 5e9afac09ba..841c364ca3c 100644 --- a/Applications/FileIO/TetGenInterface.cpp +++ b/Applications/FileIO/TetGenInterface.cpp @@ -715,9 +715,13 @@ void TetGenInterface::write2dElements(std::ofstream &out, { // the surfaces header auto const& types = MeshLib::MeshInformation::getNumberOfElementTypes(mesh); - const unsigned nTotalTriangles = - (types.at(MeshLib::MeshElemType::TRIANGLE) + - (2 * types.at(MeshLib::MeshElemType::QUAD))); + std::size_t const n_tri = + (types.find(MeshLib::MeshElemType::TRIANGLE) != types.end()) + ? types.at(MeshLib::MeshElemType::TRIANGLE) : 0; + std::size_t const n_quad = + (types.find(MeshLib::MeshElemType::QUAD) != types.end()) + ? types.at(MeshLib::MeshElemType::QUAD) : 0; + unsigned const nTotalTriangles = n_tri + 2 * n_quad; out << nTotalTriangles << " 1\n"; const std::vector<MeshLib::Element*> &elements = mesh.getElements(); -- GitLab