Skip to content

Commit 3fadd39

Browse files
committed
Merge branch 'occ_sew' into 'master'
export occ sew operation See merge request ngsolve/netgen!714
2 parents 89cf640 + 2c90b70 commit 3fadd39

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

libsrc/occ/python_occ_shapes.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2318,6 +2318,43 @@ tangents : Dict[int, gp_Vec2d]
23182318
Tangent vectors for the points indicated by the key value (0-based).
23192319
23202320
)delimiter");
2321+
2322+
m.def("Sew", [] (const std::vector<TopoDS_Shape> & faces, double tol,
2323+
bool non_manifold) -> TopoDS_Shape
2324+
{
2325+
if(faces.size() == 1)
2326+
return faces[0];
2327+
BRepBuilderAPI_Sewing sewer(tol);
2328+
sewer.SetNonManifoldMode(non_manifold);
2329+
for (auto & s : faces)
2330+
sewer.Add(s);
2331+
sewer.Perform();
2332+
for (auto & s : faces)
2333+
PropagateProperties (sewer, s);
2334+
auto sewn = sewer.SewedShape();
2335+
return sewn;
2336+
}, py::arg("faces"), py::arg("tolerance")=1e-6,
2337+
py::arg("non_manifold")=false,
2338+
R"doc(
2339+
Stitch a list of faces into one or more connected shells.
2340+
2341+
Parameters
2342+
----------
2343+
faces : list[TopoDS_Shape]
2344+
Faces or other shapes to sew together.
2345+
tolerance : float, default=1e-6
2346+
Geometric tolerance for merging edges and vertices.
2347+
non_manifold : bool, default=False
2348+
If True, allows edges shared by more than two faces (may produce
2349+
multiple shells). If False, creates only manifold shells suitable
2350+
for solids.
2351+
2352+
Returns
2353+
-------
2354+
TopoDS_Shape
2355+
The sewed shape containing one or more shells.
2356+
)doc");
2357+
23212358

23222359
m.def("Glue", [] (const std::vector<TopoDS_Shape> shapes) -> TopoDS_Shape
23232360
{

0 commit comments

Comments
 (0)