mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 04:50:34 +05:00
global_shape_properties, instead of individual maps
This commit is contained in:
parent
293b08d759
commit
66de9d4510
@ -410,10 +410,10 @@ namespace netgen
|
||||
}
|
||||
else
|
||||
{
|
||||
auto it = OCCGeometry::global_shape_cols.find(face.TShape());
|
||||
if (it != OCCGeometry::global_shape_cols.end())
|
||||
auto it = OCCGeometry::global_shape_properties.find(face.TShape());
|
||||
if (it != OCCGeometry::global_shape_properties.end() && it->second.col)
|
||||
{
|
||||
Vec<3> col = it->second;
|
||||
Vec<3> col = it->second.col.value_or(Vec<3>(0,1,0));
|
||||
mesh.GetFaceDescriptor(facenr).SetSurfColour(col);
|
||||
}
|
||||
else
|
||||
|
@ -42,8 +42,8 @@ namespace netgen
|
||||
{
|
||||
|
||||
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), Vec<3>> OCCGeometry::global_shape_cols;
|
||||
std::map<Handle(TopoDS_TShape), ShapeProperties> OCCGeometry::global_shape_properties;
|
||||
|
||||
OCCGeometry::OCCGeometry(const TopoDS_Shape& _shape)
|
||||
{
|
||||
|
@ -203,14 +203,29 @@ namespace netgen
|
||||
void Print (ostream & ost) const;
|
||||
};
|
||||
|
||||
|
||||
class ShapeProperties
|
||||
{
|
||||
public:
|
||||
optional<string> name;
|
||||
optional<Vec<3>> col;
|
||||
void Merge(const ShapeProperties & prop2)
|
||||
{
|
||||
if (prop2.name) name = prop2.name;
|
||||
if (prop2.col) col = prop2.col;
|
||||
}
|
||||
};
|
||||
|
||||
class DLL_HEADER OCCGeometry : public NetgenGeometry
|
||||
{
|
||||
Point<3> center;
|
||||
OCCParameters occparam;
|
||||
|
||||
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), Vec<3>> global_shape_cols;
|
||||
// static std::map<Handle(TopoDS_TShape), Vec<3>> global_shape_cols;
|
||||
|
||||
TopoDS_Shape shape;
|
||||
TopTools_IndexedMapOfShape fmap, emap, vmap, somap, shmap, wmap;
|
||||
|
@ -376,32 +376,39 @@ 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_names[e.Current().TShape()] = 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_names[e.Current().TShape()] = 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()];
|
||||
}, [](const TopoDS_Shape & self, string name) {
|
||||
OCCGeometry::global_shape_names[self.TShape()] = name;
|
||||
OCCGeometry::global_shape_names[self.TShape()] = name;
|
||||
OCCGeometry::global_shape_properties[self.TShape()].name = name;
|
||||
})
|
||||
|
||||
.def_property("col", [](const TopoDS_Shape & self) {
|
||||
auto it = OCCGeometry::global_shape_cols.find(self.TShape());
|
||||
auto it = OCCGeometry::global_shape_properties.find(self.TShape());
|
||||
Vec<3> col(0.2, 0.2, 0.2);
|
||||
if (it != OCCGeometry::global_shape_cols.end())
|
||||
col = it->second;
|
||||
if (it != OCCGeometry::global_shape_properties.end() && it->second.col)
|
||||
col = it->second.col.value();
|
||||
return std::vector<double> ( { col(0), col(1), col(2) } );
|
||||
}, [](const TopoDS_Shape & self, std::vector<double> c) {
|
||||
Vec<3> col(c[0], c[1], c[2]);
|
||||
OCCGeometry::global_shape_cols[self.TShape()] = col;
|
||||
OCCGeometry::global_shape_properties[self.TShape()].col = col;
|
||||
})
|
||||
|
||||
|
||||
@ -429,6 +436,10 @@ DLL_HEADER void ExportNgOCC(py::module &m)
|
||||
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);
|
||||
}
|
||||
#endif // OCC_HAVE_HISTORY
|
||||
|
||||
@ -448,11 +459,17 @@ DLL_HEADER void ExportNgOCC(py::module &m)
|
||||
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())
|
||||
for (auto s : history->Modified(e.Current()))
|
||||
OCCGeometry::global_shape_cols[s.TShape()] = it->second;
|
||||
*/
|
||||
auto propit = OCCGeometry::global_shape_properties.find(e.Current().TShape());
|
||||
if (propit != OCCGeometry::global_shape_properties.end())
|
||||
for (auto s : history->Modified(e.Current()))
|
||||
OCCGeometry::global_shape_properties[s.TShape()].Merge(propit->second);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user