Split a TopoDS_Shape into Faces and Shells. Raise if another type was found.
(
s: TopoDS_Shape,
)
| 5372 | |
| 5373 | |
| 5374 | def _shape_to_faces_shells( |
| 5375 | s: TopoDS_Shape, |
| 5376 | ) -> tuple[list[TopoDS_Face], list[TopoDS_Shell]]: |
| 5377 | """ |
| 5378 | Split a TopoDS_Shape into Faces and Shells. Raise if another type was found. |
| 5379 | """ |
| 5380 | |
| 5381 | rv_faces = [] |
| 5382 | rv_shells = [] |
| 5383 | |
| 5384 | t = s.ShapeType() |
| 5385 | |
| 5386 | if t == TopAbs_ShapeEnum.TopAbs_COMPOUND: |
| 5387 | it = TopoDS_Iterator(s) |
| 5388 | |
| 5389 | while it.More(): |
| 5390 | el = it.Value() |
| 5391 | |
| 5392 | t = el.ShapeType() |
| 5393 | |
| 5394 | if t == TopAbs_ShapeEnum.TopAbs_FACE: |
| 5395 | rv_faces.append(TopoDS.Face(el)) |
| 5396 | elif t == TopAbs_ShapeEnum.TopAbs_SHELL: |
| 5397 | rv_shells.append(TopoDS.Shell(el)) |
| 5398 | else: |
| 5399 | raise ValueError(f"Found unexpected type {t}") |
| 5400 | |
| 5401 | it.Next() |
| 5402 | elif t == TopAbs_ShapeEnum.TopAbs_SHELL: |
| 5403 | rv_shells.append(TopoDS.Shell(s)) |
| 5404 | elif t == TopAbs_ShapeEnum.TopAbs_FACE: |
| 5405 | rv_faces.append(TopoDS.Face(s)) |
| 5406 | else: |
| 5407 | raise ValueError(f"Found unexpected type {t}") |
| 5408 | |
| 5409 | return rv_faces, rv_shells |
| 5410 | |
| 5411 | |
| 5412 | def _pts_to_harray(pts: Sequence[VectorLike]) -> TColgp_HArray1OfPnt: |