From 0b926bcbf43c80298441703cc78eaff01bf3d2af Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Wed, 18 Aug 2021 11:49:40 +0200 Subject: [PATCH] shape.Move, Rotate, Mirror --- libsrc/occ/python_occ_shapes.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/libsrc/occ/python_occ_shapes.cpp b/libsrc/occ/python_occ_shapes.cpp index 282573c0..54d126c6 100644 --- a/libsrc/occ/python_occ_shapes.cpp +++ b/libsrc/occ/python_occ_shapes.cpp @@ -627,6 +627,32 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) } return props.CentreOfMass(); }) + + .def("Move", [](const TopoDS_Shape & shape, const gp_Vec v) + { + // which one to choose ? + // version 1: Transoformation + gp_Trsf trafo; + trafo.SetTranslation(v); + return BRepBuilderAPI_Transform(shape, trafo).Shape(); + // version 2: change location + // ... + }, py::arg("v")) + + + .def("Rotate", [](const TopoDS_Shape & shape, const gp_Ax1 ax, double ang) + { + gp_Trsf trafo; + trafo.SetRotation(ax, ang*M_PI/180); + return BRepBuilderAPI_Transform(shape, trafo).Shape(); + }, py::arg("axis"), py::arg("ang")) + + .def("Mirror", [] (const TopoDS_Shape & shape, const gp_Ax3 & ax) + { + gp_Trsf trafo; + trafo.SetMirror(ax.Ax2()); + return BRepBuilderAPI_Transform(shape, trafo).Shape(); + }) .def("bc", [](const TopoDS_Shape & shape, const string & name) {