I've been following along with this conversation and following the example on the wiki, I tried to do this:<br><br> vtkSmartPointer<vtkMultiBlockPLOT3DReader> m_Reader2;<br> vtkSmartPointer<vtkMultiBlockDataSet> dataset = m_Reader2->GetOutput();<br>
<br>which gave me an error <br> error C2664: 'vtkSmartPointerBase::vtkSmartPointerBase(vtkObjectBase *)' : cannot convert parameter 1 from 'vtkMultiBlockDataSet *' to 'vtkObjectBase *'<br><br>I can't seem to figure out why this is the case?<br>
<br><br><div class="gmail_quote">On Fri, Nov 6, 2009 at 4:03 PM, Alex Malyushytskyy <span dir="ltr"><<a href="mailto:alexmalvtk@gmail.com">alexmalvtk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Jeff,<br>
<div class="im"><br>
> sp = NULL; // Release would happen here.<br>
</div>That was what I was looking for.<br>
When I tried to look at the code I forgot that vtkSmartPointer is<br>
dialing with vtkObjectBase pointers.<br>
<div class="im"><br>
> Normally you just wait for the smart pointer to go out of scope.<br>
<br>
</div>Main reason for me to use smartpointers - it helps dealing with<br>
exceptions especially thrown from constructors.<br>
So I usually use smart pointers as a class members instead of raw pointers .<br>
And even though smartpointer will do his job when it goes out of scope,<br>
you may get situation when you need to replace the data when it does not.<br>
<br>
Example:<br>
Assume poly data is read from the file and stored with smartpointer.<br>
User action changes the data (for example some additional tessellation).<br>
If result is satisfactory, old data should be replaced.<br>
<br>
Thanks everybody for help,<br>
<font color="#888888"> Alex<br>
</font><div><div></div><div class="h5"><br>
<br>
<br>
<br>
On Fri, Nov 6, 2009 at 5:53 AM, Jeff Baumes <<a href="mailto:jeff.baumes@kitware.com">jeff.baumes@kitware.com</a>> wrote:<br>
>> The only thing is not clear for me is how to force smartpointer to<br>
>> release the data.<br>
>><br>
><br>
> Is this what you're looking for?<br>
> vtkSmartPointer<vtkType> sp = vtkSmartPointer<vtkType>::New();<br>
> ...<br>
> sp = NULL; // Release would happen here.<br>
> This would decrement the reference count of the object by one. If no one<br>
> else holds a reference count of the object (i.e. reference count goes to<br>
> zero), it will be released from memory.<br>
> Normally you just wait for the smart pointer to go out of scope. If you<br>
> explicitly need to make the reference go away at a certain point, you might<br>
> as well not use smart pointers and just do this equivalent code:<br>
> vtkType* p = vtkType::New();<br>
> ...<br>
> p->Delete();<br>
> Jeff<br>
</div></div><div><div></div><div class="h5">_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<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>
</div></div></blockquote></div><br>