project wire onto face

This commit is contained in:
Christopher Lackner 2021-11-29 15:54:24 +01:00
parent 564237032a
commit 86e7754c7a
2 changed files with 24 additions and 0 deletions

View File

@ -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;

View File

@ -15,6 +15,7 @@
#include <BRepAlgoAPI_Common.hxx>
#include <BRepAlgoAPI_Cut.hxx>
#include <BRepAlgoAPI_Fuse.hxx>
#include <BRepAlgo_NormalProjection.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
@ -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<WorkPlane> (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_<TopoDS_Solid, TopoDS_Shape> (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)