# Replace coordinates (vtkPoints) of vtkPolyData fast

**URL:** https://discourse.vtk.org/t/replace-coordinates-vtkpoints-of-vtkpolydata-fast/6999
**Category:** Support
**Created:** [October 28, 2021, 9:35am UTC](https://discourse.vtk.org/t/replace-coordinates-vtkpoints-of-vtkpolydata-fast/6999 "2021-10-28T09:35:42Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![AlexG](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/ecc23a/32.png) [@AlexG](https://discourse.vtk.org/u/AlexG)
#### Post date: [October 28, 2021, 9:35am UTC](https://discourse.vtk.org/t/replace-coordinates-vtkpoints-of-vtkpolydata-fast/6999/1 "2021-10-28T09:35:42Z")

</div>

I would need some tips or ideas on how to reset a volume (vtkPolyData).

More specifically, I create a line (vtkPolyLine) using a start and end point which I expand to a 3D cylinder using a vtkTubeFilter. Now I move the start and end points (vtkPoints) from the vtkPolyData. The pipeline is connected and the pointer to this vtkPolyData is shared with other renders (each creating its own actor).  
Now I want to allow the user to restore the original positions, meaning a reset of the displacement of all points.

My version is probably very slow. I store in a new variable m\_initialPoints (vtkPoints) via DeepCopy the points from the original data m\_polyObject (vtkPolyData). For each reset I make for the moved points (vtkPoints) in m\_polyObject (vtkPolyData) again a DeepCopy of the startPoints m\_initialPoints. Only in this way I can guarantee that I do not pass on my reset variable as a pointer and change it.

Is there a faster way to replace the coordinates of vtkPolyData quickly (and possibly keep the pipeline intact)?

```auto
void init()
{
	// Copy Initial points of Volume 
	m_initialPoints->DeepCopy(m_polyObject->polyData()->GetPoints());
}

//Resets to the initial volume
void resetVolume()
{
	m_polyObject->polyData()->GetPoints()->DeepCopy(m_initialPoints);
}

```

---

<div class="post-metadata">

### Author: ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)
#### Post date: [October 28, 2021, 11:21am UTC](https://discourse.vtk.org/t/replace-coordinates-vtkpoints-of-vtkpolydata-fast/6999/2 "2021-10-28T11:21:28Z")

</div>

Are you building & executing with VTK\_SMP\_IMPLEMENTATION\_TYPE to something other than “Sequential” ? I believe the deep copy is threaded, I can’t imagine this taking very long unless you are dealing with very large numbers of points …

---

<div class="post-metadata">

### Author: ![AlexG](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/ecc23a/32.png) [@AlexG](https://discourse.vtk.org/u/AlexG)
#### Post date: [November 2, 2021, 9:56am UTC](https://discourse.vtk.org/t/replace-coordinates-vtkpoints-of-vtkpolydata-fast/6999/3 "2021-11-02T09:56:19Z")

</div>

Thank you for your answer!

Yes VTK\_SMP\_IMPLEMENTATION\_TYPE is set to “Sequential”.  
From the number of points I am in the range of about 40000 points (20000 objects each with a start and an end point).

If my method of resetting is the usual way of doing it I will try to reduce the call of the reset function to a minimum.
