Skip to content

Commit 790f478

Browse files
committed
Medit format fixes
1 parent b8fe52e commit 790f478

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

libsrc/interface/rw_medit.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include <regex>
2+
13
#include <meshing.hpp>
24
#include "rw_medit.hpp"
35

@@ -6,6 +8,8 @@ namespace netgen
68
void ReadMeditFormat (Mesh & mesh, const filesystem::path & filename, map<tuple<int,int>, int> & index_map)
79
{
810
static Timer tall("ReadMeditMesh"); RegionTimer rtall(tall);
11+
if(!filesystem::exists(filename))
12+
throw Exception("File does not exist: " + filename.string());
913
auto fin = ifstream(filename);
1014
string token;
1115
int version, dim;
@@ -28,9 +32,12 @@ void ReadMeditFormat (Mesh & mesh, const filesystem::path & filename, map<tuple<
2832
while(true) {
2933
fin >> token;
3034
int index;
31-
if(token == "End")
35+
if(token == "End") {
3236
break;
33-
37+
}
38+
else if(token == "" || std::regex_match(token, std::regex("^[\\s]*$"))) {
39+
continue;
40+
}
3441
else if(token == "MeshVersionFormatted") {
3542
fin >> version;
3643
}
@@ -124,8 +131,8 @@ void WriteMeditFormat (const Mesh & mesh, const filesystem::path & filename, map
124131
for(const auto & p : mesh.Points())
125132
{
126133
for(auto i : Range(mesh.GetDimension()))
127-
fout << setw(20) << p[i];
128-
fout << setw(6) << getIndex(1, 0) << endl;
134+
fout << p[i] << ' ';
135+
fout << getIndex(1, 0) << endl;
129136
}
130137

131138
base_index = max_index;

0 commit comments

Comments
 (0)