From e4a2795414cb4858817db23b217ba7e1687979ba Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Wed, 17 May 2023 12:49:16 +0200 Subject: [PATCH 1/2] extrude with optional (closesurface) identification --- libsrc/occ/python_occ_shapes.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/libsrc/occ/python_occ_shapes.cpp b/libsrc/occ/python_occ_shapes.cpp index a6d76c8f..1b139623 100644 --- a/libsrc/occ/python_occ_shapes.cpp +++ b/libsrc/occ/python_occ_shapes.cpp @@ -982,7 +982,9 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) return CastShape(shape.Reversed()); }) .def("Extrude", [](const TopoDS_Shape & shape, double h, - optional dir) { + optional dir, bool identify, + Identifications::ID_TYPE idtype) + { for (TopExp_Explorer e(shape, TopAbs_FACE); e.More(); e.Next()) { Handle(Geom_Surface) surf = BRep_Tool::Surface (TopoDS::Face(e.Current())); @@ -1005,11 +1007,21 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) for (auto mods : builder.Generated(e.Current())) OCCGeometry::GetProperties(mods).Merge(prop); } - + if(identify) + { + Transformation<3> trsf(h * occ2ng(edir)); + for (TopExp_Explorer e(shape, TopAbs_FACE); e.More(); e.Next()) { + auto mods = builder.Generated(e.Current()); + auto faces = GetFaces(mods.First()); + Identify(faces, faces, "extrusion_cs", idtype, + trsf); + } + } return builder.Shape(); } throw Exception("no face found for extrusion"); - }, py::arg("h"), py::arg("dir")=nullopt, "extrude shape to thickness 'h', shape must contain a plane surface, optionally give an extrusion direction") + }, py::arg("h"), py::arg("dir")=nullopt, py::arg("identify")=false, + py::arg("idtype")=Identifications::CLOSESURFACES, "extrude shape to thickness 'h', shape must contain a plane surface, optionally give an extrusion direction") .def("Extrude", [] (const TopoDS_Shape & face, gp_Vec vec) { return BRepPrimAPI_MakePrism (face, vec).Shape(); From 2233275c0bfaba8c8fe2345aadda6991aaeea3fc Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Wed, 17 May 2023 16:24:06 +0200 Subject: [PATCH 2/2] do not copy faces when extrude, better identify in extrude --- libsrc/occ/python_occ_shapes.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/libsrc/occ/python_occ_shapes.cpp b/libsrc/occ/python_occ_shapes.cpp index 1b139623..641a2213 100644 --- a/libsrc/occ/python_occ_shapes.cpp +++ b/libsrc/occ/python_occ_shapes.cpp @@ -998,7 +998,7 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) surf->D1 (0,0,p,du,dv); edir = du^dv; } - BRepPrimAPI_MakePrism builder(shape, h*edir, true); + BRepPrimAPI_MakePrism builder(shape, h*edir, false); for (auto typ : { TopAbs_SOLID, TopAbs_FACE, TopAbs_EDGE, TopAbs_VERTEX }) for (TopExp_Explorer e(shape, typ); e.More(); e.Next()) @@ -1010,12 +1010,8 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) if(identify) { Transformation<3> trsf(h * occ2ng(edir)); - for (TopExp_Explorer e(shape, TopAbs_FACE); e.More(); e.Next()) { - auto mods = builder.Generated(e.Current()); - auto faces = GetFaces(mods.First()); - Identify(faces, faces, "extrusion_cs", idtype, - trsf); - } + Identify(GetFaces(shape), GetFaces(builder.LastShape()), + "extrusion_cs", idtype, trsf); } return builder.Shape(); }