How to clone a vtkPolyDataReader

Hello,

I need to clone / duplicate a vtkPolyDataReader after reading my VTK file (Mesh),
Just after reading my Mesh I want to duplicate the Mesh polyData in two variables to then apply a different transform to each variable (polyData)

I tried to use shallowCopy() but it doesn’t giving me what I want, the polyData from the first variable is always affected from what I apply to the second variable
I tried to use something like this const polydata2 = {...polydata1} in javascript, it doesn’t work,

So I’m obliged to use vtkPolyDataReader two time to read my polyData (vtkPolyDataReader.setUrl() two times), but I want to only read one time and duplicate what I read.

Thank you

You can firstly get the output by polydata = reader->GetOutput()

Then, you can clone the polydata. The DeepCopy may help.

Thank you for your answer
yes I did polydata = reader->GetOutput()
then polydata.shallowCopy() because the deepCopy() method doesn’t exist in wtk.js
But it doesn’t work

In python, the code should be:

polydata1 = vtk.vtkPolyData()

polydata2 = vtk.vtkPolyData()
polydata2.DeepCopy(polydata1)
1 Like

Thank you for your answer,
DeepCopy function doesn’t exist in vtk.js as far as I know