def GetSubExtent(executive, splitPath):
    """
    This will return a parallel extent for each rank. It
    should be called in the RequestData call (script in
    ParaView programmable filters and sources)

    executive - the vtkExecutive required for this.  For
                a vtkAlgorithm one should pass self.GetExecutive()

    splitPath - the path you wish to split the data set along i.e.
                [0] is the x direction, [0,1] is a pencil split along 
                the x-y direction, [0,1,2] is block split x-y-z
    """
    controller = vtk.vtkMultiProcessController.GetGlobalController()
    if not controller:
        rank = 0
        nranks = 1
    else:
        rank = controller.GetLocalProcessId()
        nranks = controller.GetNumberOfProcesses()

    outInfo = executive.GetOutputInformation(0)

    wholeExtent = np.array(outInfo.Get(executive.WHOLE_EXTENT()))
    globDims = wholeExtent[1::2] - wholeExtent[0::2] + 1
    extCont = vtk.vtkExtentTranslator()
    extCont.SetSplitPath(4, splitPath)
    extCont.SetWholeExtent(outInfo.Get(executive.WHOLE_EXTENT()))
    extCont.SetNumberOfPieces(nranks)
    extCont.SetPiece(rank)
    extCont.PieceToExtent()
    outInfo.Set(executive.UPDATE_EXTENT(), extCont.GetExtent(), 6)

    return extCont.GetExtent()
Пример #2
0
    def __init__(self):
        super(StreamExtents, self).__init__(
            nInputPorts=1, inputType='vtkImageData',
            nOutputPorts=1, outputType='vtkMultiBlockDataSet')

        self.Contour = vtk.vtkContourFilter()
        self.Contour.SetValue(0, 180)
        self.UpdateIndex = 0
        self.NumberOfBlocks = 20
        self.ExtentTranslator = vtk.vtkExtentTranslator()
        self.ExtentTranslator.SetNumberOfPieces(self.NumberOfBlocks)
Пример #3
0
def execute():
    info = pf.GetOutputInformation(0)
    et = vtk.vtkExtentTranslator()
    et.SetWholeExtent(
        info.Get(vtk.vtkStreamingDemandDrivenPipeline.WHOLE_EXTENT()))
    et.SetPiece(
        info.Get(vtk.vtkStreamingDemandDrivenPipeline.UPDATE_PIECE_NUMBER()))
    et.SetNumberOfPieces(
        info.Get(
            vtk.vtkStreamingDemandDrivenPipeline.UPDATE_NUMBER_OF_PIECES()))
    et.PieceToExtent()
    output = pf.GetOutput()
    input = pf.GetInput()
    output.ShallowCopy(input)
    output.Crop(et.GetExtent())
Пример #4
0
        rtData3 = dsa.VTKCompositeDataArray([rtData2])
        grad3 = dsa.VTKCompositeDataArray([grad2])
    else:
        rtData3 = dsa.NoneArray
        grad3 = dsa.NoneArray

    testArrays(rtData3, rtData2, grad3, grad2, total_npts)

# Test composite arrays with multiple blocks.

# Split the local image to 2.
datasets = []
for i in range(2):
    image = vtk.vtkImageData()
    image.ShallowCopy(w.GetOutput())
    t = vtk.vtkExtentTranslator()
    wext = image.GetExtent()
    t.SetWholeExtent(wext)
    t.SetPiece(i)
    t.SetNumberOfPieces(2)
    t.PieceToExtent()
    ext = list(t.GetExtent())

    # Crop the any ghost points out
    for i in range(3):
        if ext[2 * i] != wext[2 * i]:
            ext[2 * i] = ext[2 * i] + 1
    if ext != list(org_ext):
        image.Crop(ext)

    datasets.append(dsa.WrapDataObject(image))