From bfcd77ff9c75f2960814b27a63318002cd8d6d18 Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Wed, 27 Mar 2024 14:55:29 +0100 Subject: [PATCH] [occ] allow giving explicit edge partition --- libsrc/meshing/basegeom.cpp | 14 ++++++++++++++ libsrc/meshing/basegeom.hpp | 2 ++ libsrc/occ/python_occ_shapes.cpp | 15 ++++++++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/libsrc/meshing/basegeom.cpp b/libsrc/meshing/basegeom.cpp index c9902f71..cab14535 100644 --- a/libsrc/meshing/basegeom.cpp +++ b/libsrc/meshing/basegeom.cpp @@ -476,6 +476,20 @@ namespace netgen static Timer tdivide("Divide Edges"); RegionTimer rt(tdivide); // -------------------- DivideEdge ----------------- + if(properties.partition) + { + points.SetSize(properties.partition->Size()); + params.SetSize(properties.partition->Size()+2); + params[0] = 0.0; + params.Last() = 1.0; + for(auto i : Range(properties.partition->Size())) + { + params[i+1] = (*properties.partition)[i]; + points[i] = GetPoint(params[i+1]); + } + return; + } + tdivedgesections.Start(); auto layer = properties.layer; double safety = 0.5*(1.-mparam.grading); diff --git a/libsrc/meshing/basegeom.hpp b/libsrc/meshing/basegeom.hpp index 765eb884..f625baec 100644 --- a/libsrc/meshing/basegeom.hpp +++ b/libsrc/meshing/basegeom.hpp @@ -27,10 +27,12 @@ namespace netgen double hpref = 0; // number of hp refinement levels (will be multiplied by factor later) int layer = 1; optional quad_dominated; + optional> partition; void Merge(const ShapeProperties & prop2) { if (!name && prop2.name) name = prop2.name; if (!col && prop2.col) col = prop2.col; + if (!partition && prop2.partition) partition = prop2.partition; maxh = min2(maxh, prop2.maxh); hpref = max2(hpref, prop2.hpref); if(!quad_dominated.has_value()) quad_dominated = prop2.quad_dominated; diff --git a/libsrc/occ/python_occ_shapes.cpp b/libsrc/occ/python_occ_shapes.cpp index 2be43ca3..09381e4c 100644 --- a/libsrc/occ/python_occ_shapes.cpp +++ b/libsrc/occ/python_occ_shapes.cpp @@ -1398,7 +1398,20 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) return tuple(s0, s1); }, "parameter interval of curve") - + .def_property("partition", + [](TopoDS_Shape & self) -> optional> + { + if (OCCGeometry::HaveProperties(self)) + return OCCGeometry::GetProperties(self).partition; + return nullopt; + }, + [](TopoDS_Shape &self, py::array_t val) + { + Array partition(val.size()); + for(auto i : Range(partition)) + partition[i] = val.at(i); + OCCGeometry::GetProperties(self).partition = std::move(partition); + }) .def("Split", [](const TopoDS_Edge& self, py::args args) {