[vtkusers] Exporting after multiple addActor() calls to blah.vtk?

Bryan Bishop kanzure at gmail.com
Sun Nov 30 16:07:08 EST 2008


Hello,

I've been reading the docs for vtkWriter and its derivatives,
especially vtkDataSetWriter and am now spinning in circles. What I
have, in python, is the following code snippit; what I'd like to be
able to do is call addActor() as many times as I'd like, and then
export everything showing up on the visualization window into a dot
vtk file (particularly so that I may load it up into OpenFOAM later).
At this point I'm increasingly certain that VTK isn't really meant for
this; the image output (TIFF, PNG, etc.) works wonderfully; I'd be
willing to switch over to PyOpenGL if this is just me being too silly.

===========
===========

voxelPoints = vtk.vtkPoints()
voxelPoints.SetNumberOfPoints(8)
voxelPoints.InsertPoint(0, 0, 0, 0) # vtkidType id, x, y, z
voxelPoints.InsertPoint(1, 1, 0, 0)
voxelPoints.InsertPoint(2, 0, 1, 0)
voxelPoints.InsertPoint(3, 1, 1, 0)
voxelPoints.InsertPoint(4, 0, 0, 1)
voxelPoints.InsertPoint(5, 1, 0, 1)
voxelPoints.InsertPoint(6, 0, 1, 1)
voxelPoints.InsertPoint(7, 1, 1, 1)
aVoxel = vtk.vtkVoxel()
aVoxel.GetPointIds().SetId(0, 0)
aVoxel.GetPointIds().SetId(1, 1)
aVoxel.GetPointIds().SetId(2, 2)
aVoxel.GetPointIds().SetId(3, 3)
aVoxel.GetPointIds().SetId(4, 4)
aVoxel.GetPointIds().SetId(5, 5)
aVoxel.GetPointIds().SetId(6, 6)
aVoxel.GetPointIds().SetId(7, 7)
aVoxelGrid = vtk.vtkUnstructuredGrid()
aVoxelGrid.Allocate(1, 1)
aVoxelGrid.InsertNextCell(aVoxel.GetCellType(), aVoxel.GetPointIds())
aVoxelGrid.SetPoints(voxelPoints)
aVoxelMapper = vtk.vtkDataSetMapper()
aVoxelMapper.SetInput(aVoxelGrid)
aVoxelActor = vtk.vtkActor()
aVoxelActor.SetMapper(aVoxelMapper)
aVoxelActor.GetProperty().SetDiffuseColor(1, 0, 0)

ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
renWin.SetSize(300, 150)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
ren.SetBackground(.1, .2, .4)
ren.AddActor(aVoxelActor)

ren.ResetCamera()
ren.GetActiveCamera().Azimuth(30)
ren.GetActiveCamera().Elevation(20)
ren.GetActiveCamera().Dolly(2.8)
ren.ResetCameraClippingRange()
iren.Initialize()
renWin.Render()
iren.Start()

===========
===========

Uh, and for prosperity purposes and stuff, here's my search log of
"almost solutions" that I've been finding while doing my searching. So
if there's a solution maybe I'll write up an example and try to push
it upstream to the development list.

http://osdir.com/ml/lib.vtk.user/2002-09/msg00562.html
http://www.vtk.org/doc/nightly/html/classvtkPolyDataWriter.html
http://www.vtk.org/doc/nightly/html/classvtkWriter.html
http://74.125.45.132/search?q=cache:IRW9MyXmLNMJ:www.yeraze.com/article.php/20060706213401306+python+vtkdatasetwriter&hl=en&ct=clnk&cd=5&gl=us&client=opera
http://www.vtk.org/pipermail/vtkusers/2006-May/085091.html
http://www.google.com/search?num=100&hl=en&client=opera&rls=en&hs=Mms&q=vtk.vtkRenderer+vtkDataSetWriter+setinput&btnG=Search
http://www.vtk.org/pipermail/vtkusers/2005-November/082580.html
http://www.vtk.org/doc/nightly/html/classvtkDataSetWriter.html
http://www.vtk.org/doc/release/4.0/html/classvtkWindowToImageFilter.html
http://www.vtk.org/doc/release/4.0/html/c2_vtk_e_1.html#c2_vtk_e_vtkProgrammableSource
http://www.geologie.uni-freiburg.de/root/manuals/vtkman/vtkRenderer.html
http://www.vtk.org/doc/release/4.0/html/classvtkUnstructuredGridToPolyDataFilter.html
http://74.125.95.132/search?q=cache:-OfBh9EP1j8J:https://tahoe.ca.sandia.gov/public/cgi-bin/cvsweb.cgi/contrib/vtk/src/VTKConsoleT.cpp%3Fannotate%3D1.3+vtkRendererSource+setfilename(*.vtk)&hl=en&ct=clnk&cd=1&gl=us&client=opera
http://www.vtk.org/doc/release/4.2/html/classvtkImageWriter.html
http://www.vtk.org/doc/release/4.2/html/classvtkWriter.html
http://www.vtk.org/pipermail/vtkusers/2007-August/092191.html
http://www.google.com/search?num=100&hl=en&client=opera&rls=en&hs=e2D&q=vtk+setfilename+addActor+addActor+write&btnG=Search
http://www.google.com/search?num=100&hl=en&client=opera&rls=en&hs=d4D&q=vtk+data+exporter+%22%2A.vtk%22+%22import+vtk%22&btnG=Search
http://www.google.com/search?client=opera&rls=en&q=vtkStripper&sourceid=opera&ie=utf-8&oe=utf-8
http://www.vtk.org/pipermail/vtkusers/2006-December/088604.html
http://www.vtk.org/pipermail/vtkusers/2006-December/088606.html
http://www.vtk.org/pipermail/vtkusers/2006-December/088605.html
http://deimos.eos.uoguelph.ca/local/vtk/html/classvtkPolyData.html
http://www.google.com/search?client=opera&rls=en&q=python+%22vtkRendererSource()%22+setfilename&sourceid=opera&ie=utf-8&oe=utf-8
http://www.vtk.org/pipermail/vtkusers/2006-June/085617.html
http://www.vtk.org/pipermail/vtkusers/2005-March/078677.html
http://www.vtk.org/pipermail/vtkusers/2001-November/058111.html
http://www.vtk.org/pipermail/vtkusers/2006-December/088662.html
http://www.vtk.org/pipermail/vtkusers/2006-April/084941.html
http://www.vtk.org/pipermail/vtkusers/2006-April/thread.html#84961
http://www.csee.umbc.edu/~shari1/
http://www.vtk.org/doc/release/4.2/html/classvtkDataSet.html
http://www.vtk.org/pipermail/vtkusers/2007-January/089204.html
http://www.google.com/search?client=opera&rls=en&q=%22vtk.vtkDataSetWriter.SafeDownCast%22&sourceid=opera&ie=utf-8&oe=utf-8

- Bryan
http://heybryan.org/
1 512 203 0507



More information about the vtkusers mailing list