[vtkusers] Infovis: Icicle layout not rectangular

Eric E. Monson emonson at cs.duke.edu
Wed Mar 10 17:55:17 EST 2010


Okay, sorry for the noise. I was using TreeRingToPolyData instead of TreeMapToPolyData...

Thanks,
-Eric

On Mar 10, 2010, at 4:21 PM, Eric E. Monson wrote:

> 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
> 
> 
> <NoIcicle.png>
> 
> ===================
> 
> 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()
> 
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers




More information about the vtkusers mailing list