vtkmodules.util.selection#

Pythonic API for vtkSelection and vtkSelectionNode.

Simplifies selection construction and composition::

from vtkmodules.vtkCommonDataModel import vtkSelection, vtkSelectionNode
import numpy as np

# One-line index selection (creates a single-node selection):
sel = vtkSelection(content_type="INDICES", field_type="CELL",
                   selection_list=np.array([0, 5, 10]))

# Threshold selection via populate helper:
temp_sel = vtkSelection().from_thresholds("Temperature", (0, 100))

# Boolean composition — produces multi-node selections:
combined = sel & temp_sel          # AND
either   = sel | temp_sel          # OR
inverted = ~sel                    # NOT
compound = sel & (temp_sel | ~inverted)

# Container interface:
len(sel)                           # number of nodes
sel[0]                             # node by index
sel["NodeName"]                    # node by name
for node in sel: ...               # iterate nodes
sel.expression                     # get/set expression string

# SelectionNode properties:
node = sel[0]
node.content_type                  # "INDICES"
node.field_type                    # "CELL"
node.selection_list                # vtkAbstractArray

Module Contents#

Classes#

_SelectionNodeMixin

Pythonic properties for vtkSelectionNode.

_SelectionMixin

Pythonic container and operator interface for vtkSelection.

SelectionNode

Selection

Functions#

_resolve_content_type

Accept string or int, return int content type.

_resolve_field_type

Accept string or int, return int field type.

_set_qualifiers

Set qualifier properties on a vtkSelectionNode from a dict.

_to_vtk_array

Convert a Python sequence or numpy array to a VTK array.

_next_label

Return the next unused label.

_remap_expr

Replace node names in an expression simultaneously.

Data#

API#

vtkmodules.util.selection._CONTENT_TYPE_MAP#

None

vtkmodules.util.selection._CONTENT_TYPE_REVERSE#

None

vtkmodules.util.selection._FIELD_TYPE_MAP#

None

vtkmodules.util.selection._FIELD_TYPE_REVERSE#

None

vtkmodules.util.selection._INT_QUALIFIER_KEYS#

None

vtkmodules.util.selection._resolve_content_type(value)#

Accept string or int, return int content type.

vtkmodules.util.selection._resolve_field_type(value)#

Accept string or int, return int field type.

vtkmodules.util.selection._set_qualifiers(node, qualifiers)#

Set qualifier properties on a vtkSelectionNode from a dict.

vtkmodules.util.selection._to_vtk_array(values, array_type=None, num_components=1, name=None)#

Convert a Python sequence or numpy array to a VTK array.

class vtkmodules.util.selection._SelectionNodeMixin#

Pythonic properties for vtkSelectionNode.

property content_type#

Content type as a string (e.g. ‘INDICES’, ‘THRESHOLDS’).

property field_type#

Field type as a string (e.g. ‘CELL’, ‘POINT’).

property selection_list#

The selection list array.

property inverse#
property containing_cells#
property connected_layers#
property composite_index#
property component_number#
property epsilon#

Distance tolerance for LOCATIONS selections.

property assembly_name#

Data assembly name for BLOCK_SELECTORS selections.

__repr__()#
vtkmodules.util.selection._next_label(labels_used)#

Return the next unused label.

vtkmodules.util.selection._remap_expr(expr, name_map)#

Replace node names in an expression simultaneously.

Uses regex word-boundary matching to avoid partial replacements, and replaces all names in a single pass to prevent collisions when a new name equals another old name.

class vtkmodules.util.selection._SelectionMixin(*args, content_type=None, field_type=None, selection_list=None, **kwargs)#

Pythonic container and operator interface for vtkSelection.

Initialization

_expr_label#

None

_build_node(content_type, field_type=None, selection_list=None, qualifiers=None)#

Create, configure, and append a vtkSelectionNode to this selection.

Returns the assigned node name.

__len__()#
__getitem__(key)#
__iter__()#
append(node)#

Add a node and return its assigned name.

clear()#

Remove all nodes.

property expression#

The boolean expression combining nodes.

property node_names#

List of node names.

_get_expr_label()#

Get the expression label for this selection.

_combine(other, op_str)#

Combine two selections with a boolean operator.

__and__(other)#
__or__(other)#
__xor__(other)#
__invert__()#
from_thresholds(array_name, ranges, field_type='CELL', **qualifiers)#

Select elements whose array values fall within ranges.

Parameters

array_name : str Name of the data array to threshold on. ranges : tuple or list of tuples A single (min, max) pair or a list of (min, max) pairs. field_type : str or int Field type (default “CELL”). **qualifiers Optional qualifiers (inverse, composite_index, etc.).

from_values(array_name, values, field_type='CELL', component=-1, **qualifiers)#

Select elements with exact array values.

Parameters

array_name : str Name of the data array to match. values : array-like Values to match. field_type : str or int Field type (default “CELL”). component : int Component to compare (-1 for magnitude). **qualifiers Optional qualifiers.

from_locations(points, field_type='POINT', epsilon=None, **qualifiers)#

Select elements near world coordinates.

Parameters

points : array-like (N, 3) array of world coordinates. field_type : str or int Field type (default “POINT”). epsilon : float, optional Distance tolerance. **qualifiers Optional qualifiers.

from_frustum(corners, field_type='CELL', **qualifiers)#

Select elements within a viewing frustum.

Parameters

corners : array-like (8, 4) array of frustum corners in homogeneous coordinates, flattened to 32 values. field_type : str or int Field type (default “CELL”). **qualifiers Optional qualifiers.

from_blocks(block_indices, **qualifiers)#

Select blocks in a composite dataset by flat index.

Parameters

block_indices : array-like List or array of block indices. **qualifiers Optional qualifiers.

from_block_selectors(selectors, assembly_name=None, **qualifiers)#

Select blocks using selector expressions.

Parameters

selectors : list of str Selector expression strings. assembly_name : str, optional Name of the data assembly to apply selectors to. **qualifiers Optional qualifiers.

__repr__()#
class vtkmodules.util.selection.SelectionNode#

Bases: vtkmodules.util.selection._SelectionNodeMixin, vtkmodules.vtkCommonDataModel.vtkSelectionNode

class vtkmodules.util.selection.Selection(*args, content_type=None, field_type=None, selection_list=None, **kwargs)#

Bases: vtkmodules.util.selection._SelectionMixin, vtkmodules.vtkCommonDataModel.vtkSelection