From 86e7754c7a996a2eef139210f68e90e6640149ab Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Mon, 29 Nov 2021 15:54:24 +0100 Subject: [PATCH] project wire onto face --- libsrc/occ/occ_utils.hpp | 12 ++++++++++++ libsrc/occ/python_occ_shapes.cpp | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/libsrc/occ/occ_utils.hpp b/libsrc/occ/occ_utils.hpp index ec7872e5..1e9fa9a1 100644 --- a/libsrc/occ/occ_utils.hpp +++ b/libsrc/occ/occ_utils.hpp @@ -144,6 +144,10 @@ namespace netgen { return SubShapes(TopAbs_FACE); } + ListOfShapes Wires() const + { + return SubShapes(TopAbs_WIRE); + } ListOfShapes Edges() const { return SubShapes(TopAbs_EDGE); @@ -180,6 +184,14 @@ namespace netgen return sub; } + inline ListOfShapes GetWires(const TopoDS_Shape & shape) + { + ListOfShapes sub; + for (TopExp_Explorer e(shape, TopAbs_WIRE); e.More(); e.Next()) + sub.push_back(e.Current()); + return sub; + } + inline ListOfShapes GetEdges(const TopoDS_Shape & shape) { ListOfShapes sub; diff --git a/libsrc/occ/python_occ_shapes.cpp b/libsrc/occ/python_occ_shapes.cpp index a05907de..3d3b21dd 100644 --- a/libsrc/occ/python_occ_shapes.cpp +++ b/libsrc/occ/python_occ_shapes.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -612,6 +613,8 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) "returns all sub-shapes of type 'FACE'") .def_property_readonly("edges", GetEdges, "returns all sub-shapes of type 'EDGE'") + .def_property_readonly("wires", GetWires, + "returns all sub-shapes of type 'WIRE'") .def_property_readonly("vertices", GetVertices, "returns all sub-shapes of type 'VERTEX'") @@ -1344,6 +1347,14 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) auto ax = gp_Ax3(p, du^dv, du); return make_shared (ax); }) + .def("ProjectWire", [](const TopoDS_Face& face, + const TopoDS_Wire& wire) + { + BRepAlgo_NormalProjection builder(face); + builder.Add(wire); + builder.Build(); + return builder.Projection(); + }) ; py::class_ (m, "Solid"); @@ -1447,6 +1458,7 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) }) .def_property_readonly("solids", &ListOfShapes::Solids) .def_property_readonly("faces", &ListOfShapes::Faces) + .def_property_readonly("wires", &ListOfShapes::Wires) .def_property_readonly("edges", &ListOfShapes::Edges) .def_property_readonly("vertices", &ListOfShapes::Vertices) .def(py::self * py::self)