Skip to content
Snippets Groups Projects
Commit 5b0b38cb authored by Karsten Rink's avatar Karsten Rink
Browse files

check input stream

parent fb03f6ab
No related branches found
No related tags found
No related merge requests found
......@@ -103,10 +103,13 @@ MeshLib::Mesh* GMSHInterface::readGMSHMesh(std::string const& fname)
{
std::string line;
std::ifstream in(fname.c_str(), std::ios::in);
getline(in, line); // Node keyword
std::vector<MeshLib::Node*> nodes;
std::vector<MeshLib::Element*> elements;
if (!in.is_open())
{
WARN ("GMSHInterface::readGMSHMesh() - Could not open file %s.", fname.c_str());
return nullptr;
}
getline(in, line); // $MeshFormat keyword
if (line.find("$MeshFormat") == std::string::npos)
{
in.close();
......@@ -126,6 +129,8 @@ MeshLib::Mesh* GMSHInterface::readGMSHMesh(std::string const& fname)
}
getline(in, line); //$EndMeshFormat
std::vector<MeshLib::Node*> nodes;
std::vector<MeshLib::Element*> elements;
std::map<unsigned, unsigned> id_map;
while (line.find("$EndElements") == std::string::npos)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment