Hi Charlotte,<br><br><br> Yes, your intuition is right.<br><br><br> Calling Register() in ITK is a bad idea.<br><br><br>What you want to do is actually a lot simpler.<br><br> A) Use a Raw pointer for doing the casting and<br>
<br> B) Just after casting assign the pointer to a<br> SmartPointer. The operator assignment<br> of the SmartPointer will do the Register<br> calls for you.<br><br><br><br> Regards,<br><br><br> Luis<br>
<br><br>-----------------------------------------------------<br><div class="gmail_quote">On Thu, Jun 25, 2009 at 12:56 PM, Charlotte Curtis <span dir="ltr"><<a href="mailto:c.f.curtis@gmail.com">c.f.curtis@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;"><div class="im">On Sat, Jun 20, 2009 at 6:38 PM, motes motes<<a href="mailto:mort.motes@gmail.com">mort.motes@gmail.com</a>> wrote:<br>
</div><div class="im">> cannot convert from 'itk::SmartPointer<TObjectType>' to<br>
> 'itk::SmartPointer<TObjectType>'<br>
><br>
> But as I understand ImageToImageFilter is a base class for<br>
> RescaleIntensityImageFilter so I don't see why I get this error, but maybe<br>
> my C++ skills are a bit rusty.<br>
<br>
</div>I've also been working on casting to the base class lately and one<br>
thing that I've discovered is that you need to cast to a raw pointer<br>
instead of a smart pointer (like Luis said). Maybe try:<br>
<br>
ImageToImageFilterType *pp1 = static_cast<ImageToImageFilterType *>(pp0);<br>
<br>
However, if you do that you might get a seg fault from the filter<br>
going out of scope (assuming pp0 is created in the function as a smart<br>
pointer and is not a member variable). The workaround for this that<br>
I've found (and I'm sure it's a terrible hack) is to artificially<br>
increase the reference count before casting to the base class by first<br>
calling:<br>
<br>
pp0->Register();<br>
<br>
Of course, if there's a better way to be doing this, I'd love to hear<br>
about it too.<br>
<font color="#888888"><br>
Charlotte<br>
</font><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<br>
<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 ITK FAQ at: <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
</div></div></blockquote></div><br>