releso.shape_parameterization.ShapeDefinition

class releso.shape_parameterization.ShapeDefinition(*, save_location: Path, logger_name: str | None = None, control_points: List[List[VariableLocation]])

Bases: BaseModel

Base of shape parameterization, also represents a simple point cloud.

__init__(**data: Any) None

Constructor for the ReLeSO basemodel object.

Methods

convert_all_control_point_locations_to_variable_locations(v, ...)

Validator control_points.

convert_to_pathlib_add_datetime(v)

Add timestamp to save_location, of applicable.

draw_action_space([save_location, no_axis, ...])

Draw the action space of the defined shape as a matplotlib figure.

get_actions()

Returns the action defined.

get_logger()

Gets the currently defined environment logger.

get_number_of_points()

Returns the number of points in the Cube.

get_parameter_values()

Returns the current positions of all control points.

get_shape()

Generates the current shape.

reset()

Resets the shape to the original values.

set_logger_name_recursively(logger_name)

Set the logger_name variable for all child elements.

Attributes

control_points

control_points of the shape.

save_location

Definition of the save location of the logs and validation results.

logger_name

name of the logger.

control_points: List[List[VariableLocation]]

control_points of the shape. These are the base variables used for the optimization. Overwrite get_actions and get_parameter_values if additional optimization variables are needed. See (WIP) NURBSDefinition.

classmethod convert_all_control_point_locations_to_variable_locations(v, values)

Validator control_points.

Converts all control points values into VariableLocations if the value is given as a simple float. Simple float will be converted into VariableLocation with current_position=value and no variability.

Parameters:
  • v ([type]) – value to validate

  • values ([type]) – already validated values

Returns:

validated value

Return type:

[type]

draw_action_space(save_location: str | None = None, no_axis: bool = False, fig_size: List[float] | None = None, dpi: int = 400)

Draw the action space of the defined shape as a matplotlib figure.

Needs to be reimplemented in subclasses where non control point variables are also used as actions. And if the control points are have more than 2D. The figure will plotted with matplotlib.

Parameters:
  • save_location (Optional[str], optional) – Location to save the resulting figure to. Defaults to None.

  • no_axis (bool, optional) – Remove axis from the resulting figure. Defaults to False.

  • fig_size (List[float], optional) – Size of the resulting figure. Defaults to [6, 6].

  • dpi (int, optional) – DPI of the resulting figure. Defaults to 400.

Raises:

RuntimeError – Error is thrown if the control point’s dimensionality is to high.

get_actions() List[VariableLocation]

Returns the action defined.

Returns list of VariableLocations but only if the variable location is actually variable.

Returns:

See above

Return type:

List[VariableLocation]

get_number_of_points() int

Returns the number of points in the Cube.

Number of control points multiplied by the number of dimensions for each cp. Assumes that all dimensions have the same number of control points.

Returns:

number of points in the geometry

Return type:

int

get_parameter_values() List[List[float]]

Returns the current positions of all control points.

Returns:

Positions of all control points.

Return type:

List[List[float]]

get_shape() Any

Generates the current shape.

Here the control points are returned since there is no other meaning to this shape.

Returns:

Shape that is generated.

Return type:

Any

reset() None

Resets the shape to the original values.