diff --git a/docs/topology_selection.rst b/docs/topology_selection.rst index 694c75f..776478a 100644 --- a/docs/topology_selection.rst +++ b/docs/topology_selection.rst @@ -235,7 +235,7 @@ Overview +----------------------+------------------------------------------------------------------+-------------------------------------------------------+ | |group_by| | ``Axis``, ``Edge``, ``Wire``, ``SortBy``, callable, property | Group ``ShapeList`` by criteria | +----------------------+------------------------------------------------------------------+-------------------------------------------------------+ -| |filter_by| | ``Axis``, ``Plane``, ``GeomType``, ``ShapePredicate``, property | Filter ``ShapeList`` by criteria | +| |filter_by| | ``Axis``, ``Plane``, ``GeomType``, callable, property | Filter ``ShapeList`` by criteria | +----------------------+------------------------------------------------------------------+-------------------------------------------------------+ | |filter_by_position| | ``Axis`` | Filter ``ShapeList`` by ``Axis`` & mix / max values | +----------------------+------------------------------------------------------------------+-------------------------------------------------------+ @@ -247,8 +247,8 @@ fall into the following categories, though not all operators take all criteria: - Topological objects: ``Edge``, ``Wire`` - Enums: :class:`~build_enums.SortBy`, :class:`~build_enums.GeomType` - Properties, eg: ``Face.area``, ``Edge.length`` -- ``ShapePredicate``, eg: ``lambda e: e.is_interior == 1``, ``lambda f: lf.edges() >= 3`` -- Callable eg: ``Vertex().distance`` +- Callable, eg: ``lambda e: e.is_interior == 1``, ``lambda f: f.edges() >= 3``, + ``Vertex().distance`` Sort ======= diff --git a/src/build123d/topology/__init__.py b/src/build123d/topology/__init__.py index 6471c29..1cbe647 100644 --- a/src/build123d/topology/__init__.py +++ b/src/build123d/topology/__init__.py @@ -32,7 +32,6 @@ license: from .shape_core import ( Shape, Comparable, - ShapePredicate, GroupBy, ShapeList, Joint, @@ -68,7 +67,6 @@ __all__ = [ "Shape", "Comparable", "DraftAngleError", - "ShapePredicate", "GroupBy", "ShapeList", "Joint", diff --git a/src/build123d/topology/shape_core.py b/src/build123d/topology/shape_core.py index aee2567..818b258 100644 --- a/src/build123d/topology/shape_core.py +++ b/src/build123d/topology/shape_core.py @@ -1607,7 +1607,7 @@ class Shape(NodeMixin, Generic[TOPODS]): path_position = path.position_at(relative_position_on_wire) path_tangent = path.tangent_at(relative_position_on_wire) projection_axis = Axis(path_position, shape_center - path_position) - (surface_point, surface_normal) = self.find_intersection_points( + surface_point, surface_normal = self.find_intersection_points( projection_axis )[0] surface_normal_plane = Plane( @@ -2430,14 +2430,6 @@ T = TypeVar("T", bound=Union[Shape, Vector]) K = TypeVar("K", bound=SupportsLessThan) -class ShapePredicate(Protocol): - """Predicate for shape filters""" - - # ---- Instance Methods ---- - - def __call__(self, shape: Shape) -> bool: ... - - class GroupBy(Generic[T, K]): """Result of a Shape.groupby operation. Groups can be accessed by index or key""" @@ -2656,11 +2648,11 @@ class ShapeList(list[T]): def filter_by( self, - filter_by: ShapePredicate | Axis | Plane | GeomType | property, + filter_by: Callable[[T], bool] | Axis | Plane | GeomType | property, reverse: bool = False, tolerance: float = 1e-5, ) -> ShapeList[T]: - """filter by Axis, Plane, or GeomType + """filter by Either: - filter objects of type planar Face or linear Edge by their normal or tangent @@ -2669,9 +2661,9 @@ class ShapeList(list[T]): objects. Args: - filter_by (Union[Axis,Plane,GeomType]): axis, plane, or geom type to filter - and possibly sort by. Filtering by a plane returns faces/edges parallel - to that plane. + filter_by (Callable[[T], bool] | Axis | Plane | GeomType): function, axis, + plane, or geom type to filter and possibly sort by. Filtering by a plane + returns faces/edges parallel to that plane. reverse (bool, optional): invert the geom type filter. Defaults to False. tolerance (float, optional): maximum deviation from axis. Defaults to 1e-5.