From bda192ba9088cdbff424762f5799084383816367 Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Fri, 30 Aug 2024 11:01:03 +0200 Subject: [PATCH] write identification names into mesh --- libsrc/meshing/meshclass.cpp | 18 ++++++++++++++++++ libsrc/meshing/meshtype.hpp | 13 +++++++++++++ 2 files changed, 31 insertions(+) diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 0727162d..43c4b581 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -901,6 +901,13 @@ namespace netgen outfile << " " << type; } outfile << "\n"; + outfile << "identificationnames\n"; + outfile << ident -> GetMaxNr() << "\n"; + for (i = 1; i <= ident -> GetMaxNr(); i++) + { + string name = ident -> GetName(i); + outfile << ident->GetName(i) << "\n"; + } } int cntmat = 0; @@ -1451,6 +1458,17 @@ namespace netgen ident -> SetType(i,Identifications::ID_TYPE(type)); } } + if (strcmp (str, "identificationnames") == 0) + { + infile >> n; + PrintMessage (3, n, " identificationnames"); + for (i = 1; i <= n; i++) + { + string name; + infile >> name; + ident -> SetName(i,name); + } + } if (strcmp (str, "materials") == 0) { diff --git a/libsrc/meshing/meshtype.hpp b/libsrc/meshing/meshtype.hpp index 5186572d..634165c6 100644 --- a/libsrc/meshing/meshtype.hpp +++ b/libsrc/meshing/meshtype.hpp @@ -1642,6 +1642,19 @@ namespace netgen names.Append(name); return names.Pos(name)+1; } + string GetName(int nr) const + { + if (nr <= names.Size()) + return names[nr - 1]; + else + return ""; + } + void SetName(int nr, string name) + { + while(names.Size() < nr) + names.Append(""); + names[nr-1] = name; + } /// remove secondorder void SetMaxPointNr (int maxpnum);