<div dir="ltr"><div>Matt, </div><div>Thanks for the quick response.</div><div>Does a ConstPointer allow any changes to the underlying pixels/PixelContainer?</div><div>This hails from the whole const pointer to a mutable type, and the possibility that the data can still be changed when the pointer itself is const.</div>

<div><br></div><div>Thanks,</div><div>Andrew</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jan 16, 2014 at 10:27 PM, Matt McCormick <span dir="ltr"><<a href="mailto:matt.mccormick@kitware.com" target="_blank">matt.mccormick@kitware.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Andrew,<br>
<br>
Even with changing cast, on G++ in it not compile because of<br>
initialization of a const array with new.<br>
<br>
A const version of the image can be obtained with<br>
<br>
ImageType::ConstPointer importedImage = importFilter->GetOutput();<br>
<br>
Hopt this helps,<br>
Matt<br>
<div><div class="h5"><br>
On Thu, Jan 16, 2014 at 8:34 PM, Andrew Pound<br>
<<a href="mailto:Andrew.Pound@aggiemail.usu.edu">Andrew.Pound@aggiemail.usu.edu</a>> wrote:<br>
> I am working on an interface between some current data and ITK, and ran into<br>
> an issue.<br>
> When my data has const pixels, I hoped to obtain an itk::Image with const<br>
> pixels also.  I was also looking for a shallow-copy-type solution, which led<br>
> me to use the itkImportImageFilter.  But it won't compile, because of a<br>
> casting problem down in the PrintSelf() function of the<br>
> itkImportImageContainer.  Attached is a modified and stripped down copy of<br>
> the example program Image5.cxx that exhibits the problem.<br>
><br>
> The error is:<br>
><br>
> 1> C:\itk\itkimportimagecontainer.hxx(220): error C2440: 'static_cast' :<br>
> cannot convert from 'const unsigned char *const ' to 'void *'<br>
> 1> Conversion loses qualifiers<br>
> 1> C:\itk\itkimportimagecontainer.hxx(217) : while compiling class template<br>
> member function 'void<br>
> itk::ImportImageContainer<TElementIdentifier,TElement>::PrintSelf(std::ostream<br>
> &,itk::Indent) const'<br>
> 1> with<br>
> 1> [<br>
> 1> TElementIdentifier=unsigned long,<br>
> 1> TElement=const unsigned char<br>
> 1> ]<br>
><br>
> The function that is referenced is in itkimportimagecontainer.hxx:<br>
><br>
> template< typename TElementIdentifier, typename TElement ><br>
> void<br>
> ImportImageContainer< TElementIdentifier, TElement ><br>
> ::PrintSelf(std::ostream & os, Indent indent) const<br>
> {<br>
>   Superclass::PrintSelf(os, indent);<br>
><br>
>   os << indent << "Pointer: " << static_cast< void * >( m_ImportPointer ) <<<br>
> std::endl;<br>
>   os << indent << "Container manages memory: "<br>
>      << ( m_ContainerManageMemory ? "true" : "false" ) << std::endl;<br>
>   os << indent << "Size: " << m_Size << std::endl;<br>
>   os << indent << "Capacity: " << m_Capacity << std::endl;<br>
> }<br>
><br>
> I am currently compiling on Win64 using Visual Studio 2010 Professional.<br>
> (But I also will be compiling this on G++ on both solaris and Linux...)<br>
><br>
> Is this a bug that should be addressed? Or...<br>
> Is there an easier way to do what I'd like to do?<br>
><br>
> Thanks,<br>
> Andrew<br>
><br>
</div></div>> _____________________________________<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>
> Kitware offers ITK Training Courses, for more information visit:<br>
> <a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
><br>
> Please keep messages on-topic and check the ITK FAQ at:<br>
> <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>
><br>
> _______________________________________________<br>
> Community mailing list<br>
> <a href="mailto:Community@itk.org">Community@itk.org</a><br>
> <a href="http://public.kitware.com/cgi-bin/mailman/listinfo/community" target="_blank">http://public.kitware.com/cgi-bin/mailman/listinfo/community</a><br>
><br>
</blockquote></div><br></div>