diff --git a/libsrc/geom2d/genmesh2d.cpp b/libsrc/geom2d/genmesh2d.cpp index c1eadf1a..6d00f1fe 100644 --- a/libsrc/geom2d/genmesh2d.cpp +++ b/libsrc/geom2d/genmesh2d.cpp @@ -458,9 +458,6 @@ namespace netgen for ( int sindex = 0; sindex < maxsegmentindex; sindex++ ) mesh->SetBCName ( sindex, geometry.GetBCName( sindex+1 ) ); - for (SegmentIndex si = 0; si < mesh->GetNSeg(); si++) - (*mesh)[si].SetBCName ( (*mesh).GetBCNamePtr( (*mesh)[si].si-1 ) ); - mesh->CalcLocalH(mp.grading); int bnp = mesh->GetNP(); // boundary points diff --git a/libsrc/interface/nginterface.cpp b/libsrc/interface/nginterface.cpp index 7c647119..42d26094 100644 --- a/libsrc/interface/nginterface.cpp +++ b/libsrc/interface/nginterface.cpp @@ -560,7 +560,7 @@ char * Ng_GetSurfaceElementBCName (int ei) if ( mesh->GetDimension() == 3 ) return const_cast(mesh->GetFaceDescriptor(mesh->SurfaceElement(ei).GetIndex()).GetBCName().c_str()); else - return const_cast(mesh->LineSegment(ei).GetBCName().c_str()); + return const_cast(mesh->GetBCName(mesh->LineSegment(ei).si).c_str()); } diff --git a/libsrc/interface/readuser.cpp b/libsrc/interface/readuser.cpp index d3d50cf2..29b16afa 100644 --- a/libsrc/interface/readuser.cpp +++ b/libsrc/interface/readuser.cpp @@ -313,7 +313,6 @@ namespace netgen ednr = mesh.AddEdgeDescriptor(ed); mesh.SetCD2Name(bcpr, name); auto nr = mesh.AddSegment(tmp_segments[get<0>(element_map[index])-1]); - mesh[nr].SetBCName(mesh.GetCD2NamePtr(mesh.GetNCD2Names())); mesh[nr].edgenr = ednr+1; } else if(dim == 2) @@ -321,7 +320,6 @@ namespace netgen Segment & seg = mesh.LineSegment(get<0>(element_map[index])); seg.si = bccounter + 1; mesh.SetBCName(bccounter, name); - seg.SetBCName(mesh.GetBCNamePtr(bccounter)); bccounter++; } break; @@ -353,13 +351,11 @@ namespace netgen { auto nr = mesh.AddSegment(tmp_segments[get<0>(element_map[index])-1]); mesh[nr].edgenr = ednr+1; - mesh[nr].SetBCName(mesh.GetCD2NamePtr(mesh.GetNCD2Names())); } else if(dim == 2) { Segment & seg = mesh.LineSegment(get<0>(element_map[index])); seg.si = bccounter; - seg.SetBCName(mesh.GetBCNamePtr(bccounter-1)); } break; default: @@ -388,7 +384,6 @@ namespace netgen if(seg.si == -1){ seg.si = bccounter + 1; if(bccounter_tmp == bccounter) mesh.SetBCName(bccounter, "default"); // could be more efficient - seg.SetBCName(mesh.GetBCNamePtr(bccounter)); bccounter_tmp++; } } diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 76a22ffc..703109a1 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -105,11 +105,18 @@ namespace netgen if ( mesh2.materials[i] ) materials[i] = new string ( *mesh2.materials[i] ); else materials[i] = 0; - + std::map bcmap; bcnames.SetSize( mesh2.bcnames.Size() ); for ( int i = 0; i < mesh2.bcnames.Size(); i++ ) + { if ( mesh2.bcnames[i] ) bcnames[i] = new string ( *mesh2.bcnames[i] ); else bcnames[i] = 0; + bcmap[mesh2.bcnames[i]] = bcnames[i]; + } + + // Remap string* members in FaceDescriptor to new mesh + for (auto & f : facedecoding) + f.SetBCName( bcmap[&f.GetBCName()] ); cd2names.SetSize(mesh2.cd2names.Size()); @@ -1112,18 +1119,7 @@ namespace netgen bcnames[bcnrs[i-1]-1] = new string(nextbcname); } - if ( GetDimension() == 2 ) - { - for (i = 1; i <= GetNSeg(); i++) - { - Segment & seg = LineSegment (i); - if ( seg.si <= n ) - seg.SetBCName (bcnames[seg.si-1]); - else - seg.SetBCName(0); - } - } - else + if ( GetDimension() == 3 ) { for (SurfaceElementIndex sei = 0; sei < GetNSE(); sei++) { @@ -1156,17 +1152,6 @@ namespace netgen { throw NgException("co dim 2 elements not implemented for dimension 2"); } - else - { - for (i = 1; i<= GetNSeg(); i++) - { - Segment & seg = LineSegment(i); - if ( seg.edgenr <= n ) - seg.SetBCName (cd2names[seg.edgenr-1]); - else - seg.SetBCName(0); - } - } } if (strcmp (str, "singular_points") == 0) diff --git a/libsrc/meshing/meshtype.cpp b/libsrc/meshing/meshtype.cpp index 9523fab7..f512c683 100644 --- a/libsrc/meshing/meshtype.cpp +++ b/libsrc/meshing/meshtype.cpp @@ -80,8 +80,6 @@ namespace netgen epgeominfo[1].edgenr = 1; epgeominfo[1].dist = 0; */ - - bcname = nullptr; } Segment::Segment (const Segment & other) @@ -109,7 +107,6 @@ namespace netgen geominfo[1] = other.geominfo[1]; epgeominfo[0] = other.epgeominfo[0]; epgeominfo[1] = other.epgeominfo[1]; - bcname = other.bcname; } Segment& Segment::operator=(const Segment & other) @@ -135,7 +132,6 @@ namespace netgen pnums[2] = other.pnums[2]; meshdocval = other.meshdocval; hp_elnr = other.hp_elnr; - bcname = other.bcname; is_curved = other.is_curved; } @@ -144,11 +140,12 @@ namespace netgen void Segment :: DoArchive (Archive & ar) { + string * bcname_dummy = nullptr; ar & pnums[0] & pnums[1] & pnums[2] & edgenr & singedge_left & singedge_right & si & cd2i & domin & domout & tlosurf & surfnr1 & surfnr2 - & bcname + & bcname_dummy // keep this for backward compatiblity & epgeominfo[0].edgenr & epgeominfo[1].edgenr; } diff --git a/libsrc/meshing/meshtype.hpp b/libsrc/meshing/meshtype.hpp index e6ccc83e..84e9aec8 100644 --- a/libsrc/meshing/meshtype.hpp +++ b/libsrc/meshing/meshtype.hpp @@ -1031,7 +1031,6 @@ namespace netgen // #endif private: - string* bcname; bool is_curved; public: @@ -1048,24 +1047,6 @@ namespace netgen int hp_elnr; - void SetBCName ( string * abcname ) - { - bcname = abcname; - } - - string * BCNamePtr () - { return bcname; } - - const string * BCNamePtr () const - { return bcname; } - - const string & GetBCName () const - { - static string defaultstring = "default"; - if (! bcname ) return defaultstring; - return *bcname; - } - int GetNP() const { return pnums[2].IsValid() ? 3 : 2;