spateo.tdr.models.utilities.model_utils#

Module Contents#

Functions#

merge_models(→ PolyData or UnstructuredGrid)

Merge all models in the models list. The format of all models must be the same.

collect_models(→ pyvista.MultiBlock)

A composite class to hold many data sets which can be iterated over.

multiblock2model(model[, message])

Merge all models in MultiBlock into one model

split_model(→ pyvista.MultiBlock)

Find, label, and split connected bodies/volumes.

_scale_model_by_distance(→ pyvista.DataSet)

_scale_model_by_scale_factor(→ pyvista.DataSet)

scale_model(→ Union[pyvista.PolyData, ...)

Scale the model around the center of the model.

translate_model(, inplace, pyvista.UnstructuredGrid, None])

Translate the mesh.

center_to_zero(model[, inplace])

Translate the center point of the model to the (0, 0, 0).

rotate_model(, rotate_center, tuple] = None, inplace, ...)

Rotate the model around the rotate_center.

spateo.tdr.models.utilities.model_utils.merge_models(models: List[PolyData or UnstructuredGrid or DataSet]) PolyData or UnstructuredGrid[source]#

Merge all models in the models list. The format of all models must be the same.

spateo.tdr.models.utilities.model_utils.collect_models(models: List[PolyData or UnstructuredGrid or DataSet], models_name: List[str] | None = None) pyvista.MultiBlock[source]#

A composite class to hold many data sets which can be iterated over. You can think of MultiBlock like lists or dictionaries as we can iterate over this data structure by index and we can also access blocks by their string name. If the input is a dictionary, it can be iterated in the following ways:

>>> blocks = collect_models(models, models_name)
>>> for name in blocks.keys():
...     print(blocks[name])
If the input is a list, it can be iterated in the following ways:
>>> blocks = collect_models(models)
>>> for block in blocks:
...    print(block)
spateo.tdr.models.utilities.model_utils.multiblock2model(model, message=None)[source]#

Merge all models in MultiBlock into one model

spateo.tdr.models.utilities.model_utils.split_model(model: pyvista.PolyData | pyvista.UnstructuredGrid | pyvista.DataSet, label: bool | None = False) pyvista.MultiBlock[source]#

Find, label, and split connected bodies/volumes. This splits different connected bodies into blocks in a pyvista.MultiBlock dataset.

spateo.tdr.models.utilities.model_utils._scale_model_by_distance(model: pyvista.DataSet, distance: int | float | list | tuple = 1, scale_center: list | tuple = None) pyvista.DataSet[source]#
spateo.tdr.models.utilities.model_utils._scale_model_by_scale_factor(model: pyvista.DataSet, scale_factor: int | float | list | tuple = 1, scale_center: list | tuple = None) pyvista.DataSet[source]#
spateo.tdr.models.utilities.model_utils.scale_model(model: pyvista.PolyData | pyvista.UnstructuredGrid, distance: float | int | list | tuple = None, scale_factor: float | int | list | tuple = 1, scale_center: list | tuple = None, inplace: bool = False) pyvista.PolyData | pyvista.UnstructuredGrid | None[source]#

Scale the model around the center of the model.

Parameters:
model

A 3D reconstructed model.

distance

The distance by which the model is scaled. If distance is float, the model is scaled same distance along the xyz axis; when the scale factor is list, the model is scaled along the xyz axis at different distance. If distance is None, there will be no scaling based on distance.

scale_factor

The scale by which the model is scaled. If scale factor is float, the model is scaled along the xyz axis at the same scale; when the scale factor is list, the model is scaled along the xyz axis at different scales. If scale_factor is None, there will be no scaling based on scale factor.

scale_center

Scaling center. If scale factor is None, the scale_center will default to the center of the model.

inplace

Updates model in-place.

Returns:

The scaled model.

Return type:

model_s

spateo.tdr.models.utilities.model_utils.translate_model(model: pyvista.PolyData | pyvista.UnstructuredGrid, distance: list | tuple = (0, 0, 0), inplace: bool = False) pyvista.PolyData | pyvista.UnstructuredGrid | None[source]#

Translate the mesh.

Parameters:
model

A 3D reconstructed model.

distance

Distance to translate about the x-axis, y-axis, z-axis. Length 3 list or tuple.

inplace

Updates model in-place.

Returns:

The translated model.

Return type:

model_t

spateo.tdr.models.utilities.model_utils.center_to_zero(model: pyvista.PolyData | pyvista.UnstructuredGrid, inplace: bool = False)[source]#

Translate the center point of the model to the (0, 0, 0).

Parameters:
model

A 3D reconstructed model.

inplace

Updates model in-place.

Returns:

Model with center point at (0, 0, 0).

Return type:

model_z

spateo.tdr.models.utilities.model_utils.rotate_model(model: pyvista.PolyData | pyvista.UnstructuredGrid, angle: list | tuple = (0, 0, 0), rotate_center: list | tuple = None, inplace: bool = False) pyvista.PolyData | pyvista.UnstructuredGrid | None[source]#

Rotate the model around the rotate_center.

Parameters:
model

A 3D reconstructed model.

angle

Angles in degrees to rotate about the x-axis, y-axis, z-axis. Length 3 list or tuple.

rotate_center

Rotation center point. The default is the center of the model. Length 3 list or tuple.

inplace

Updates model in-place.

Returns:

The rotated model.

Return type:

model_r