<html><body><div style="color:#000; background-color:#fff; font-family:Courier New, courier, monaco, monospace, sans-serif;font-size:10pt"><div style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 10pt;">Hi,</div><div style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 10pt;"><br></div><div style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;">I'm experiencing troubles when copying pointers of VTK object.</div><div style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div><div style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;">Let's say I want to apply
transformation to a polydata recursively like this:</div><div style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent; font-style: normal;"><br></div><div style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; color: rgb(0, 0, 0); background-color: transparent;"><span style="font-style: italic;"> //Read STL</span></div><div style="background-color: transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"> vtkSTLReader * reader = vtkSTLReader::New();</span></div><div style="background-color: transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"> reader->SetFileName("1.stl");</span></div><div style="background-color: transparent;"><span
style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"> reader->Update();</span></div><div style="background-color: transparent;"><span style="font-style: italic;"><br></span></div><div style="background-color: transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"> vtkPolyData * polydata = reader->GetOutput();</span></div><div style="background-color: transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"> polydata->Register(NULL);</span></div><div style="background-color: transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"> reader->Delete();</span></div><div style="background-color:
transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"><br></span></div><div style="background-color: transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"> vtkTransform * tr = vtkTransform::New();</span></div><div style="background-color: transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"> tr->Translate(5, 10, 1);</span></div><div style="background-color: transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"> tr->Update();</span></div><div style="background-color: transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style:
italic;"><br></span></div><div style="background-color: transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"> for(int i = 0 ; i < 1000 ; ++i)</span></div><div style="background-color: transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"> {</span></div><div style="background-color: transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"> <span class="Apple-tab-span" style="white-space:pre">        </span>std::cout << i << std::endl;</span></div><div style="background-color: transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"> <span class="Apple-tab-span" style="white-space:pre">
        </span>vtkTransformPolyDataFilter * trFilter = vtkTransformPolyDataFilter::New();</span></div><div style="background-color: transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"><span class="Apple-tab-span" style="white-space:pre">        </span>trFilter->SetInput(polydata);</span></div><div style="background-color: transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"><span class="Apple-tab-span" style="white-space:pre">        </span>trFilter->SetTransform(tr);</span></div><div style="background-color: transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"><span class="Apple-tab-span" style="white-space:pre">        </span>trFilter->Update();</span></div><div style="background-color: transparent;"><span style="font-family: 'Courier
New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"><br></span></div><div style="background-color: transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"><span class="Apple-tab-span" style="white-space:pre">        </span>vtkPolyData * output = trFilter->GetOutput();</span></div><div style="background-color: transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"><span class="Apple-tab-span" style="white-space:pre">        </span>output->Register(NULL);</span></div><div style="background-color: transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"><span class="Apple-tab-span" style="white-space:pre">        </span>trFilter->Delete();</span></div><div style="background-color: transparent;"><span
style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"><br></span></div><div style="background-color: transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"><span class="Apple-tab-span" style="white-space:pre">        </span>polydata->Delete();</span></div><div style="background-color: transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"><span class="Apple-tab-span" style="white-space:pre">        </span>polydata = output;</span></div><div style="background-color: transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"> }</span></div><div style="background-color: transparent;"><span style="font-style: italic;"><span style="font-family: 'Courier New', courier,
monaco, monospace, sans-serif; font-size: 13px; background-color: transparent;"> tr->Delete();</span><br></span></div><div style="background-color: transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"> polydata->Delete();</span></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 13px; font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-style: normal;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px;"><br></span></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 13px; font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-style: normal;">This is working fine and I have no VTK leaks. Unfortunately, I'm noticing that memory for my program increases instead of remaining constant.</div><div
style="background-color: transparent; color: rgb(0, 0, 0); font-size: 13px; font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-style: normal;">What's wrong with theses few lines?</div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 13px; font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-style: normal;"><br></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 13px; font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-style: normal;">By the way, using DeepCopy to save output data is working:</div><div style="background-color: transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px;"><span class="Apple-tab-span" style="white-space:pre">        </span><span style="font-style: italic;">polydata = vtkPolyData::New();</span></span></div><div style="background-color: transparent;"><span
style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"><span class="Apple-tab-span" style="white-space:pre">        </span>polydata->DeepCopy(output);</span></div><div style="background-color: transparent;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px; font-style: italic;"><span class="Apple-tab-span" style="white-space: pre;">        </span>output->Delete();</span></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 13px; font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-style: normal;"><span style="font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-size: 13px;">But I would like to avoid to deep copy data when I only need to add a reference to the pointer. I also would like to avoid the use of vtkSmartPointer.</span></div><div style="background-color: transparent; color: rgb(0, 0,
0); font-size: 13px; font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-style: normal;"><br></div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 13px; font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-style: normal;">Thank you for your help</div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 13px; font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-style: normal;">Best.</div><div style="background-color: transparent; color: rgb(0, 0, 0); font-size: 13px; font-family: 'Courier New', courier, monaco, monospace, sans-serif; font-style: normal;"><br></div></div></body></html>