Skip to content

Commit 89cf640

Browse files
committed
Merge branch 'occ_shells' into 'master'
query shells from topods shape, and allow setting name for spline See merge request ngsolve/netgen!713
2 parents 47f6dfc + d2c19ee commit 89cf640

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

libsrc/occ/occ_utils.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ namespace netgen
152152
{
153153
return SubShapes(TopAbs_SOLID);
154154
}
155+
ListOfShapes Shells() const
156+
{
157+
return SubShapes(TopAbs_SHELL);
158+
}
155159
ListOfShapes Faces() const
156160
{
157161
return SubShapes(TopAbs_FACE);
@@ -199,6 +203,14 @@ namespace netgen
199203
return sub;
200204
}
201205

206+
inline ListOfShapes GetShells(const TopoDS_Shape & shape)
207+
{
208+
ListOfShapes sub;
209+
for (TopExp_Explorer e(shape, TopAbs_SHELL); e.More(); e.Next())
210+
sub.push_back(e.Current());
211+
return sub;
212+
}
213+
202214
inline ListOfShapes GetFaces(const TopoDS_Shape & shape)
203215
{
204216
ListOfShapes sub;

libsrc/occ/python_occ_shapes.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ class WorkPlane : public enable_shared_from_this<WorkPlane>
351351
}
352352

353353
auto Spline(const std::vector<gp_Pnt2d> &points, bool periodic, double tol, const std::map<int, gp_Vec2d> &tangents,
354-
bool start_from_localpos)
354+
bool start_from_localpos, std::optional<string> name)
355355
{
356356
gp_Pnt2d P1 = start_from_localpos ? localpos.Location() : points.front();
357357
gp_Pnt P13d = surf->Value(P1.X(), P1.Y());
@@ -413,6 +413,8 @@ class WorkPlane : public enable_shared_from_this<WorkPlane>
413413
lastvertex = endv;
414414
BRepLib::BuildCurves3d(edge);
415415
wire_builder.Add(edge);
416+
if(name.has_value())
417+
OCCGeometry::GetProperties(edge).name = name;
416418

417419
// update localpos
418420
localpos.SetLocation(PLast);
@@ -783,6 +785,8 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
783785

784786
.def_property_readonly("solids", GetSolids,
785787
"returns all sub-shapes of type 'SOLID'")
788+
.def_property_readonly("shells", GetShells,
789+
"returns all sub-shapes of type 'SHELL'")
786790
.def_property_readonly("faces", GetFaces,
787791
"returns all sub-shapes of type 'FACE'")
788792
.def_property_readonly("edges", GetEdges,
@@ -1879,6 +1883,7 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
18791883
return selected;
18801884
})
18811885
.def_property_readonly("solids", &ListOfShapes::Solids)
1886+
.def_property_readonly("shells", &ListOfShapes::Shells)
18821887
.def_property_readonly("faces", &ListOfShapes::Faces)
18831888
.def_property_readonly("wires", &ListOfShapes::Wires)
18841889
.def_property_readonly("edges", &ListOfShapes::Edges)
@@ -2792,7 +2797,7 @@ degen_tol : double
27922797
.def("Line", [](WorkPlane&wp,double h,double v, optional<string> name) { return wp.Line(h,v,name); },
27932798
py::arg("dx"), py::arg("dy"), py::arg("name")=nullopt)
27942799
.def("Spline", &WorkPlane::Spline, py::arg("points"), py::arg("periodic")=false, py::arg("tol")=1e-8,
2795-
py::arg("tangents")=std::map<int, gp_Vec2d>{}, py::arg("start_from_localpos")=true,
2800+
py::arg("tangents")=std::map<int, gp_Vec2d>{}, py::arg("start_from_localpos")=true, py::arg("name")=nullopt,
27962801
"draw spline (default: starting from current position, which is implicitly added to given list of points), tangents can be specified for each point (0 refers to starting point)")
27972802
.def("Rectangle", &WorkPlane::Rectangle, py::arg("l"), py::arg("w"), py::arg("name")=nullopt, "draw rectangle, with current position as corner, use current direction")
27982803
.def("RectangleC", &WorkPlane::RectangleCentered, py::arg("l"), py::arg("w"), py::arg("name")=nullopt, "draw rectangle, with current position as center, use current direction")

0 commit comments

Comments
 (0)