[Insight-users] Importing Const Data Buffer

Andrew Pound Andrew.Pound at aggiemail.usu.edu
Thu Jan 16 20:34:01 EST 2014


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20140116/8ed83405/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.cpp
Type: text/x-c++src
Size: 3412 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20140116/8ed83405/attachment.cpp>


More information about the Insight-users mailing list