Commit a2a0e08f authored by Nikhil Shetty's avatar Nikhil Shetty

Adding IOGeometry python tests

Change-Id: Ifa7aafd4600ebd975b42a1cf2bba77117067c60e
parent 5c0bfb43
add_test_python(ParticleReader.py IO)
add_test_python(Plot3DScalars.py IO)
add_test_python(Plot3DVectors.py IO)
add_test_python(TestAVSucdReader.py IO)
add_test_python(TestGAMBITReader.py IO)
add_test_python(TestPolygonWriters.py IO)
add_test_python(TestXYZMol.py IO)
add_test_python(caffeine.py IO)
add_test_python(motor.py Graphics)
add_test_python(testHexaPenta.py Graphics)
#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
# Create the RenderWindow, Renderer and both Actors
#
ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
reader = vtk.vtkParticleReader()
reader.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/Particles.raw")
reader.SetDataByteOrderToBigEndian()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(reader.GetOutputPort())
mapper.SetScalarRange(4,9)
mapper.SetPiece(1)
mapper.SetNumberOfPieces(2)
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetPointSize(2.5)
# Add the actors to the renderer, set the background and size
#
ren1.AddActor(actor)
ren1.SetBackground(0,0,0)
renWin.SetSize(200,200)
# Get handles to some useful objects
#
iren.Initialize()
renWin.Render()
# prevent the tk window from showing up then start the event loop
# --- end of script --
#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
#
# All Plot3D scalar functions
#
# Create the RenderWindow, Renderer and both Actors
#
renWin = vtk.vtkRenderWindow()
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
scalarLabels = "Density Pressure Temperature Enthalpy Internal_Energy Kinetic_Energy Velocity_Magnitude Stagnation_Energy Entropy Swirl"
scalarFunctions = "100 110 120 130 140 144 153 163 170 184"
camera = vtk.vtkCamera()
light = vtk.vtkLight()
math = vtk.vtkMath()
# All text actors will share the same text prop
textProp = vtk.vtkTextProperty()
textProp.SetFontSize(10)
textProp.SetFontFamilyToArial()
textProp.SetColor(0,0,0)
i = 0
for scalarFunction in scalarFunctions.split():
locals()[get_variable_name("pl3d", scalarFunction, "")] = vtk.vtkMultiBlockPLOT3DReader()
locals()[get_variable_name("pl3d", scalarFunction, "")].SetXYZFileName("" + str(VTK_DATA_ROOT) + "/Data/bluntfinxyz.bin")
locals()[get_variable_name("pl3d", scalarFunction, "")].SetQFileName("" + str(VTK_DATA_ROOT) + "/Data/bluntfinq.bin")
locals()[get_variable_name("pl3d", scalarFunction, "")].SetScalarFunctionNumber(expr.expr(globals(), locals(),["int","(","scalarFunction",")"]))
locals()[get_variable_name("pl3d", scalarFunction, "")].Update()
output = locals()[get_variable_name("pl3d", scalarFunction, "")].GetOutput().GetBlock(0)
locals()[get_variable_name("plane", scalarFunction, "")] = vtk.vtkStructuredGridGeometryFilter()
locals()[get_variable_name("plane", scalarFunction, "")].SetInputData(output)
locals()[get_variable_name("plane", scalarFunction, "")].SetExtent(25,25,0,100,0,100)
locals()[get_variable_name("mapper", scalarFunction, "")] = vtk.vtkPolyDataMapper()
locals()[get_variable_name("mapper", scalarFunction, "")].SetInputConnection(locals()[get_variable_name("plane", scalarFunction, "")].GetOutputPort())
locals()[get_variable_name("mapper", scalarFunction, "")].SetScalarRange(output.GetPointData().GetScalars().GetRange())
locals()[get_variable_name("actor", scalarFunction, "")] = vtk.vtkActor()
locals()[get_variable_name("actor", scalarFunction, "")].SetMapper(locals()[get_variable_name("mapper", scalarFunction, "")])
locals()[get_variable_name("ren", scalarFunction, "")] = vtk.vtkRenderer()
locals()[get_variable_name("ren", scalarFunction, "")].SetBackground(0,0,.5)
locals()[get_variable_name("ren", scalarFunction, "")].SetActiveCamera(camera)
locals()[get_variable_name("ren", scalarFunction, "")].AddLight(light)
renWin.AddRenderer(locals()[get_variable_name("ren", scalarFunction, "")])
locals()[get_variable_name("ren", scalarFunction, "")].SetBackground(math.Random(.5,1),math.Random(.5,1),math.Random(.5,1))
locals()[get_variable_name("ren", scalarFunction, "")].AddActor(locals()[get_variable_name("actor", scalarFunction, "")])
locals()[get_variable_name("textMapper", scalarFunction, "")] = vtk.vtkTextMapper()
locals()[get_variable_name("textMapper", scalarFunction, "")].SetInput(lindex(scalarLabels,i))
locals()[get_variable_name("textMapper", scalarFunction, "")].SetTextProperty(textProp)
locals()[get_variable_name("text", scalarFunction, "")] = vtk.vtkActor2D()
locals()[get_variable_name("text", scalarFunction, "")].SetMapper(locals()[get_variable_name("textMapper", scalarFunction, "")])
locals()[get_variable_name("text", scalarFunction, "")].SetPosition(2,3)
if (info.command(globals(), locals(), "rtExMath") == ""):
locals()[get_variable_name("ren", scalarFunction, "")].AddActor2D(locals()[get_variable_name("text", scalarFunction, "")])
pass
i = i + 1
pass
#
# now layout renderers
column = 1
row = 1
deltaX = expr.expr(globals(), locals(),["1.0","/","5.0"])
deltaY = expr.expr(globals(), locals(),["1.0","/","2.0"])
for scalarFunction in scalarFunctions.split():
locals()[get_variable_name("ren", scalarFunction, "")].SetViewport(expr.expr(globals(), locals(),["(","column","-","1",")","*","deltaX"]),expr.expr(globals(), locals(),["(","row","-","1",")","*","deltaY"]),expr.expr(globals(), locals(),["column","*","deltaX"]),expr.expr(globals(), locals(),["row","*","deltaY"]))
column = column + 1
if (column > 5):
column = 1
row = row + 1
pass
pass
camera.SetViewUp(0,1,0)
camera.SetFocalPoint(0,0,0)
camera.SetPosition(1,0,0)
ren100.ResetCamera()
camera.Dolly(1.25)
ren100.ResetCameraClippingRange()
ren110.ResetCameraClippingRange()
ren120.ResetCameraClippingRange()
ren130.ResetCameraClippingRange()
ren140.ResetCameraClippingRange()
ren144.ResetCameraClippingRange()
ren153.ResetCameraClippingRange()
ren163.ResetCameraClippingRange()
ren170.ResetCameraClippingRange()
ren184.ResetCameraClippingRange()
light.SetPosition(camera.GetPosition())
light.SetFocalPoint(camera.GetFocalPoint())
renWin.SetSize(600,180)
renWin.Render()
iren.Initialize()
# render the image
#
# prevent the tk window from showing up then start the event loop
# --- end of script --
#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
#
# All Plot3D vector functions
#
# Create the RenderWindow, Renderer and both Actors
#
renWin = vtk.vtkRenderWindow()
renWin.SetMultiSamples(0)
ren1 = vtk.vtkRenderer()
ren1.SetBackground(.8,.8,.2)
renWin.AddRenderer(ren1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
vectorLabels = "Velocity Vorticity Momentum Pressure_Gradient"
vectorFunctions = "200 201 202 210"
camera = vtk.vtkCamera()
light = vtk.vtkLight()
# All text actors will share the same text prop
textProp = vtk.vtkTextProperty()
textProp.SetFontSize(10)
textProp.SetFontFamilyToArial()
textProp.SetColor(.3,1,1)
i = 0
for vectorFunction in vectorFunctions.split():
locals()[get_variable_name("pl3d", vectorFunction, "")] = vtk.vtkMultiBlockPLOT3DReader()
locals()[get_variable_name("pl3d", vectorFunction, "")].SetXYZFileName("" + str(VTK_DATA_ROOT) + "/Data/bluntfinxyz.bin")
locals()[get_variable_name("pl3d", vectorFunction, "")].SetQFileName("" + str(VTK_DATA_ROOT) + "/Data/bluntfinq.bin")
locals()[get_variable_name("pl3d", vectorFunction, "")].SetVectorFunctionNumber(expr.expr(globals(), locals(),["int","(","vectorFunction",")"]))
locals()[get_variable_name("pl3d", vectorFunction, "")].Update()
output = locals()[get_variable_name("pl3d", vectorFunction, "")].GetOutput().GetBlock(0)
locals()[get_variable_name("plane", vectorFunction, "")] = vtk.vtkStructuredGridGeometryFilter()
locals()[get_variable_name("plane", vectorFunction, "")].SetInputData(output)
locals()[get_variable_name("plane", vectorFunction, "")].SetExtent(25,25,0,100,0,100)
locals()[get_variable_name("hog", vectorFunction, "")] = vtk.vtkHedgeHog()
locals()[get_variable_name("hog", vectorFunction, "")].SetInputConnection(locals()[get_variable_name("plane", vectorFunction, "")].GetOutputPort())
maxnorm = output.GetPointData().GetVectors().GetMaxNorm()
locals()[get_variable_name("hog", vectorFunction, "")].SetScaleFactor(expr.expr(globals(), locals(),["1.0","/","maxnorm"]))
locals()[get_variable_name("mapper", vectorFunction, "")] = vtk.vtkPolyDataMapper()
locals()[get_variable_name("mapper", vectorFunction, "")].SetInputConnection(locals()[get_variable_name("hog", vectorFunction, "")].GetOutputPort())
locals()[get_variable_name("actor", vectorFunction, "")] = vtk.vtkActor()
locals()[get_variable_name("actor", vectorFunction, "")].SetMapper(locals()[get_variable_name("mapper", vectorFunction, "")])
locals()[get_variable_name("ren", vectorFunction, "")] = vtk.vtkRenderer()
locals()[get_variable_name("ren", vectorFunction, "")].SetBackground(0.5,.5,.5)
locals()[get_variable_name("ren", vectorFunction, "")].SetActiveCamera(camera)
locals()[get_variable_name("ren", vectorFunction, "")].AddLight(light)
renWin.AddRenderer(locals()[get_variable_name("ren", vectorFunction, "")])
locals()[get_variable_name("ren", vectorFunction, "")].AddActor(locals()[get_variable_name("actor", vectorFunction, "")])
locals()[get_variable_name("textMapper", vectorFunction, "")] = vtk.vtkTextMapper()
locals()[get_variable_name("textMapper", vectorFunction, "")].SetInput(lindex(vectorLabels,i))
locals()[get_variable_name("textMapper", vectorFunction, "")].SetTextProperty(textProp)
locals()[get_variable_name("text", vectorFunction, "")] = vtk.vtkActor2D()
locals()[get_variable_name("text", vectorFunction, "")].SetMapper(locals()[get_variable_name("textMapper", vectorFunction, "")])
locals()[get_variable_name("text", vectorFunction, "")].SetPosition(2,5)
if (info.command(globals(), locals(), "rtExMath") == ""):
locals()[get_variable_name("ren", vectorFunction, "")].AddActor2D(locals()[get_variable_name("text", vectorFunction, "")])
pass
i = i + 1
pass
#
# now layout renderers
column = 1
row = 1
deltaX = expr.expr(globals(), locals(),["1.0","/","2.0"])
deltaY = expr.expr(globals(), locals(),["1.0","/","2.0"])
for vectorFunction in vectorFunctions.split():
locals()[get_variable_name("ren", vectorFunction, "")].SetViewport(expr.expr(globals(), locals(),["(","column","-","1",")","*","deltaX","+","(","deltaX","*",".05",")"]),expr.expr(globals(), locals(),["(","row","-","1",")","*","deltaY","+","(","deltaY","*",".05",")"]),expr.expr(globals(), locals(),["column","*","deltaX","-","(","deltaX","*",".05",")"]),expr.expr(globals(), locals(),["row","*","deltaY","-","(","deltaY","*",".05",")"]))
column = column + 1
if (column > 2):
column = 1
row = row + 1
pass
pass
camera.SetViewUp(1,0,0)
camera.SetFocalPoint(0,0,0)
camera.SetPosition(.4,-.5,-.75)
ren200.ResetCamera()
camera.Dolly(1.25)
ren200.ResetCameraClippingRange()
ren201.ResetCameraClippingRange()
ren202.ResetCameraClippingRange()
ren210.ResetCameraClippingRange()
light.SetPosition(camera.GetPosition())
light.SetFocalPoint(camera.GetFocalPoint())
renWin.SetSize(350,350)
renWin.Render()
iren.Initialize()
# render the image
#
# prevent the tk window from showing up then start the event loop
# --- end of script --
#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
# Read some AVS UCD data in ASCII form
r = vtk.vtkAVSucdReader()
r.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/cellsnd.ascii.inp")
AVSMapper = vtk.vtkDataSetMapper()
AVSMapper.SetInputConnection(r.GetOutputPort())
AVSActor = vtk.vtkActor()
AVSActor.SetMapper(AVSMapper)
# Read some AVS UCD data in binary form
r2 = vtk.vtkAVSucdReader()
r2.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/cellsnd.bin.inp")
AVSMapper2 = vtk.vtkDataSetMapper()
AVSMapper2.SetInputConnection(r2.GetOutputPort())
AVSActor2 = vtk.vtkActor()
AVSActor2.SetMapper(AVSMapper2)
AVSActor2.AddPosition(5,0,0)
# Create the RenderWindow, Renderer and both Actors
#
ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# Add the actors to the renderer, set the background and size
#
ren1.AddActor(AVSActor)
ren1.AddActor(AVSActor2)
renWin.SetSize(300,150)
iren.Initialize()
renWin.Render()
ren1.GetActiveCamera().Zoom(2)
# prevent the tk window from showing up then start the event loop
# --- end of script --
#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
# Read some Fluent GAMBIT in ASCII form
reader = vtk.vtkGAMBITReader()
reader.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/prism.neu")
mapper = vtk.vtkDataSetMapper()
mapper.SetInputConnection(reader.GetOutputPort())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
# Create the RenderWindow, Renderer and both Actors
#
ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# Add the actors to the renderer, set the background and size
#
ren1.AddActor(actor)
renWin.SetSize(300,300)
iren.Initialize()
renWin.Render()
# prevent the tk window from showing up then start the event loop
# --- end of script --
#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
# Create the RenderWindow, Renderer and both Actors
#
ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# read data
#
input = vtk.vtkPolyDataReader()
input.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/brainImageSmooth.vtk")
#
# generate vectors
clean = vtk.vtkCleanPolyData()
clean.SetInputConnection(input.GetOutputPort())
smooth = vtk.vtkWindowedSincPolyDataFilter()
smooth.SetInputConnection(clean.GetOutputPort())
smooth.GenerateErrorVectorsOn()
smooth.GenerateErrorScalarsOn()
smooth.Update()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(smooth.GetOutputPort())
mapper.SetScalarRange(smooth.GetOutput().GetScalarRange())
brain = vtk.vtkActor()
brain.SetMapper(mapper)
# Add the actors to the renderer, set the background and size
#
ren1.AddActor(brain)
renWin.SetSize(320,240)
ren1.GetActiveCamera().SetPosition(149.653,-65.3464,96.0401)
ren1.GetActiveCamera().SetFocalPoint(146.003,22.3839,0.260541)
ren1.GetActiveCamera().SetViewAngle(30)
ren1.GetActiveCamera().SetViewUp(-0.255578,-0.717754,-0.647695)
ren1.GetActiveCamera().SetClippingRange(79.2526,194.052)
iren.Initialize()
renWin.Render()
# render the image
#
# prevent the tk window from showing up then start the event loop
#
# If the current directory is writable, then test the witers
#
if (catch.catch(globals(),"""channel = open("test.tmp", "w")""") == 0):
channel.close()
file.delete("-force", "test.tmp")
#
#
# test the writers
dsw = vtk.vtkDataSetWriter()
dsw.SetInputConnection(smooth.GetOutputPort())
dsw.SetFileName("brain.dsw")
dsw.Write()
file.delete("-force", "brain.dsw")
pdw = vtk.vtkPolyDataWriter()
pdw.SetInputConnection(smooth.GetOutputPort())
pdw.SetFileName("brain.pdw")
pdw.Write()
file.delete("-force", "brain.pdw")
if (info.command(globals(), locals(), "vtkIVWriter") != ""):
iv = vtk.vtkIVWriter()
iv.SetInputConnection(smooth.GetOutputPort())
iv.SetFileName("brain.iv")
iv.Write()
file.delete("-force", "brain.iv")
pass
#
# the next writers only handle triangles
triangles = vtk.vtkTriangleFilter()
triangles.SetInputConnection(smooth.GetOutputPort())
if (info.command(globals(), locals(), "vtkIVWriter") != ""):
iv2 = vtk.vtkIVWriter()
iv2.SetInputConnection(triangles.GetOutputPort())
iv2.SetFileName("brain2.iv")
iv2.Write()
file.delete("-force", "brain2.iv")
pass
if (info.command(globals(), locals(), "vtkIVWriter") != ""):
edges = vtk.vtkExtractEdges()
edges.SetInputConnection(triangles.GetOutputPort())
iv3 = vtk.vtkIVWriter()
iv3.SetInputConnection(edges.GetOutputPort())
iv3.SetFileName("brain3.iv")
iv3.Write()
file.delete("-force", "brain3.iv")
pass
byu = vtk.vtkBYUWriter()
byu.SetGeometryFileName("brain.g")
byu.SetScalarFileName("brain.s")
byu.SetDisplacementFileName("brain.d")
byu.SetInputConnection(triangles.GetOutputPort())
byu.Write()
file.delete("-force", "brain.g")
file.delete("-force", "brain.s")
file.delete("-force", "brain.d")
mcubes = vtk.vtkMCubesWriter()
mcubes.SetInputConnection(triangles.GetOutputPort())
mcubes.SetFileName("brain.tri")
mcubes.SetLimitsFileName("brain.lim")
mcubes.Write()
file.delete("-force", "brain.lim")
file.delete("-force", "brain.tri")
stl = vtk.vtkSTLWriter()
stl.SetInputConnection(triangles.GetOutputPort())
stl.SetFileName("brain.stl")
stl.Write()
file.delete("-force", "brain.stl")
stlBinary = vtk.vtkSTLWriter()
stlBinary.SetInputConnection(triangles.GetOutputPort())
stlBinary.SetFileName("brainBinary.stl")
stlBinary.SetFileType(2)
stlBinary.Write()
file.delete("-force", "brainBinary.stl")
cgm = vtk.vtkCGMWriter()
cgm.SetInputConnection(triangles.GetOutputPort())
cgm.SetFileName("brain.cgm")
cgm.Write()
file.delete("-force", "brain.cgm")
pass
# --- end of script --
#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
ren1 = vtk.vtkRenderer()
ren1.SetBackground(0,0,0)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
renWin.SetSize(300,300)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
pdb0 = vtk.vtkXYZMolReader()
pdb0.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/thio3xx.xyz")
Sphere0 = vtk.vtkSphereSource()
Sphere0.SetCenter(0,0,0)
Sphere0.SetRadius(1)
Sphere0.SetThetaResolution(8)
Sphere0.SetStartTheta(0)
Sphere0.SetEndTheta(360)
Sphere0.SetPhiResolution(8)
Sphere0.SetStartPhi(0)
Sphere0.SetEndPhi(180)
Glyph0 = vtk.vtkGlyph3D()
Glyph0.SetInputConnection(pdb0.GetOutputPort())
Glyph0.SetOrient(1)
Glyph0.SetColorMode(1)
#Glyph0 ScalingOn
Glyph0.SetScaleMode(2)
Glyph0.SetScaleFactor(.25)
Glyph0.SetSourceConnection(Sphere0.GetOutputPort())
Mapper5 = vtk.vtkPolyDataMapper()
Mapper5.SetInputConnection(Glyph0.GetOutputPort())
Mapper5.SetImmediateModeRendering(1)
Mapper5.UseLookupTableScalarRangeOff()
Mapper5.SetScalarVisibility(1)
Mapper5.SetScalarModeToDefault()
Actor5 = vtk.vtkLODActor()
Actor5.SetMapper(Mapper5)
Actor5.GetProperty().SetRepresentationToSurface()
Actor5.GetProperty().SetInterpolationToGouraud()
Actor5.GetProperty().SetAmbient(0.15)
Actor5.GetProperty().SetDiffuse(0.85)
Actor5.GetProperty().SetSpecular(0.1)
Actor5.GetProperty().SetSpecularPower(100)
Actor5.GetProperty().SetSpecularColor(1,1,1)
Actor5.GetProperty().SetColor(1,1,1)
Actor5.SetNumberOfCloudPoints(30000)
ren1.AddActor(Actor5)
Tuber0 = vtk.vtkTubeFilter()
Tuber0.SetInputConnection(pdb0.GetOutputPort())
Tuber0.SetNumberOfSides(8)
Tuber0.SetCapping(0)
Tuber0.SetRadius(0.2)
Tuber0.SetVaryRadius(0)
Tuber0.SetRadiusFactor(10)
Mapper7 = vtk.vtkPolyDataMapper()
Mapper7.SetInputConnection(Tuber0.GetOutputPort())
Mapper7.SetImmediateModeRendering(1)
Mapper7.UseLookupTableScalarRangeOff()
Mapper7.SetScalarVisibility(1)
Mapper7.SetScalarModeToDefault()
Actor7 = vtk.vtkLODActor()
Actor7.SetMapper(Mapper7)
Actor7.GetProperty().SetRepresentationToSurface()
Actor7.GetProperty().SetInterpolationToGouraud()
Actor7.GetProperty().SetAmbient(0.15)
Actor7.GetProperty().SetDiffuse(0.85)
Actor7.GetProperty().SetSpecular(0.1)
Actor7.GetProperty().SetSpecularPower(100)
Actor7.GetProperty().SetSpecularColor(1,1,1)
Actor7.GetProperty().SetColor(1,1,1)
ren1.AddActor(Actor7)
# enable user interface interactor
#iren SetUserMethod {wm deiconify .vtkInteract}
iren.Initialize()
# prevent the tk window from showing up then start the event loop
# --- end of script --
#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
ren1 = vtk.vtkRenderer()
ren1.SetBackground(0,0,0)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
renWin.SetSize(300,300)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
pdb0 = vtk.vtkPDBReader()
pdb0.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/caffeine.pdb")
pdb0.SetHBScale(1.0)
pdb0.SetBScale(1.0)
Sphere0 = vtk.vtkSphereSource()
Sphere0.SetCenter(0,0,0)
Sphere0.SetRadius(1)
Sphere0.SetThetaResolution(8)
Sphere0.SetStartTheta(0)
Sphere0.SetEndTheta(360)
Sphere0.SetPhiResolution(8)
Sphere0.SetStartPhi(0)
Sphere0.SetEndPhi(180)
Glyph0 = vtk.vtkGlyph3D()
Glyph0.SetInputConnection(pdb0.GetOutputPort())
Glyph0.SetOrient(1)
Glyph0.SetColorMode(1)
#Glyph0 ScalingOn
Glyph0.SetScaleMode(2)
Glyph0.SetScaleFactor(.25)
Glyph0.SetSourceConnection(Sphere0.GetOutputPort())
Mapper5 = vtk.vtkPolyDataMapper()
Mapper5.SetInputConnection(Glyph0.GetOutputPort())
Mapper5.SetImmediateModeRendering(1)
Mapper5.UseLookupTableScalarRangeOff()
Mapper5.SetScalarVisibility(1)
Mapper5.SetScalarModeToDefault()
Actor5 = vtk.vtkLODActor()
Actor5.SetMapper(Mapper5)
Actor5.GetProperty().SetRepresentationToSurface()
Actor5.GetProperty().SetInterpolationToGouraud()
Actor5.GetProperty().SetAmbient(0.15)
Actor5.GetProperty().SetDiffuse(0.85)
Actor5.GetProperty().SetSpecular(0.1)
Actor5.GetProperty().SetSpecularPower(100)
Actor5.GetProperty().SetSpecularColor(1,1,1)
Actor5.GetProperty().SetColor(1,1,1)
Actor5.SetNumberOfCloudPoints(30000)
ren1.AddActor(Actor5)
Tuber0 = vtk.vtkTubeFilter()
Tuber0.SetInputConnection(pdb0.GetOutputPort())
Tuber0.SetNumberOfSides(8)
Tuber0.SetCapping(0)
Tuber0.SetRadius(0.2)
Tuber0.SetVaryRadius(0)
Tuber0.SetRadiusFactor(10)
Mapper7 = vtk.vtkPolyDataMapper()
Mapper7.SetInputConnection(Tuber0.GetOutputPort())
Mapper7.SetImmediateModeRendering(1)
Mapper7.UseLookupTableScalarRangeOff()
Mapper7.SetScalarVisibility(1)
Mapper7.SetScalarModeToDefault()
Actor7 = vtk.vtkLODActor()
Actor7.SetMapper(Mapper7)
Actor7.GetProperty().SetRepresentationToSurface()
Actor7.GetProperty().SetInterpolationToGouraud()
Actor7.GetProperty().SetAmbient(0.15)
Actor7.GetProperty().SetDiffuse(0.85)
Actor7.GetProperty().SetSpecular(0.1)
Actor7.GetProperty().SetSpecularPower(100)
Actor7.GetProperty().SetSpecularColor(1,1,1)
Actor7.GetProperty().SetColor(1,1,1)
ren1.AddActor(Actor7)
# enable user interface interactor
#iren SetUserMethod {wm deiconify .vtkInteract}
iren.Initialize()
# prevent the tk window from showing up then start the event loop
# --- end of script --
#!/usr/bin/env python
import vtk
from vtk.test import Testing
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
# Create the RenderWindow, Renderer and both Actors
#
ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# create cutting planes
planes = vtk.vtkPlanes()
points = vtk.vtkPoints()
norms = vtk.vtkFloatArray()
norms.SetNumberOfComponents(3)
points.InsertPoint(0,0.0,0.0,0.0)
norms.InsertTuple3(0,0.0,0.0,1.0)
points.InsertPoint(1,0.0,0.0,0.0)
norms.InsertTuple3(1,-1.0,0.0,0.0)
planes.SetPoints(points)
planes.SetNormals(norms)
# texture
texReader = vtk.vtkStructuredPointsReader()
texReader.SetFileName("" + str(VTK_DATA_ROOT) + "/Data/texThres2.vtk")
texture = vtk.vtkTexture()
texture.SetInputConnection(texReader.GetOutputPort())
texture.InterpolateOff()
texture.RepeatOff()
# read motor parts...each part colored separately
#
byu = vtk.vtkBYUReader()
byu.SetGeometryFileName("" + str(VTK_DATA_ROOT) + "/Data/motor.g")
byu.SetPartNumber(1)
normals = vtk.vtkPolyDataNormals()
normals.SetInputConnection(byu.GetOutputPort())
tex1 = vtk.vtkImplicitTextureCoords()
tex1.SetInputConnection(normals.GetOutputPort())
tex1.SetRFunction(planes)
# tex1 FlipTextureOn
byuMapper = vtk.vtkDataSetMapper()
byuMapper.SetInputConnection(tex1.GetOutputPort())
byuActor = vtk.vtkActor()
byuActor.SetMapper(byuMapper)
byuActor.SetTexture(texture)
byuActor.GetProperty().SetColor(cold_grey)
byu2 = vtk.vtkBYUReader()
byu2.SetGeometryFileName("" + str(VTK_DATA_ROOT) + "/Data/motor.g")
byu2.SetPartNumber(2)
normals2 = vtk.vtkPolyDataNormals()
normals2.SetInputConnection(byu2.GetOutputPort())
tex2 = vtk.vtkImplicitTextureCoords()
tex2.SetInputConnection(normals2.GetOutputPort())
tex2.SetRFunction(planes)
# tex2 FlipTextureOn
byuMapper2 = vtk.vtkDataSetMapper()
byuMapper2.SetInputConnection(tex2.GetOutputPort())
byuActor2 = vtk.vtkActor()
byuActor2.SetMapper(byuMapper2)
byuActor2.SetTexture(texture)
byuActor2.GetProperty().SetColor(peacock)
byu3 = vtk.vtkBYUReader()
byu3.SetGeometryFileName("" + str(VTK_DATA_ROOT) + "/Data/motor.g")
byu3.SetPartNumber(3)
triangle3 = vtk.vtkTriangleFilter()
triangle3.SetInputConnection(byu3.GetOutputPort())
normals3 = vtk.vtkPolyDataNormals()
normals3.SetInputConnection(triangle3.GetOutputPort())
tex3 = vtk.vtkImplicitTextureCoords()
tex3.SetInputConnection(normals3.GetOutputPort())
tex3.SetRFunction(planes)
# tex3 FlipTextureOn
byuMapper3 = vtk.vtkDataSetMapper()
byuMapper3.SetInputConnection(tex3.GetOutputPort())
byuActor3 = vtk.vtkActor()
byuActor3.SetMapper(byuMapper3)