[Paraview] pythonnurbs inside ProgrammableFilter

Oliver Borm oli.borm at web.de
Mon Jan 11 05:41:42 EST 2010


It works like expected:

$ pvpython
Python 2.6.4 (r264:75706, Dec  8 2009, 20:49:52)
[GCC 4.3.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def getPointX():
...     from pythonnurbs import NurbsPoint
...     x = 0.0
...     point = NurbsPoint.Point3Dd(x,0.0,0.0)
...     print point.getx()
...
>>> getPointX()
0.0
>>> getPointX()
0.0

Even with an additional argument:

$ pvpython
Python 2.6.4 (r264:75706, Dec  8 2009, 20:49:52)
[GCC 4.3.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def getPointX(x):
...     from pythonnurbs import NurbsPoint
...     point = NurbsPoint.Point3Dd(x,0.0,0.0)
...     print point.getx()
...
>>> getPointX(0.0)
0.0
>>> getPointX(100.0)
100.0



Berk Geveci schrieb:
> What happens if you put all of these in a function and call that
> function twice? That's what the GUI does.
>
> -berk
>
> On Fri, Jan 8, 2010 at 11:34 AM, Oliver Borm <oli.borm at web.de> wrote:
>   
>> It just works:
>>
>> ~ $ pvpython
>> Python 2.6.4 (r264:75706, Dec  8 2009, 20:49:52)
>> [GCC 4.3.4] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>>     
>>>>> from pythonnurbs import NurbsPoint
>>>>> point = NurbsPoint.Point3Dd(100.0,0.0,0.0)
>>>>> print point.getx()
>>>>>           
>> 100.0
>>     
>>>>> point = NurbsPoint.Point3Dd(0.0,0.0,0.0)
>>>>> print point.getx()
>>>>>           
>> 0.0
>>     
>>>>> print(point)
>>>>>           
>> <pythonnurbs.NurbsPoint.Point3Dd; proxy of <Swig Object of type
>> 'PlPoint3Dd *' at 0xd8c910> >
>>     
>>>>> point.setx(25.0)
>>>>> print point.getx()
>>>>>           
>> 25.0
>>     
>> Berk Geveci schrieb:
>>     
>>> What happens if you run this in pvpython?
>>>
>>> On Fri, Jan 8, 2010 at 10:52 AM, Oliver Borm <oli.borm at web.de> wrote:
>>>
>>>       
>>>> Ok, here the test code:
>>>>
>>>> from pythonnurbs import NurbsPoint
>>>>
>>>> point = NurbsPoint.Point3Dd(100.0,0.0,0.0)
>>>>
>>>> print(point)
>>>>
>>>> print point.getx()
>>>>
>>>>
>>>> first time output:
>>>>
>>>> <pythonnurbs.NurbsPoint.Point3Dd; proxy of <Swig Object of type
>>>> 'PlPoint3Dd *' at 0x2d37710> >
>>>>
>>>> 100.0
>>>>
>>>>
>>>> second time output:
>>>>
>>>> <pythonnurbs.NurbsPoint.Point3Dd; proxy of <Swig Object of type
>>>> 'PlPoint3Dd *' at 0x2d37710> >
>>>>
>>>>
>>>> Traceback (most recent call last):
>>>>
>>>> File "<string>", line 23, in <module>
>>>>
>>>> File "<string>", line 5, in RequestData
>>>>
>>>> File "/usr/lib64/python2.6/site-packages/pythonnurbs/NurbsPoint.py",
>>>> line 104, in getx
>>>>
>>>> def getx(*args): return _NurbsPoint.Point3Dd_getx(*args)
>>>>
>>>> TypeError: in method 'Point3Dd_getx', argument 1 of type
>>>> 'PLib::Point_nD< double,3 > *'
>>>>
>>>>
>>>> Well if I do not access the point object, then it seems that all went
>>>> fine. But if I want to get any data from the point object, then I get
>>>> the error.
>>>>
>>>> Berk Geveci schrieb:
>>>>
>>>>         
>>>>> Sorry, I assumed that you had more than those few lines. OK, this is
>>>>> very weird. Can you simply print what
>>>>> NurbsPoint.Point3Dd(0.0,0.0,0.0)
>>>>> returns the first time and the second time?
>>>>>
>>>>>
>>>>> On Fri, Jan 8, 2010 at 9:49 AM, Oliver Borm <oli.borm at web.de> wrote:
>>>>>
>>>>>
>>>>>           
>>>>>> Do you mean the source code of pythonnurbs or my test code? Pythonnurbs itself is a python binding of the NURBS++ library using SWIG. This is the whole python code I'm using inside the ProgrammableFilter:
>>>>>>
>>>>>> from pythonnurbs import NurbsCurve, NurbsPoint
>>>>>>
>>>>>> curve=NurbsCurve.NurbsCurved()
>>>>>> curve.makeCircle(NurbsPoint.Point3Dd(0.0,0.0,0.0), 100.0)
>>>>>> u = 0.5
>>>>>> print curve.pointAt(u).getx(), curve.pointAt(u).gety(), curve.pointAt(u).getz()
>>>>>>
>>>>>>
>>>>>>
>>>>>> Berk Geveci schrieb:
>>>>>>
>>>>>>
>>>>>>             
>>>>>>> I am guessing somehow the arguments passed to makeCircle are getting
>>>>>>> clobbered. Can you post you Python code?
>>>>>>>
>>>>>>> -berk
>>>>>>>
>>>>>>> On Fri, Jan 8, 2010 at 4:12 AM, Oliver Borm <oli.borm at web.de> wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>               
>>>>>>>> Hello,
>>>>>>>>
>>>>>>>> I am using pythonnurbs from http://pypi.python.org/pypi/PythonNURBS in
>>>>>>>> conjunction with the python bindings from vtk. As a standalone script it
>>>>>>>> works perfectly, but if I want to use it inside paraview with the
>>>>>>>> ProgrammableFilter it just works once a time. After that some errors
>>>>>>>> occur. Here is a simple python test code:
>>>>>>>>
>>>>>>>> from pythonnurbs import NurbsCurve, NurbsPoint
>>>>>>>> curve=NurbsCurve.NurbsCurved()
>>>>>>>> curve.makeCircle(NurbsPoint.Point3Dd(0.0,0.0,0.0), 100.0)
>>>>>>>> u = 0.5
>>>>>>>> print curve.pointAt(u).getx(), curve.pointAt(u).gety(),
>>>>>>>> curve.pointAt(u).getz()
>>>>>>>>
>>>>>>>> The following output is printed:
>>>>>>>>
>>>>>>>> -100.0 0.0 0.0
>>>>>>>>
>>>>>>>>
>>>>>>>> If one changes for example:
>>>>>>>> u = 0.25
>>>>>>>>
>>>>>>>> and want to re-execute the ProgrammableFilter again, the following error
>>>>>>>> occured
>>>>>>>>
>>>>>>>> Traceback (most recent call last):
>>>>>>>>
>>>>>>>> File "<string>", line 23, in <module>
>>>>>>>>
>>>>>>>> File "<string>", line 5, in RequestData
>>>>>>>>
>>>>>>>> File "/usr/lib64/python2.6/site-packages/pythonnurbs/NurbsCurve.py",
>>>>>>>> line 277, in makeCircle
>>>>>>>>
>>>>>>>> def makeCircle(*args): return _NurbsCurve.NurbsCurved_makeCircle(*args)
>>>>>>>>
>>>>>>>> NotImplementedError: Wrong number of arguments for overloaded function
>>>>>>>> 'NurbsCurved_makeCircle'.
>>>>>>>>
>>>>>>>> Possible C/C++ prototypes are:
>>>>>>>>
>>>>>>>> makeCircle(PLib::NurbsCurve< double,3 > *,PLib::Point_nD< double,3 >
>>>>>>>> const &,PLib::Point_nD< double,3 > const &,PLib::Point_nD< double,3 >
>>>>>>>> const &,double,double,double)
>>>>>>>>
>>>>>>>> makeCircle(PLib::NurbsCurve< double,3 > *,PLib::Point_nD< double,3 >
>>>>>>>> const &,double,double,double)
>>>>>>>>
>>>>>>>> makeCircle(PLib::NurbsCurve< double,3 > *,PLib::Point_nD< double,3 >
>>>>>>>> const &,double)
>>>>>>>>
>>>>>>>>
>>>>>>>> while running the same code a second time in a normal python shell, the
>>>>>>>> output looks like the following:
>>>>>>>> 0.0 100.0 0.0
>>>>>>>>
>>>>>>>> One has to restart paraview and the python code in the
>>>>>>>> ProgrammableFilter works as expected (once a time). The error message is
>>>>>>>> not very helpful, as it says that this method is not implemented in the
>>>>>>>> way I'm using it. But that is not correct. Does anybody has an idea
>>>>>>>> what's the real problem? At first one could expect the problem is in
>>>>>>>> pythonnurbs (maybe it is, but not in the way the error message says),
>>>>>>>> but as the code works once a time, why does it not works twice?
>>>>>>>>
>>>>>>>> Best regards,
>>>>>>>> Oliver Borm
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Powered by www.kitware.com
>>>>>>>>
>>>>>>>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>>>>>>>
>>>>>>>> Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView
>>>>>>>>
>>>>>>>> Follow this link to subscribe/unsubscribe:
>>>>>>>> http://www.paraview.org/mailman/listinfo/paraview
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>                 


More information about the ParaView mailing list