Shallow copy a node into a scene

I’ve created a scene and I want to copy nodes from the current scene into my new scene.
But I don’t want to copy any underlying bulk data in the nodes. I want new nodes that refer to the same underlying data when there is any. Is this possible in the current api with vtkMRMLScene or vtkMRMLNode?

vtkMRMLScene::CopyNode seems to do a deep copy.

Looking at the CopyContent function should be helpful:

I thought this might help, but the deepCopy parameter doesn’t get used. And I’m not seeing CopyContent get overriden by descendants of vtkMRMLNode. Maybe I am missing something-- I will test and see if it really does a shallow copy.

I was indeed missing something:
CopyContent does get overriden, the override was just tucked into the macro vtkMRMLCopyContentMacro.

Thanks @jcfr, I think this should do what I need!

1 Like