[vtkusers] ReleaseData and ShallowCopy -- incompatible?

Volpe, Christopher R (CRD) volpecr at crd.ge.com
Thu Jan 11 13:36:39 EST 2001


I believe that, in vtkDataObject, the behavior of ShallowCopy is a bit too shallow, because it's not
as deep as ReleaseData. ReleaseData calls Initialize, which, instead of unregistering the FieldData
component, passes the Initialize() call on to the FieldData component. ShallowCopy, on the other
hand, copies and registers the pointer to the FieldData ivar, instead of doing a further ShallowCopy
from the source DataObject's FieldData to the target DataObject's FieldData. This fact makes what I
want to do less straightforward than it ought to be.

I have a custom mapper that takes a custom subclass of vtkDataObject as input. (This subclass uses
the FieldData ivar of vtkDataObject to store the bulk of its information, plus a few scalar ivars to
indicate more information about what is stored in the FieldData.) This custom mapper wants to latch
onto the input data so that it can process it in a background thread, while the main app goes back
and starts generating more data, overwriting into the same output data that serves as the input to
the mapper. Now, I can have the mapper do a DeepCopy of the input, but that ought not to be
necessary, since I really don't need two copies of the underlying data arrays at once. What I'd like
to do is have the mapper be able to ShallowCopy from the Input to a private DataObject, then call
ReleaseData on the Input, so that it will allocate new storage arrays on the next Update while the
mapper has its own copy of the array data safely reference counted within its private DataObject's
FieldData. If I try doing this now, what happens is that the FieldData pointer gets copied from the
Input DataObject to the private DataObject. So if I ReleaseData on the Input, my private DataObject's
FieldData will lose its array storage while I'm still using it (since it is referenced only by the
one FieldData, of which there are two pointers). And if I *don't* ReleaseData on the input, my data
will be overwritten during the next Update().

So, I would like to change the semantics of ShallowCopy, so that it gets passed to the FieldData
objects, instead of replacing one FieldData pointer with another. From a philosophical standpoint, I
think it's good to have consistency between these two methods: the things that are Registered in a
ShallowCopy should be the same things that are Unregistered in a ReleaseData. 

Comments?


Chris

 <<...>> GE Corporate Research & Development 
> ___________________________________________________________________________________________________
> _______________________________________________
> 
Christopher R. Volpe
Computer Scientist
Visual Information Program
Bldg KW, Room C215
P.O. Box 8, Schenectady, NY 12301

(518) 387-7766, Dial Comm: 8*833-7766, Fax: (518) 387-6981
e-mail: volpecr at crd.ge.com    web: http://www.crd.ge.com/~volpecr








More information about the vtkusers mailing list