Exemple #1
0
    def testSource(self):
        class MyAlgorithm(vta.VTKAlgorithm):
            def __init__(self):
                vta.VTKAlgorithm.__init__(self, nInputPorts=0, outputType='vtkImageData')
                self.Wavelet = vtk.vtkRTAnalyticSource()

            def RequestInformation(self, vtkself, request, inInfo, outInfo):
                self.Wavelet.UpdateInformation()
                wOutInfo = self.Wavelet.GetOutputInformation(0)
                vtkSDDP = vtk.vtkStreamingDemandDrivenPipeline
                outInfo.GetInformationObject(0).Set(vtkSDDP.WHOLE_EXTENT(), wOutInfo.Get(vtkSDDP.WHOLE_EXTENT()), 6)
                return 1

            def RequestData(self, vtkself, request, inInfo, outInfo):
                self.Wavelet.Update()
                out = self.GetOutputData(outInfo, 0)
                out.ShallowCopy(self.Wavelet.GetOutput())
                return 1

        ex = vtk.vtkPythonAlgorithm()
        ex.SetPythonObject(MyAlgorithm())

        ex.Update()

        w = vtk.vtkRTAnalyticSource()
        w.Update()

        output = ex.GetOutputDataObject(0)
        self.assertEqual(output.GetPointData().GetScalars().GetRange(),\
            w.GetOutput().GetPointData().GetScalars().GetRange())
        vtkSDDP = vtk.vtkStreamingDemandDrivenPipeline
        self.assertEqual(ex.GetOutputInformation(0).Get(vtkSDDP.WHOLE_EXTENT()),\
            w.GetOutputInformation(0).Get(vtkSDDP.WHOLE_EXTENT()))
Exemple #2
0
    def testFilter(self):
        class MyAlgorithm(vta.VTKAlgorithm):
            def RequestData(self, vtkself, request, inInfo, outInfo):
                inp = self.GetInputData(inInfo, 0, 0)
                out = self.GetOutputData(outInfo, 0)
                out.ShallowCopy(inp)
                return 1

        sphere = vtk.vtkSphereSource()

        ex = vtk.vtkPythonAlgorithm()
        ex.SetPythonObject(MyAlgorithm())

        ex.SetInputConnection(sphere.GetOutputPort())

        ex.Update()

        output = ex.GetOutputDataObject(0)
        ncells = output.GetNumberOfCells()
        self.assertNotEqual(ncells, 0)
        self.assertEqual(ncells, sphere.GetOutput().GetNumberOfCells())
        self.assertEqual(output.GetBounds(), sphere.GetOutput().GetBounds())
    def testFilter(self):
        class MyAlgorithm(vta.VTKAlgorithm):
            def RequestData(self, vtkself, request, inInfo, outInfo):
                inp = self.GetInputData(inInfo, 0, 0)
                out = self.GetOutputData(outInfo, 0)
                out.ShallowCopy(inp)
                return 1

        sphere = vtk.vtkSphereSource()

        ex = vtk.vtkPythonAlgorithm()
        ex.SetPythonObject(MyAlgorithm())

        ex.SetInputConnection(sphere.GetOutputPort())

        ex.Update()

        output = ex.GetOutputDataObject(0)
        ncells = output.GetNumberOfCells()
        self.assertNotEqual(ncells, 0)
        self.assertEqual(ncells, sphere.GetOutput().GetNumberOfCells())
        self.assertEqual(output.GetBounds(), sphere.GetOutput().GetBounds())
    def testSource(self):
        class MyAlgorithm(vta.VTKAlgorithm):
            def __init__(self):
                vta.VTKAlgorithm.__init__(self,
                                          nInputPorts=0,
                                          outputType='vtkImageData')
                self.Wavelet = vtk.vtkRTAnalyticSource()

            def RequestInformation(self, vtkself, request, inInfo, outInfo):
                self.Wavelet.UpdateInformation()
                wOutInfo = self.Wavelet.GetOutputInformation(0)
                vtkSDDP = vtk.vtkStreamingDemandDrivenPipeline
                outInfo.GetInformationObject(0).Set(
                    vtkSDDP.WHOLE_EXTENT(),
                    wOutInfo.Get(vtkSDDP.WHOLE_EXTENT()), 6)
                return 1

            def RequestData(self, vtkself, request, inInfo, outInfo):
                self.Wavelet.Update()
                out = self.GetOutputData(outInfo, 0)
                out.ShallowCopy(self.Wavelet.GetOutput())
                return 1

        ex = vtk.vtkPythonAlgorithm()
        ex.SetPythonObject(MyAlgorithm())

        ex.Update()

        w = vtk.vtkRTAnalyticSource()
        w.Update()

        output = ex.GetOutputDataObject(0)
        self.assertEqual(output.GetPointData().GetScalars().GetRange(),\
            w.GetOutput().GetPointData().GetScalars().GetRange())
        vtkSDDP = vtk.vtkStreamingDemandDrivenPipeline
        self.assertEqual(ex.GetOutputInformation(0).Get(vtkSDDP.WHOLE_EXTENT()),\
            w.GetOutputInformation(0).Get(vtkSDDP.WHOLE_EXTENT()))
  print 'grank: ' + str(grank)
  
  localSize = gsize / NUM_NODES
  localGroup = grank / localSize
  
  r = vtk.vtkEnsembleSource()
  
  table = vtk.vtkTable()
  table.SetNumberOfRows(MEMBERS)
  
  aColumn = vtk.vtkIntArray()
  aColumn.SetName("Ensemble Index")
 
  for mem in range(1,MEMBERS+1):
      # Add source / reader
      ps = vtk.vtkPythonAlgorithm()
      ps.SetPythonObject(EnsembleReader(mem))
      r.AddMember(ps)
       
      aColumn.InsertNextValue(mem)
      
  table.GetRowData().AddArray(aColumn)
  r.SetMetaData(table)
  r.UpdateInformation()
  outInfo = r.GetOutputInformation(0)
  outInfo.Set(vtk.vtkEnsembleSource.UPDATE_MEMBER(), localGroup)
  r.Update()
 
  st = vtk.vtkStreamTracer()
  
  #will need vtkDummyController for earlier versions of VTK
Exemple #6
0
        outMask = vtk.vtkBitArray()
        outMask.SetNumberOfTuples(out.GetNumberOfVertices())

        cursor = vtk.vtkHyperTreeGridNonOrientedCursor()
        for treeId in range(inp.GetMaxNumberOfTrees()):
            inp.InitializeNonOrientedCursor(cursor, treeId)
            self.RecursiveProcess(cursor, scalar, outMask)

        out.SetMask(outMask)
        return 1


myAlgo = MyAlgorithm()
myAlgo.SetSelectValue(1)  # 1 or -1

ex = vtk.vtkPythonAlgorithm()
ex.SetPythonObject(myAlgo)
ex.SetInputConnection(depth.GetOutputPort())

ex.Update()

from vtk.util.misc import vtkGetTempDir

nrep = vtkGetTempDir()

withAscii = False
if withAscii:
    filename = nrep + 'toto_1_ascii.htg'
else:
    filename = nrep + 'toto_1_binary.htg'
#Avant writer default (1.0)