[vtk-developers] vtkArrayExtents (and others) Python wrapping
Eric E. Monson
emonson at cs.duke.edu
Tue Sep 7 12:38:26 EDT 2010
I was just thinking of something simple like this (note that I've gotten rid of all of Tim's typedef stuff in this version. At first I thought of GetRange(), but I changed it since that means something else in other VTK classes...):
diff --git a/Common/vtkArrayExtents.cxx b/Common/vtkArrayExtents.cxx
index 833fe5d..59e7c64 100644
--- a/Common/vtkArrayExtents.cxx
+++ b/Common/vtkArrayExtents.cxx
@@ -114,6 +114,11 @@ void vtkArrayExtents::SetDimensions(vtkIdType dimensions)
this->Storage.assign(dimensions, vtkArrayRange());
}
+vtkArrayRange& vtkArrayExtents::GetDimensionRange(vtkIdType i)
+{
+ return this->Storage[i];
+}
+
vtkArrayRange& vtkArrayExtents::operator[](vtkIdType i)
{
return this->Storage[i];
diff --git a/Common/vtkArrayExtents.h b/Common/vtkArrayExtents.h
index 7d45861..ed4095a 100644
--- a/Common/vtkArrayExtents.h
+++ b/Common/vtkArrayExtents.h
@@ -124,6 +124,10 @@ public:
// Description:
// Accesses the extent of the i-th dimension.
+ vtkArrayRange& GetDimensionRange(vtkIdType i);
+
+ // Description:
+ // Accesses the extent of the i-th dimension.
vtkArrayRange& operator[](vtkIdType i);
// Description:
On Sep 7, 2010, at 12:07 PM, David Gobbi wrote:
> Maybe we can all work together to get these classes fully wrapped.
> Can you post your changes somewhere?
>
> David
>
>
> On Tue, Sep 7, 2010 at 9:17 AM, Eric E. Monson <emonson at cs.duke.edu> wrote:
>> Hey David,
>>
>> I was able to check out the older versions and change some other typedef spots and the extra methods are now available, but it looks like there's still no way to access the data.
>>
>> In C++ it looks like the only way to get a vtkArrayRange object out of the vtkArrayExtents is to use the bracket [] operator, and that doesn't translate into Python correctly, as far as I can tell. We may just need to add some sort of GetRange(DimensionT i) method for the wrapping... (I'm cc-ing Tim on this since I know you didn't come up with these classes.)
>>
>> Thanks,
>> -Eric
>>
>>
>> On Sep 7, 2010, at 9:14 AM, David Gobbi wrote:
>>
>>> Hi Eric,
>>>
>>> Code maintenance for the wrappers is no different from any other part
>>> of VTK, i.e. anything that isn't tested will eventually break, if it
>>> isn't broken already.
>>>
>>> On the dashboard, TestStringsPython and TestVariantPython used
>>> vtkArray methods and both are failing because of the recent vtkArray
>>> changes, so you can bet that this issue will eventually be resolved
>>> but it might take time. If I'd written a vtkArray-specific python
>>> test (like I did for vtkVariant), it would have helped.
>>>
>>> The moving target issue is usually not a problem. The wrappers are
>>> generated automatically and they will adapt to most changes in the C++
>>> code; cases like this one with vtkArray are the exception rather than
>>> the rule. I'm looking into how easy/difficult it will be to add basic
>>> typedef support to the wrappers.
>>>
>>> David
>>>
>>>
>>> On Tue, Sep 7, 2010 at 6:43 AM, Eric E. Monson <emonson at cs.duke.edu> wrote:
>>>> Hey David,
>>>>
>>>> Thanks for the explanation. I'll try to get back to before that commit with all of Titan and see how it works. I hope this can be worked out eventually, though.
>>>>
>>>> It seems like the wrappers are a tough thing because the C++ code is such a moving target! I'm just curious -- I know there are strong motivations in place for people to fix things when their commits break other parts of VTK, but is there anything formal in place regarding breaking the python wrapping? (I would assume it only shows up on the dashboards if there happens to be a Python test that covers a given class.)
>>>>
>>>> Thanks again,
>>>> -Eric
>>>>
>>>>
>>>> On Sep 6, 2010, at 8:48 PM, David Gobbi wrote:
>>>>
>>>>> Hi Eric,
>>>>>
>>>>> The python wrapping of the vtkArray class was broken by this commit,
>>>>> which happened while I was on vacation:
>>>>>
>>>>> http://vtk.org/gitweb?p=VTK.git;a=commit;h=ba442dcd57fe6bf52ef7fb9c21cb842e78e489cd
>>>>>
>>>>> This commit added the typedefs CoordinateT, DimensionT, and SizeT to
>>>>> vtkArray and its support classes. The wrappers do not support
>>>>> typedefs yet, except for a few like vtkIdType that have been
>>>>> hard-coded. You can try doing a checkout before the commit mentioned
>>>>> above and see how things work. I didn't have much time to experiment
>>>>> with these classes.
>>>>>
>>>>> David
>>>>>
>>>>>
>>>>> On Mon, Sep 6, 2010 at 6:18 PM, Eric E. Monson <emonson at cs.duke.edu> wrote:
>>>>>> Hello,
>>>>>>
>>>>>> I've been trying to see how much of the Titan text analysis functionality can be done from Python, but I ran into a problem accessing the contents of a vtkArrayExtents. The object is obtained by calling GetExtents() on a vtkArray, and if I print the array object I can see that the proper extents are there, but I can't figure out how to access them: the only methods on the vtkArrayExtents that seem to be wrapped are Append, Contains, SameShape and ZeroBased, and the object isn't iterable or scriptable. As I started trying out other things like vtkArrayRange and vtkArrayCoordinates, I also had trouble figuring out how to use them from Python.
>>>>>>
>>>>>> I know David Gobbi has made a lot of great progress on the Python wrapping over the summer, and I saw his wiki example for vtkVariant, but does anyone know if these supporting classes around vtkArray work from Python right now?
>>>>>>
>>>>>> Thanks a lot,
>>>>>> -Eric
>>>>>>
>>>>>> ------------------------------------------------------
>>>>>> Eric E Monson
>>>>>> Duke Visualization Technology Group
>>>>>>
>>>>>>
>>>>
>>>>
>>
>>
More information about the vtk-developers
mailing list