# ShallowCopy cost more time than building itself

**URL:** https://discourse.vtk.org/t/shallowcopy-cost-more-time-than-building-itself/8472
**Category:** Development
**Tags:** proposal
**Created:** [May 11, 2022, 9:52am UTC](https://discourse.vtk.org/t/shallowcopy-cost-more-time-than-building-itself/8472 "2022-05-11T09:52:19Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Ren](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/r/ed655f/32.png) [@Ren](https://discourse.vtk.org/u/Ren)
#### Post date: [May 11, 2022, 9:52am UTC](https://discourse.vtk.org/t/shallowcopy-cost-more-time-than-building-itself/8472/1 "2022-05-11T09:52:20Z")

</div>

Hello, everyone, I would like to create a actor, the poly data shallow copies from another actor,  
For some models, why ShallowCopy takes too long time even than building data itself?  
For some models, it is indeed fast.

vtkSmartPointer pData = vtkSmartPointer::New();  
pData-\>ShallowCopy(m\_pBaseActor-\>GetMapper()-\>GetInput());

vtkSmartPointer pMapper = vtkSmartPointer::New();  
pMapper-\>SetInputData(pData);  
pMapper-\>ScalarVisibilityOff();

pActor-\>SetMapper(pMapper);

---

<div class="post-metadata">

### Author: ![Ren](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/r/ed655f/32.png) [@Ren](https://discourse.vtk.org/u/Ren)
#### Post date: [May 11, 2022, 9:59am UTC](https://discourse.vtk.org/t/shallowcopy-cost-more-time-than-building-itself/8472/2 "2022-05-11T09:59:16Z")

</div>

How to fix the problem? Thanks

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [May 12, 2022, 6:38am UTC](https://discourse.vtk.org/t/shallowcopy-cost-more-time-than-building-itself/8472/3 "2022-05-12T06:38:59Z")

</div>

Please provide a minimal example reproduces the issue. For example, replace `m_pBaseActor->GetMapper()->GetInput()` by reading input from a file and share the file with us (upload somewhere and post the link here). It is also important to place triple backtick before and after the code block because as otherwise the text that you put between `<` and `>` is interpreted as HTML tag and does not get displayed.

---

<div class="post-metadata">

### Author: ![andreasbuykx](https://discourse.vtk.org/user_avatar/discourse.vtk.org/andreasbuykx/32/8137_2.png) [@andreasbuykx](https://discourse.vtk.org/u/andreasbuykx)
#### Post date: [May 12, 2022, 8:43am UTC](https://discourse.vtk.org/t/shallowcopy-cost-more-time-than-building-itself/8472/4 "2022-05-12T08:43:36Z")

</div>

Another way to analyse this is to separate the updating of the pipeline that produces the mapper input from the shallow copy:

> m\_pBaseActor-\>GetMapper()-\>Update()  
> pData-\>ShallowCopy(m\_pBaseActor-\>GetMapper()-\>GetInput())

I suspect it’s not the shallow copying that is slow, but the production of the dataset.
