[Insight-users] Namespace problem with custom ImageIO class

Bill Lorensen bill.lorensen at gmail.com
Fri Oct 26 23:40:34 EDT 2007


David,

I just compiled your example with a Borland compiler. I commented out all of
the AIM specific stuff and added {}'s to the methods that would normally be
defined on the .cxx file. It compiled without error.

Another possibility. Is there another itkAIMImageIO.h somewhere on the
system that you are getting instead of the one you think you are getting?
Introduce a syntax error in your copy and see if the compiler picks it up.

Bill


On 10/26/07, Bill Lorensen <bill.lorensen at gmail.com> wrote:
>
> David,
>
> Looks OK to me. Does aimpack.h contain and strange #define's?
>
> Bill
>
>
>  On 10/18/07, David Christen <davidchristen at gmail.com> wrote:
> >
> > Hi all.
> >
> > I wrote an ImageIO-class for a proprietary image file format (AIM).
> > (see  itkAIMImageIO.h below) For the last few days I was trying to add
> > the possibility of reading/writing a log about the processing done on
> > the image (ProcessingLog). However, if I call the Set- or
> > GetProcessingLog functions, I get a compiler error:
> >
> > AIMReadWrite.cxx:59: error: 'class itk::AIMImageIO' has no member
> > named 'SetProcessingLog'
> >
> > The idea is to get the log from the reader-object, eventually modify
> > it and finally pass it to the writer-object.
> >
> > I've been trying many things and I found out, that I can't declare any
> > additional public functions or members. Well, I can, and I can even
> > find it in the (shared) library, but if I include it in an application
> > and try to call the method or variable, I get the error above.
> > If I don't call any of the added functions, the application compiles
> > smoothly and the executable does exactly as expected.
> >
> > If I make the member variable m_ProcessingLog public, I still can't
> > access it from outside the class. ("... has no member named
> > 'm_ProcessingLog' ")
> >
> > The output of nm is:
> > [dch at neuron itkUtilities]$ nm -C libvtkmyITKUtility.so | grep AIMImageIO
> > <..>
> > 00000000000f15fa W itk::AIMImageIO::SetProcessingLog(char const*)
> > 00000000000f15cc W
> > itk::AIMImageIO::SetProcessingLog(std::basic_string<char,
> > std::char_traits<char>, std::allocator<char> > const&)
> > <..>
> > 00000000000f15dc W itk::AIMImageIO::GetProcessingLog() const
> > <..>
> >
> > So the macro was correctly expanded (I even tested it in a member
> > function of the class).
> >
> > I strongly suspect a namespace problem, but I can't figure out what I
> > have to change.
> >
> > Any help is very much appreciated,
> > David
> >
> >
> >
> > /**========================================================================
> > itkAIMImageIO.h
> > =========================================================================*/
> >
> > #ifndef __itkAIMImageIO_h
> > #define __itkAIMImageIO_h
> >
> > #include "itkImageIOBase.h"
> >
> > #include "aimpack.h"
> >
> > namespace itk
> > {
> > /** \class AIMImageIO
> > *
> > * \brief ImageIO object for reading and writing AIM Files
> > *
> > */
> > class ITK_EXPORT AIMImageIO : public ImageIOBase
> > {
> > public:
> > /** Standard class typedefs. */
> > typedef AIMImageIO            Self;
> > typedef ImageIOBase  Superclass;
> > typedef SmartPointer<Self>  Pointer;
> > typedef SmartPointer<const Self>  ConstPointer;
> >
> > /** Method for creation through the object factory. */
> > itkNewMacro(Self);
> >
> > /** Run-time type information (and related methods). */
> > itkTypeMacro(AIMImageIO, ImageIOBase);
> >
> > /** Any other get/set options that should be public */
> >
> > itkGetStringMacro(ProcessingLog);
> > itkSetStringMacro(ProcessingLog);
> >
> > /*-------- This part of the interface deals with reading data. -----*/
> >
> > /** Determine the file type. Returns true if this ImageIO can read the
> >   * file specified. */
> > virtual bool CanReadFile(const char*);
> >
> > /** Set the spacing and diemention information for the set filename.*/
> > virtual void ReadImageInformation();
> >
> > /** Reads the data from disk into the memory buffer provided. */
> > virtual void Read(void* buffer);
> >
> >
> > /*-------- This part of the interfaces deals with writing data. ----*/
> >
> > /** Determine the file type. Returns true if this ImageIO can read the
> >   * file specified. */
> > virtual bool CanWriteFile(const char*);
> >
> > /** Writes the spacing and dimentions of the image.
> >   * Assumes SetFileName has been called with a valid file name. */
> > virtual void WriteImageInformation();
> >
> > /** Writes the data to disk from the memory buffer provided. Make sure
> >   * that the IORegion has been set properly. */
> > virtual void Write(const void* buffer);
> >
> > protected:
> > AIMImageIO();
> > ~AIMImageIO();
> > void PrintSelf(std::ostream& os, Indent indent) const;
> >
> > D3AnyImage030 * m_AIMimage;
> > std::string m_ProcessingLog;
> >
> > private:
> > AIMImageIO(const Self&); //purposely not implemented
> > void operator=(const Self&); //purposely not implemented
> >
> > };
> >
> > } // end namespace itk
> >
> > #endif // __itkAIMImageIO_h
> >
> >
> > /**========================================================================
> >
> > AIMReadWrite.cxx
> >
> > =========================================================================*/
> > #include "itkImageFileReader.h"
> > #include "itkImageFileWriter.h"
> > #include "itkAIMImageIO.h "
> >
> > //#include "itkImage.h"
> >
> >
> > int main( int argc, char ** argv )
> > {
> > // Verify the number of parameters in the command line
> > if( argc < 3 )
> >    {
> >    std::cerr << "Usage: " << std::endl;
> >    std::cerr << argv[0] << " inputImageFile  outputImageFile "
> >              <<std::endl;
> >    return EXIT_FAILURE;
> >    }
> >
> > typedef float      PixelType;
> > const   unsigned int        Dimension = 3;
> > typedef itk::Image< PixelType, Dimension >    ImageType;
> >
> > typedef itk::ImageFileReader< ImageType >  ReaderType;
> > typedef itk::ImageFileWriter< ImageType >  WriterType;
> > typedef itk::AIMImageIO                    ImageIOType;
> >
> > ReaderType::Pointer reader = ReaderType::New();
> > WriterType::Pointer writer = WriterType::New();
> > ImageIOType::Pointer aimIOwrite = ImageIOType::New();
> > ImageIOType::Pointer aimIOread = ImageIOType::New();
> >
> > const char * inputFilename  = argv[1];
> > const char * outputFilename = argv[2];
> >
> > reader->SetFileName( inputFilename  );
> > writer->SetFileName( outputFilename );
> >
> > writer->SetInput( reader->GetOutput() );
> >
> > aimIOread->CanReadFile(inputFilename);
> >
> > reader->SetImageIO( aimIOread );
> > writer->SetImageIO( aimIOwrite );
> >
> > try
> >    {
> >    reader->Update();
> >    }
> > catch( itk::ExceptionObject & err )
> >    {
> >    std::cerr << "ExceptionObject caught !" << std::endl;
> >    std::cerr << err << std::endl;
> >    return EXIT_FAILURE;
> >    }
> >
> > aimIOwrite->SetProcessingLog( aimIOread->GetProcessingLog() );
> >
> > try
> >    {
> >    writer->Update();
> >    }
> > catch( itk::ExceptionObject & err )
> >    {
> >    std::cerr << "ExceptionObject caught !" << std::endl;
> >    std::cerr << err << std::endl;
> >    return EXIT_FAILURE;
> >    }
> >
> > return EXIT_SUCCESS;
> > }
> > _______________________________________________
> > Insight-users mailing list
> > Insight-users at itk.org
> > http://www.itk.org/mailman/listinfo/insight-users
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20071026/c20f0f4f/attachment-0001.html


More information about the Insight-users mailing list