From 143f113d784bcec9fc6d1f1a498e39fccc2b7a4f Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Wed, 28 Jun 2023 15:59:04 +0200 Subject: [PATCH] separate_layers now also working for 2d occ geometries --- libsrc/occ/occgenmesh.cpp | 14 +++++++++++--- libsrc/occ/python_occ_shapes.cpp | 7 +++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/libsrc/occ/occgenmesh.cpp b/libsrc/occ/occgenmesh.cpp index 517e1ebb..6800e429 100644 --- a/libsrc/occ/occgenmesh.cpp +++ b/libsrc/occ/occgenmesh.cpp @@ -486,13 +486,21 @@ namespace netgen int maxlayer = 1; int dom = 0; - for (TopExp_Explorer e(geom.GetShape(), TopAbs_SOLID); e.More(); e.Next(), dom++) + for(const auto& s : GetSolids(geom.GetShape())) { - auto& props = OCCGeometry::GetProperties(e.Current()); + if(!OCCGeometry::HaveProperties(s)) + continue; + auto& props = OCCGeometry::GetProperties(s); maxhdom[dom] = min2(maxhdom[dom], props.maxh); maxlayer = max2(maxlayer, props.layer); + dom++; } - + for(const auto& f : GetFaces(geom.GetShape())) + if(OCCGeometry::HaveProperties(f)) + maxlayer = max2(maxlayer, OCCGeometry::GetProperties(f).layer); + for(const auto& e : GetEdges(geom.GetShape())) + if(OCCGeometry::HaveProperties(e)) + maxlayer = max2(maxlayer, OCCGeometry::GetProperties(e).layer); mesh.SetMaxHDomain (maxhdom); diff --git a/libsrc/occ/python_occ_shapes.cpp b/libsrc/occ/python_occ_shapes.cpp index 9bd1aa8d..477328fc 100644 --- a/libsrc/occ/python_occ_shapes.cpp +++ b/libsrc/occ/python_occ_shapes.cpp @@ -846,6 +846,13 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) col[3] = c[3]; OCCGeometry::GetProperties(self).col = col; }, "color of shape as RGB - tuple") + .def_property("layer", [](const TopoDS_Shape& self) { + if (!OCCGeometry::HaveProperties(self)) + return 1; + return OCCGeometry::GetProperties(self).layer; + }, [](const TopoDS_Shape& self, int layer) { + OCCGeometry::GetProperties(self).layer = layer; + }, "layer of shape") .def("UnifySameDomain", [](const TopoDS_Shape& shape, bool edges, bool faces, bool concatBSplines)