]> Creatis software - clitk.git/blob - common/clitkXdrImageIO.h
Synergy projections file format
[clitk.git] / common / clitkXdrImageIO.h
1 #ifndef CLITKXDRIMAGEIO_H
2 #define CLITKXDRIMAGEIO_H
3
4 /**
5  * @file   clitkXdrImageIO.h
6  * @author Simon Rit <simon.rit@gmail.com>
7  * @date   Sun Jun  1 22:07:45 2008
8  *
9  * @brief
10  *
11  *
12  */
13
14 // itk include
15 #include "itkImageIOBase.h"
16
17 #define AVSerror(v)   itkGenericExceptionMacro(<< "Error in clitk::XdrImageIO. Message:" << v);
18 #define AVSwarning(v) itkWarningMacro(<< "Error in clitk::XdrImageIO. Message:" << v);
19
20 namespace clitk {
21
22 //====================================================================
23 // Class for reading xdr Image file format
24 class XdrImageIO: public itk::ImageIOBase
25 {
26 public:
27     /** Standard class typedefs. */
28     typedef XdrImageIO              Self;
29     typedef itk::ImageIOBase        Superclass;
30     typedef itk::SmartPointer<Self> Pointer;
31     typedef signed short int        PixelType;
32     typedef enum {UNIFORM,RECTILINEAR,IRREGULAR} AVSType;
33
34     XdrImageIO():Superclass() {
35         forcenoswap = 0;
36     }
37
38     /** Method for creation through the object factory. */
39     itkNewMacro(Self);
40
41     /** Run-time type information (and related methods). */
42     itkTypeMacro(XdrImageIO, ImageIOBase);
43
44     /*-------- This part of the interface deals with reading data. ------ */
45     virtual int ReadImageInformationWithError();
46     virtual int ReadWithError(void * buffer);
47     virtual void ReadImageInformation();
48     virtual void Read(void * buffer);
49     virtual bool CanReadFile( const char* FileNameToRead );
50
51     /*-------- This part of the interfaces deals with writing data. ----- */
52     virtual void WriteImageInformation(bool keepOfStream) {;}
53     virtual void WriteImageInformation() { WriteImageInformation(false); }
54     virtual bool CanWriteFile(const char* FileNameToWrite);
55     virtual void Write(const void* buffer);
56
57 protected:
58     void ITKError(std::string funcName, int msgID);
59     void WriteImage(const char* file, char* headerinfo, char* headerfile, int raw,\r
60                     int offset, char bLittleEndian, int iNkiCompression,\r
61                     int wcoords, int append, int getsize, char *tobuffer, const void* data);\r
62
63     int m_HeaderSize;
64     int forcenoswap;
65 }; // end class XdrImageIO
66
67 } // end namespace
68
69 // explicit template instantiation
70 template class itk::CreateObjectFunction<clitk::XdrImageIO>;
71
72 #endif /* end #define CLITKXDRIMAGEIO_H */
73