Skip to content

Commit

Permalink
Merge pull request #695 from danieledapo/dev
Browse files Browse the repository at this point in the history
Fix thicken normal calculation when no override is provided
  • Loading branch information
gumyr authored Sep 19, 2024
2 parents 99b378f + 82f3dd8 commit debdf84
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/build123d/operations_part.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,12 +592,12 @@ def thicken(
logger.info("%d face(s) to thicken", len(to_thicken_faces))

for face in to_thicken_faces:
normal_override = (
face_normal = (
normal_override if normal_override is not None else face.normal_at()
)
for direction in [1, -1] if both else [1]:
new_solids.append(
face.thicken(depth=amount, normal_override=normal_override * direction)
face.thicken(depth=amount, normal_override=face_normal * direction)
)

if context is not None:
Expand Down
11 changes: 11 additions & 0 deletions tests/test_build_part.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,17 @@ def test_thicken(self):
outer_sphere = thicken(non_planar, amount=0.1)
self.assertAlmostEqual(outer_sphere.volume, (4 / 3) * pi * (1.1**3 - 1**3), 5)

wire = JernArc((0, 0), (-1, 0), 1, 180).edge().reversed() + JernArc(
(0, 0), (1, 0), 2, -90
)
part = thicken(sweep((wire ^ 0) * RadiusArc((0, 0), (0, -1), 1), wire), 0.4)
self.assertAlmostEqual(part.volume, 2.241583787221904, 5)

part = thicken(
sweep((wire ^ 0) * RadiusArc((0, 0), (0, -1), 1), wire), 0.4, both=True
)
self.assertAlmostEqual(part.volume, 4.711747154435256, 5)


class TestTorus(unittest.TestCase):
def test_simple_torus(self):
Expand Down

0 comments on commit debdf84

Please sign in to comment.