From f808a2bb64a853ac9db58b1202f37a00dd19e40c Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Fri, 26 Apr 2024 09:55:53 +0200 Subject: [PATCH] Propagate maxh to children only in occgeom constructor Allows resetting maxh to larger values again: ``` from netgen.occ import * from ngsolve import * b1 = Box((-1,-1,-1), (1,1,1)) b1.faces.Max(X).maxh = 0.1 b1.faces.Max(X).maxh = 0.2 geo = OCCGeometry(b1) mesh = Mesh(geo.GenerateMesh(maxh=0.5)) Draw(mesh) ``` Needed for example in meshing app. Before it was not possible to set maxh to larger value again. --- libsrc/occ/occ_solid.hpp | 1 + libsrc/occ/occgeom.cpp | 18 ++++++++++++++++++ libsrc/occ/python_occ_shapes.cpp | 7 +------ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/libsrc/occ/occ_solid.hpp b/libsrc/occ/occ_solid.hpp index 1ce2d50c..505a1617 100644 --- a/libsrc/occ/occ_solid.hpp +++ b/libsrc/occ/occ_solid.hpp @@ -16,6 +16,7 @@ namespace netgen OCCSolid(TopoDS_Shape dshape) : solid(TopoDS::Solid(dshape)) { } + TopoDS_Solid& GetShape() { return solid; } }; } diff --git a/libsrc/occ/occgeom.cpp b/libsrc/occ/occgeom.cpp index 9d71fa77..821cbf8b 100644 --- a/libsrc/occ/occgeom.cpp +++ b/libsrc/occ/occgeom.cpp @@ -1261,6 +1261,24 @@ namespace netgen } } + // Propagate maxh to children + for(auto& solid : solids) + { + auto& shape = static_cast(*solid).GetShape(); + if(!OCCGeometry::HaveProperties(shape)) + continue; + for(auto& f : GetFaces(shape)) + { + auto& face = GetFace(f); + face.properties.maxh = min2(face.properties.maxh, + GetProperties(shape).maxh); + } + } + for(auto& face : faces) + for(auto& edge : face->edges) + edge->properties.maxh = min2(edge->properties.maxh, + face->properties.maxh); + // Add identifications auto add_identifications = [&](auto & shapes, auto & shape_map) { diff --git a/libsrc/occ/python_occ_shapes.cpp b/libsrc/occ/python_occ_shapes.cpp index fbeb8e5a..f2992d73 100644 --- a/libsrc/occ/python_occ_shapes.cpp +++ b/libsrc/occ/python_occ_shapes.cpp @@ -836,12 +836,7 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) }, [](TopoDS_Shape& self, double val) { - for (auto typ : { TopAbs_SOLID, TopAbs_FACE, TopAbs_EDGE, TopAbs_VERTEX }) - for (TopExp_Explorer e(self, typ); e.More(); e.Next()) - { - auto & maxh = OCCGeometry::GetProperties(e.Current()).maxh; - maxh = min2(val, maxh); - } + OCCGeometry::GetProperties(self).maxh = val; }, "maximal mesh-size for shape") .def_property("hpref",