[vtkusers] pick and update

David Gobbi dgobbi at atamai.com
Mon Jan 30 17:58:24 EST 2006


In Python you should never use Register() or Delete().  The python 
wrappers tie together the Python GC with VTK and call these for you 
automatically.

If you want to keep the data around, you just have to keep a python 
reference to it around, you don't need to Register it.  Note that the 
data keeps a reference to the source, so you need to break the pipeline 
after the Update() if you want the source to be deleted.  In VTK 4, you 
would do data.SetSource(None).

 - David

Tom Radcliffe wrote:

> I meant using DeepCopy when I said "make a copy of the output data", 
> so you've tried the right thing.  I had forgotten about GC in 
> Python--I don't know what effect it might have.  Generally Register 
> and UnRegister should be called with a null pointer in C++, which I 
> guess is equivalent to None in Python.  The only reason to use 
> something other than null is for debugging, so you can see what 
> objects have registered something and not unregistered it.
>
> --Tom
>
> Boris Avdeev wrote:
>
>> Thanks for your reply. I tried the second alternative. I guess
>> Delete() method is not exported to Python (because of GC?). I tried to
>> use the following code instead:
>>
>> data.Register(None)
>> data.Update()
>> read.UnRegister(None)
>>
>> It did not do any good and now I get seg.fault at the exit.
>> I did not quite get the copy explanation. What is "make the copy of
>> the data from the reader the start of your pipeline"?
>> I tried the following with as much success as earlier:
>> ...
>> read.Update()
>> data.DeepCopy(read.GetOutput())
>> ...
>>
>> Thanks,
>> Boris
>>
>>
>> On 1/30/06, Tom Radcliffe <tradcliffe at predictivepatterns.com> wrote:
>>  
>>
>>> The reader's output will be regenerated during the next Update, so your
>>> changes will be wiped out.  You should pull the data out of the reader
>>> and make a copy.  Then make the copy of the data from the reader the
>>> start of your pipeline.
>>>
>>> To do this without copying you can do something like this (in C++,
>>> something similar in Python):
>>>
>>> vtkPolyData* pData = pReader->GetOutput();
>>> pData->Register(0);
>>> pReader->Delete();
>>>
>>> This should drop the reader but keep the data around.
>>>
>>> --Tom
>>>   
>>
>>
>>  
>>
>
>




More information about the vtkusers mailing list