named edges in CSG geometry

This commit is contained in:
Joachim Schöberl 2020-01-13 16:41:06 +01:00
parent 30b10c1aaa
commit d53f28c89b
3 changed files with 38 additions and 1 deletions

View File

@ -367,6 +367,11 @@ namespace netgen
NgArray<BCModification> bcmodifications;
map<tuple<Surface*,Surface*>, string> named_edges;
virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam) override;
void AddSplineSurface (shared_ptr<SplineSurface> ss) { spline_surfaces.Append(ss); }

View File

@ -485,6 +485,29 @@ namespace netgen
layer,
mesh);
}
{
// named edge ?
// cout << "check edge name, size = " << geometry.named_edges.size() << endl;
// for (auto pair : geometry.named_edges)
// cout << "key = " << get<0> (pair.first) << "-" << get<1> (pair.first) << ", val = " << pair.second << endl;
Surface * sp1 = const_cast<Surface*> (geometry.GetSurface(s1));
Surface * sp2 = const_cast<Surface*> (geometry.GetSurface(s2));
// cout << "sp1 = " << sp1 << ", sp2 = " << sp2 << endl;
auto ptr = geometry.named_edges.find(tuple(sp1, sp2));
if (ptr != geometry.named_edges.end())
for (int i = 0; i < refedges.Size(); i++)
mesh.SetCD2Name(refedges[i].edgenr, ptr->second);
ptr = geometry.named_edges.find(tuple(sp2, sp1));
if (ptr != geometry.named_edges.end())
for (int i = 0; i < refedges.Size(); i++)
mesh.SetCD2Name(refedges[i].edgenr, ptr->second);
}
for(int i=0; i<refedges.Size(); i++)
{
auto splinesurface = dynamic_cast<const SplineSurface*>(geometry.GetSurface(refedges[i].surfnr1));

View File

@ -569,7 +569,16 @@ However, when r = 0, the top part becomes a point(tip) and meshing fails!
py::arg("solid1"), py::arg("solid2"),
py::arg("trafo")=Transformation<3>(Vec<3>(0,0,0))
)
.def("NameEdge", [] (CSGeometry & self, shared_ptr<SPSolid> s1, shared_ptr<SPSolid> s2, string name)
{
Array<Surface*> surfs1, surfs2;
s1->GetSolid()->ForEachSurface( [&surfs1] (Surface * s, bool inv) { surfs1.Append(s); });
s2->GetSolid()->ForEachSurface( [&surfs2] (Surface * s, bool inv) { surfs2.Append(s); });
for (auto s1 : surfs1)
for (auto s2 : surfs2)
self.named_edges[tuple(s1,s2)] = name;
})
.def("AddPoint", [] (CSGeometry & self, Point<3> p, int index) -> CSGeometry&
{
self.AddUserPoint(CSGeometry::UserPoint(p, index));