[vtkusers] Infovis: Use calculator on graphs?

Jeff Baumes jeff.baumes at kitware.com
Wed Dec 3 10:59:38 EST 2008


This appears to be an artifact (bug) dating back to when vtkGraph was
a vtkDataSet subclass. It now derives directly from vtkDataObject, so
it cannot be an input to vtkArrayCalculator, which only works on
vtkDataSets. I've entered a bug in the tracker for this.

http://public.kitware.com/Bug/view.php?id=8218

For a workaround, you could execute vtkGraphToPolyData, send the
polydata through the calculator (points = vertices, cells = edges),
something like

pd = vtk.vtkGraphToPolyData()
pd.SetInputConnection(centrality.GetOuputPort())
calc = vtk.vtkArrayCalculator()
calc.SetInputConnection(pd.GetOutputPort())
// Set up calculator here
calc.Update()

graph = centrality.GetOutput()
graph.GetVertexData().PassData(pd.GetPointData())

Jeff

On Wed, Dec 3, 2008 at 10:07 AM, Eric E. Monson <emonson at cs.duke.edu> wrote:
> I forgot to mention, that when I run this code I get:
>
> ERROR: In /Users/emonson/Programming/VTK_cvs/VTK/Filtering/vtkExecutive.cxx,
> line 757
> vtkStreamingDemandDrivenPipeline (0x894300): Algorithm
> vtkArrayCalculator(0x894240) returned failure for request: vtkInformation
> (0x8944d0)
>  Debug: Off
>  Modified Time: 319
>  Reference Count: 1
>  Registered Events: (none)
>  Request: REQUEST_DATA_OBJECT
>  FORWARD_DIRECTION: 0
>  ALGORITHM_AFTER_FORWARD: 1
>  FROM_OUTPUT_PORT: 0
>
>
> On Dec 3, 2008, at 9:52 AM, Eric E. Monson wrote:
>
>> Hey,
>>
>> I've been having trouble using the vtkArrayCalculator on a
>> vtkUndirectedGraph. From the options (like UseVertexData) it looks like it
>> should work, but I can't tell if there's a problem or if I'm just doing
>> something wrong.
>>
>> Here's my test code that starts like
>> Examples/Infovis/Python/boost_centrality.py -- can anyone see something
>> silly I'm doing? (CVS VTK, OS X 10.5.5, Python 2.5)
>>
>> # ===================
>> import vtk
>>
>> source = vtk.vtkRandomGraphSource()
>> source.DirectedOff()
>> source.SetNumberOfVertices(50)
>> source.SetEdgeProbability(0.01)
>> source.SetUseEdgeProbability(True)
>> source.AllowParallelEdgesOn()
>> source.AllowSelfLoopsOn()
>> source.SetStartWithTree(True)
>>
>> # Connect to the Boost centrality filter.
>> centrality = vtk.vtkBoostBrandesCentrality ()
>> centrality.SetInputConnection(source.GetOutputPort())
>> centrality.Update()
>>
>> centrality.GetOutputDataObject(0).GetVertexData().SetActiveScalars('centrality')
>>
>> # Rescale the graph vertex scalars
>> calc = vtk.vtkArrayCalculator()
>> calc.SetInputConnection(centrality.GetOutputPort())
>> calc.SetAttributeModeToUseVertexData()
>> calc.AddScalarArrayName("centrality", 0)
>> calc.SetFunction("centrality / 100.0")
>> calc.SetResultArrayName("centScaled")
>> calc.Update()
>>
>> # =================
>>
>> Thanks,
>> -Eric
>>
>> ------------------------------------------------------
>> Eric E Monson
>> Duke Visualization Technology Group
>>
>>
>>
>> _______________________________________________
>> This is the private VTK discussion list.
>> Please keep messages on-topic. Check the FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



-- 
Jeff Baumes, Ph.D.
R&D Engineer, Kitware Inc.
(518) 371-3971 x132
jeff.baumes at kitware.com



More information about the vtkusers mailing list