[ITK Community] [Insight-users] Importing Const Data Buffer

Andrew Pound Andrew.Pound at aggiemail.usu.edu
Fri Jan 17 11:45:50 EST 2014


Matt,
Thanks for the quick response.
Does a ConstPointer allow any changes to the underlying
pixels/PixelContainer?
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.

Thanks,
Andrew


On Thu, Jan 16, 2014 at 10:27 PM, Matt McCormick <matt.mccormick at kitware.com
> wrote:

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

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-users


More information about the Community mailing list