From 239cdf694f9750baee634c813b43b9125552d452 Mon Sep 17 00:00:00 2001 From: "mhochsteger@cerbsim.com" Date: Fri, 5 Nov 2021 20:26:43 +0100 Subject: [PATCH] Don't copy occ shape in OCCGeometry ctor by default --- libsrc/occ/occgeom.cpp | 25 +++++++++++++++++++------ libsrc/occ/occgeom.hpp | 2 +- libsrc/occ/python_occ.cpp | 4 ++-- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/libsrc/occ/occgeom.cpp b/libsrc/occ/occgeom.cpp index 229d9d78..7ae89306 100644 --- a/libsrc/occ/occgeom.cpp +++ b/libsrc/occ/occgeom.cpp @@ -52,17 +52,30 @@ namespace netgen { void LoadOCCInto(OCCGeometry* occgeo, const char* filename); + void PrintContents (OCCGeometry * geom); std::map OCCGeometry::global_shape_properties; std::map> OCCGeometry::identifications; - OCCGeometry::OCCGeometry(const TopoDS_Shape& _shape, int aoccdim) + OCCGeometry::OCCGeometry(const TopoDS_Shape& _shape, int aoccdim, bool copy) { - auto filename = GetTempFilename(); - step_utils::WriteSTEP(_shape, filename.c_str()); - LoadOCCInto(this, filename.c_str()); - occdim = aoccdim; - std::remove(filename.c_str()); + if(copy) + { + auto filename = GetTempFilename(); + step_utils::WriteSTEP(_shape, filename.c_str()); + LoadOCCInto(this, filename.c_str()); + occdim = aoccdim; + std::remove(filename.c_str()); + } + else + { + shape = _shape; + changed = 1; + occdim = aoccdim; + BuildFMap(); + CalcBoundingBox(); + PrintContents (this); + } } string STEP_GetEntityName(const TopoDS_Shape & theShape, STEPCAFControl_Reader * aReader) diff --git a/libsrc/occ/occgeom.hpp b/libsrc/occ/occgeom.hpp index aacbbbc5..e2fd950b 100644 --- a/libsrc/occ/occgeom.hpp +++ b/libsrc/occ/occgeom.hpp @@ -298,7 +298,7 @@ namespace netgen vmap.Clear(); } - OCCGeometry(const TopoDS_Shape& _shape, int aoccdim = 3); + OCCGeometry(const TopoDS_Shape& _shape, int aoccdim = 3, bool copy = false); 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 24aecc02..4c1e1330 100644 --- a/libsrc/occ/python_occ.cpp +++ b/libsrc/occ/python_occ.cpp @@ -126,7 +126,7 @@ DLL_HEADER void ExportNgOCC(py::module &m) .def(py::init(), py::arg("shape"), "Create Netgen OCCGeometry from existing TopoDS_Shape") */ - .def(py::init([] (const TopoDS_Shape& shape, int occdim) + .def(py::init([] (const TopoDS_Shape& shape, int occdim, bool copy) { auto geo = make_shared (shape, occdim); // ng_geometry = geo; @@ -134,7 +134,7 @@ DLL_HEADER void ExportNgOCC(py::module &m) // geo->BuildFMap(); // geo->CalcBoundingBox(); return geo; - }), py::arg("shape"), py::arg("dim")=3, + }), py::arg("shape"), py::arg("dim")=3, py::arg("copy")=false, "Create Netgen OCCGeometry from existing TopoDS_Shape") .def(py::init([] (const std::vector shapes)