[VTK ARB] Dependency generations and visualisation - take 3

Andrew Maclean a.maclean at cas.edu.au
Wed Aug 25 18:27:45 EDT 2010


Hi all,
   Attached are new versions of depends.py, get_subgraph.py,
dependsview.py and a readme called readme.txt.

Changes are:
1) depends.py takes an optional parameter (-k) that outputs a third
field corresponding to the kit. This is used by get_subgraph.py when a
particular kit or kits are selected.
2) get_subgraph.py now allows you to specify a kit (or a list of kits),
a class (or a list of classes), the depth of the tree and optional
output for the graphviz programs.
3) dependsview.py - fixed a minor bug.

Please look at readme.txt for more instructions and usage. E.g the
includes from cubes.cxx are used as an example.

Thanks for the initial code and ideas, Jeff.

By the way I ran this against one of my home grown libraries and it
revealed a few redundant includes! So the visualisation is quite useful.

The graphviz output may be the best way to go. In macs you can enlarge >
400% however in Linux/Windows 400% seems to be the max. Does anyone know
of a uitlity that will handle ps files and enlarge > 400%? I also tried
splitting graphviz across several pages but didn't spend much time doing
this.


Regards
    Andrew




-- 
___________________________________________
Andrew J. P. Maclean
Centre for Autonomous Systems
The Rose Street Building J04
The University of Sydney  2006  NSW
AUSTRALIA
Ph: +61 2 9351 3283
Fax: +61 2 9351 7474
URL: http://www.acfr.usyd.edu.au/
___________________________________________

-------------- next part --------------
A non-text attachment was scrubbed...
Name: depends.py
Type: text/x-python
Size: 1744 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/arb/attachments/20100826/2b62faaf/attachment-0006.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dependsview.py
Type: text/x-python
Size: 1828 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/arb/attachments/20100826/2b62faaf/attachment-0007.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: get_subgraph.py
Type: text/x-python
Size: 8831 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/arb/attachments/20100826/2b62faaf/attachment-0008.py>
-------------- next part --------------
Usage:

python depends.py > vtkdepends.txt
vtkpython dependsview.py vtkdepends.txt

The first will create a two-column list of all includes from one class to another in VTK and must be called from the root of VTK source. The second visualizes the data with VTK itself and prints out the classes with the highest number of connections. Since the network makes a so-called "hairball", the second script optionally takes a maximum linkage cutoff to simplify the graph, e.g.

vtkpython dependsview.py vtkdepends.txt 10

will remove any classes with more than 10 links. Nodes are colored by number of connections. 

There is another program that operated on the data produced by depends.py called get_subgraph.py.
The program get_subgraph.py allows you to:
1) Select a particular kit or list of kits.
2) Select a particular class or list of classes.
3) Control the depth of the tree produced.

python depends.py > vtkdepends.txt
If you want to select kits, run:
python depends.py -k > vtkdepends.txt

Here we select a particular class (vtkParametricTorus), the topmost two levels of the tree and format for subsequent use by graphviz.
python get_subgraph.py -i vtkdepends.txt -c vtkParametricTorus -g -d 2 > x
dot -Tps -O x
We can select more than one class:
python get_subgraph.py -i vtkdepends.txt -c 'vtkParametricTorus vtkParametricEllipsoid' -g -d 3 > x

Here we select a particular class (vtkParametricTorus), all levels of the tree and run it through dependsview.py.
python get_subgraph.py -i vtkdepends.txt -c vtkParametricTorus > x
vtkpython dependsview.py x

To select a particular kit:
python depends.py -k > vtkdepends.txt
python get_subgraph.py -i vtkdepends.txt -k Graphics -g > x
dot -Tps -O x
(This can take a long time as each class is recursively chased down.)

You cam also provide a list of classes e.g take the following ones from the cube example (cube.cxx):
#include <vtkSmartPointer.h>
#include <vtkActor.h>
#include <vtkCubeSource.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>

Do this:
python get_subgraph.py -i vtkdepends.txt -g -c'vtkSmartPointer vtkActor vtkCubeSource vtkPolyData vtkPolyDataMapper vtkRenderWindow vtkRenderWindowInteractor vtkRenderer' -d3 | dot -Tps > y.ps



More information about the Arb mailing list