ShallowCopy cost more time than building itself

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);

How to fix the problem? Thanks

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.

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.

1 Like