[vtkusers] converting a tree stored in vtkGraph into vtkTree (or creating a loop walk through a tree)

Jeff Baumes jeff.baumes at kitware.com
Mon Jan 28 08:25:09 EST 2013


You can use vtkTreeBFSIterator to iterate over a vtkTree in a loop (so you
need a vtkTree to use this). vtkBoostBreadthFirstSearchTree is a
vtkAlgorithm that takes a vtkGraph as input, along with a root vertex, and
generates a vtkTree as its output, which is the BFS tree starting at the
root vertex..

HTH,
Jeff


On Mon, Jan 28, 2013 at 7:37 AM, Dr. Roman Grothausmann <
grothausmann.roman at mh-hannover.de> wrote:

> Dear Jeff,
>
>
> Many thanks for Your reply. I had come across vtkTreeBFSIterator but since
> that only takes an already existent tree as input, I deemed this not to be
> the right method for my task.
> Now I wonder what the difference is between vtkTreeBFSIterator and
> vtkBoostBreadthFirstSearchTree**?
> Perhaps it would be sensible to mention each other method in their docs. I
> had searched for BFS, therefore it did not hit BreadthFirstSearch:-(
>
> Thanks again for Your help
> Roman
>
>
> On 24/01/13 15:55, Jeff Baumes wrote:
>
>> If you have a vtkGraph, you can convert it to a vtkTree with
>> vtkBoostBreadthFirstSearchTree**. Then you can probably use the tree
>> iterators do
>> make the path you desire.
>>
>> Jeff
>>
>>
>> On Fri, Jan 18, 2013 at 2:49 PM, Dr. Roman Grothausmann
>> <grothausmann.roman at mh-**hannover.de <grothausmann.roman at mh-hannover.de><mailto:
>> grothausmann.roman at mh-**hannover.de <grothausmann.roman at mh-hannover.de>>>
>>
>> wrote:
>>
>>     Dear mailing list members,
>>
>>
>>     Now that I have managed to convert vtkPolyData (which represents a
>> tree, the
>>     root node position is known) to a vtkGraph (thanks to David Doria's
>>     vtkPolyDataToGraph: https://github.com/daviddoria/**
>> __VTK-GraphConversions<https://github.com/daviddoria/__VTK-GraphConversions>
>>     <https://github.com/**daviddoria/VTK-**GraphConversions<https://github.com/daviddoria/VTK-GraphConversions>
>> >)
>>
>>     I'm now facing the problem how to convert the tree that is contained
>> in the
>>     vtkGraph into a vtkTree?
>>     In the docs it is said that a tree can only be created via
>>     vtkMutableDirectedGraph, so guess I need to traverse the vtkGraph in
>> a way
>>     that the traversal yields a tree and during traversal a
>>     vtkMutableDirectedGraph needs to be created.
>>     But how to traverse the graph? In the docs it says that
>> vtkTreeDFSIterator
>>     would iterate through a graph but it inherits vtkTreeIterator and
>> only has a
>>     method setTree (no setGraph).
>>     Is there any other way to tell a PC that a graph is actually a tree
>> if it is
>>     told where the root node is?
>>
>>     My final goal is to create a vtkPolyData that represents the path
>> walked by
>>     e.g. a person that starts walking along the tree from the root,
>> visiting
>>     every node along a branch till it reaches its end, then goes back to
>> the
>>     next branching node (i.e. parent node with more than one child) and
>> then
>>     goes an like that until it comes back to the root. The person should
>> then
>>     have visited each node at least twice except end-nodes. If the start
>> and the
>>     end point of the path are connected the result would be a directed
>> loop.
>>     The result could be created very easily by duplicating the initial
>>     vtkPolyData and joining the two at each end-node, only the joints
>> needed at
>>     the branching-nodes give trouble.
>>
>>     Any help or hints is very much appreciated
>>     Roman
>>
>>
>>     --
>>     Dr. Roman Grothausmann
>>
>>     Tomographie und Digitale Bildverarbeitung
>>     Tomography and Digital Image Analysis
>>
>>     Institut für Funktionelle und Angewandte Anatomie, OE 4120
>>     Medizinische Hochschule Hannover
>>     Carl-Neuberg-Str. 1
>>     D-30625 Hannover
>>
>>     Tel. +49 511 532-9574 <tel:%2B49%20511%20532-9574>
>>     ______________________________**___________________
>>     Powered by www.kitware.com <http://www.kitware.com>
>>
>>
>>     Visit other Kitware open-source projects at
>>     http://www.kitware.com/__**opensource/opensource.html<http://www.kitware.com/__opensource/opensource.html>
>>
>>     <http://www.kitware.com/**opensource/opensource.html<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<http://www.vtk.org/Wiki/VTK___FAQ><
>> http://www.vtk.org/Wiki/VTK_**FAQ <http://www.vtk.org/Wiki/VTK_FAQ>>
>>
>>
>>     Follow this link to subscribe/unsubscribe:
>>     http://www.vtk.org/mailman/__**listinfo/vtkusers<http://www.vtk.org/mailman/__listinfo/vtkusers>
>>     <http://www.vtk.org/mailman/**listinfo/vtkusers<http://www.vtk.org/mailman/listinfo/vtkusers>
>> >
>>
>>
>>
> --
> Dr. Roman Grothausmann
>
> Tomographie und Digitale Bildverarbeitung
> Tomography and Digital Image Analysis
>
> Institut für Funktionelle und Angewandte Anatomie, OE 4120
> Medizinische Hochschule Hannover
> Carl-Neuberg-Str. 1
> D-30625 Hannover
>
> Tel. +49 511 532-9574
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130128/8e69889f/attachment.htm>


More information about the vtkusers mailing list