[vtkusers] vtk and python - some questions.

Prabhu Ramachandran prabhu at aero.iitm.ernet.in
Thu Oct 26 01:55:32 EDT 2000


hi,

>>>>> "Sebastien" == Sebastien BARRE <seb-ml-a at barre.nom.fr> writes:

    Sebastien> At 24/10/00 16:30 -0400, Chris Myers wrote:

    >> P.S.  Having looked at the VTK introspection code that Prabhu
    >> wrote to implement his VTK-CFD, I can understand his
    >> frustration with the lack of certain features in the Python/VTK
    >> interface.

    Sebastien> Could you be more descriptive ?

	In the python pipeline browser, to find the methods that a
particular vtk object provides I have to do a little gymnastics.  I
first do a dir(vtk_object) and get those listed methods.  But this
will not reveal the inherited methods.  Since there is no __bases__
attribute I cannot recurse thru the bases and find all the methods.
So I print the object and parse the resulting output.  Pretty messy,
but not too bad.  Parsing is not enough since some of the printed
output will have no corresponding function.  So I throw in a large
amount of try/except code to check if things are ok.  I then combine
the results of both the dir() and the parsed output (since not every
method is printed either).  Sometimes there are bugs and even doing a
try/except wont work because the method may segfault.  So I throw in
stupid checks that eliminate such functions.  This results in not too
nice code.  But IMHO this approach works beautifully and most of the
useful functionality is captured.  I think this is what Chris Myers
meant.

<snip>

    Sebastien> For example, it'd be nice to include some typedef's in
    Sebastien> VTK so that functions could provide semantic clues
    Sebastien> about their parameters.
    Sebastien> Say, for example :
    Sebastien>    void SetColor(rgbcolor c) void SetAngle(angle_d a)
    Sebastien> instead of :
    Sebastien>    void SetColor(float a[3]) void SetAngle(float a)
    Sebastien> where rgbcolor would be something like a typedef to an
    Sebastien> array of 3 float, and angle_d just a typedef to a
    Sebastien> float.

	This sounds good, so make the vote count three. :)

    Sebastien> The idea behind this is to provide a wrapper or a
    Sebastien> parser that would dump an XML description of the VTK
<snip>
    Sebastien> (color chooser, or angle representation) this could be
    Sebastien> generated automatically.

	Sure, it would help.

    Sebastien> I introduced this XML wrapper idea some time ago in the
    Sebastien> "GUI [demo]" discussion, but I had no time to work on
    Sebastien> it, sorry.

    Sebastien> This also imply a lot of search/replace stuff :) I'm
    Sebastien> not sure VTK authors are very permissive about massive
    Sebastien> changes :)) (as we get no feedback regarding the 3 or 4
    Sebastien> lines that one could add to each VTK .cxx files to
    Sebastien> speed up compilation time by a factor of 2 or 3 using
    Sebastien> precompiled headers).

	Maybe we are not making enough noise??

prabhu




More information about the vtkusers mailing list