From ae80b27c9bad72e76baac9b9f7319c1f9b4c210a Mon Sep 17 00:00:00 2001 From: jdegenstein Date: Sat, 11 Jan 2025 13:37:09 -0600 Subject: [PATCH 1/2] pyproject.toml -> change cadquery-ocp dep to >= 7.8.1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6ef699d..b89afad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,7 @@ classifiers = [ ] dependencies = [ - "cadquery-ocp >= 7.7.0", + "cadquery-ocp >= 7.8.1", "typing_extensions >= 4.6.0, <5", "numpy >= 2, <3", "svgpathtools >= 1.5.1, <2", From b93538c3119c911c40a0a546c3c4e1a2637cdcd7 Mon Sep 17 00:00:00 2001 From: jdegenstein Date: Sat, 11 Jan 2025 13:42:57 -0600 Subject: [PATCH 2/2] shape_core.py -> move to OCP>7.8 hash method --- src/build123d/topology/shape_core.py | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/build123d/topology/shape_core.py b/src/build123d/topology/shape_core.py index 63703d7..6933c55 100644 --- a/src/build123d/topology/shape_core.py +++ b/src/build123d/topology/shape_core.py @@ -167,7 +167,6 @@ if TYPE_CHECKING: # pragma: no cover from .composite import Compound # pylint: disable=R0801 from build123d.build_part import BuildPart # pylint: disable=R0801 -HASH_CODE_MAX = 2147483647 Shapes = Literal["Vertex", "Edge", "Wire", "Face", "Shell", "Solid", "Compound"] TrimmingTool = Union[Plane, "Shell", "Face"] TOPODS = TypeVar("TOPODS", bound=TopoDS_Shape) @@ -805,8 +804,10 @@ class Shape(NodeMixin, Generic[TOPODS]): return NotImplemented def __hash__(self) -> int: - """Return has code""" - return self.hash_code() + """Return hash code""" + if self.wrapped is None: + return 0 + return hash(self.wrapped) def __rmul__(self, other): """right multiply for positioning operator *""" @@ -1181,19 +1182,6 @@ class Shape(NodeMixin, Generic[TOPODS]): self.__class__.cast(s) for s in get_top_level_topods_shapes(self.wrapped) ) - def hash_code(self) -> int: - """Returns a hashed value denoting this shape. It is computed from the - TShape and the Location. The Orientation is not used. - - Args: - - Returns: - - """ - if self.wrapped is None: - return 0 - return self.wrapped.HashCode(HASH_CODE_MAX) - def intersect( self, *to_intersect: Shape | Axis | Plane ) -> None | Self | ShapeList[Self]: @@ -2852,7 +2840,7 @@ def _topods_entities(shape: TopoDS_Shape, topo_type: Shapes) -> list[TopoDS_Shap while explorer.More(): item = explorer.Current() - out[item.HashCode(HASH_CODE_MAX)] = ( + out[hash(item)] = ( item # needed to avoid pseudo-duplicate entities ) explorer.Next()