replace global_shape_names by global_shape_properties

This commit is contained in:
Joachim Schoeberl 2021-07-29 16:40:11 +02:00
parent b22ae4f90d
commit 751f193d81
3 changed files with 48 additions and 30 deletions

View File

@ -41,7 +41,7 @@
namespace netgen
{
std::map<Handle(TopoDS_TShape), string> OCCGeometry::global_shape_names;
// std::map<Handle(TopoDS_TShape), string> OCCGeometry::global_shape_names;
// std::map<Handle(TopoDS_TShape), Vec<3>> OCCGeometry::global_shape_cols;
std::map<Handle(TopoDS_TShape), ShapeProperties> 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();

View File

@ -224,7 +224,7 @@ namespace netgen
public:
static std::map<Handle(TopoDS_TShape), ShapeProperties> global_shape_properties;
static std::map<Handle(TopoDS_TShape), string> global_shape_names;
// static std::map<Handle(TopoDS_TShape), string> global_shape_names;
// static std::map<Handle(TopoDS_TShape), Vec<3>> global_shape_cols;
TopoDS_Shape shape;

View File

@ -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<OCCGeometry> (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