Hello,
I just met a question about creating a new vtkDataSet from an existing vtkDataSet. I have an original dataset A
vtkSmartPointer<vtkDataSet> A = CreateDataSetA();
And now I want to create a deepcopy of the DataSet A with all the PointData and CellData. I tried different ways and print the new Dataset B:
//***Not working in the compiling***
vtkSmartPointer<vtkDataSet> B = vtkSmartPointer<vtkDataSet>::New();
B->DeepCopy(A);
//***Working but probably Shallow copy***
vtkSmartPointer<vtkDataSet> B = vtkSmartPointer<vtkDataSet>(A);
//***Has coordinates of A but no Point Data***
vtkSmartPointer<vtkDataSet> B = vtkSmartPointer<vtkDataSet>(A);
B->DeepCopy(A);
//***Working***
vtkSmartPointer<vtkDataSet> B = vtkSmartPointer<vtkDataSet>::Newinstance(A);
B->DeepCopy(A);
//***Print function***
std::filebuf file_Buff;
file_Buff.open("./test.txt", std::ios::out);
std::ostream os(&file_Buff);
B->Print(os);
file_Buff.close();
The last one is working and I guess that is a Deep Copy. But I wonder why thoese weird things happen.
I would be appreciate if someone could explain that.