]> Creatis software - clitk.git/blob - common/clitkXdrImageIO.h
d145e063cd122590b4eb85c30288d40836916288
[clitk.git] / common / clitkXdrImageIO.h
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
18 #ifndef CLITKXDRIMAGEIO_H
19 #define CLITKXDRIMAGEIO_H
20
21 /**
22  * @file   clitkXdrImageIO.h
23  * @author Simon Rit <simon.rit@gmail.com>
24  * @date   Sun Jun  1 22:07:45 2008
25  *
26  * @brief
27  *
28  *
29  */
30
31 // itk include
32 #include "itkImageIOBase.h"
33
34 #define AVSerror(v)   itkGenericExceptionMacro(<< "Error in clitk::XdrImageIO. Message:" << v);
35 #define AVSwarning(v) itkWarningMacro(<< "Error in clitk::XdrImageIO. Message:" << v);
36
37 namespace clitk {
38
39 //====================================================================
40 // Class for reading xdr Image file format
41 class XdrImageIO: public itk::ImageIOBase
42 {
43 public:
44     /** Standard class typedefs. */
45     typedef XdrImageIO              Self;
46     typedef itk::ImageIOBase        Superclass;
47     typedef itk::SmartPointer<Self> Pointer;
48     typedef signed short int        PixelType;
49     typedef enum {UNIFORM,RECTILINEAR,IRREGULAR} AVSType;
50
51     XdrImageIO():Superclass() {
52         forcenoswap = 0;
53     }
54
55     /** Method for creation through the object factory. */
56     itkNewMacro(Self);
57
58     /** Run-time type information (and related methods). */
59     itkTypeMacro(XdrImageIO, ImageIOBase);
60
61     /*-------- This part of the interface deals with reading data. ------ */
62     virtual int ReadImageInformationWithError();
63     virtual int ReadWithError(void * buffer);
64     virtual void ReadImageInformation();
65     virtual void Read(void * buffer);
66     virtual bool CanReadFile( const char* FileNameToRead );
67
68     /*-------- This part of the interfaces deals with writing data. ----- */
69     virtual void WriteImageInformation(bool keepOfStream) {;}
70     virtual void WriteImageInformation() { WriteImageInformation(false); }
71     virtual bool CanWriteFile(const char* FileNameToWrite);
72     virtual void Write(const void* buffer);
73
74 protected:
75     void ITKError(std::string funcName, int msgID);
76     void WriteImage(const char* file, char* headerinfo, char* headerfile, int raw,
77                     int offset, char bLittleEndian, int iNkiCompression,
78                     int wcoords, int append, int getsize, char *tobuffer, const void* data);
79
80     int m_HeaderSize;
81     int forcenoswap;
82 }; // end class XdrImageIO
83
84 } // end namespace
85
86 // explicit template instantiation
87 //template class itk::CreateObjectFunction<clitk::XdrImageIO>;
88
89 #endif /* end #define CLITKXDRIMAGEIO_H */
90