From 081c05ce81c00bcb5772c845eb12864ee07ce700 Mon Sep 17 00:00:00 2001 From: Julius Zimmermann Date: Sat, 18 Sep 2021 18:17:44 +0200 Subject: [PATCH] revolution also for edges and wires --- libsrc/occ/python_occ_shapes.cpp | 59 +++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 12 deletions(-) diff --git a/libsrc/occ/python_occ_shapes.cpp b/libsrc/occ/python_occ_shapes.cpp index f87e4ed5..3d58ad6a 100644 --- a/libsrc/occ/python_occ_shapes.cpp +++ b/libsrc/occ/python_occ_shapes.cpp @@ -1010,22 +1010,57 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) }, py::arg("v"), "extrude shape by vector 'v'") .def("Revolve", [](const TopoDS_Shape & shape, const gp_Ax1 &A, const double D) { - for (TopExp_Explorer e(shape, TopAbs_FACE); e.More(); e.Next()) - { - // return BRepPrimAPI_MakeRevol (shape, A, D*M_PI/180).Shape(); - BRepPrimAPI_MakeRevol builder(shape, A, D*M_PI/180); + switch (shape.ShapeType()) + { + case TopAbs_EDGE: + for (TopExp_Explorer e(shape, TopAbs_EDGE); e.More(); e.Next()) + { + // return BRepPrimAPI_MakeRevol (shape, A, D*M_PI/180).Shape(); + BRepPrimAPI_MakeRevol builder(shape, A, D*M_PI/180); + + for (auto typ : { TopAbs_VERTEX }) + for (TopExp_Explorer e(shape, typ); e.More(); e.Next()) + { + auto prop = OCCGeometry::global_shape_properties[e.Current().TShape()]; + for (auto mods : builder.Generated(e.Current())) + OCCGeometry::global_shape_properties[mods.TShape()].Merge(prop); + } + return builder.Shape(); + } + case TopAbs_WIRE: + for (TopExp_Explorer e(shape, TopAbs_WIRE); e.More(); e.Next()) + { + // return BRepPrimAPI_MakeRevol (shape, A, D*M_PI/180).Shape(); + BRepPrimAPI_MakeRevol builder(shape, A, D*M_PI/180); + + for (auto typ : { TopAbs_EDGE, TopAbs_VERTEX }) + for (TopExp_Explorer e(shape, typ); e.More(); e.Next()) + { + auto prop = OCCGeometry::global_shape_properties[e.Current().TShape()]; + for (auto mods : builder.Generated(e.Current())) + OCCGeometry::global_shape_properties[mods.TShape()].Merge(prop); + } + return builder.Shape(); + } + + case TopAbs_FACE: + for (TopExp_Explorer e(shape, TopAbs_FACE); e.More(); e.Next()) + { + // return BRepPrimAPI_MakeRevol (shape, A, D*M_PI/180).Shape(); + BRepPrimAPI_MakeRevol builder(shape, A, D*M_PI/180); - for (auto typ : { TopAbs_EDGE, TopAbs_VERTEX }) - for (TopExp_Explorer e(shape, typ); e.More(); e.Next()) - { + for (auto typ : { TopAbs_EDGE, TopAbs_VERTEX }) + for (TopExp_Explorer e(shape, typ); e.More(); e.Next()) + { auto prop = OCCGeometry::global_shape_properties[e.Current().TShape()]; for (auto mods : builder.Generated(e.Current())) OCCGeometry::global_shape_properties[mods.TShape()].Merge(prop); - } - - return builder.Shape(); - } - throw Exception("no face found for revolve"); + } + return builder.Shape(); + } + default: + throw Exception("no edge / wire / face found for revolve"); + } }, py::arg("axis"), py::arg("ang"), "revolve shape around 'axis' by 'ang' degrees") .def("Find", [](const TopoDS_Shape & shape, gp_Pnt p)