From fb13152004ce323353a6d5825b3fb664a22b2940 Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Mon, 13 Jul 2020 18:54:55 +0200 Subject: [PATCH] create occ geometry from TopoDS_Shape and export constructor this only works if OCC bindings are done using pybind11! --- libsrc/occ/occgeom.cpp | 8 ++++++++ libsrc/occ/occgeom.hpp | 2 ++ libsrc/occ/python_occ.cpp | 2 ++ 3 files changed, 12 insertions(+) diff --git a/libsrc/occ/occgeom.cpp b/libsrc/occ/occgeom.cpp index 91dfb2cf..a3e8ddd3 100644 --- a/libsrc/occ/occgeom.cpp +++ b/libsrc/occ/occgeom.cpp @@ -40,6 +40,14 @@ namespace netgen { + OCCGeometry::OCCGeometry(const TopoDS_Shape& _shape) + { + shape = _shape; + changed = true; + BuildFMap(); + CalcBoundingBox(); + } + string STEP_GetEntityName(const TopoDS_Shape & theShape, STEPCAFControl_Reader * aReader) { const Handle(XSControl_WorkSession)& theSession = aReader->Reader().WS(); diff --git a/libsrc/occ/occgeom.hpp b/libsrc/occ/occgeom.hpp index 447d212f..a491952f 100644 --- a/libsrc/occ/occgeom.hpp +++ b/libsrc/occ/occgeom.hpp @@ -261,6 +261,8 @@ namespace netgen vmap.Clear(); } + OCCGeometry(const TopoDS_Shape& _shape); + Mesh::GEOM_TYPE GetGeomType() const override { return Mesh::GEOM_OCC; } diff --git a/libsrc/occ/python_occ.cpp b/libsrc/occ/python_occ.cpp index a7508c31..a887c0f2 100644 --- a/libsrc/occ/python_occ.cpp +++ b/libsrc/occ/python_occ.cpp @@ -50,6 +50,8 @@ DLL_HEADER void ExportNgOCC(py::module &m) m.attr("occ_version") = OCC_VERSION_COMPLETE; py::class_, NetgenGeometry> (m, "OCCGeometry", R"raw_string(Use LoadOCCGeometry to load the geometry from a *.step file.)raw_string") .def(py::init<>()) + .def(py::init(), py::arg("shape"), + "Create Netgen OCCGeometry from existing TopoDS_Shape") .def(py::init([] (const string& filename) { shared_ptr geo;