[vtkusers] DeepCopy doesn't copy vectors?
tom fogal
tfogal at apollo.sr.unh.edu
Fri Sep 3 16:45:55 EDT 2004
>Try ShallowCopy(); it works for me.
No luck, unfortunately. I get the same crash, but I suspect that if it
did copy the PointData that I need it to, it would crash later on when
I tried to use the data from the first call to 'func'. I mentioned (but
forgot to spell out in the psuedo-code, oops) that I would be calling
the function twice, more like:
vtkDataSet *my_data[2];
my_data[0] = vtkDataSet::New();
my_data[1] = vtkDataSet::New();
my_data[0]->DeepCopy(this->func());
my_data[1]->DeepCopy(this->func());
than what I had originally given in psuedo code. Sorry.
Since this->func() will modify the 'Data' pointer (this was probably
unclear in my original post; func() will Delete() Data and create a New()
dataset), it is necessary to do a complete copy of the data returned
from the initial func() call.
Thank you, though. Responses / ideas are always welcome -- if I'm
mailing here I'm at the end of my rope =). Well, I suppose I could
always just rewrite this "func"tionality (har, har) to not rely on
DeepCopy()...
-tom
>Madhu.
>
>I have a function which returns a vtkDataSet*, but subsequent calls
>will make the pointer returned in earlier calls invalid, so I want to
>copy the output of the function into my own vtkDataSet. I figured
>DeepCopy would do what I want, but it doesn't seem to copy (at least)
>the vector data from the point data of the source dataset.
>
>To spell it out better:
>
>vtkDataSet* MyObj::func()
>{
> this->Data = some_filter->GetOutput();
> return this->Data; //Data is a vtkDataSet*
>}
>
>void MyObj::SomeOtherFunc()
>{
> vtkDataSet *my_data = vtkDataSet::New();
>
> my_data->DeepCopy(this->func());
>
> /*** CRASH HERE ***/
> my_data->GetPointData()->GetVectors();
> /*** CRASH HERE ***/
>}
>
>Psuedo-ish code, of course. Running through gdb, it seems that
>GetPointData() returns a valid pointer, but when I try to GetVectors()
>from the pointer returned by GetPointData(), i get a segmentation
>fault.
>
>So it looks to me as if the vector data isn't being copied. Is this
>normal behavior? How / what should I set to enable a complete copy of
>the vtkDataSet and all of the data it holds?
>
>Thanks,
>
>-tom
More information about the vtkusers
mailing list