Exemplo n.º 1
0
 def __init__(self, module_manager):
     SimpleVTKClassModuleBase.__init__(
         self, module_manager,
         vtk.vtkTimeSourceExample(), 'Processing.',
         (), ('vtkImageData',),
         replaceDoc=True,
         inputFunctions=None, outputFunctions=None)
Exemplo n.º 2
0
def main():
    time_source = vtk.vtkTimeSourceExample()

    exodus_writer = vtk.vtkExodusIIWriter()
    exodus_writer.SetFileName("output.exii")
    exodus_writer.SetInputConnection(time_source.GetOutputPort())
    exodus_writer.WriteAllTimeStepsOn()
    exodus_writer.Write()
Exemplo n.º 3
0
def RunTest():
    fail = False

    print "TEST SET 1 - verify reader/writer work for range of canonical datasets"
    print MemUsage("Before starting TEST SET 1")
    dog = vtk.vtkDataObjectGenerator()
    i = 0
    for testObject in testObjects:
        fileName = "xdmfIOtest_" + str(i)
        print "Test vtk object", testObject
        dog.SetProgram(testObject)
        dog.Update()
        TestXdmfConversion(dog.GetOutput(), fileName)
        i += 1

    print "TEST SET 2 - verify reader/writer work for Graphs"
    print MemUsage("Before starting TEST SET 2")
    print "Test Graph data"
    gsrc = vtk.vtkRandomGraphSource()
    gsrc.DirectedOn()
    gsrc.Update()
    gFilePrefix = "xdmfIOtest_Graph"
    gFileName = OutputDir + gFilePrefix + ".xdmf"
    ghFileName = OutputDir + gFilePrefix + ".h5"
    xWriter = vtk.vtkXdmf3Writer()
    xWriter.SetLightDataLimit(LightDataLimit)
    xWriter.SetFileName(gFileName)
    xWriter.SetInputConnection(0, gsrc.GetOutputPort(0))
    timer.StartTimer()
    xWriter.Write()
    timer.StopTimer()
    print "vtkXdmf3Writer took", timer.GetElapsedTime(), "seconds to write",\
      gFileName
    xReader = vtk.vtkXdmf3Reader()
    xReader.SetFileName(gFileName)
    xReader.Update()
    rOutput = xReader.GetOutputDataObject(0)
    fail = DoDataObjectsDiffer(gsrc.GetOutputDataObject(0),
                               xReader.GetOutputDataObject(0))
    if fail:
        raiseErrorAndExit("Failed graph conversion test")
    if not DoFilesExist(gFileName, ghFileName, None, CleanUpGood):
        raiseErrorAndExit("Failed to write Graph file")

    print "TEST SET 3 - verify reader/writer handle time varying data"
    print MemUsage("Before starting TEST SET 3")
    print "Test temporal data"
    tsrc = vtk.vtkTimeSourceExample()
    tsrc.GrowingOn()
    tsrc.SetXAmplitude(2.0)
    tFilePrefix = "xdmfIOTest_Temporal"
    tFileName = OutputDir + tFilePrefix + ".xdmf"
    thFileName = OutputDir + tFilePrefix + ".h5"
    xWriter = vtk.vtkXdmf3Writer()
    xWriter.SetLightDataLimit(LightDataLimit)
    xWriter.WriteAllTimeStepsOn()
    xWriter.SetFileName(tFileName)
    xWriter.SetInputConnection(0, tsrc.GetOutputPort(0))
    timer.StartTimer()
    xWriter.Write()
    timer.StopTimer()
    print "vtkXdmf3Writer took", timer.GetElapsedTime(), "seconds to write",\
      tFileName
    xReader = vtk.vtkXdmf3Reader()
    xReader.SetFileName(tFileName)
    xReader.UpdateInformation()
    oi = xReader.GetOutputInformation(0)
    timerange = oi.Get(vtk.vtkCompositeDataPipeline.TIME_STEPS())
    ii = tsrc.GetOutputInformation(0)
    correcttimes = ii.Get(vtk.vtkCompositeDataPipeline.TIME_STEPS())

    #compare number of and values for temporal range
    if len(timerange) != len(correcttimes):
        print "timesteps failed"
        print timerange, "!=", correcttimes
        raiseErrorAndExit("Failed to get same times")
    for i in xrange(0, len(correcttimes)):
        if abs(abs(timerange[i]) - abs(correcttimes[i])) > 0.000001:
            print "time result failed"
            print timerange, "!=", correcttimes
            raiseErrorAndExit("Failed to get same times")

    #exercise temporal processing and compare geometric bounds at each tstep
    indices = range(0, len(timerange)) + range(len(timerange) - 2, -1, -1)
    for x in indices:
        xReader.GetExecutive().SetUpdateTimeStep(0, timerange[x])
        xReader.Update()
        obds = xReader.GetOutputDataObject(0).GetBounds()
        tsrc.GetExecutive().SetUpdateTimeStep(
            0, timerange[x] + 0.0001)  #workaround a precision bug in TSE
        tsrc.Update()
        ibds = tsrc.GetOutputDataObject(0).GetBounds()
        print timerange[x], obds
        for i in (0, 1, 2, 3, 4, 5):
            if abs(abs(obds[i]) - abs(ibds[i])) > 0.000001:
                print "time result failed"
                print obds, "!=", ibds
                raiseErrorAndExit("Failed to get same data for this timestep")
    fail = DoFilesExist(tFileName, thFileName, None, CleanUpGood)
    if not fail:
        raiseErrorAndExit("Failed Temporal Test")

    print MemUsage("End of Testing")
Exemplo n.º 4
0
def RunTest():
  fail = False

  print "TEST SET 1 - verify reader/writer work for range of canonical datasets"
  print MemUsage("Before starting TEST SET 1")
  dog = vtk.vtkDataObjectGenerator()
  i = 0
  for testObject in testObjects:
    fileName = "xdmfIOtest_" + str(i)
    print "Test vtk object", testObject
    dog.SetProgram(testObject)
    dog.Update()
    TestXdmfConversion(dog.GetOutput(), fileName)
    i += 1

  print "TEST SET 2 - verify reader/writer work for Graphs"
  print MemUsage("Before starting TEST SET 2")
  print "Test Graph data"
  gsrc = vtk.vtkRandomGraphSource()
  gsrc.DirectedOn()
  gsrc.Update()
  gFilePrefix = "xdmfIOtest_Graph"
  gFileName = OutputDir + gFilePrefix + ".xdmf"
  ghFileName = OutputDir + gFilePrefix + ".h5"
  xWriter = vtk.vtkXdmf3Writer()
  xWriter.SetLightDataLimit(LightDataLimit)
  xWriter.SetFileName(gFileName)
  xWriter.SetInputConnection(0, gsrc.GetOutputPort(0))
  timer.StartTimer()
  xWriter.Write()
  timer.StopTimer()
  print "vtkXdmf3Writer took", timer.GetElapsedTime(), "seconds to write",\
    gFileName
  xReader = vtk.vtkXdmf3Reader()
  xReader.SetFileName(gFileName)
  xReader.Update()
  rOutput = xReader.GetOutputDataObject(0)
  fail = DoDataObjectsDiffer(gsrc.GetOutputDataObject(0), xReader.GetOutputDataObject(0))
  if fail:
    raiseErrorAndExit("Failed graph conversion test")
  if not DoFilesExist(gFileName, ghFileName, None, CleanUpGood):
    raiseErrorAndExit("Failed to write Graph file")

  print "TEST SET 3 - verify reader/writer handle time varying data"
  print MemUsage("Before starting TEST SET 3")
  print "Test temporal data"
  tsrc = vtk.vtkTimeSourceExample()
  tsrc.GrowingOn()
  tsrc.SetXAmplitude(2.0)
  tFilePrefix = "xdmfIOTest_Temporal"
  tFileName = OutputDir + tFilePrefix + ".xdmf"
  thFileName = OutputDir + tFilePrefix + ".h5"
  xWriter = vtk.vtkXdmf3Writer()
  xWriter.SetLightDataLimit(LightDataLimit)
  xWriter.WriteAllTimeStepsOn()
  xWriter.SetFileName(tFileName)
  xWriter.SetInputConnection(0, tsrc.GetOutputPort(0))
  timer.StartTimer()
  xWriter.Write()
  timer.StopTimer()
  print "vtkXdmf3Writer took", timer.GetElapsedTime(), "seconds to write",\
    tFileName
  xReader = vtk.vtkXdmf3Reader()
  xReader.SetFileName(tFileName)
  xReader.UpdateInformation()
  oi = xReader.GetOutputInformation(0)
  timerange = oi.Get(vtk.vtkCompositeDataPipeline.TIME_STEPS())
  ii = tsrc.GetOutputInformation(0)
  correcttimes = ii.Get(vtk.vtkCompositeDataPipeline.TIME_STEPS())

  #compare number of and values for temporal range
  if len(timerange) != len(correcttimes):
    print "timesteps failed"
    print timerange, "!=", correcttimes
    raiseErrorAndExit("Failed to get same times")
  for i in xrange(0, len(correcttimes)):
    if abs(abs(timerange[i])-abs(correcttimes[i])) > 0.000001:
      print "time result failed"
      print timerange, "!=", correcttimes
      raiseErrorAndExit("Failed to get same times")

  #exercise temporal processing and compare geometric bounds at each tstep
  indices = range(0,len(timerange)) + range(len(timerange)-2,-1,-1)
  for x in indices:
      xReader.UpdateTimeStep(timerange[x])
      obds = xReader.GetOutputDataObject(0).GetBounds()
      tsrc.Update(timerange[x]+0.0001) #workaround a precision bug in TSE
      ibds = tsrc.GetOutputDataObject(0).GetBounds()
      print timerange[x], obds
      for i in (0,1,2,3,4,5):
        if abs(abs(obds[i])-abs(ibds[i])) > 0.000001:
          print "time result failed"
          print obds, "!=", ibds
          raiseErrorAndExit("Failed to get same data for this timestep")
  fail = DoFilesExist(tFileName, thFileName, None, CleanUpGood)
  if not fail:
    raiseErrorAndExit("Failed Temporal Test")

  print MemUsage("End of Testing")