Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix thicken normal calculation when no override is provided #695

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading