vtkmodules.numpy_interface.vtk_structured_point_array#
VTKStructuredPointArray — lazy numpy-compatible wrapper for structured points.
This module provides VTKStructuredPointArray and VTKStructuredAxisArray classes that lazily represent the point coordinates of vtkImageData and vtkRectilinearGrid datasets without materializing the full (N, 3) array.
For a grid with dimensions (nx, ny, nz), only O(nx + ny + nz) storage is needed instead of O(nx * ny * nz * 3). Ufuncs and scalar arithmetic operate per-axis and stay lazy. Reductions (sum, min, max, mean) use optimized O(nx+ny+nz) formulas.
VTK uses Fortran ordering where i increases fastest: flat_idx = i + j * nx + k * nx * ny
模組目次#
類別#
A lazy 1D array representing one coordinate component (X, Y, or Z) of a structured point array. |
|
A lazy array wrapper for structured point arrays that stores three 1D axis arrays and computes points without materializing the full (N, 3) grid. |
|
Numpy-compatible mixin for vtkStructuredPointArray template instances. |
Functions#
Register an array_function override for VTKStructuredPointArrayMixin. |
|
Register an array_function implementation for VTKStructuredPointArray. |
|
Add native-type aliases so template[『float64』] etc. work. |
|
Register VTKStructuredPointArrayMixin for all vtkStructuredPointArray template instantiations. |
Data#
API#
- vtkmodules.numpy_interface.vtk_structured_point_array._STRUCTURED_POINT_OVERRIDE#
None
- vtkmodules.numpy_interface.vtk_structured_point_array._STRUCTURED_POINT_MIXIN_OVERRIDE#
None
- vtkmodules.numpy_interface.vtk_structured_point_array._override_mixin_numpy(numpy_function)#
Register an array_function override for VTKStructuredPointArrayMixin.
- vtkmodules.numpy_interface.vtk_structured_point_array._override_structured_point_numpy(numpy_function)#
Register an array_function implementation for VTKStructuredPointArray.
- class vtkmodules.numpy_interface.vtk_structured_point_array.VTKStructuredAxisArray(values, axis, dims, dataset=None)#
A lazy 1D array representing one coordinate component (X, Y, or Z) of a structured point array.
For a structured grid with dims (nx, ny, nz), there are only nx unique X values, ny unique Y values, and nz unique Z values. This class stores just the unique values and expands them lazily when needed.
Repeat patterns (Fortran ordering, i fastest):
Axis 0 (X): X[i] appears at indices where flat_idx % nx == i
Axis 1 (Y): Y[j] appears at indices where (flat_idx // nx) % ny == j
Axis 2 (Z): Z[k] appears at indices where flat_idx // (nx * ny) == k
初始化
Parameters
values : numpy array The unique coordinate values for this axis. axis : int Which axis (0=X, 1=Y, 2=Z). dims : tuple of 3 ints Grid dimensions (nx, ny, nz). dataset : vtkDataObject, optional The owning dataset (kept as weak reference).
- property shape#
- property dtype#
- property ndim#
- property size#
- __len__()#
- __repr__()#
- __array__(dtype=None, **kwargs)#
Materialize the full 1D array using Fortran ordering (i fastest).
- __getitem__(index)#
Index into the array using Fortran ordering.
- __array_ufunc__(ufunc, method, *inputs, **kwargs)#
Handle numpy ufuncs. Unary ufuncs and scalar operations stay lazy.
- __add__(other)#
- __radd__(other)#
- __sub__(other)#
- __rsub__(other)#
- __mul__(other)#
- __rmul__(other)#
- __truediv__(other)#
- __rtruediv__(other)#
- __neg__()#
- __pow__(other)#
- __rpow__(other)#
- class vtkmodules.numpy_interface.vtk_structured_point_array.VTKStructuredPointArray(dataset=None, axis_arrays=None, dims=None, uses_dir_matrix=False)#
A lazy array wrapper for structured point arrays that stores three 1D axis arrays and computes points without materializing the full (N, 3) grid.
When the direction matrix is identity (common case for vtkImageData and all vtkRectilinearGrid), ufuncs and arithmetic operate per-axis and stay lazy. When a non-identity direction matrix is used, operations fall back to full materialization.
VTK uses Fortran ordering where i increases fastest: flat_idx = i + j * nx + k * nx * ny
初始化
- classmethod from_image_data(image_data)#
Create from vtkImageData.
Computes axis arrays from origin, spacing, and dimensions. Detects non-identity direction matrices.
- classmethod from_rectilinear_grid(rectilinear_grid)#
Create from vtkRectilinearGrid.
Uses the X/Y/Z coordinate arrays directly. RectilinearGrid never has a direction matrix.
- classmethod _from_axes(axis_arrays, dims=None, uses_dir_matrix=False)#
Create from axis arrays for intermediate results (no VTK backing).
- _get_dataset()#
Get the dataset from the weak reference.
- property _axis_arrays#
Get axis arrays, computing from dataset if needed.
- property _dims#
Get dimensions from axis arrays or dataset.
- property _uses_dir_matrix#
Check if a non-identity direction matrix is used.
- property VTKObject#
Get the underlying VTK point data array from the dataset.
- property shape#
- property dtype#
- property ndim#
- property size#
- __len__()#
- __repr__()#
- _flat_to_ijk(flat_idx)#
Convert a flat index to (i, j, k) structured indices.
VTK uses Fortran ordering (i fastest): flat_idx = i + j * nx + k * nx * ny
- __array__(dtype=None, **kwargs)#
Materialize the full (N, 3) array.
- __getitem__(index)#
Index into the structured point array.
- __array_ufunc__(ufunc, method, *inputs, **kwargs)#
Handle numpy ufuncs. For identity-matrix arrays, apply per-axis and stay lazy.
- __array_function__(func, types, args, kwargs)#
Handle numpy functions with optimized paths.
- __add__(other)#
- __radd__(other)#
- __sub__(other)#
- __rsub__(other)#
- __mul__(other)#
- __rmul__(other)#
- __truediv__(other)#
- __rtruediv__(other)#
- __neg__()#
- vtkmodules.numpy_interface.vtk_structured_point_array._sp_sum(a, axis=None, **kwargs)#
- vtkmodules.numpy_interface.vtk_structured_point_array._sp_min(a, axis=None, **kwargs)#
- vtkmodules.numpy_interface.vtk_structured_point_array._sp_max(a, axis=None, **kwargs)#
- vtkmodules.numpy_interface.vtk_structured_point_array._sp_mean(a, axis=None, **kwargs)#
- class vtkmodules.numpy_interface.vtk_structured_point_array.VTKStructuredPointArrayMixin(*args, **kwargs)#
基底類別:
vtkmodules.numpy_interface._vtk_array_mixin.VTKDataArrayMixinNumpy-compatible mixin for vtkStructuredPointArray template instances.
This mixin is automatically applied to all
vtkStructuredPointArrayinstantiations (e.g.vtkStructuredPointTypeFloat64Array). It provides__array__,__buffer__, indexing, and basic numpy protocol so that structured point arrays returned by VTK are directly usable with numpy.The mixin retrieves axis coordinate arrays directly from the C++ backend via
GetXCoordinates(),GetYCoordinates(), andGetZCoordinates(), enabling lazy per-axis operations and O(nx+ny+nz) reductions. When no backend is available, it materializes viaDeepCopyto an AOS array.初始化
- _get_axis_arrays()#
Get the X, Y, Z coordinate arrays directly from the backend.
Returns a list of 3 numpy arrays [X, Y, Z], or None if the backend has not been constructed yet.
- _get_dims()#
Get grid dimensions from axis arrays.
- _uses_dir_matrix()#
Check if a non-identity direction matrix is being used.
- property dtype#
- property nbytes#
- _materialize(dtype=None)#
Materialize the full array as a numpy ndarray.
When axis arrays are available and no direction matrix is used, materializes via meshgrid (efficient). Otherwise, uses DeepCopy to an AOS array.
- to_numpy(dtype=None)#
Return the full (N, 3) array as a numpy ndarray.
- __array__(dtype=None, copy=None)#
- __buffer__(flags)#
- __getitem__(index)#
- __setitem__(key, value)#
- __array_ufunc__(ufunc, method, *inputs, **kwargs)#
- __array_function__(func, types, args, kwargs)#
- __add__(other)#
- __radd__(other)#
- __sub__(other)#
- __rsub__(other)#
- __mul__(other)#
- __rmul__(other)#
- __truediv__(other)#
- __rtruediv__(other)#
- __neg__()#
- __pos__()#
- __abs__()#
- __lt__(other)#
- __le__(other)#
- __eq__(other)#
- __ne__(other)#
- __ge__(other)#
- __gt__(other)#
- __iter__()#
- __repr__()#
- __str__()#
- vtkmodules.numpy_interface.vtk_structured_point_array._mixin_sum(a, axis=None, **kwargs)#
- vtkmodules.numpy_interface.vtk_structured_point_array._mixin_min(a, axis=None, **kwargs)#
- vtkmodules.numpy_interface.vtk_structured_point_array._mixin_max(a, axis=None, **kwargs)#
- vtkmodules.numpy_interface.vtk_structured_point_array._mixin_mean(a, axis=None, **kwargs)#
- vtkmodules.numpy_interface.vtk_structured_point_array._VTKTYPE_TO_MANGLING#
None
- vtkmodules.numpy_interface.vtk_structured_point_array._add_template_type_aliases(template_cls, prefix)#
Add native-type aliases so template[『float64』] etc. work.
Templates that only have vtkType-based instantiations (e.g. vtkTypeFloat64) need aliases under the native IA64 mangled names (e.g. _IdE for double) so that the Python template subscript notation template[『float64』] can find them.
- vtkmodules.numpy_interface.vtk_structured_point_array._register_structured_point_overrides()#
Register VTKStructuredPointArrayMixin for all vtkStructuredPointArray template instantiations.