From 24782ccc0477b429a282041fb814b9e1609136d3 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Wed, 9 Sep 2020 17:07:36 +0200 Subject: [PATCH] CSG2d Rectangle() - individual bc names --- libsrc/geom2d/python_geom2d.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/libsrc/geom2d/python_geom2d.cpp b/libsrc/geom2d/python_geom2d.cpp index aa3b77c4..b5a07a1f 100644 --- a/libsrc/geom2d/python_geom2d.cpp +++ b/libsrc/geom2d/python_geom2d.cpp @@ -9,6 +9,7 @@ #include using namespace netgen; +using namespace pybind11::literals; namespace netgen { @@ -426,9 +427,18 @@ DLL_HEADER void ExportGeom2d(py::module &m) ; - m.def("Rectangle", [](Point<2> pmin, Point<2> pmax, string mat, string bc) - { return Rectangle(pmin, pmax, mat, bc); }, - py::arg("pmin"), py::arg("pmax"), py::arg("mat")=MAT_DEFAULT, py::arg("bc")=BC_DEFAULT + m.def("Rectangle", [](Point<2> p0, Point<2> p1, string mat, string bc, optional bottom, optional right, optional top, optional left) -> Solid2d + { + using P = Point<2>; + return { { + p0, bottom ? *bottom : bc, + P{p1[0],p0[1]}, right ? *right : bc, + p1, top ? *top : bc, + P{p0[0],p1[1]}, left ? *left : bc, + }, mat}; + }, + "pmin"_a, "pmax"_a, "mat"_a=MAT_DEFAULT, "bc"_a=BC_DEFAULT, + "bottom"_a=nullopt, "right"_a=nullopt, "top"_a=nullopt, "left"_a=nullopt ); m.def("Circle", Circle, py::arg("center"), py::arg("radius"), py::arg("mat")=MAT_DEFAULT, py::arg("bc")=BC_DEFAULT);