]> Creatis software - clitk.git/blob - common/clitkXdrImageIO.h
Remove sonarQube
[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://www.centreleonberard.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 #include "clitkCommon.h"
38
39 namespace clitk {
40
41 //====================================================================
42 // Class for reading xdr Image file format
43 class XdrImageIO: public itk::ImageIOBase
44 {
45 public:
46     /** Standard class typedefs. */
47     typedef XdrImageIO              Self;
48     typedef itk::ImageIOBase        Superclass;
49     typedef itk::SmartPointer<Self> Pointer;
50     typedef signed short int        PixelType;
51     typedef enum {UNIFORM,RECTILINEAR,IRREGULAR} AVSType;
52
53     XdrImageIO():Superclass() {
54         forcenoswap = 0;
55     }
56
57     /** Method for creation through the object factory. */
58     itkNewMacro(Self);
59
60     /** Run-time type information (and related methods). */
61     itkTypeMacro(XdrImageIO, ImageIOBase);
62
63     /*-------- This part of the interface deals with reading data. ------ */
64     virtual int ReadImageInformationWithError();
65     virtual int ReadWithError(void * buffer);
66     virtual void ReadImageInformation() ITK_OVERRIDE;
67     virtual void Read(void * buffer) ITK_OVERRIDE;
68     virtual bool CanReadFile( const char* FileNameToRead ) ITK_OVERRIDE;
69
70     /*-------- This part of the interfaces deals with writing data. ----- */
71     virtual void WriteImageInformation(bool keepOfStream) {;}
72     virtual void WriteImageInformation() ITK_OVERRIDE { WriteImageInformation(false); }
73     virtual bool CanWriteFile(const char* FileNameToWrite) ITK_OVERRIDE;
74     virtual void Write(const void* buffer) ITK_OVERRIDE;
75
76 protected:
77     void ITKError(std::string funcName, int msgID);
78     void WriteImage(const char* file, char* headerinfo, char* headerfile, int raw,
79                     int offset, char bLittleEndian, int iNkiCompression,
80                     int wcoords, int append, int getsize, char *tobuffer, const void* data);
81
82     int m_HeaderSize;
83     int forcenoswap;
84 }; // end class XdrImageIO
85
86 } // end namespace
87
88 // explicit template instantiation
89 //template class itk::CreateObjectFunction<clitk::XdrImageIO>;
90
91 #endif /* end #define CLITKXDRIMAGEIO_H */
92