[vtkusers] Infovis: Icicle layout not rectangular

Eric E. Monson emonson at cs.duke.edu
Wed Mar 10 16:21:18 EST 2010


Hey folks,

I need to do an icicle layout of a tree without using the vtkIcicleView, but I'm having two problems:

1. Even though I'm setting UseRectangularCoordinatesOn() in vtkStackedTreeLayoutStrategy, my output looks like a tree ring rather than an icicle layout.

2. I don't see the root node of my tree after the layout.

I'll paste in the python script I'm using and a screen shot -- can anyone spot something I've left out? I tried to duplicate what's done in vtkRenderedTreeAreaRepresentation and vtkIcicleView, but I must have missed something... 

As input, I'm using the treetest.xml file in [vtk]/Examples/Infovis/Python

Thanks a lot!
-Eric

------------------------------------------------------
Eric E Monson
Duke Visualization Technology Group


-------------- next part --------------
A non-text attachment was scrubbed...
Name: NoIcicle.png
Type: image/png
Size: 986 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100310/3deff177/attachment.png>
-------------- next part --------------


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

import vtk

reader1 = vtk.vtkXMLTreeReader()
reader1.SetFileName("treetest.xml")

TreeLevels = vtk.vtkTreeLevelsFilter()
TreeLevels.SetInputConnection(reader1.GetOutputPort(0))

VertexDegree = vtk.vtkVertexDegree()
VertexDegree.SetInputConnection(TreeLevels.GetOutputPort(0))

TreeAggregation = vtk.vtkTreeFieldAggregator()
TreeAggregation.LeafVertexUnitSizeOn()
TreeAggregation.SetInputConnection(VertexDegree.GetOutputPort(0))

strategy = vtk.vtkStackedTreeLayoutStrategy()
strategy.UseRectangularCoordinatesOn()
# strategy.SetInteriorRadius(10.0)
strategy.SetRootStartAngle(0.0)
strategy.SetRootEndAngle(15.0)
strategy.SetRingThickness(3.0)	# layer thickness
strategy.ReverseOn()
strategy.SetShrinkPercentage(0.1)

layout = vtk.vtkAreaLayout()
layout.SetLayoutStrategy(strategy)
layout.SetInputConnection(TreeAggregation.GetOutputPort(0))
layout.SetAreaArrayName("area")
layout.SetSizeArrayName("size")

areapoly = vtk.vtkTreeRingToPolyData()
areapoly.SetInputConnection(layout.GetOutputPort(0))
areapoly.SetInputArrayToProcess( 0, 0, 0, 4, "area")  # 4 = VERTICES

# Create the RenderWindow, Renderer and both Actors
ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
istyle = vtk.vtkInteractorStyleRubberBand2D()
iren.SetInteractorStyle(istyle)
ren1.GetActiveCamera().ParallelProjectionOn()

mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(areapoly.GetOutputPort(0))
actor = vtk.vtkActor()
actor.SetMapper(mapper)
ren1.AddActor(actor)
renWin.SetSize(400, 400)

# render the image
ren1.ResetCamera()
renWin.Render()
iren.Start()



More information about the vtkusers mailing list