|
167 | 167 | from .composite import Compound # pylint: disable=R0801 |
168 | 168 | from build123d.build_part import BuildPart # pylint: disable=R0801 |
169 | 169 |
|
170 | | -HASH_CODE_MAX = 2147483647 |
171 | 170 | Shapes = Literal["Vertex", "Edge", "Wire", "Face", "Shell", "Solid", "Compound"] |
172 | 171 | TrimmingTool = Union[Plane, "Shell", "Face"] |
173 | 172 | TOPODS = TypeVar("TOPODS", bound=TopoDS_Shape) |
@@ -805,8 +804,10 @@ def __eq__(self, other) -> bool: |
805 | 804 | return NotImplemented |
806 | 805 |
|
807 | 806 | def __hash__(self) -> int: |
808 | | - """Return has code""" |
809 | | - return self.hash_code() |
| 807 | + """Return hash code""" |
| 808 | + if self.wrapped is None: |
| 809 | + return 0 |
| 810 | + return hash(self.wrapped) |
810 | 811 |
|
811 | 812 | def __rmul__(self, other): |
812 | 813 | """right multiply for positioning operator *""" |
@@ -1181,19 +1182,6 @@ def get_top_level_shapes(self) -> ShapeList[Shape]: |
1181 | 1182 | self.__class__.cast(s) for s in get_top_level_topods_shapes(self.wrapped) |
1182 | 1183 | ) |
1183 | 1184 |
|
1184 | | - def hash_code(self) -> int: |
1185 | | - """Returns a hashed value denoting this shape. It is computed from the |
1186 | | - TShape and the Location. The Orientation is not used. |
1187 | | -
|
1188 | | - Args: |
1189 | | -
|
1190 | | - Returns: |
1191 | | -
|
1192 | | - """ |
1193 | | - if self.wrapped is None: |
1194 | | - return 0 |
1195 | | - return self.wrapped.HashCode(HASH_CODE_MAX) |
1196 | | - |
1197 | 1185 | def intersect( |
1198 | 1186 | self, *to_intersect: Shape | Axis | Plane |
1199 | 1187 | ) -> None | Self | ShapeList[Self]: |
@@ -2852,7 +2840,7 @@ def _topods_entities(shape: TopoDS_Shape, topo_type: Shapes) -> list[TopoDS_Shap |
2852 | 2840 |
|
2853 | 2841 | while explorer.More(): |
2854 | 2842 | item = explorer.Current() |
2855 | | - out[item.HashCode(HASH_CODE_MAX)] = ( |
| 2843 | + out[hash(item)] = ( |
2856 | 2844 | item # needed to avoid pseudo-duplicate entities |
2857 | 2845 | ) |
2858 | 2846 | explorer.Next() |
|
0 commit comments