[vtkusers] DeepCopy doesn't copy vectors?

Madhusudhanan Balasubramanian madhu_lsu at yahoo.com
Sat Sep 4 13:54:11 EDT 2004


Tom,

I would first make sure the vtkImageData instance created/recreated in func() is updated with the right data.  Usually, I insert an <vtkImageData instance>->Update() function while debugging to ensure the availability of the data in the pipeline at that point.  If there is any problem in having the data right (this could be possibly because this instance might be an output of an intermediate filter), the program will throw an exception right at the Update();

Usually, if the data is intact, copy won't have any problem.  To validate, you can create a dummy vtkImageData instance just before you copy and try your code.

Madhu.

=======================================================

>Try ShallowCopy(); it works for me.No luck, unfortunately. I get the same crash, but I suspect that if itdid copy the PointData that I need it to, it would crash later on whenI tried to use the data from the first call to 'func'. I mentioned (butforgot to spell out in the psuedo-code, oops) that I would be callingthe 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 probablyunclear in my original post; func() will Delete() Data and create a New()dataset), it is necessary to do a complete copy of the data returnedfrom the initial func() call.Thank you, though. Responses / ideas are always welcome -- if I'mmailing here I'm at the end of my rope =). Well, I suppose I couldalways just rewrite this "func"tionality (har, har) to not rely
 onDeepCopy()...-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-&gt;Data = some_filter-&gt;GetOutput();>	return this-&gt;Data; //Data is a vtkDataSet*>}>>void MyObj::SomeOtherFunc()>{>	vtkDataSet *my_data = vtkDataSet::New();>>	my_data-&gt;DeepCopy(this-&gt;func());>>	/*** CRASH HERE ***/>	my_data-&gt;GetPointData()-&gt;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


		
---------------------------------
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040904/6c398c75/attachment.htm>


More information about the vtkusers mailing list