예제 #1
0
 def __new__(cls, input_array, array=None, dataset=None):
     # Input array is an already formed ndarray instance
     # We first cast to be our class type
     obj = numpy.asarray(input_array).view(cls)
     obj.Association = ArrayAssociation.FIELD
     # add the new attributes to the created instance
     obj.VTKObject = array
     if dataset:
         obj._dataset = vtkWeakReference()
         obj._dataset.Set(dataset.VTKObject)
     # Finally, we must return the newly created object:
     return obj
예제 #2
0
    def DataSet(self, dataset):
        """
        Set the dataset this array is associated with. The reference is held
        through a vtkWeakReference.
        """
        # Do we have dataset to store
        if dataset and dataset.VTKObject:
            # Do we need to create a vtkWeakReference
            if not hasattr(self, '_dataset') or self._dataset is None:
                self._dataset = vtkWeakReference()

            self._dataset.Set(dataset.VTKObject)
        else:
            self._dataset = None