Skip to content

Commit 2c90b70

Browse files
committed
export occ sew operation
This operation is different from glue as it assumes the faces are forming a shell and do not have to be intersected. But edges can be different topologically. So I think a nice addition to have.
1 parent 47f6dfc commit 2c90b70

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

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

0 commit comments

Comments
 (0)