Skip to content

Commit 0364153

Browse files
Fix _entities (#1260)
* Fix _entities Fix iteration over entities and avoid hash collisions * Use TopTools_MapOfShape * Black fix * Use 7.7 stubs * Remove redundant pip call
1 parent 2997a3a commit 0364153

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

appveyor.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ init:
2828
install:
2929
- mamba env create -f environment.yml
3030
- conda activate cadquery
31-
- pip install git+https://github.com/CadQuery/[email protected]
3231

3332
build: false
3433

cadquery/occ_impl/shapes.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,11 @@
156156
BRepFilletAPI_MakeFillet2d,
157157
)
158158

159-
from OCP.TopTools import TopTools_IndexedDataMapOfShapeListOfShape, TopTools_ListOfShape
159+
from OCP.TopTools import (
160+
TopTools_IndexedDataMapOfShapeListOfShape,
161+
TopTools_ListOfShape,
162+
TopTools_MapOfShape,
163+
)
160164

161165
from OCP.TopExp import TopExp
162166

@@ -747,18 +751,21 @@ def ShapeType(self) -> Shapes:
747751

748752
def _entities(self, topo_type: Shapes) -> List[TopoDS_Shape]:
749753

750-
out = {} # using dict to prevent duplicates
754+
rv = []
755+
shape_set = TopTools_MapOfShape()
751756

752757
explorer = TopExp_Explorer(self.wrapped, inverse_shape_LUT[topo_type])
753758

754759
while explorer.More():
755760
item = explorer.Current()
756-
out[
757-
item.HashCode(HASH_CODE_MAX)
758-
] = item # needed to avoid pseudo-duplicate entities
761+
762+
# needed to avoid pseudo-duplicate entities
763+
if shape_set.Add(item):
764+
rv.append(item)
765+
759766
explorer.Next()
760767

761-
return list(out.values())
768+
return rv
762769

763770
def _entitiesFrom(
764771
self, child_type: Shapes, parent_type: Shapes

0 commit comments

Comments
 (0)