[vtkusers] Problem with proper axis visulization

Hom Nath Gharti hng.email at gmail.com
Wed Apr 22 05:05:18 EDT 2009


Dear all,
I want to visualize only  X and Z axis in my plot. Following is my python
code:

# Read image data from a file
reader1 = vtk.vtkExodusIIReader()
reader1.SetFileName("py_noair.e")
reader.Update()

geom1 = vtk.vtkCompositeDataGeometryFilter()
geom1.SetInputConnection(reader1.GetOutputPort())

mapper1 = vtk.vtkPolyDataMapper()
mapper1.SetInputConnection(geom1.GetOutputPort())
mapper.ImmediateModeRenderingOff()

actor1 = vtk.vtkActor()
actor1.SetMapper(mapper1)
actor1.GetProperty().SetColor(0,0,0)
actor1.GetProperty().SetLineWidth(1.0)
actor1.GetProperty().SetRepresentationToWireframe()

# Create a text property for both cube axes
tprop = vtk.vtkTextProperty()
tprop.SetColor(0.0, 0.0, 0.0)
tprop.ShadowOff()
tprop.SetFontSize(8)

ren.AddActor(actor1)
ren.SetBackground(1.0, 1.0, 1.0)

ren.ResetCamera()

cam=vtk.vtkCamera()
cam.SetFocalPoint(0.0,0.0,0.0)
cam.SetPosition(0.0,-1,0.0)
ren.SetActiveCamera(cam)
ren.ResetCamera()

outline = vtk.vtkOutlineFilter()
outline.SetInputConnection(geom1.GetOutputPort())
outline.Update() # This is required to execute following line

# Create a vtkCubeAxesActor2D.  Use the outer edges of the bounding box to
# draw the axes
axes = vtk.vtkCubeAxesActor2D()
axes.GetProperty().SetColor(0,0,0)
axes.YAxisVisibilityOff()
axes.SetCamera(ren.GetActiveCamera())
axes.SetLabelFormat("%6.3f")
axes.SetFlyModeToOuterEdges()
axes.SetShowActualBounds(1)
axes.SetCornerOffset(0.0)
axes.GetXAxisActor2D().SetNumberOfMinorTicks(5)
axes.GetZAxisActor2D().SetNumberOfMinorTicks(5)
axes.SetFontFactor(1.8)
axes.SetAxisTitleTextProperty(tprop)
axes.SetAxisLabelTextProperty(tprop)
axes.SetXLabel("X (m)")
axes.SetZLabel("Z (m)")
axes.SetNumberOfLabels(7)
ren.AddViewProp(axes)

# Save the window to a png file
image = vtk.vtkWindowToImageFilter()
image.SetInput(renWin)
writer = vtk.vtkPNGWriter()
writer.SetInputConnection(image.GetOutputPort())
writer.SetFileName("test.png")
writer.Write()

iren.Initialize()
renWin.Render()
iren.Start()

Because my image is in ZX plane I was trying to plot only the X and Z axis.
But I get only the X axes and some part of Y axes (very strange) as in
the attached figure. Am I doing something wrong?

I would be grateful for the suggestion.

Thanks,
Hom nath
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090422/e35b7ae4/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.png
Type: image/png
Size: 40053 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090422/e35b7ae4/attachment.png>


More information about the vtkusers mailing list