create occ geometry from TopoDS_Shape and export constructor

this only works if OCC bindings are done using pybind11!
This commit is contained in:
Christopher Lackner 2020-07-13 18:54:55 +02:00
parent 8926d93e07
commit fb13152004
3 changed files with 12 additions and 0 deletions

View File

@ -40,6 +40,14 @@
namespace netgen namespace netgen
{ {
OCCGeometry::OCCGeometry(const TopoDS_Shape& _shape)
{
shape = _shape;
changed = true;
BuildFMap();
CalcBoundingBox();
}
string STEP_GetEntityName(const TopoDS_Shape & theShape, STEPCAFControl_Reader * aReader) string STEP_GetEntityName(const TopoDS_Shape & theShape, STEPCAFControl_Reader * aReader)
{ {
const Handle(XSControl_WorkSession)& theSession = aReader->Reader().WS(); const Handle(XSControl_WorkSession)& theSession = aReader->Reader().WS();

View File

@ -261,6 +261,8 @@ namespace netgen
vmap.Clear(); vmap.Clear();
} }
OCCGeometry(const TopoDS_Shape& _shape);
Mesh::GEOM_TYPE GetGeomType() const override Mesh::GEOM_TYPE GetGeomType() const override
{ return Mesh::GEOM_OCC; } { return Mesh::GEOM_OCC; }

View File

@ -50,6 +50,8 @@ DLL_HEADER void ExportNgOCC(py::module &m)
m.attr("occ_version") = OCC_VERSION_COMPLETE; m.attr("occ_version") = OCC_VERSION_COMPLETE;
py::class_<OCCGeometry, shared_ptr<OCCGeometry>, NetgenGeometry> (m, "OCCGeometry", R"raw_string(Use LoadOCCGeometry to load the geometry from a *.step file.)raw_string") py::class_<OCCGeometry, shared_ptr<OCCGeometry>, NetgenGeometry> (m, "OCCGeometry", R"raw_string(Use LoadOCCGeometry to load the geometry from a *.step file.)raw_string")
.def(py::init<>()) .def(py::init<>())
.def(py::init<const TopoDS_Shape&>(), py::arg("shape"),
"Create Netgen OCCGeometry from existing TopoDS_Shape")
.def(py::init([] (const string& filename) .def(py::init([] (const string& filename)
{ {
shared_ptr<OCCGeometry> geo; shared_ptr<OCCGeometry> geo;