Skip to content

Commit a8d364c

Browse files
committed
fix: bounding box can be defined from max, origin or nsteps + step vector
1 parent e755c29 commit a8d364c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

LoopStructural/datatypes/_bounding_box.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
class BoundingBox:
88
def __init__(
99
self,
10-
dimensions: int = 3,
1110
origin: Optional[np.ndarray] = None,
1211
maximum: Optional[np.ndarray] = None,
1312
nsteps: Optional[np.ndarray] = None,
13+
step_vector: Optional[np.ndarray] = None,
14+
dimensions: int = 3,
1415
):
1516
"""A bounding box for a model, defined by the
1617
origin, maximum and number of steps in each direction
@@ -26,6 +27,14 @@ def __init__(
2627
nsteps : Optional[np.ndarray], optional
2728
_description_, by default None
2829
"""
30+
if origin is None:
31+
raise LoopValueError("Origin is not set")
32+
if maximum is None and nsteps is not None and step_vector is not None:
33+
maximum = origin + nsteps * step_vector
34+
if maximum is None:
35+
raise LoopValueError(
36+
"Maximum is not set, either specify nsteps and step vector or maximum"
37+
)
2938
self._origin = np.array(origin)
3039
self._maximum = np.array(maximum)
3140
self.dimensions = dimensions

0 commit comments

Comments
 (0)