[vtkusers] smart pointer as member in class
Feng Xing
snakexf at gmail.com
Tue Sep 22 16:13:03 EDT 2015
Hello everyone,
I tried to define a class, its number is vtkSmartPointer<vtkDoubleArray> data. It is allocated in one member function (init()), and given values in another member function(setdata()). I get always segmentation errors. Il seems that data in setdata() function is not allocated or (freed?). If I put data->SetComponents in init(). All works well. Where is the problem? The pointer?
Thank you very much.
The code is similar like this
class VisuVTK
private:
vtkSmartPointer<vtkDoubleArray> data;
public:
init(){
data = vtkSmartPointer<vtkDoubleArray>::New();
data->SetNumberOfComponents(1); // size of component in tuple is 1
data->SetNumberOfTuples(Ncell); // size of data
};
setdata(){
for(int i=0;i<Ncell;i++){
data->SetComponent(i,0,1.0); }
};
end class
Feng Xing
Postdoc in France
More information about the vtkusers
mailing list