Skip to content

shapes

SupportShape

SupportShape(
    name: str,
    xyz_arms: ndarray,
    set_number: ndarray,
    ground_point: ndarray = array([0, 0, 0]),
    arms_length: ndarray | None = None,
)

Support shape class enables to store a support complete "set" representation. The support is then represented by a set of arms, each arm being represented by x,y,z coordinate. Assumption for the representation:

1
2
3
4
- The support is centered with origin at the support ground.
- Trunk is a vertical bar
- base arms are on Y coordinate only, from the trunk
- set point are on X coordinate only, from the edge of the base arms

The class supposes the support centered with origin at the support ground. However, the ground origin can be moved by user.

Usages: generated with support catalog, and use plotting.plot_support_shape to visualize.

Parameters:

Name Type Description Default

name

str

support name

required

xyz_arms

ndarray

(n, 3) array with x,y,z set point coordinates in the support frame (n is the number of arms)

required

set_number

ndarray

(n,) array with the set numbers

required

ground_point

ndarray

ground point of the support. Defaults to np.array([0, 0, 0]).

array([0, 0, 0])

arms_length

ndarray | None

(n,) array with the arms lengths. Defaults to None means the amrs are the norm of x,y values

None
Source code in src/mechaphlowers/entities/shapes.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
def __init__(
    self,
    name: str,
    xyz_arms: np.ndarray,
    set_number: np.ndarray,
    ground_point: np.ndarray = np.array([0, 0, 0]),
    arms_length: np.ndarray | None = None,
):
    """Support Shape

    Args:
        name (str): support name
        xyz_arms (np.ndarray): (n, 3) array with x,y,z set point coordinates in the support frame (n is the number of arms)
        set_number (np.ndarray): (n,) array with the set numbers
        ground_point (np.ndarray, optional): ground point of the support. Defaults to np.array([0, 0, 0]).
        arms_length (np.ndarray | None, optional): (n,) array with the arms lengths. Defaults to None means the amrs are the norm of x,y values
    """
    self.name = name
    self.ground_point = ground_point
    self.xyz_arms = xyz_arms
    if arms_length is None:
        self.arms_length = np.linalg.norm(xyz_arms[:, 0:2], axis=1)
    else:
        self.arms_length = arms_length
    self.set_number = set_number

arms_points property

arms_points: ndarray

arms_points

Returns:

Type Description
ndarray

np.ndarray: (3*n, 3) array with the points of the arms of the support in points format

arms_set_points property

arms_set_points: ndarray

arms_set_points

Support shape can have X coordinates different from 0, which means several set points for the same arm. This property returns the points of the arms of the support in points format.

Returns:

Type Description
ndarray

np.ndarray: (3*n, 3) with n the number on nonzero values on the X coordinates of the arms of the support. If n=0 returns array([np.nan, np.nan, np.nan])

labels_points property

labels_points: ndarray

labels_points

Returns:

Type Description
ndarray

np.ndarray: (n,) array with set numbers of the arms of the support

support_points property

support_points: ndarray

support_points

Returns:

Type Description
ndarray

np.ndarray: ( (n+1)*3, 3) array with the points of the trunk of the support in points format

trunk_points property

trunk_points: ndarray

trunk_points

Returns:

Type Description
ndarray

np.ndarray: (2, 3) array with the points of the trunk of the support in points format

from_dataframe staticmethod

from_dataframe(df: DataFrame) -> list[SupportShape]

from_dataframe allows to generate a list of SupportShape object from a dataframe

Parameters:

Name Type Description Default

df

DataFrame

description

required

Raises:

Type Description
IndexError

if the dataframe has no index

Returns:

Type Description
list[SupportShape]

list[SupportShape]: list of SupportShape objects

Source code in src/mechaphlowers/entities/shapes.py
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
@staticmethod
def from_dataframe(df: pd.DataFrame) -> list[SupportShape]:
    """from_dataframe allows to generate a list of SupportShape object from a dataframe

    Args:
        df (pd.DataFrame): _description_

    Raises:
        IndexError: if the dataframe has no index

    Returns:
        list[SupportShape]: list of SupportShape objects
    """

    name = df.index.unique().tolist()

    if len(name) >= 1:
        support_shape_list = []
        for n in name:
            xyz_arms = df.loc[n, ['X', 'Y', 'Z']].to_numpy()
            set_number = df.loc[n, ['set_number']].to_numpy()
            support_shape_list.append(
                SupportShape(
                    name=n,
                    xyz_arms=xyz_arms,
                    set_number=set_number,
                    ground_point=np.array([0, 0, 0]),
                )
            )
    else:
        raise IndexError(
            "The asked key is missing from catalog index. Verify the key or the catalog name ?"
        )
    return support_shape_list