[vtkusers] DeepCopy doesn't copy vectors?
ALIZIER Julien AUSY
julien.alizier-ausy at irsn.fr
Tue Sep 7 09:04:09 EDT 2004
Hi Tom,
DeepCopy works well if both instances are of the same type (e.g. both
vtkPolydata or both vtkUnstructuredGrid, etc...).
Use NewInstance to create an new instance of the same type :
vtkDataSet * original = this->func();
vtkDataSet * my_data = original->NewInstance();
my_data->DeepCopy(original);
my_data->GetPointData()->GetVectors();
HTH
-- Julien
-----Message d'origine-----
De : tom fogal [mailto:tfogal at apollo.sr.unh.edu]
Envoyé : vendredi 3 septembre 2004 20:54
À : vtkusers at vtk.org
Objet : [vtkusers] DeepCopy doesn't copy vectors?
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
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at:
<http://public.kitware.com/cgi-bin/vtkfaq>
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list