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

Geometry enhancements #583

Merged
merged 17 commits into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
20 changes: 15 additions & 5 deletions weldx/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import weldx.transformations as tf
import weldx.util as ut
from weldx.constants import Q_
from weldx.constants import WELDX_UNIT_REGISTRY as UREG

_DEFAULT_LEN_UNIT = UREG.millimeters
Expand All @@ -23,6 +24,8 @@
if TYPE_CHECKING: # pragma: no cover
import matplotlib.axes

import weldx.welding.groove.iso_9692_1 as iso

# helper -------------------------------------------------------------------------------


Expand Down Expand Up @@ -2002,26 +2005,33 @@ class Geometry:

"""

def __init__(self, profile, trace):
def __init__(
self,
profile: Union[Profile, VariableProfile, iso.IsoBaseGroove],
trace_or_length: Union[Trace, pint.Quantity],
):
"""Construct a geometry.

Parameters
----------
profile : Profile, VariableProfile
Constant or variable profile that is used as cross section along the
specified trace
trace : Trace
The path that is used to extrude the given profile
trace_or_length :
The path that is used to extrude the given profile or a quantity that
specifies the length of a linear, horizontal extrusion

Returns
-------
Geometry :
A Geometry class instance

"""
self._check_inputs(profile, trace)
if isinstance(trace_or_length, Q_):
trace_or_length = Trace(LinearHorizontalTraceSegment(trace_or_length))
vhirtham marked this conversation as resolved.
Show resolved Hide resolved
self._check_inputs(profile, trace_or_length)
self._profile = profile
self._trace = trace
self._trace = trace_or_length

def __repr__(self):
"""Output representation of a Geometry class."""
Expand Down
4 changes: 2 additions & 2 deletions weldx/tests/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2849,7 +2849,7 @@ def get_test_geometry_constant_profile() -> geo.Geometry:
"""
profile = get_test_profile()
trace = geo.Trace([geo.LinearHorizontalTraceSegment(Q_(1, "cm"))])
return geo.Geometry(profile=profile, trace=trace)
return geo.Geometry(profile=profile, trace_or_length=trace)


def get_test_geometry_variable_profile():
Expand All @@ -2866,7 +2866,7 @@ def get_test_geometry_variable_profile():
[profile, profile], [0, 1], [geo.linear_profile_interpolation_sbs]
)
trace = geo.Trace([geo.LinearHorizontalTraceSegment(Q_(1, "cm"))])
return geo.Geometry(profile=variable_profile, trace=trace)
return geo.Geometry(profile=variable_profile, trace_or_length=trace)


class TestGeometry:
Expand Down