Class Interlinkage and Hierarchy

Robert Riviere Robert.Riviere at sophia.inria.fr
Thu Oct 14 04:09:52 EDT 1999


Hi,

> Is there any page which gives the hierarchy of classes and how
> they are interlinked etc. for vtk ?

Some time ago I had committed the attached script.

It uses my favourite meta-method "ListMethods" on every class
defined in vtk, and looks for the pattern "Methods from xxx" to find 
what are current object super-classes.

It's appeared to be very stressing to the vtk-tcl interpretor, i.e. 
it makes it dump a core easily, and you need to avoid somme classes
(for example vtkStamp and vtkIndent under certain versions).

So I didn't work on it any more. BTW, if anyone wants to augment it 
(for example, interface it to a tk tree widget), he'll be welcome...

See comments for other fun stuff...

Hope it helps,

Robert 
Riviere

_______________________________________________________________________
# hierarchy.tcl
# for each known vtk* class, we create an instance and call ListMethods on it
# so we get a list of base classes of the current object.

# another way to do this would be to create an object always with the same name
# and call Delete on it after examining. BUT Delete stills core dumps on some
# classes (ie vtkRIBLight)

# regexp of vtkCommands to Exclude (bugs,...)
# vtkStamp and vtkIndent for 2.3, tcl/tk widget wrappers, ...
set toExclude vtkTk.*|vtkCommand|vtkTimeStamp|vtkIndent

proc go {} {
    global toExclude
    set n 0
    set allClasses [info commands vtk*]
    foreach aClass $allClasses {
        # excluding special classes
        if {[regexp $toExclude $aClass]} {
            puts "EXCLUDING $aClass"
            continue
        }
        #puts "WORKING on $aClass"
        #create temporary instance
        $aClass tmpObject$n
        set objMethods [tmpObject$n ListMethods]
        # we now have a list made of each word given by ListMethods
        set objHier [extractHier $objMethods]
        puts $objHier
        incr n
    }
}

# extracting 'Methods from xxx' from a list of words
# returns an ordered list of xxx having matched
proc extractHier {methodsList} {
    set result {}
    set index 0
    foreach aWord $methodsList {
        #puts "$aWord $index"
        if [string match Methods $aWord] {
            lappend result [lindex $methodsList [expr $index + 2]]
        }
        incr index
    }
    return $result
}




-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------




More information about the vtkusers mailing list