csg.AddPoint with names

This commit is contained in:
Joachim Schöberl 2020-01-15 11:56:23 +01:00
parent 3ece315bd0
commit 0209472ef6
5 changed files with 25 additions and 5 deletions

View File

@ -127,13 +127,16 @@ namespace netgen
class UserPoint : public Point<3> class UserPoint : public Point<3>
{ {
int index; int index;
string name;
public: public:
UserPoint() = default; UserPoint() = default;
UserPoint (Point<3> p, int _index) : Point<3>(p), index(_index) { ; } 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; } int GetIndex() const { return index; }
const string & GetName() const { return name; }
void DoArchive(Archive& archive) void DoArchive(Archive& archive)
{ {
archive & index; archive & index & name;
Point<3>::DoArchive(archive); Point<3>::DoArchive(archive);
} }
}; };

View File

@ -32,7 +32,11 @@ namespace netgen
auto pnum = mesh.AddPoint(up); auto pnum = mesh.AddPoint(up);
mesh.Points().Last().Singularity (geom.GetUserPointRefFactor(i)); mesh.Points().Last().Singularity (geom.GetUserPointRefFactor(i));
mesh.AddLockedPoint (PointIndex (i+1)); 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; SpecialPointCalculation spc;

View File

@ -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; 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<int,string> index) -> CSGeometry&
{ {
self.AddUserPoint(CSGeometry::UserPoint(p, index)); if (auto pint = std::get_if<int> (&index))
self.AddUserPoint(CSGeometry::UserPoint(p, *pint));
if (auto pstr = std::get_if<string> (&index))
self.AddUserPoint(CSGeometry::UserPoint(p, *pstr));
return self; return self;
}) })

View File

@ -6571,6 +6571,15 @@ namespace netgen
cd3names[cd3nr] = nullptr; 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"; string Mesh :: cd3_default_name = "default";
const string & Mesh :: GetCD3Name (int cd3nr) const const string & Mesh :: GetCD3Name (int cd3nr) const
{ {

View File

@ -673,6 +673,7 @@ namespace netgen
DLL_HEADER void SetNCD3Names (int ncd3n); DLL_HEADER void SetNCD3Names (int ncd3n);
DLL_HEADER void SetCD3Name (int cd3nr, const string & abcname); 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 const string & GetCD3Name (int cd3nr ) const;
DLL_HEADER static string cd3_default_name; DLL_HEADER static string cd3_default_name;