mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 21:10:33 +05:00
csg.AddPoint with names
This commit is contained in:
parent
3ece315bd0
commit
0209472ef6
@ -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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -6570,7 +6570,16 @@ namespace netgen
|
|||||||
else
|
else
|
||||||
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
|
||||||
{
|
{
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user