Advertisement
Guest User

vtk memory test

a guest
Aug 29th, 2012
154
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import sys
  2. import time
  3. import vtk
  4.  
  5. def test_mem(filename):
  6.     reader = vtk.vtkXMLPolyDataReader()
  7.     reader.SetFileName(filename)
  8.     reader.ReleaseDataFlagOn()
  9.     reader.GetOutput().ReleaseDataFlagOn()
  10.     reader.Update()
  11.  
  12.     polydata = reader.GetOutput()
  13.     polydata.SetSource(None)
  14.     del reader
  15.  
  16.     smoother = vtk.vtkWindowedSincPolyDataFilter()
  17.     smoother.SetInput(polydata)
  18.     smoother.SetNumberOfIterations(2)
  19.     smoother.SetFeatureAngle(120)
  20.     smoother.SetEdgeAngle(90.0)
  21.     smoother.BoundarySmoothingOn()
  22.     smoother.SetPassBand(0.1)
  23.     smoother.ReleaseDataFlagOn()
  24.     smoother.GetOutput().ReleaseDataFlagOn()
  25.     smoother.Update()
  26.  
  27.     del polydata
  28.     polydata = smoother.GetOutput()
  29.     polydata.SetSource(None)
  30.     del smoother
  31.  
  32.     decimation = vtk.vtkQuadricDecimation()
  33.     decimation.SetInput(polydata)
  34.     decimation.SetTargetReduction(0.5)
  35.     decimation.ReleaseDataFlagOn()
  36.     decimation.GetOutput().ReleaseDataFlagOn()
  37.     decimation.Update()
  38.  
  39.     del polydata
  40.     polydata = decimation.GetOutput()
  41.     polydata.SetSource(None)
  42.     del decimation
  43.  
  44.     normals = vtk.vtkPolyDataNormals()
  45.     normals.SetInput(polydata)
  46.     normals.SetFeatureAngle(80)
  47.     normals.AutoOrientNormalsOn()
  48.     normals.ReleaseDataFlagOn()
  49.     normals.GetOutput().ReleaseDataFlagOn()
  50.     normals.Update()
  51.  
  52.     del polydata
  53.     polydata = normals.GetOutput()
  54.     polydata.SetSource(None)
  55.     del normals
  56.  
  57.     stripper = vtk.vtkStripper()
  58.     stripper.SetInput(polydata)
  59.     stripper.PassThroughCellIdsOn()
  60.     stripper.PassThroughPointIdsOn()
  61.     stripper.ReleaseDataFlagOn()
  62.     stripper.GetOutput().ReleaseDataFlagOn()
  63.     stripper.Update()
  64.  
  65.     del polydata
  66.     polydata = stripper.GetOutput()
  67.     polydata.SetSource(None)
  68.     del stripper
  69.  
  70. def main():
  71.     test_mem(sys.argv[-1])
  72.  
  73. if __name__ == '__main__':
  74.     main()
Advertisement
RAW Paste Data Copied
Advertisement