brainspace.vtk_interface.wrappers.data_object.BSPolyData¶
-
class
brainspace.vtk_interface.wrappers.data_object.
BSPolyData
(vtkobject=None, **kwargs)[source]¶ Wrapper for vtkPolyData.
-
__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. GetCells2D
()Return cells as a 2D ndarray. GetFieldData
()Returns the field data as a DataSetAttributes instance. GetLines
()Returns the lines as a 1D VTKArray instance. GetLines2D
()Returns the lines as a 2D VTKArray instance. GetPointData
()Returns the point data as a DataSetAttributes instance. GetPoints
()Returns the points as a VTKArray instance. GetPolygons
()Returns the polys as a VTKArray instance. GetPolys
()Returns the polys as a 1D VTKArray instance. GetPolys2D
()Returns the polys as a 2D VTKArray instance. GetVerts
()Returns the verts as a 1D VTKArray instance. GetVerts2D
()Returns the verts as a 2D VTKArray instance. SetLines
(lines)Set lines. SetPoints
(pts)Given a VTKArray instance, sets the points of the dataset. SetPolys
(polys)Set polys. SetVerts
(verts)Set verts. __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. 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. Polygons
This property returns the connectivity of polygons. 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. lines
Return lines as a 1D VTKArray. lines2D
Return lines as a 2D VTKArray if possible. 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. polys
Return polys as a 1D VTKArray. polys2D
Return polys as a 2D VTKArray if possible. verts
Return verts as a 1D VTKArray. verts2D
Return verts as a 2D VTKArray if possible. vtk_map
Dictionary of vtk setter and getter methods. -
CellData
¶ This property returns the cell data of a dataset.
-
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.
-
GetCells2D
()[source]¶ Return cells as a 2D ndarray.
Returns: cells (2D ndarray, shape = (n_points, n)) – PolyData cells. Raises: ValueError
– If PolyData has different cell types.
-
GetFieldData
()¶ Returns the field data as a DataSetAttributes instance.
-
GetLines2D
()[source]¶ Returns the lines as a 2D VTKArray instance.
Returns: lines (2D ndarray, shape = (n_points, n)) – PolyData lines. Raises: ValueError
– If PolyData has different line types.
-
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.
-
GetPolygons
()¶ Returns the polys as a VTKArray instance.
-
GetPolys2D
()[source]¶ Returns the polys as a 2D VTKArray instance.
Returns: polys (2D ndarray, shape = (n_points, n)) – PolyData polys. Raises: ValueError
– If PolyData has different poly types.
-
GetVerts2D
()[source]¶ Returns the verts as a 2D VTKArray instance.
Returns: verts (2D ndarray, shape = (n_points, n)) – PolyData verts. Raises: ValueError
– If PolyData has different vertex types.
-
PointData
¶ This property returns the point data of the dataset.
-
Points
¶ This property returns the point coordinates of dataset.
-
Polygons
¶ This property returns the connectivity of polygons.
-
SetLines
(lines)[source]¶ Set lines.
Parameters: lines (1D or 2D ndarray) – If 2D, shape = (n_points, n), and n is the number of points per line. All lines must use the same number of points.
-
SetPoints
(pts)¶ Given a VTKArray instance, sets the points of the dataset.
-
SetPolys
(polys)[source]¶ Set polys.
Parameters: polys (1D or 2D ndarray) – If 2D, shape = (n_points, n), and n is the number of points per poly. All polys must use the same number of points.
-
SetVerts
(verts)[source]¶ Set verts.
Parameters: verts (1D or 2D ndarray) – If 2D, shape = (n_points, n), and n is the number of points per vertex. All verts must use the same number of points.
-
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
-
lines
¶ Return lines as a 1D VTKArray.
-
lines2D
¶ Return lines as a 2D VTKArray if possible.
-
point_keys
¶ Returns keys of point data.
Type: list of str
-
polys
¶ Return polys as a 1D VTKArray.
-
polys2D
¶ Return polys as a 2D VTKArray if possible.
-
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'
-
verts
¶ Return verts as a 1D VTKArray.
-
verts2D
¶ Return verts as a 2D VTKArray if possible.
-