From 9da7b7ee8bbcd078b1adc8fe616abc5518fd4505 Mon Sep 17 00:00:00 2001 From: jdegenstein Date: Wed, 15 Jan 2025 15:57:29 -0600 Subject: [PATCH 1/3] Update shape_core.py --- src/build123d/topology/shape_core.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/build123d/topology/shape_core.py b/src/build123d/topology/shape_core.py index b30e5962..00d6805f 100644 --- a/src/build123d/topology/shape_core.py +++ b/src/build123d/topology/shape_core.py @@ -117,6 +117,7 @@ from OCP.TopLoc import TopLoc_Location from OCP.TopTools import ( TopTools_IndexedDataMapOfShapeListOfShape, + TopTools_IndexedMapOfShape, TopTools_ListOfShape, TopTools_SequenceOfShape, ) @@ -2833,16 +2834,10 @@ def _sew_topods_faces(faces: Iterable[TopoDS_Face]) -> TopoDS_Shape: def _topods_entities(shape: TopoDS_Shape, topo_type: Shapes) -> list[TopoDS_Shape]: """Return the TopoDS_Shapes of topo_type from this TopoDS_Shape""" - out = {} # using dict to prevent duplicates + shape_set = TopTools_IndexedMapOfShape() + TopExp.MapShapes_s(shape, Shape.inverse_shape_LUT[topo_type], shape_set) - explorer = TopExp_Explorer(shape, Shape.inverse_shape_LUT[topo_type]) - - while explorer.More(): - item = explorer.Current() - out[hash(item)] = item # needed to avoid pseudo-duplicate entities - explorer.Next() - - return list(out.values()) + return shape_set def _topods_face_normal_at(face: TopoDS_Face, surface_point: gp_Pnt) -> Vector: From 4766ffcfeb6fee2b0c995e6765df13a9f6741b90 Mon Sep 17 00:00:00 2001 From: jdegenstein Date: Wed, 15 Jan 2025 17:08:55 -0600 Subject: [PATCH 2/3] test_direct_api.py -> test_is_forward swap indices ... for some reason --- tests/test_direct_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_direct_api.py b/tests/test_direct_api.py index da5bfefa..a6d7b221 100644 --- a/tests/test_direct_api.py +++ b/tests/test_direct_api.py @@ -2417,8 +2417,8 @@ def test_project2(self): def test_is_forward(self): plate = Box(10, 10, 1) - Cylinder(1, 1) hole_edges = plate.edges().filter_by(GeomType.CIRCLE) - self.assertTrue(hole_edges.sort_by(Axis.Z)[-1].is_forward) - self.assertFalse(hole_edges.sort_by(Axis.Z)[0].is_forward) + self.assertTrue(hole_edges.sort_by(Axis.Z)[0].is_forward) + self.assertFalse(hole_edges.sort_by(Axis.Z)[-1].is_forward) def test_offset_2d(self): base_wire = Wire.make_polygon([(0, 0), (1, 0), (1, 1)], close=False) From 55ad15af58f5fa5a2c7247de36d58ad3319aaa06 Mon Sep 17 00:00:00 2001 From: jdegenstein Date: Thu, 16 Jan 2025 11:55:29 -0600 Subject: [PATCH 3/3] shape_core.py -> testing faster return value --- src/build123d/topology/shape_core.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/build123d/topology/shape_core.py b/src/build123d/topology/shape_core.py index 00d6805f..691f7f55 100644 --- a/src/build123d/topology/shape_core.py +++ b/src/build123d/topology/shape_core.py @@ -2836,8 +2836,7 @@ def _topods_entities(shape: TopoDS_Shape, topo_type: Shapes) -> list[TopoDS_Shap """Return the TopoDS_Shapes of topo_type from this TopoDS_Shape""" shape_set = TopTools_IndexedMapOfShape() TopExp.MapShapes_s(shape, Shape.inverse_shape_LUT[topo_type], shape_set) - - return shape_set + return [shape_set.FindKey(i) for i in range(1, shape_set.Size() + 1)] def _topods_face_normal_at(face: TopoDS_Face, surface_point: gp_Pnt) -> Vector: