# Copying a collection of heterogenous vtkProp types

**URL:** https://discourse.vtk.org/t/copying-a-collection-of-heterogenous-vtkprop-types/12026
**Category:** Support
**Tags:** code
**Created:** [July 26, 2023, 7:37am UTC](https://discourse.vtk.org/t/copying-a-collection-of-heterogenous-vtkprop-types/12026 "2023-07-26T07:37:04Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Sean\_Curtis](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sean_curtis/32/718_2.png) [@Sean\_Curtis](https://discourse.vtk.org/u/Sean_Curtis)
#### Post date: [July 26, 2023, 7:37am UTC](https://discourse.vtk.org/t/copying-a-collection-of-heterogenous-vtkprop-types/12026/1 "2023-07-26T07:37:04Z")

</div>

Pretend I have a `std::vector<vtkSmartPointer<vtkProp>> things;` I populate it with a number of different types (all derived from `vtkProp`). For example, let’s say one item is a `vtkAssembly` and one is a `vtkActor`. Now I want to copy that collection of `things`.

As I read the signature of `ShallowCopy()`, I already have to know the _most derived_ type of the thing I’m copying in order to copy it without slicing. For example, if I had a `vtkSmartPointer<vtkProp3D> target`, I’d be able to successfully copy _either_ vector entry into `target`, having sliced away all of the `vtkActor` or `vtkAssembly` related data.

So, two-ish questions:

1. Have I read that correctly?
2. If so, how do I find the most derived type so that I can copy into a new instance of that type?
3. (Or am I trying to solve the problem in completely the wrong way and there is some virtual method that clones the whole thing and returns something like a `vtkProp`?)
