<div class="gmail_quote">On Thu, Mar 4, 2010 at 10:41 AM, Marius Erdt <span dir="ltr"><<a href="mailto:marius.erdt@gmx.de">marius.erdt@gmx.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi vtk-users,<br>
<br>
I've got a function that should recompute the normals of a vtkPolyData. However, if I try to delete the input poly by calling Delete and assign the output of the filter to its variable, the program chrashes.<br>
<br>
void computeNormals( vtkPolyData* &poly ){<br>
<br>
vtkPolyDataNormals* normalsGen = vtkPolyDataNormals::New();<br>
normalsGen->SetInput( poly );<br>
normalsGen->Update();<br>
<br>
poly->Delete();<br>
poly = NULL;<br>
poly = vtkPolyData::New();<br>
poly->DeepCopy( normalsGen->GetOutput() );<br>
<br>
normalsGen->Delete();<br>
}<br>
<br>
The codes works if I don't delete the input PolyData. However, then I got a memory leak since the data of the original poly is not released.<br>
<br>
Does anyone knows a solution?<br>
<br>
Thanks,<br>
Marius<br><br></blockquote><div class="gmail_quote"><br></div><div class="gmail_quote">What happens if you do:</div><div class="gmail_quote"><br></div>void computeNormals( vtkPolyData* &poly )</div><div class="gmail_quote">
{<br><br> vtkSmartPointer<vtkPolyDataNormals> normalsGen = </div><div class="gmail_quote"> vtkSmartPointer<vtkPolyDataNormals>::New();<br> normalsGen->SetInput( poly );<br> normalsGen->Update();<br>
<br> poly->ShallowCopy(normalsGen->GetOutput() <br>}</div><div class="gmail_quote"><br></div><div class="gmail_quote">?</div>