Browse Source

Refactor: Move list_of_shapes_to_compound function into compound.py

- The function `list_of_shapes_to_compound` was removed in `pythonocc-core` 7.9.0.
- but occwl depends on it. So we have replaced it with a manual implementation using `BRep_Builder` in:
main
mckay 3 weeks ago
parent
commit
a518252419
  1. 15
      src/occwl/compound.py

15
src/occwl/compound.py

@ -1,5 +1,7 @@
from OCC.Core.TopoDS import TopoDS_Compound from OCC.Core.TopoDS import TopoDS_Compound
from OCC.Extend.DataExchange import read_step_file, list_of_shapes_to_compound from OCC.Extend.DataExchange import read_step_file
from OCC.Core.BRep import BRep_Builder
from OCC.Core.BRepTools import BRepTools_ShapeSet from OCC.Core.BRepTools import BRepTools_ShapeSet
from OCC.Core.STEPControl import STEPControl_Reader from OCC.Core.STEPControl import STEPControl_Reader
from OCC.Core.TopAbs import ( from OCC.Core.TopAbs import (
@ -19,6 +21,17 @@ from occwl.base import BottomUpFaceIterator, BottomUpEdgeIterator, BoundingBoxMi
ShellContainerMixin ShellContainerMixin
from occwl.shape import Shape from occwl.shape import Shape
def list_of_shapes_to_compound(shapes):
"""
Combine a list of TopoDS_Shapes into a single TopoDS_Compound.
Returns (compound, True) if successful.
"""
builder = BRep_Builder()
compound = TopoDS_Compound()
builder.MakeCompound(compound)
for s in shapes:
builder.Add(compound, s)
return compound, True
class Compound(Shape, BottomUpFaceIterator, BoundingBoxMixin, BottomUpEdgeIterator, class Compound(Shape, BottomUpFaceIterator, BoundingBoxMixin, BottomUpEdgeIterator,
EdgeContainerMixin, FaceContainerMixin, SolidContainerMixin, ShellContainerMixin, SurfacePropertiesMixin, EdgeContainerMixin, FaceContainerMixin, SolidContainerMixin, ShellContainerMixin, SurfacePropertiesMixin,

Loading…
Cancel
Save