From 6b662a9634b671821b24b1768825759be501f6be Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Sat, 28 Sep 2024 15:15:44 +0200 Subject: [PATCH 1/3] export occ MakePolygon --- libsrc/occ/python_occ_shapes.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libsrc/occ/python_occ_shapes.cpp b/libsrc/occ/python_occ_shapes.cpp index 62c8f387..02a97d9a 100644 --- a/libsrc/occ/python_occ_shapes.cpp +++ b/libsrc/occ/python_occ_shapes.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -1671,8 +1672,14 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) py::implicitly_convertible(); py::implicitly_convertible(); - + m.def("MakePolygon", [](std::vector verts) + { + BRepBuilderAPI_MakePolygon builder; + for(auto& v : verts) + builder.Add(v); + return builder.Wire(); + }); class ListOfShapesIterator { From 10986ffbab4bc6cabc3157cbe7a5a7c301bc33d9 Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Sat, 28 Sep 2024 16:39:19 +0200 Subject: [PATCH 2/3] convert gp_Dir to gp_Vec --- libsrc/occ/python_occ_basic.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libsrc/occ/python_occ_basic.cpp b/libsrc/occ/python_occ_basic.cpp index 30601b5d..52fc5b80 100644 --- a/libsrc/occ/python_occ_basic.cpp +++ b/libsrc/occ/python_occ_basic.cpp @@ -73,6 +73,7 @@ DLL_HEADER void ExportNgOCCBasic(py::module &m) .def(py::init([] (double x, double y, double z) { return gp_Vec(x, y, z); }), py::arg("x"), py::arg("y"), py::arg("z")) + .def(py::init([](gp_Dir d) { return gp_Vec(d); })) .def_property("x", [](gp_Vec&p) { return p.X(); }, [](gp_Vec&p,double x) { p.SetX(x); }) .def_property("y", [](gp_Vec&p) { return p.Y(); }, [](gp_Vec&p,double y) { p.SetY(y); }) .def_property("z", [](gp_Vec&p) { return p.Z(); }, [](gp_Vec&p,double z) { p.SetZ(z); }) @@ -368,7 +369,8 @@ DLL_HEADER void ExportNgOCCBasic(py::module &m) py::implicitly_convertible(); py::implicitly_convertible(); py::implicitly_convertible(); - py::implicitly_convertible(); + py::implicitly_convertible(); + py::implicitly_convertible(); py::implicitly_convertible(); py::implicitly_convertible(); py::implicitly_convertible(); From c4dbe60f789cff707cdc91cd451a57a5809edb74 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Sat, 28 Sep 2024 20:29:12 +0200 Subject: [PATCH 3/3] create edge from two vertices --- libsrc/occ/python_occ_shapes.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libsrc/occ/python_occ_shapes.cpp b/libsrc/occ/python_occ_shapes.cpp index 02a97d9a..1c4a00ec 100644 --- a/libsrc/occ/python_occ_shapes.cpp +++ b/libsrc/occ/python_occ_shapes.cpp @@ -1407,6 +1407,9 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) BRepLib::BuildCurves3d(edge); return edge; })) + .def(py::init([] (const TopoDS_Vertex & v1, const TopoDS_Vertex & v2) { + return BRepBuilderAPI_MakeEdge(v1, v2).Edge(); + })) .def("Value", [](const TopoDS_Edge & e, double s) { double s0, s1; auto curve = BRep_Tool::Curve(e, s0, s1);