How to use the brainspace.vtk_interface.wrappers.base.BSVTKObjectWrapper function in brainspace

To help you get started, we’ve selected a few brainspace examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MICA-MNI / BrainSpace / brainspace / vtk_interface / wrappers / base.py View on Github external
if not is_vtk(obj):
        raise ValueError('Unknown object type: {0}'.format(type(obj)))

    # Is this really needed? is there a vtk class that doesn't start with vtk?
    if not obj.__vtkname__.startswith('vtk'):
        raise ValueError('Unknown object type: {0}'.format(type(obj)))

    # Find wrapper for vtk class or one of its superclasses
    for c in [sc.__vtkname__[3:] for sc in obj.__class__.mro()[:-3]]:
        if c in BSVTKObjectWrapperMeta.entries:
            bs_cls = BSVTKObjectWrapperMeta.entries[c]
            return bs_cls(obj)

    # Fall back to generic wrapper
    return BSVTKObjectWrapper(obj)
github MICA-MNI / BrainSpace / brainspace / vtk_interface / wrappers / misc.py View on Github external
"""
Misc wrappers for some VTK classes.
"""

# Author: Oualid Benkarim 
# License: BSD 3 clause


from vtk.util.vtkConstants import VTK_ID_TYPE

from .base import BSVTKObjectWrapper
from ..decorators import unwrap_input, wrap_output


class BSCollection(BSVTKObjectWrapper):
    """Wrapper for vtkCollection."""
    def __init__(self, vtkobject=None, **kwargs):
        super().__init__(vtkobject, **kwargs)

    @property
    def n_items(self):
        return self.VTKObject.GetNumberOfItems()

    @wrap_output
    def __getitem__(self, i):
        if i < 0:
            i += self.n_items
        return self.VTKObject.GetItemAsObject(i)

    def __setitem__(self, i, obj):
        if i < 0:
github MICA-MNI / BrainSpace / brainspace / vtk_interface / wrappers / misc.py View on Github external
############################################################
# Coordinate object
############################################################
class BSCoordinate(BSVTKObjectWrapper):
    """Wrapper for vtkCoordinate."""

    def __init__(self, vtkobject=None, **kwargs):
        super().__init__(vtkobject, **kwargs)


############################################################
# Cell Array
############################################################
class BSCellArray(BSVTKObjectWrapper):
    """Wrapper for vtkCellArray."""

    def __init__(self, vtkobject=None, **kwargs):
        super().__init__(vtkobject=vtkobject, **kwargs)

    @unwrap_input(2, vtype={2: VTK_ID_TYPE})
    def SetCells(self, n_cells, cells):
        self.VTKObject.SetCells(n_cells, cells)


############################################################
# GL2PS Exporter
############################################################
class BSGL2PSExporter(BSVTKObjectWrapper):
    """Wrapper for vtkGL2PSExporter."""
github MICA-MNI / BrainSpace / brainspace / vtk_interface / wrappers / misc.py View on Github external
############################################################
class BSCellArray(BSVTKObjectWrapper):
    """Wrapper for vtkCellArray."""

    def __init__(self, vtkobject=None, **kwargs):
        super().__init__(vtkobject=vtkobject, **kwargs)

    @unwrap_input(2, vtype={2: VTK_ID_TYPE})
    def SetCells(self, n_cells, cells):
        self.VTKObject.SetCells(n_cells, cells)


############################################################
# GL2PS Exporter
############################################################
class BSGL2PSExporter(BSVTKObjectWrapper):
    """Wrapper for vtkGL2PSExporter."""

    def __init__(self, vtkobject=None, **kwargs):
        super().__init__(vtkobject=vtkobject, **kwargs)
github MICA-MNI / BrainSpace / brainspace / vtk_interface / wrappers / misc.py View on Github external
class BSPolyDataCollection(BSCollection):
    """Wrapper for vtkPolyDataCollection."""
    pass


class BSTextPropertyCollection(BSCollection):
    """Wrapper for vtkTextPropertyCollection."""
    pass


############################################################
# Coordinate object
############################################################
class BSCoordinate(BSVTKObjectWrapper):
    """Wrapper for vtkCoordinate."""

    def __init__(self, vtkobject=None, **kwargs):
        super().__init__(vtkobject, **kwargs)


############################################################
# Cell Array
############################################################
class BSCellArray(BSVTKObjectWrapper):
    """Wrapper for vtkCellArray."""

    def __init__(self, vtkobject=None, **kwargs):
        super().__init__(vtkobject=vtkobject, **kwargs)

    @unwrap_input(2, vtype={2: VTK_ID_TYPE})
github MICA-MNI / BrainSpace / brainspace / vtk_interface / wrappers / base.py View on Github external
def is_wrapper(obj):
    """ Check if `obj` is a wrapper.

    Parameters
    ----------
    obj : object
        Any object.

    Returns
    -------
    res : bool
        True if `obj` is a VTK wrapper. False, otherwise.
    """
    return isinstance(obj, BSVTKObjectWrapper)