[vtkusers] TransformConcatenation

Srinivasan, Rajagopalan (GE Healthcare) Rajagopalan.Srinivasan at ge.com
Thu Oct 27 17:15:30 EDT 2005


all,

I took the TransformConcatenation.tcl script and converted to work with python - using VTK 4.2

Clearly i goofed somewhere in the conversion so when some operations are performed, it feels as though the Camera is getting moved around. In other words instead of just one of the objects moving like i intended, the whole scene moves closer and farther depending. I am not sure i have explained properly but hopefully someone with vtkpython from 4.2 can test it.

can someone please spot where i messed up?

thanks


-----------------------python script - TransformConcatenation.py

#!/usr/bin/env python

import vtk
import time
import sys

def Keypress(obj, event):
    key = obj.GetKeySym()
    if key == "e":
        obj.InvokeEvent("DeleteAllObjects")
        print "Quitting...."
        sys.exit()
    elif key == "r":
        joint1.RotateX(5)
    elif key == "R":
        joint1.RotateX(-5)
    elif key == "l":
        joint2.RotateY(-5)
    elif key == "L":
        joint2.RotateY(5)
    renderer.ResetCameraClippingRange()
    interactor.Render()
        

renderer = vtk.vtkRenderer()
renderer.SetBackground(250,250,250)
renwin = vtk.vtkRenderWindow()
renwin.AddRenderer(renderer)
renwin.SetSize(400,400)

c1 = vtk.vtkCylinderSource()
c1.SetHeight(1.6)
c1.SetRadius(0.2)
c1.SetCenter(0,0.8,0)

t1=vtk.vtkTransform()
f1=vtk.vtkTransformPolyDataFilter()
f1.SetInput(c1.GetOutput())
f1.SetTransform(t1)

m1=vtk.vtkDataSetMapper()
m1.SetInput(f1.GetOutput())

a1=vtk.vtkActor()
a1.SetMapper(m1)
a1.GetProperty().SetColor(1,0,0)

c2=vtk.vtkCylinderSource()
c2.SetHeight(1.6)
c2.SetRadius(0.15)
c2.SetCenter(0, 0.8, 0)

joint1=vtk.vtkTransform()

t2=vtk.vtkTransform()
t2.SetInput(t1)
t2.Translate(0,1.6,0)
t2.Concatenate(joint1)

f2=vtk.vtkTransformPolyDataFilter()
f2.SetInput(c2.GetOutput())
f2.SetTransform(t2)

m2=vtk.vtkDataSetMapper()
m2.SetInput(f2.GetOutput())

a2=vtk.vtkActor()
a2.SetMapper(m2)
a2.GetProperty().SetColor(0,0.7,1.0)

c3=vtk.vtkCylinderSource()
c3.SetHeight(0.5)
c3.SetRadius(0.1)
c3.SetCenter(0, 0.25, 0)

joint2=vtk.vtkTransform()

t3=vtk.vtkTransform()
t3.SetInput(t2)
t3.Translate(0,1.6,0)
t3.Concatenate(joint2)

f3=vtk.vtkTransformPolyDataFilter()
f3.SetInput(c3.GetOutput())
f3.SetTransform(t3)

m3=vtk.vtkDataSetMapper()
m3.SetInput(f3.GetOutput())
a3=vtk.vtkActor()
a3.SetMapper(m3)
a3.GetProperty().SetColor(0.9,0.9,0)

renderer.AddActor(a1)
renderer.AddActor(a2)
renderer.AddActor(a3)

#renderer.ResetCamera(-1,1,-0.1,2,-3,3)
renderer.ResetCamera()

phi2=70
theta2=85
phi3=50
theta3=90

joint1.Identity()
joint1.RotateY(phi2)
joint1.RotateX(theta2)

joint2.Identity()
joint2.RotateY(phi3)
joint2.RotateX(theta3)

interactor = renwin.MakeRenderWindowInteractor()
#istyle = vtk.vtkInteractorStyleTrackballCamera()
#interactor.SetInteractorStyle(istyle)
interactor.SetRenderWindow(renwin)
interactor.AddObserver("KeyPressEvent", Keypress)
interactor.Initialize()
renwin.Render()
interactor.Start()


DISCLAIMER:
This e-mail and any attachment is intended only for the exclusive and confidential use of the addressee(s). If you are not the intended recipient, any use, interference with, disclosure or copying of this material is unauthorised and prohibited. If you have received this message in error, please notify the sender by return e-mail immediately and delete the message from your computer without making any copies. Please see http://www.ge.com.au/help/email_privacy_policy.html for information about our privacy practices.



More information about the vtkusers mailing list