Hi<br><br><br>thanks for the tip! I will try this as soon as possible.<br><br>Adrian<br><br><div class="gmail_quote">On Wed, Apr 23, 2008 at 3:14 AM, Mike Jackson <<a href="mailto:imikejackson@gmail.com">imikejackson@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Look at vtkSmartPointer.h. Basically you use one of these to wrap your object and when it goes out of scope your object will get deleted for you.<br>
<br>
vtkStructuredPoints* GetField (int index)<br>
{<br>
vtkSmartPointer< vtkImageExtractComponents > extr = vtkSmartPointer< vtkImageExtractComponents >::New();<div class="Ih2E3d"><br>
extr->SetInput (this->GetInputField ());<br>
extr->SetComponents (index);<br>
extr->Update ();<br></div>
vtkStructuredPoints* pts = xtr->GetOutput ();<br>
pts->Register(NULL)<br>
return pts;<br>
}<br>
<br>
Note, that pts will have a ref count of 1 by the time it returns to the calling function. When the calling function is done with "pts", it should call pts->Delete();.<br>
<br>
Hope that helps.<br>
-- <br>
Mike Jackson Senior Research Engineer<br>
Innovative Management & Technology Services<div><div></div><div class="Wj3C7c"><br>
<br>
<br>
On Apr 22, 2008, at 6:32 PM, Adrian Albert wrote:<br>
<br>
</div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div></div><div class="Wj3C7c">
Dear All,<br>
<br>
I have a small problem in vtk: I have a class (not derived from any VTK object) that has methods for dealing with vtkImageData in various ways. For example, I am extracting one scalar component from a multi-component vtkImageData object using this function<br>
<br>
vtkStructuredPoints* GetField (int index)<br>
{<br>
vtkImageExtractComponents *extr = vtkImageExtractComponents::New ();<br>
extr->SetInput (this->GetInputField ());<br>
extr->SetComponents (index);<br>
extr->Update ();<br>
return (vtkStructuredPoints*) (extr->GetOutput ());<br>
}<br>
<br>
I am wondering if there is a problem with deallocating the extr object in the above function. I obviously cannot manually call Delete () on it, since I must use it for returning my output. Is the Delete () method automatically called when returning from the function to the calling routine? How 'big' is the extr object? Is it of the same size as the input to the vtkImageExtractComponents filter?<br>
<br>
Thanks for taking the pain in reading this!<br>
Adrian<br>
-- <br>
---------------------------------------------------<br>
Adrian Albert<br>
School of Engineering and Science<br>
Jacobs University Bremen<br>
Germany<br>
Tel.: 00494212003258<br></div></div>
_______________________________________________<br>
This is the private VTK discussion list.<br>
Please keep messages on-topic. Check the FAQ at: <a href="http://www.vtk.org/" target="_blank">http://www.vtk.org/</a>Wiki/VTK_FAQ<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote>
<br>
</blockquote></div><br><br clear="all"><br>-- <br>---------------------------------------------------<br>Adrian Albert<br>School of Engineering and Science<br>Jacobs University Bremen<br>Germany<br>Tel.: 00494212003258