[vtk-developers] VTK 6.1 python examples

Andrew Maclean andrew.amaclean at gmail.com
Wed Dec 10 17:18:19 EST 2014


Hi Grant,
   I think you will find that most of the recent submissions support either
VTK 6.1 or more recent. I for one have not bothered writing compatible
versions for VTK 5.x. I also have adopted this approach in writing the C++
examples.

I refer you to the following discussion that we had a while back regarding
supporting different versions of Python:
http://markmail.org/message/43hbrqh3tu4nmig3

The upshot of this is that it is just not possible to support different
versions of Python within the code itself since python has no
equivalents "#if" or "#ifdef", from this discussion you will also see that
your Option 3 will not work. The implication here is that the approach used
in the C++ examples using #ifdef for pipeline differences will not work in
Python.

In one or two cases I have used an approach like this:

def CheckVTKVersion(requiredMajorVersion):
    '''
    Check the VTK version.
    :param: requiredMajorVersion e.g. 6
    '''
    version = vtk.vtkVersion()
    if version.GetVTKMajorVersion() > requiredMajorVersion:
        raise
    else:
        return
 if __name__ == '__main__':
    try:
        CheckVTKVersion(6)
    except:
        print "You need VTK Version 6 or greater."
        print "The class vtkNamedColors is in VTK version 6 or greater."
        exit(0)
    iren = main()
    iren.Start()



This code would give errors anyway if run under VTK5 because of the
pipeline re-architecture so it is of more use for checking for 6.2 features.

My preference would be to just update the examples to VTK 6. In most cases
it is a fairly straight forward process.

I think creating separate examples for VTK5 and VTK6 would be a lot of work
for very little return, given that people seem to be migrating to VTK6
anyway and new users should be using VTK6.

Regards
   Andrew





> ---------- Forwarded message ----------
> From: "Windes, Grant" <Grant.Windes at smith-nephew.com>
> To: "vtk-developers at vtk.org" <vtk-developers at vtk.org>
> Cc:
> Date: Wed, 10 Dec 2014 00:22:16 +0000
> Subject: [vtk-developers] VTK 6.1 python examples
>
> I’ve been working on migrating our application (written in python) from
> vtk 5.10 to vtk 6.1
>
>
>
> All the python examples that I have read through on the vtk wiki are still
> using vtk 5 syntax (
> http://vtk.org/Wiki/VTK/Examples/Python/GeometricObjects/Display/Cube)
>
>
>
> What’s the best way to go about updating these to both support vtk 5 and
> support vtk 6+
>
>
>
> Any preference about updating the wiki pages? Or maybe I am missing the
> location of the vtk6 python examples
>
>
>
> 1.       Fix something in the current build system?
>
> 2.       Create separate examples for vtk5 and vtk6
>
> 3.       Use if check (Seems like it could get messy)
>
> if VTK_MAJOR_VERSION <= 5:
>
>       current vtk
>
> code else:
>
>       vtk6+ code
>
>
>
> -Grant
>
>
>
>
> ---------- Forwarded message ----------
> From: Bill Lorensen <bill.lorensen at gmail.com>
> To: "Windes, Grant" <Grant.Windes at smith-nephew.com>
> Cc: VTK Developers <vtk-developers at vtk.org>
> Date: Tue, 9 Dec 2014 21:14:00 -0500
> Subject: Re: [vtk-developers] VTK 6.1 python examples
>
> You can edit the examples on the wiki. For the c++ examples we use offers
> to support vtk5 and 6.
> On Dec 9, 2014 8:55 PM, "Windes, Grant" <Grant.Windes at smith-nephew.com>
> wrote:
>
>>  I’ve been working on migrating our application (written in python) from
>> vtk 5.10 to vtk 6.1
>>
>>
>>
>> All the python examples that I have read through on the vtk wiki are
>> still using vtk 5 syntax (
>> http://vtk.org/Wiki/VTK/Examples/Python/GeometricObjects/Display/Cube)
>>
>>
>>
>> What’s the best way to go about updating these to both support vtk 5 and
>> support vtk 6+
>>
>>
>>
>> Any preference about updating the wiki pages? Or maybe I am missing the
>> location of the vtk6 python examples
>>
>>
>>
>> 1.       Fix something in the current build system?
>>
>> 2.       Create separate examples for vtk5 and vtk6
>>
>> 3.       Use if check (Seems like it could get messy)
>>
>> if VTK_MAJOR_VERSION <= 5:
>>
>>       current vtk
>>
>> code else:
>>
>>       vtk6+ code
>>
>>
>>
>> -Grant
>>
>>
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/vtk-developers
>>
>>
>>
>
> --
___________________________________________
Andrew J. P. Maclean

___________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20141211/58977e99/attachment.html>


More information about the vtk-developers mailing list