[vtkusers] problem with unstructured grid

Silke.Karner at ecs.steyr.com Silke.Karner at ecs.steyr.com
Tue Jul 2 21:11:57 EDT 2002


Hi!
Hope somebody can help me. I have to write a tool to visualize very large
data sets in the form of an unstructured grid. But the visualization runs
very slow when you try to zoom or move it. And although it draws everything
as it should, I get an error message:

---------
ERROR In vtkFieldDataToAttributeDataFilter.cxx, line 345
vtkFieldDataToAttributeDataFilter (0x20327f38): Can't find array/component
requested
ERROR In vtkWarpVector.cxx, line 61
vtkWarpVector (0x20337038): No input data
--------------

At the moment eyerything is drawn in wireframe, and it's slow. But later it
should be hidden-line or coloured. I have not tried how slow it'll be then.
I post a part of the code. Maybe I have understand something wrong cause
I'am a newbie to vtk and tcl/tk.

Thanks for any help
Silke

-------------------
  # create graphics object
  vtkTkRenderWidget $rgui.render_widget
  set renWin $rgui.render_widget
  pack $renWin -fill both -expand true
  set renWin [$renWin GetRenderWindow]
  
  # create a reader for the data file and write out the field
  vtkUnstructuredGridReader reader
    reader SetFileName "cube_testfile.vtk"
    reader SetScalarsName "pressure"
  vtkDataSetToDataObjectFilter ds2do
    ds2do SetInput [reader GetOutput]
  if {[catch {set channel [open CubeField.vtk w]}] == 0 } {
    close $channel
    vtkDataObjectWriter writer
      writer SetInput [ds2do GetOutput]
      writer SetFileName "CubeField.vtk"
      writer Write

  # create pipeline for visualization
  vtkDataObjectReader dor
    dor SetFileName "CubeField.vtk"
  vtkDataObjectToDataSetFilter do2ds
    do2ds SetInput [dor GetOutput]
    do2ds SetDataSetTypeToUnstructuredGrid
    do2ds SetPointComponent 0 Points 0 
    do2ds SetPointComponent 1 Points 1 
    do2ds SetPointComponent 2 Points 2 
    do2ds SetCellConnectivityComponent Cells 0
    do2ds SetCellTypeComponent CellTypes 0
  vtkFieldDataToAttributeDataFilter fd2ad
    fd2ad SetInput [do2ds GetUnstructuredGridOutput]
    fd2ad SetInputFieldToDataObjectField
    fd2ad SetOutputAttributeDataToPointData
    fd2ad SetScalarComponent 0 pressure 0 

  # Now start visualizing
  vtkWarpVector warp
    warp SetInput [fd2ad GetUnstructuredGridOutput]
  vtkConnectivityFilter connect
    connect SetInput [warp GetOutput]
    connect SetExtractionModeToSpecifiedRegions
    connect AddSpecifiedRegion 0
    connect AddSpecifiedRegion 1
  vtkDataSetMapper moldMapper
    moldMapper SetInput [connect GetOutput]
    moldMapper ScalarVisibilityOn
  # draws a wireframe model
  vtkActor actor
    actor SetMapper moldMapper
    [actor GetProperty] SetColor 1 1 1
    [actor GetProperty] SetRepresentationToWireframe
  # Scalar Bar (has no connection to the cubes at the moment)
  vtkScalarBarActor scalarBar
    scalarBar SetLookupTable [moldMapper GetLookupTable]
    scalarBar SetTitle "Stress"
    [scalarBar GetPositionCoordinate] \
    SetCoordinateSystemToNormalizedViewport
    [scalarBar GetPositionCoordinate] SetValue 0.1 0.01
    scalarBar SetOrientationToVertical
    scalarBar SetWidth 0.10
    scalarBar SetHeight 1.0
    
  # create the renderWindow, renderer and actors
  vtkRenderer ren1
  $renWin AddRenderer ren1
  vtkRenderWindowInteractor iren
  iren SetRenderWindow $renWin
  ren1 AddActor actor
  ren1 AddActor scalarBar
  ren1 SetBackground 0.5 0.5 0.5
  iren Initialize
-----------





More information about the vtkusers mailing list