[Paraview] Doubts in paraview scripting.

Raashid Baig raashid.b at rediffmail.com
Mon Jun 18 08:50:45 EDT 2007


I have some elementary doubts regarding python scripts in paraview :

1. Can we get the normal VTK pipeline working in paraview.
   
   If we just want to have the conventional VTK pipeline in paraview script the script does not seem to work

      import paraview

      paraview.ActiveConnection = paraview.Connect()

      reader = paraview.CreateProxy("sources", "XMLUnstructuredGridReader", "sources")

      pyproxy = paraview.pyProxy(reader)
      pyproxy.SetFileName("fire_ug.vtu")
      pyproxy.UpdateVTKObjects()

      isosurface_filter = paraview.CreateProxy("filters", "Contour", "filters")

      pyproxy1 = paraview.pyProxy(isosurface_filter)
      pyproxy1.SetInput(reader)
      pyproxy1.SetContourValues(298.38, 396.84, 495.31, 593.775, 692)
      pyproxy1.UpdateVTKObjects()

      mapper = paraview.CreateProxy("mappers", "PolyDataMapper", "mappers")
      pyproxy2 = paraview.pyProxy(mapper)
      pyproxy2.SetInput(isosurface_filter)
      
      actor = paraview.CreateProxy("props", "Actor", "props")
      pyproxy3 = paraview.pyProxy(actor)
      pyproxy3.SetMapper(mapper)

      renderer = paraview.CreateProxy("renderers", "Renderer", "renderers")
      pyproxy4 = paraview.pyProxy(renderer)
      
      outline_filter = paraview.CreateProxy("filters", "OutlineFilter", "filters")
      pyproxy5 = paraview.pyProxy(outline_filter)
      pyproxy5.SetInput(reader)

      renWin = paraview.CreateRenderWindow()

      display1 = paraview.CreateDisplay(isosurface_filter, renWin)
      display2 = paraview.CreateDisplay(outline_filter, renWin)

      renWin.ResetCamera()
      renWin.StillRender()
      raw_input("Enter")      

      Traceback (most recent call last):
	File "test5.py", line 24, in <module>
	     pyproxy3.SetMapper(mapper)
	File "/home/raashid/Desktop/paraview-3.0.1-Linux-x86/lib/paraview-3.0/paraview/__init__.py", line 250, in __getattr__
	     if re.compile("^Set").match(name) and self.SMProxy.GetProperty(name[3:]):
      TypeError: __GetProperty() takes exactly 1 argument (2 given)

      Renderer : ['AutomaticLightCreation', 'Background',
      'DepthPeeling', 'Erase', 'Layer', 'Lights', 'ViewProps',
      'Viewport'] 
      The Renderder does not have a AddActor() method.

      Render Window : ['CacheLimit', 'CacheUpdate', 'Displays',
      'GUISize', 'InteractiveRender', 'InvalidateGeometry',
      'LODResolution', 'LODThreshold', 'RenderInterruptsEnabled',
      'StillRender', 'UseImmediateMode', 'UseLight',
      'UseTriangleStrips', 'ViewTime', 'WindowPosition',
      'BackLightAzimuth', 'BackLightElevation', 'BackLightK:B Ratio',
      'BackLightWarmth', 'Background', 'CameraClippingRange',
      'CameraClippingRangeInfo', 'CameraFocalPoint',
      'CameraFocalPointInfo', 'CameraParallelProjection',
      'CameraParallelScale', 'CameraPosition', 'CameraPositionInfo',
      'CameraViewAngle', 'CameraViewUp', 'CameraViewUpInfo',
      'CenterOfRotation', 'EyeAngle', 'FillLightAzimuth',
      'FillLightElevation', 'FillLightK:F Ratio', 'FillLightWarmth',
      'FullScreen', 'HeadLightK:H Ratio', 'HeadLightWarmth',
      'InteractorStyle', 'KeyLightAzimuth', 'KeyLightElevation',
      'KeyLightIntensity', 'KeyLightWarmth', 'LightAmbientColor',
      'LightDiffuseColor', 'LightIntensity', 'LightSpecularColor',
      'LightSwitch', 'MaintainLuminance', 'OffScreenRendering',
      'RenderWindowSize', 'RenderWindowSizeInfo', 'Viewport']
      The Render Window does not have a AddRenderer() method.
  

2. How to get the scaler range of a given dataset. 

   The normal vtk script that I have written for the velocity glyph for a particular data-set is :

      import vtk

      reader = vtk.vtkXMLUnstructuredGridReader() 
      reader.SetFileName("fire_ug.vtu")
      reader.Update()

      range = reader.GetOutput().GetScalarRange()

   .................... the usual VTK pipeline

   How do we get the scaler range in paraview


3. How to color the Iso-surfaces.
   
      import vtk

      reader = vtk.vtkXMLUnstructuredGridReader() 
      reader.SetFileName("fire_ug.vtu")
      reader.Update()

      range = reader.GetOutput().GetScalarRange()

      iso = vtk.vtkContourFilter()   
      iso.SetInput(reader.GetOutput())
      iso.GenerateValues(50,range) 

      isoMapper = vtk.vtkPolyDataMapper()
      isoMapper.SetInput(iso.GetOutput())
      isoMapper.SetScalarRange(reader.GetOutput().GetScalarRange())

   .................... the usual VTK pipeline

   Poly Data Mapper
   None
   None
   None
   ['ClippingPlanes', 'ColorArray', 'ColorMode', 'ImmediateModeRendering', 'Input', 'InterpolateScalarsBeforeMapping', 'LookupTable', 
    'MapScalars', 'NumberOfSubPieces', 'ScalarMode', 'ScalarVisibility', 'UseLookupTableScalarRange']
   
   PolyDataMapper does not seem to have a ScalerRange method.


4. SetFactor not working with the Velocity glyph, and how to use the other parameters ?

   The normal vtk script that I have written for the velocity glyph for a particular data-set is :
   
      import vtk

      reader = vtk.vtkXMLUnstructuredGridReader() 
      reader.SetFileName("fire_ug.vtu")
      reader.Update()

      arrow = vtk.vtkArrowSource()

      glyph = vtk.vtkGlyph3D()
      glyph.SetInput(reader.GetOutput())
      glyph.SetSource(arrow.GetOutput())
      glyph.SetVectorModeToUseVector()
      glyph.SetScaleModeToScaleByVector()
      glyph.SetScaleFactor(0.1)

   .................... the usual VTK pipeline

   The corresponding paraview script that I have written is :

      import paraview

      paraview.ActiveConnection = paraview.Connect()

      reader = paraview.CreateProxy("sources", "XMLUnstructuredGridReader", "sources")

      pyproxy = paraview.pyProxy(reader)
      pyproxy.SetFileName("fire_ug.vtu")
      pyproxy.UpdateVTKObjects()

      arrow = paraview.CreateProxy("sources", "ArrowSource", "sources")

      glyph = paraview.CreateProxy("filters", "Glyph", "filters")
      pyproxy1 = paraview.pyProxy(glyph)
      pyproxy1.SetInput(reader)
      pyproxy1.SetSource(arrow)
      pyproxy1.SetScaleMode = "Vector"
      pyproxy1.SetScaleFactor = 0.1
      pyproxy1.UpdateVTKObjects()

   .................... the usual paraview pipeline

   The problem is that the SetScaleFactor dose not seem to have any effect and the velocity Glyph's dose not scale
   What will be the corresponding paraview script for above vtk one.

5. How to get an Event/Observer pattern of VTK work in paraview ?
   I cannot find an AddObserver() method for any 3d_widgets.   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/paraview/attachments/20070618/7fcb8f66/attachment.htm


More information about the ParaView mailing list