Skip to content

Commit

Permalink
Improving performance and removing random failures Issue #508 #509
Browse files Browse the repository at this point in the history
  • Loading branch information
gumyr committed Jan 29, 2024
1 parent 89eda23 commit 15a2b89
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
12 changes: 2 additions & 10 deletions src/build123d/build_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,17 +1030,9 @@ def _move_to_existing(local_locations: list[Location]) -> list[Location]:
list[Location]: group of locations moved to existing locations as a group
"""
location_group = []
if LocationList._get_context():
local_vertex_compound = Compound.make_compound(
[Face.make_rect(1, 1).locate(l) for l in local_locations]
)
if LocationList._get_context() is not None:
for group_center in LocationList._get_context().local_locations:
location_group.extend(
[
v.location
for v in local_vertex_compound.moved(group_center).faces()
]
)
location_group.extend([group_center * l for l in local_locations])
else:
location_group = local_locations
return location_group
Expand Down
3 changes: 1 addition & 2 deletions src/build123d/build_sketch.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ def sketch(self):
)
global_objs = []
for plane in workplanes:
for face in self._obj.faces():
global_objs.append(plane.from_local_coords(face))
global_objs.append(plane.from_local_coords(self._obj))
return Sketch(Compound.make_compound(global_objs).wrapped)

def __init__(
Expand Down
13 changes: 8 additions & 5 deletions src/build123d/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -5644,11 +5644,14 @@ def chamfer_2d(

def is_coplanar(self, plane: Plane) -> bool:
"""Is this planar face coplanar with the provided plane"""
return all(
[
plane.contains(pnt)
for pnt in self.outer_wire().positions([i / 7 for i in range(8)])
]
u_val0, _u_val1, v_val0, _v_val1 = self._uv_bounds()
gp_pnt = gp_Pnt()
normal = gp_Vec()
BRepGProp_Face(self.wrapped).Normal(u_val0, v_val0, gp_pnt, normal)

return (
plane.contains(Vector(gp_pnt))
and (plane.z_dir - Vector(normal)).length < TOLERANCE
)

def thicken(self, depth: float, normal_override: VectorLike = None) -> Solid:
Expand Down

0 comments on commit 15a2b89

Please sign in to comment.