From 72d8ef47830b4b8dc0ed79f7c727197d7833ca87 Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Tue, 4 Jul 2023 16:27:01 +0200 Subject: [PATCH] [occ] MakeFillet for 2d shapes --- libsrc/occ/python_occ_shapes.cpp | 33 ++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/libsrc/occ/python_occ_shapes.cpp b/libsrc/occ/python_occ_shapes.cpp index 477328fc..df2138c5 100644 --- a/libsrc/occ/python_occ_shapes.cpp +++ b/libsrc/occ/python_occ_shapes.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -1052,8 +1053,36 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) } // throw Exception("no face found for revolve"); }, py::arg("axis"), py::arg("ang"), "revolve shape around 'axis' by 'ang' degrees") - - .def("MakeFillet", [](const TopoDS_Shape & shape, std::vector edges, double r) { + .def("MakeFillet", [](const TopoDS_Shape& shape, const std::vector>& fillets) -> TopoDS_Shape + { + if (shape.ShapeType() == TopAbs_FACE) { + BRepFilletAPI_MakeFillet2d mkFillet2d(TopoDS::Face(shape)); + for (auto [v, r] : fillets) + mkFillet2d.AddFillet(TopoDS::Vertex(v), r); + mkFillet2d.Build(); + PropagateProperties (mkFillet2d, shape); + return mkFillet2d.Shape(); + } + BRepFilletAPI_MakeFillet mkFillet(shape); + for (auto [e, r] : fillets) + mkFillet.Add(r, TopoDS::Edge(e)); + mkFillet.Build(); + PropagateProperties (mkFillet, shape); + for (auto [e, r] : fillets) + for (auto gen : mkFillet.Generated(e)) + OCCGeometry::GetProperties(gen).name = "fillet"; + return mkFillet.Shape(); + }, py::arg("fillets"), "make fillets for shapes of radius 'r'") + .def("MakeFillet", [](const TopoDS_Shape & shape, std::vector edges, double r) -> TopoDS_Shape { + if(shape.ShapeType() == TopAbs_FACE) + { + BRepFilletAPI_MakeFillet2d mkFillet(TopoDS::Face(shape)); + for (auto e : edges) + mkFillet.AddFillet (TopoDS::Vertex(e), r); + mkFillet.Build(); + PropagateProperties (mkFillet, shape); + return mkFillet.Shape(); + } BRepFilletAPI_MakeFillet mkFillet(shape); for (auto e : edges) mkFillet.Add (r, TopoDS::Edge(e));