diff --git a/libsrc/include/nginterface_v2_impl.hpp b/libsrc/include/nginterface_v2_impl.hpp index 472f7e61..0bcd71d9 100644 --- a/libsrc/include/nginterface_v2_impl.hpp +++ b/libsrc/include/nginterface_v2_impl.hpp @@ -74,9 +74,8 @@ NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<1> (size_t nr) const ret.mat = mesh->GetBCNamePtr(el.si-1); else { - if (mesh->GetDimension() == 3){ - ret.mat = &mesh->GetCD2Name(el.edgenr-1); - } + if (mesh->GetDimension() == 3) + ret.mat = mesh->GetCD2NamePtr(el.edgenr-1); else ret.mat = nullptr; } diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 396631f4..396bb167 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -5832,6 +5832,7 @@ namespace netgen cd2names[cd2nr] = nullptr; } + string Mesh :: cd2_default_name = "default"; const string & Mesh :: GetCD2Name (int cd2nr) const { static string defaultstring = "default"; diff --git a/libsrc/meshing/meshclass.hpp b/libsrc/meshing/meshclass.hpp index 7fc6ca1a..cf5e7de2 100644 --- a/libsrc/meshing/meshclass.hpp +++ b/libsrc/meshing/meshclass.hpp @@ -606,6 +606,12 @@ namespace netgen DLL_HEADER void SetCD2Name (int cd2nr, const string & abcname); const string & GetCD2Name (int cd2nr ) const; + static string cd2_default_name; + string * GetCD2NamePtr (int cd2nr ) const + { + if (cd2nr < cd2names.Size() && cd2names[cd2nr]) return cd2names[cd2nr]; + return &cd2_default_name; + } size_t GetNCD2Names() const { return cd2names.Size(); } string * GetBCNamePtr (int bcnr) const