Commit 4a878122 authored by Philippe Pébay's avatar Philippe Pébay
Browse files

An example reading AVS/UCD binary file for Youngs Material Interface

Change-Id: I03a1ab40b8c7faffb74cfd339369c559633f7dc8
parent 8f734518
############################################################
from vtk import *
from vtk.util.misc import vtkGetDataRoot
############################################################
# Retrieve data root
VTK_DATA_ROOT = vtkGetDataRoot()
# Read from AVS UCD data in binary form
reader = vtkAVSucdReader()
reader.SetFileName( VTK_DATA_ROOT + "/Data/UCD/UCD_00005.inp" )
# Update reader and get cell data
reader.Update()
cellData = reader.GetOutput().GetCellData()
cellData.SetActiveScalars("Material Id")
# Create mapper
mapper = vtkDataSetMapper()
mapper.SetInputConnection( reader.GetOutputPort() )
mapper.SetScalarRange( cellData.GetScalars().GetRange() )
mapper.SetScalarModeToUseCellData()
mapper.SetColorModeToMapScalars()
mapper.ScalarVisibilityOn()
# Create actor
actor = vtkActor()
actor.SetMapper( mapper )
#actor.GetProperty().SetRepresentationToWireframe()
# Create renderer
renderer = vtkRenderer()
renderer.AddViewProp( actor )
renderer.SetBackground( .3, .4 ,.5 )
# Create render window
window = vtkRenderWindow()
window.AddRenderer( renderer )
window.SetSize( 500, 500 )
# Create interactor
interactor = vtkRenderWindowInteractor()
interactor.SetRenderWindow( window )
# Start interaction
window.Render()
interactor.Start()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment