pyvista.DataObjectFilters.resize#
- DataObjectFilters.resize(
- *,
- bounds: VectorLike[float] | None = None,
- bounds_size: float | VectorLike[float] | None = None,
- center: VectorLike[float] | None = None,
- transform_all_input_vectors: bool = False,
- inplace: bool = False,
Resize the dataset’s bounds.
This filter rescales and translates the mesh to fit specified bounds. This is useful for normalizing datasets, changing units, or fitting datasets into specific coordinate ranges.
Use
boundsto set the mesh’sboundsdirectly or usebounds_sizeandcenterto implicitly set the new bounds.Added in version 0.46.
- Parameters:
- bounds
VectorLike[float],optional Target
boundsfor the resized dataset in the format[xmin, xmax, ymin, ymax, zmin, zmax]. If provided, the dataset is scaled and translated to fit exactly within these bounds. Cannot be used together withbounds_sizeorcenter.- bounds_size
float|VectorLike[float],optional Target size of the
boundsfor the resized dataset. Use a single float to specify the size of all three axes, or a 3-element vector to set the size of each axis independently. Cannot be used together withbounds.- center
VectorLike[float],optional Center of the resized dataset in
[x, y, z]. By default, the mesh’scenteris used. Only used whenbounds_sizeis specified.- transform_all_input_vectorsbool, default:
False When
True, all input vectors are transformed as part of the resize. Otherwise, only the points, normals and active vectors are transformed.- inplacebool, default:
False If True, the dataset is modified in place. If False, a new dataset is returned.
- bounds
- Returns:
DataSet|MultiBlockResized dataset. Return type matches input.
See also
scale(),translate()Scale and/or translate a mesh. Used internally by
resize().
Examples
Load a mesh with asymmetric bounds and show them.
>>> import pyvista as pv >>> mesh = pv.Cube( ... x_length=1.0, y_length=2.0, z_length=3.0, center=(1.0, 2.0, 3.0) ... ) >>> mesh.bounds BoundsTuple(x_min = 0.5, x_max = 1.5, y_min = 1.0, y_max = 3.0, z_min = 1.5, z_max = 4.5)
Resize it to fit specific bounds.
>>> resized = mesh.resize(bounds=[-1, 2, -3, 4, -5, 6]) >>> resized.bounds BoundsTuple(x_min = -1.0, x_max = 2.0, y_min = -3.0, y_max = 4.0, z_min = -5.0, z_max = 6.0)
Resize the mesh so its size is
4.0.>>> resized = mesh.resize(bounds_size=4.0) >>> resized.bounds_size (4.0, 4.0, 4.0) >>> resized.bounds BoundsTuple(x_min = -1.0, x_max = 3.0, y_min = 0.0, y_max = 4.0, z_min = 1.0, z_max = 5.0)
Specify a different size for each axis and set the desired center.
>>> resized = mesh.resize(bounds_size=(2.0, 1.0, 0.5), center=(1.0, 0.5, 0.25)) >>> resized.bounds_size (2.0, 1.0, 0.5) >>> resized.center (1.0, 0.5, 0.25)
Center the mesh at the origin and normalize its bounds to
1.0.>>> resized = mesh.resize(bounds_size=1.0, center=(0.0, 0.0, 0.0)) >>> resized.bounds BoundsTuple(x_min = -0.5, x_max = 0.5, y_min = -0.5, y_max = 0.5, z_min = -0.5, z_max = 0.5)