From 18dc32c51ad83c5b397d4f3874ea79f36326b354 Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Tue, 26 Jan 2021 15:33:21 +0100 Subject: [PATCH] Add RestrictHLine function in Python --- libsrc/meshing/python_mesh.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/libsrc/meshing/python_mesh.cpp b/libsrc/meshing/python_mesh.cpp index c125c3de..cb7c6ea9 100644 --- a/libsrc/meshing/python_mesh.cpp +++ b/libsrc/meshing/python_mesh.cpp @@ -1197,13 +1197,25 @@ project_boundaries : Optional[str] = None return mp; }), py::arg("mp")=nullptr, meshingparameter_description.c_str()) .def("__str__", &ToString) - .def("RestrictH", FunctionPointer - ([](MP & mp, double x, double y, double z, double h) + .def("RestrictH", [](MP & mp, double x, double y, double z, double h) { - mp.meshsize_points.Append ( MeshingParameters::MeshSizePoint (Point<3> (x,y,z), h)); - }), - py::arg("x"), py::arg("y"), py::arg("z"), py::arg("h") + mp.meshsize_points.Append ( MeshingParameters::MeshSizePoint(Point<3> (x,y,z), h)); + }, py::arg("x"), py::arg("y"), py::arg("z"), py::arg("h") ) + .def("RestrictH", [](MP & mp, const Point<3>& p, double h) + { + mp.meshsize_points.Append ({p, h}); + }, py::arg("p"), py::arg("h")) + .def("RestrictHLine", [](MP& mp, const Point<3>& p1, const Point<3>& p2, + double maxh) + { + int steps = int(Dist(p1, p2) / maxh) + 2; + auto v = p2 - p1; + for (int i = 0; i <= steps; i++) + { + mp.meshsize_points.Append({p1 + double(i)/steps * v, maxh}); + } + }, py::arg("p1"), py::arg("p2"), py::arg("maxh")) ; m.def("SetTestoutFile", FunctionPointer ([] (const string & filename)