[vtk-developers] Wrapping templated types

David Gobbi david.gobbi at gmail.com
Fri May 20 16:08:34 EDT 2011


Hi Marcus,

I noticed your changes from this morning, so I updated my python
template patch on gerrit to incorporate them.  So far I've only given
this patch a minimal amount of testing, but things like this will work:

a = vtk.vtkChartXY()
a.SetSize(vtk.vtkRectf(0,0,10,10) )
a.GetSize()
(vtkRectf)[0,0,10,10]

I also notice that this works, and honestly I don't know if it should:

a.SetSize( (0.0, 0.0, 10.0, 10.0) )

The reason this works is that the following constructor is automatically
used for argument conversion:

vtkVector(const T* init)

Do you really want to allow implicit conversion from "T *" to vtkVector?
If not, you should declare this constructor as "explicit".

 - David









On Thu, May 19, 2011 at 9:05 AM, Marcus D. Hanwell
<marcus.hanwell at kitware.com> wrote:
> On Thu, May 19, 2011 at 10:02 AM, David Gobbi <david.gobbi at gmail.com> wrote:
>> Hi All,
>>
>> I've put an experimental branch on Gerrit that wraps templated
>> types in python:
>> http://review.source.kitware.com/#change,1680
>>
>> The templated types that it wraps are vtkVector, vtkRect, and
>> vtkColor.  It allows these (and their subclasses) to be used as
>> interface types in the Charts classes.
>
> That is great news - I will take a look.
>>
>> As an aside, I noticed some issues with these classes:
>> - vtkRect should have its own header file
>
> Quite right - I will take care of that.
>
>> - they do not define "<<" operators for printability
>
> That would be a great addition, let me see about adding it in too.
>
>> - they are used from Rendering, but their headers are in Charts
>>
> Yes, they should quite probably be in Common, does that seem reasonable?
>
> Marcus
>



More information about the vtk-developers mailing list