It sounds like I should be moving away from smart pointers for my threaded application.  With that in mind, I was hoping you could answer this question.  I want to store a bunch of vtkImageData&#39;s in a permanent storage.  However, these can be made in a number of ways (from different filters, io, my own special sauce), and I was wondering what the best way to get information out of a vtk filter is.  For instance if I have<div>
<br></div><div>vtkImageData -&gt; vtk filter -&gt; temp vtkImageData -&gt; vtk filter -&gt; output</div><div><br></div><div>I&#39;ve been using vtkImageData::New(), followed by vtkImageData-&gt;DeepCopy(filter-&gt;GetOutput()).  I&#39;ve been doing this cause I notice that once I delete the filter the output no longer exists.</div>
<div><br></div><div>Is this the correct way to go about handling this situation?</div><div><br><div class="gmail_quote">On Tue, Sep 6, 2011 at 11:55 AM, David Gobbi <span dir="ltr">&lt;<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im"><div>On Tue, Sep 6, 2011 at 12:34 PM, Jonathan Morra <span dir="ltr">&lt;<a href="mailto:jonmorra@gmail.com" target="_blank">jonmorra@gmail.com</a>&gt;</span> wrote:<br>
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

This could make sense, I&#39;m going to try and change all my method signatures to pass around const references to vtkSmartPointers where appropriate.  Do you know what happens to the reference count upon returning a vtkSmartPointer?</blockquote>


</div><br></div><div><br></div></div><div>In VTK, smart pointers should only be used to store references, not to pass them.  VTK methods should take regular pointers as arguments.</div><div><br></div><div>The general rules are:</div>


<div><br></div><div>1) Refcounts are not automatically incremented when objects are returned, i.e. when an object is returned to you, then you are just &quot;borrowing&quot; it.  If you need to own it for a while, then store it in a smart pointer.</div>


<div><br></div><div>2) Refcounts are not automatically incremented when objects are passed to a method.  If a method needs to own the object for a while, it should store it in a smart pointer.  All methods in the VTK libraries that need to own the objects that are passed to them will increment the refcount of those objects, either by storing it in a smart pointer or by calling Register() on it.</div>


<div><br></div><div>There are a few very rare exceptions to rule #1, such as the NewInstance() method.</div><div><br></div><font color="#888888"><div> - David</div>
</font></blockquote></div><br></div>