# Working of shallowcopy in vtk

**URL:** https://discourse.vtk.org/t/working-of-shallowcopy-in-vtk/13585
**Category:** Support
**Created:** [March 20, 2024, 4:15am UTC](https://discourse.vtk.org/t/working-of-shallowcopy-in-vtk/13585 "2024-03-20T04:15:20Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![JunYeolChae](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/848f3c/32.png) [@JunYeolChae](https://discourse.vtk.org/u/JunYeolChae)
#### Post date: [March 20, 2024, 4:15am UTC](https://discourse.vtk.org/t/working-of-shallowcopy-in-vtk/13585/1 "2024-03-20T04:15:20Z")

</div>

I have the following c++ code:

vtkNew \_surf;   
\_surf-\>ShallowCopy(surf);  
vtkIdType cellId = Get\_ClosestCellId(\_surf, seedxyz);  
\_surf-\>DeleteCell(cellId);  
\_surf-\>RemoveDeletedCells();

After creating \_surf, we specify it as a shallowcopy of surf. Afterwards, remove the cell closest to the seedxyz coordinate from \_surf.  
I thought that if I shallowcopy like this, since \_surf and surf share the same pointer, the modifications made to \_surf would also be reflected in surf.  
However, if you output the two in vtp format, the modifications to \_surf are not reflected in surf. Why is this?

I used a translator. I apologize if the sentences are not smooth.
