DataObjectFilters.resize#
- DataObjectFilters.resize(
- *,
- bounds: VectorLike[float] | None = None,
- bounds_size: float | VectorLike[float] | None = None,
- length: 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.
It has three independent use cases:
Use
boundsto set the mesh’sboundsdirectly.Use
bounds_sizeto set the mesh’sbounds_sizedirectly.Use
lengthto set the mesh’s diagonallengthdirectly.
By default, the
bounds_sizeandlengthoptions resize the mesh so that itscenteris unchanged. Optionally,centermay be set explicitly for these cases.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_size,length, orcenter.- 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 withboundsorlength.- length
float,optional Target length of the
boundsfor the resized dataset. Cannot be used together withboundsorbounds_size.Added in version 0.47.
- center
VectorLike[float],optional Center of the resized dataset in
[x, y, z]. By default, the mesh’scenteris used. Only used whenbounds_sizeorlengthis 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:
- output
DataSet|MultiBlock Resized dataset. Return type matches input.
- output
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 diagonal length is
4.0. The mesh’s center is unchanged.>>> resized = mesh.resize(length=4.0) >>> resized.length 4.0 >>> resized.center (1.0, 2.0, 3.0)
Resize the mesh so its size is
4.0. The mesh’s center is again unchanged.>>> resized = mesh.resize(bounds_size=4.0) >>> resized.bounds_size (4.0, 4.0, 4.0) >>> resized.center (1.0, 2.0, 3.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)