From 751f193d819f7682dcf1f508e8a2b01f894fb5a2 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Thu, 29 Jul 2021 16:40:11 +0200 Subject: [PATCH] replace global_shape_names by global_shape_properties --- libsrc/occ/occgeom.cpp | 30 ++++++++++++++++++++----- libsrc/occ/occgeom.hpp | 2 +- libsrc/occ/python_occ.cpp | 46 +++++++++++++++++++-------------------- 3 files changed, 48 insertions(+), 30 deletions(-) diff --git a/libsrc/occ/occgeom.cpp b/libsrc/occ/occgeom.cpp index 9426405d..a874dcbe 100644 --- a/libsrc/occ/occgeom.cpp +++ b/libsrc/occ/occgeom.cpp @@ -41,7 +41,7 @@ namespace netgen { - std::map OCCGeometry::global_shape_names; + // std::map OCCGeometry::global_shape_names; // std::map> OCCGeometry::global_shape_cols; std::map OCCGeometry::global_shape_properties; @@ -56,27 +56,45 @@ namespace netgen for (e.Init(shape, TopAbs_SOLID); e.More(); e.Next()) { TopoDS_Solid solid = TopoDS::Solid(e.Current()); + /* string name = global_shape_names[solid.TShape()]; if (name == "") name = string("domain_") + ToString(snames.Size()); - snames.Append(name); + snames.Append(name); + */ + if (auto name = global_shape_properties[solid.TShape()].name) + snames.Append(*name); + else + snames.Append(string("domain_") + ToString(snames.Size())); } for (e.Init(shape, TopAbs_FACE); e.More(); e.Next()) { TopoDS_Face face = TopoDS::Face(e.Current()); + /* string name = global_shape_names[face.TShape()]; if (name == "") name = string("bc_") + ToString(fnames.Size()); fnames.Append(name); + */ + if (auto name = global_shape_properties[face.TShape()].name) + fnames.Append(*name); + else + fnames.Append(string("bc_") + ToString(fnames.Size())); for (exp1.Init(face, TopAbs_EDGE); exp1.More(); exp1.Next()) { TopoDS_Edge edge = TopoDS::Edge(exp1.Current()); // name = STEP_GetEntityName(edge,&reader); // cout << "getname = " << name << ", mapname = " << shape_names[edge.TShape()] << endl; + /* name = global_shape_names[edge.TShape()]; enames.Append(name); + */ + if (auto name = global_shape_properties[edge.TShape()].name) + enames.Append(*name); + else + enames.Append("noname-edge"); } } } @@ -296,9 +314,9 @@ namespace netgen for (TopExp_Explorer e(shape, TopAbs_SOLID); e.More(); e.Next()) { - auto name = OCCGeometry::global_shape_names[e.Current().TShape()]; - for (auto mods : history->Modified(e.Current())) - OCCGeometry::global_shape_names[mods.TShape()] = name; + if (auto name = OCCGeometry::global_shape_properties[e.Current().TShape()].name) + for (auto mods : history->Modified(e.Current())) + OCCGeometry::global_shape_properties[mods.TShape()].name = *name; } #endif // OCC_HAVE_HISTORY @@ -1569,7 +1587,7 @@ namespace netgen } for (auto [s,n] : shape_names) - OCCGeometry::global_shape_names[s] = n; + OCCGeometry::global_shape_properties[s].name = n; timer_getnames.Start(); diff --git a/libsrc/occ/occgeom.hpp b/libsrc/occ/occgeom.hpp index d073b7cc..3dd991ef 100644 --- a/libsrc/occ/occgeom.hpp +++ b/libsrc/occ/occgeom.hpp @@ -224,7 +224,7 @@ namespace netgen public: static std::map global_shape_properties; - static std::map global_shape_names; + // static std::map global_shape_names; // static std::map> global_shape_cols; TopoDS_Shape shape; diff --git a/libsrc/occ/python_occ.cpp b/libsrc/occ/python_occ.cpp index de1f396f..17d9beb7 100644 --- a/libsrc/occ/python_occ.cpp +++ b/libsrc/occ/python_occ.cpp @@ -107,12 +107,12 @@ DLL_HEADER void ExportNgOCC(py::module &m) for (auto & s : shapes) for (TopExp_Explorer e(s, TopAbs_SOLID); e.More(); e.Next()) - { - auto name = OCCGeometry::global_shape_names[e.Current().TShape()]; - TopTools_ListOfShape modlist = history->Modified(e.Current()); - for (auto mods : modlist) - OCCGeometry::global_shape_names[mods.TShape()] = name; - } + if (auto name = OCCGeometry::global_shape_properties[e.Current().TShape()].name) + { + TopTools_ListOfShape modlist = history->Modified(e.Current()); + for (auto mods : modlist) + OCCGeometry::global_shape_properties[mods.TShape()].name = *name; + } #endif // OCC_HAVE_HISTORY auto geo = make_shared (builder.Shape()); @@ -376,27 +376,23 @@ DLL_HEADER void ExportNgOCC(py::module &m) .def("bc", [](const TopoDS_Shape & shape, const string & name) { for (TopExp_Explorer e(shape, TopAbs_FACE); e.More(); e.Next()) - { - OCCGeometry::global_shape_names[e.Current().TShape()] = name; - OCCGeometry::global_shape_properties[e.Current().TShape()].name = name; - } + OCCGeometry::global_shape_properties[e.Current().TShape()].name = name; return shape; }) .def("mat", [](const TopoDS_Shape & shape, const string & name) { for (TopExp_Explorer e(shape, TopAbs_SOLID); e.More(); e.Next()) - { - OCCGeometry::global_shape_names[e.Current().TShape()] = name; - OCCGeometry::global_shape_properties[e.Current().TShape()].name = name; - } + OCCGeometry::global_shape_properties[e.Current().TShape()].name = name; return shape; }) .def_property("name", [](const TopoDS_Shape & self) { - return OCCGeometry::global_shape_names[self.TShape()]; + if (auto name = OCCGeometry::global_shape_properties[self.TShape()].name) + return *name; + else + return string(); }, [](const TopoDS_Shape & self, string name) { - OCCGeometry::global_shape_names[self.TShape()] = name; OCCGeometry::global_shape_properties[self.TShape()].name = name; }) @@ -433,10 +429,6 @@ DLL_HEADER void ExportNgOCC(py::module &m) for (auto & s : { shape1, shape2 }) for (TopExp_Explorer e(s, TopAbs_FACE); e.More(); e.Next()) { - const string & name = OCCGeometry::global_shape_names[e.Current().TShape()]; - for (auto smod : history->Modified(e.Current())) - OCCGeometry::global_shape_names[smod.TShape()] = name; - auto & prop = OCCGeometry::global_shape_properties[e.Current().TShape()]; for (auto smod : history->Modified(e.Current())) OCCGeometry::global_shape_properties[smod.TShape()].Merge(prop); @@ -456,10 +448,11 @@ DLL_HEADER void ExportNgOCC(py::module &m) for (auto s : { shape1, shape2 }) for (TopExp_Explorer e(s, TopAbs_FACE); e.More(); e.Next()) { + /* const string & name = OCCGeometry::global_shape_names[e.Current().TShape()]; for (auto s : history->Modified(e.Current())) OCCGeometry::global_shape_names[s.TShape()] = name; - + */ /* auto it = OCCGeometry::global_shape_cols.find(e.Current().TShape()); if (it != OCCGeometry::global_shape_cols.end()) @@ -532,11 +525,18 @@ DLL_HEADER void ExportNgOCC(py::module &m) for (auto & s : shapes) for (TopExp_Explorer e(s, TopAbs_SOLID); e.More(); e.Next()) + { + auto prop = OCCGeometry::global_shape_properties[e.Current().TShape()]; + for (auto mods : history->Modified(e.Current())) + OCCGeometry::global_shape_properties[mods.TShape()].Merge(prop); + } + /* { auto name = OCCGeometry::global_shape_names[e.Current().TShape()]; for (auto mods : history->Modified(e.Current())) OCCGeometry::global_shape_names[mods.TShape()] = name; } + */ #endif // OCC_HAVE_HISTORY return builder.Shape(); @@ -561,9 +561,9 @@ DLL_HEADER void ExportNgOCC(py::module &m) for (TopExp_Explorer e(shape, TopAbs_SOLID); e.More(); e.Next()) { - auto name = OCCGeometry::global_shape_names[e.Current().TShape()]; + auto prop = OCCGeometry::global_shape_properties[e.Current().TShape()]; for (auto mods : history->Modified(e.Current())) - OCCGeometry::global_shape_names[mods.TShape()] = name; + OCCGeometry::global_shape_properties[mods.TShape()].Merge(prop); } #endif // OCC_HAVE_HISTORY