diff --git a/libsrc/csg/csgeom.hpp b/libsrc/csg/csgeom.hpp index f5cb21a4..35453b30 100644 --- a/libsrc/csg/csgeom.hpp +++ b/libsrc/csg/csgeom.hpp @@ -127,13 +127,16 @@ namespace netgen class UserPoint : public Point<3> { int index; + string name; public: UserPoint() = default; UserPoint (Point<3> p, int _index) : Point<3>(p), index(_index) { ; } + UserPoint (Point<3> p, const string & _name) : Point<3>(p), name(_name), index(-1) { ; } int GetIndex() const { return index; } + const string & GetName() const { return name; } void DoArchive(Archive& archive) { - archive & index; + archive & index & name; Point<3>::DoArchive(archive); } }; diff --git a/libsrc/csg/genmesh.cpp b/libsrc/csg/genmesh.cpp index 6e3c76c2..4a9c4a2a 100644 --- a/libsrc/csg/genmesh.cpp +++ b/libsrc/csg/genmesh.cpp @@ -32,7 +32,11 @@ namespace netgen auto pnum = mesh.AddPoint(up); mesh.Points().Last().Singularity (geom.GetUserPointRefFactor(i)); mesh.AddLockedPoint (PointIndex (i+1)); - mesh.pointelements.Append (Element0d(pnum, up.GetIndex())); + int index = up.GetIndex(); + if (index == -1) + index = mesh.AddCD3Name (up.GetName())+1; + // cout << "adding 0d element, pnum = " << pnum << ", material index = " << index << endl; + mesh.pointelements.Append (Element0d(pnum, index)); } SpecialPointCalculation spc; diff --git a/libsrc/csg/python_csg.cpp b/libsrc/csg/python_csg.cpp index a48475e0..09063e51 100644 --- a/libsrc/csg/python_csg.cpp +++ b/libsrc/csg/python_csg.cpp @@ -579,9 +579,12 @@ However, when r = 0, the top part becomes a point(tip) and meshing fails! self.named_edges[tuple(s1,s2)] = name; }) - .def("AddPoint", [] (CSGeometry & self, Point<3> p, int index) -> CSGeometry& + .def("AddPoint", [] (CSGeometry & self, Point<3> p, variant index) -> CSGeometry& { - self.AddUserPoint(CSGeometry::UserPoint(p, index)); + if (auto pint = std::get_if (&index)) + self.AddUserPoint(CSGeometry::UserPoint(p, *pint)); + if (auto pstr = std::get_if (&index)) + self.AddUserPoint(CSGeometry::UserPoint(p, *pstr)); return self; }) diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index 36bbdf5b..8c340041 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -6570,7 +6570,16 @@ namespace netgen else cd3names[cd3nr] = nullptr; } - + + int Mesh :: AddCD3Name (const string & aname) + { + for (int i = 0; i < cd3names.Size(); i++) + if (*cd3names[i] == aname) + return i; + cd3names.Append (new string(aname)); + return cd3names.Size()-1; + } + string Mesh :: cd3_default_name = "default"; const string & Mesh :: GetCD3Name (int cd3nr) const { diff --git a/libsrc/meshing/meshclass.hpp b/libsrc/meshing/meshclass.hpp index fab9a13f..e455f02e 100644 --- a/libsrc/meshing/meshclass.hpp +++ b/libsrc/meshing/meshclass.hpp @@ -673,6 +673,7 @@ namespace netgen DLL_HEADER void SetNCD3Names (int ncd3n); DLL_HEADER void SetCD3Name (int cd3nr, const string & abcname); + DLL_HEADER int AddCD3Name (const string & aname); DLL_HEADER const string & GetCD3Name (int cd3nr ) const; DLL_HEADER static string cd3_default_name;