Skip to content

Commit

Permalink
Sweep shape API additions (#3130)
Browse files Browse the repository at this point in the history
* 👽️ Improve sweep shape API

* 🎨 Move enum API to tools
  • Loading branch information
je-cook authored Apr 9, 2024
1 parent 98e2564 commit 817bddf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion bluemira/codes/_freecadapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1635,6 +1635,7 @@ def sweep_shape(
*,
solid: bool = True,
frenet: bool = True,
transition: int = 0,
) -> apiShell | apiSolid:
"""
Sweep a a set of profiles along a path.
Expand Down Expand Up @@ -1677,7 +1678,7 @@ def sweep_shape(
" produce unexpected results."
)

result = path.makePipeShell(profiles, True, frenet) # noqa: FBT003
result = path.makePipeShell(profiles, solid, frenet, transition)

solid_result = apiSolid(result)
if solid:
Expand Down
20 changes: 19 additions & 1 deletion bluemira/geometry/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""

import datetime
import enum
import functools
import inspect
import json
Expand Down Expand Up @@ -836,12 +837,21 @@ def extrude_shape(
return convert(cadapi.extrude_shape(shape.shape, vec), label)


class SweepShapeTransition(enum.IntEnum):
"""Sweep shape corner transition options"""

DEFAULT = 0
RIGHT_CORNER = 1
ROUND_CORNER = 2


def sweep_shape(
profiles: BluemiraWire | Iterable[BluemiraWire],
path: BluemiraWire,
*,
solid: bool = True,
frenet: bool = True,
transition: SweepShapeTransition | int = SweepShapeTransition.DEFAULT,
label: str = "",
) -> BluemiraSolid | BluemiraShell:
"""
Expand All @@ -858,6 +868,8 @@ def sweep_shape(
frenet:
If true, the orientation of the profile(s) is calculated based on local curvature
and tangency. For planar paths, should not make a difference.
transition:
transition type between sweep sections
Returns
-------
Expand All @@ -868,7 +880,13 @@ def sweep_shape(

profile_shapes = [p.shape for p in profiles]

result = cadapi.sweep_shape(profile_shapes, path.shape, solid=solid, frenet=frenet)
result = cadapi.sweep_shape(
profile_shapes,
path.shape,
solid=solid,
frenet=frenet,
transition=SweepShapeTransition(transition),
)

return convert(result, label=label)

Expand Down

0 comments on commit 817bddf

Please sign in to comment.