mirror of
https://github.com/gumyr/build123d.git
synced 2025-12-06 02:30:55 -08:00
Conform Shape.intersect to None | ShapeList
This commit is contained in:
parent
315605f485
commit
069b691964
1 changed files with 9 additions and 12 deletions
|
|
@ -1327,7 +1327,7 @@ class Shape(NodeMixin, Generic[TOPODS]):
|
||||||
|
|
||||||
def intersect(
|
def intersect(
|
||||||
self, *to_intersect: Shape | Vector | Location | Axis | Plane
|
self, *to_intersect: Shape | Vector | Location | Axis | Plane
|
||||||
) -> None | Self | ShapeList[Self]:
|
) -> None | ShapeList[Self]:
|
||||||
"""Intersection of the arguments and this shape
|
"""Intersection of the arguments and this shape
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
|
@ -1335,8 +1335,8 @@ class Shape(NodeMixin, Generic[TOPODS]):
|
||||||
intersect with
|
intersect with
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Self | ShapeList[Self]: Resulting object may be of a different class than self
|
None | ShapeList[Self]: Resulting ShapeList may contain different class
|
||||||
or a ShapeList if multiple non-Compound object created
|
than self
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _to_vertex(vec: Vector) -> Vertex:
|
def _to_vertex(vec: Vector) -> Vertex:
|
||||||
|
|
@ -1380,15 +1380,12 @@ class Shape(NodeMixin, Generic[TOPODS]):
|
||||||
|
|
||||||
# Find the shape intersections
|
# Find the shape intersections
|
||||||
intersect_op = BRepAlgoAPI_Common()
|
intersect_op = BRepAlgoAPI_Common()
|
||||||
shape_intersections = self._bool_op((self,), objs, intersect_op)
|
intersections = self._bool_op((self,), objs, intersect_op)
|
||||||
if isinstance(shape_intersections, ShapeList) and not shape_intersections:
|
if isinstance(intersections, ShapeList):
|
||||||
return None
|
return intersections or None
|
||||||
if (
|
if isinstance(intersections, Shape) and not intersections.is_null:
|
||||||
not isinstance(shape_intersections, ShapeList)
|
return ShapeList([intersections])
|
||||||
and shape_intersections.is_null
|
return None
|
||||||
):
|
|
||||||
return None
|
|
||||||
return shape_intersections
|
|
||||||
|
|
||||||
def is_equal(self, other: Shape) -> bool:
|
def is_equal(self, other: Shape) -> bool:
|
||||||
"""Returns True if two shapes are equal, i.e. if they share the same
|
"""Returns True if two shapes are equal, i.e. if they share the same
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue