brainspace.vtk_interface.wrappers.data_object.BSUnstructuredGrid¶
-
class
brainspace.vtk_interface.wrappers.data_object.
BSUnstructuredGrid
(vtkobject=None, **kwargs)[source]¶ Wrapper for vtkUnstructuredGrid.
-
__init__
(vtkobject=None, **kwargs)¶ Initialize self. See help(type(self)) for accurate signature.
Methods
GetAttributes
(type)Returns the attributes specified by the type as a DataSetAttributes instance. GetCellData
()Returns the cell data as a DataSetAttributes instance. GetCellLocations
()Returns the cell locations as a VTKArray instance. GetCellTypes
()Returns the cell types as a VTKArray instance. GetCells
()Returns the cells as a VTKArray instance. GetFieldData
()Returns the field data as a DataSetAttributes instance. GetPointData
()Returns the point data as a DataSetAttributes instance. GetPoints
()Returns the points as a VTKArray instance. SetCells
(cellTypes, cellLocations, cells)Given cellTypes, cellLocations, cells as VTKArrays, populates the unstructured grid data structures. SetPoints
(pts)Given a VTKArray instance, sets the points of the dataset. __init__
([vtkobject])Initialize self. append_array
(array[, name, at, …])Append array to attributes. getVTK
(*args, **kwargs)Invoke get methods on the vtk object. get_array
([name, at, return_name])Return array in attributes. remove_array
([name, at])Remove array from vtk dataset. setVTK
(*args, **kwargs)Invoke set methods on the vtk object. Attributes
CellData
This property returns the cell data of a dataset. CellLocations
This property returns the locations of cells. CellTypes
This property returns the types of cells. Cells
This property returns the connectivity of cells. FieldData
This property returns the field data of a data object. PointData
This property returns the point data of the dataset. Points
This property returns the point coordinates of dataset. cell_keys
Returns keys of cell data. cell_types
Returns cell types of the object. field_keys
Returns keys of field data. has_only_line
Returns True if object has only lines. has_only_quad
Returns True if object has only quad cells. has_only_triangle
Returns True if object has only triangles. has_only_vertex
Returns True if object has only vertex cells. has_unique_cell_type
Returns True if object has a unique cell type. n_cell_data
Returns number of entries in cell data. n_cells
Returns number of cells. n_field_data
Returns number of entries in field data. n_point_data
Returns number of entries in point data. n_points
Returns number of points. number_of_cell_types
Returns number of cell types. point_keys
Returns keys of point data. vtk_map
Dictionary of vtk setter and getter methods. -
CellData
¶ This property returns the cell data of a dataset.
-
CellLocations
¶ This property returns the locations of cells.
-
CellTypes
¶ This property returns the types of cells.
-
Cells
¶ This property returns the connectivity of cells.
-
FieldData
¶ This property returns the field data of a data object.
-
GetAttributes
(type)¶ Returns the attributes specified by the type as a DataSetAttributes instance.
-
GetCellData
()¶ Returns the cell data as a DataSetAttributes instance.
-
GetCellLocations
()¶ Returns the cell locations as a VTKArray instance.
-
GetCellTypes
()¶ Returns the cell types as a VTKArray instance.
-
GetCells
()¶ Returns the cells as a VTKArray instance.
-
GetFieldData
()¶ Returns the field data as a DataSetAttributes instance.
-
GetPointData
()¶ Returns the point data as a DataSetAttributes instance.
-
GetPoints
()¶ Returns the points as a VTKArray instance. Returns None if the dataset has implicit points.
-
PointData
¶ This property returns the point data of the dataset.
-
Points
¶ This property returns the point coordinates of dataset.
-
SetCells
(cellTypes, cellLocations, cells)¶ Given cellTypes, cellLocations, cells as VTKArrays, populates the unstructured grid data structures.
-
SetPoints
(pts)¶ Given a VTKArray instance, sets the points of the dataset.
-
append_array
(array, name=None, at=None, convert_bool='warn', overwrite='warn')¶ Append array to attributes.
Parameters: - array (1D or 2D ndarray) – Array to append to the dataset.
- name (str or None, optional) – Array name. If None, a random string is generated and returned. Default is None.
- at ({'point', 'cell', 'field', 'p', 'c', 'f'} or None, optional.) – Attribute to append data to. Points (i.e., ‘point’ or ‘p’), cells (i.e., ‘cell’ or ‘c’) or field (i.e., ‘field’ or ‘f’) data. If None, it will attempt to append data to the attributes with the same number of elements. Only considers points and cells. If both have the same number of elements or the size of the array does not coincide with any of them, it raises an exception. Default is None.
- convert_bool (bool or {'warn', 'raise'}, optional) – If True append array after conversion to uint8. If False, array is not appended. If ‘warn’, issue a warning but append the array. If raise, raise an exception.
- overwrite (bool or {'warn', 'raise'}, optional) – If True append array even if its name already exists. If False, array is not appended, issue a warning. If ‘warn’, issue a warning but append the array. If raise, raise an exception.
Returns: name (str) – Array name used to append the array to the dataset.
-
cell_keys
¶ Returns keys of cell data.
Type: list of str
-
cell_types
¶ Returns cell types of the object.
Type: list of int
-
field_keys
¶ Returns keys of field data.
Type: list of str
-
getVTK
(*args, **kwargs)¶ Invoke get methods on the vtk object.
Parameters: - args (list of str) – Method that require no arguments.
- kwargs (list of keyword-value arguments) – key-word arguments can be use for methods that require arguments. When several arguments are required, use a tuple. Methods that require no arguments can also be used here using None as the argument.
Returns: results (dict) – Dictionary of results where the keys are the method names and the values the results.
Examples
>>> import vtk >>> from brainspace.vtk_interface.wrappers import BSVTKObjectWrapper >>> m1 = BSVTKObjectWrapper(vtk.vtkPolyDataMapper()) >>> m1.getVTK('arrayId', colorModeAsString=None) {'arrayId': -1, 'colorModeAsString': 'Default'} >>> m1.getVTK('colorModeAsString', arrayId=None) {'colorModeAsString': 'Default', 'arrayId': -1} >>> m1.getVTK(numberOfInputConnections=0) {'numberOfInputConnections': 0}
-
get_array
(name=None, at=None, return_name=False)¶ Return array in attributes.
Parameters: - name (str, list of str or None, optional) – Array names. If None, return all arrays. Cannot be None
if
at == None
. Default is None. - at ({'point', 'cell', 'field', 'p', 'c', 'f'} or None, optional.) – Attributes to get the array from. Points (i.e., ‘point’ or
‘p’), cells (i.e., ‘cell’ or ‘c’) or field (i.e., ‘field’ or
‘f’). If None, get array name from all attributes that have an
array with the same array name. Cannot be None
if
name == None
. Default is None. - return_name (bool, optional) – Whether to return array names too. Default is False.
Returns: - arrays (VTKArray or list of VTKArray) – Data arrays. None is returned if name does not exist.
- names (str or list of str) – Names of returned arrays. Only if
return_name == True
.
- name (str, list of str or None, optional) – Array names. If None, return all arrays. Cannot be None
if
-
point_keys
¶ Returns keys of point data.
Type: list of str
-
remove_array
(name=None, at=None)¶ Remove array from vtk dataset.
Parameters: - name (str, list of str or None, optional) – Array name to remove. If None, remove all arrays. Default is None.
- at ({'point', 'cell', 'field', 'p', 'c', 'f'} or None, optional.) – Attributes to remove the array from. Points (i.e., ‘point’ or ‘p’), cells (i.e., ‘cell’ or ‘c’) or field (i.e., ‘field’ or ‘f’). If None, remove array name from all attributes. Default is None.
-
setVTK
(*args, **kwargs)¶ Invoke set methods on the vtk object.
Parameters: - args (list of str) – Setter methods that require no arguments.
- kwargs (list of keyword-value arguments) – key-word arguments can be use for methods that require arguments. When several arguments are required, use a tuple. Methods that require no arguments can also be used here using None as the argument.
Returns: self (BSVTKObjectWrapper object) – Return self.
Examples
>>> import vtk >>> from brainspace.vtk_interface.wrappers import BSVTKObjectWrapper >>> m1 = BSVTKObjectWrapper(vtk.vtkPolyDataMapper()) >>> m1.setVTK(arrayId=3, colorMode='mapScalars') <brainspace.vtk_interface.base.BSVTKObjectWrapper at 0x7f38a4ace320> >>> m1.arrayId 3 >>> m1.colorModeAsString 'MapScalars'
-