[vtkusers] Axes

Randy Heiland heiland at ncsa.uiuc.edu
Fri Jul 6 12:49:23 EDT 2001


On Jul 6,  9:01am, Marta Kersten wrote:
> Subject: Re: [vtkusers] Axes
> I'm looking for 3d axes (a simple triad) each axis in a different colour
> that is in vtk format.  I don't like vtkAxes because the lines are too
> thick- is there anyway of making them thicker and making them have arrow
> heads on the ends or does anyone have such a file????

Don't know if there's any class that constructs an axes like you want, but it's
easy enough to do so using the TubeFilter and ConeSource.  Here's some (Python)
code to get you started...

--Randy


#!/usr/local/bin/python

from libVTKCommonPython import *
from libVTKGraphicsPython import *

# Create renderer stuff
#
ren = vtkRenderer()
renWin = vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

#--- Axes (tubes)
Axes = vtkAxes()
#Axes.SetOrigin(0,0,0)
sfactor = 1.0
Axes.SetScaleFactor(sfactor)

AxesTube = vtkTubeFilter()
AxesTube.SetInput(Axes.GetOutput())
AxesTube.SetRadius(0.05)
AxesTube.SetNumberOfSides(8)

AxesTubeMapper = vtkDataSetMapper()
#AxesMapper.SetInput(Axes.GetOutput())
AxesTubeMapper.SetInput(AxesTube.GetOutput())

AxesTubeActor = vtkActor()
AxesTubeActor.SetMapper(AxesTubeMapper)

#--- Cone-heads
coneRes = 12
coneScale=0.4

#--- x-Cone
xcone = vtkConeSource()
xcone.SetResolution(coneRes)
xconeMapper = vtkPolyDataMapper()
xconeMapper.SetInput(xcone.GetOutput())
xconeActor = vtkActor()
xconeActor.SetMapper(xconeMapper)
xconeActor.GetProperty().SetColor(1,0,0)

xform=vtkTransform()
xform.Translate(sfactor,0,0)
xform.Scale(coneScale,coneScale,coneScale)
xconeActor.SetUserMatrix(xform.GetMatrix())


#--- y-Cone
ycone = vtkConeSource()
ycone.SetResolution(coneRes)
yconeMapper = vtkPolyDataMapper()
yconeMapper.SetInput(ycone.GetOutput())
yconeActor = vtkActor()
yconeActor.SetMapper(yconeMapper)
yconeActor.GetProperty().SetColor(1,1,0)

yform=vtkTransform()
yform.Translate(0,sfactor,0)
yform.RotateZ(90)
yform.Scale(coneScale,coneScale,coneScale)
yconeActor.SetUserMatrix(yform.GetMatrix())


#--- z-Cone (an exercise for the reader)


#--------------------------
ren.AddActor(AxesTubeActor)
ren.AddActor(xconeActor)
ren.AddActor(yconeActor)
#ren.AddActor(zconeActor)

renWin.Render()
iren.Start()




More information about the vtkusers mailing list