]> Creatis software - clitk.git/blob - common/clitkGateAsciiImageIO.h
d0abbea0b91922c47e73b48a3768eec279266ec4
[clitk.git] / common / clitkGateAsciiImageIO.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 CLITKGATEASCIIIMAGEIO_H
19 #define CLITKGATEASCIIIMAGEIO_H
20
21 // itk include
22 #include "itkImageIOBase.h"
23
24 #if defined (_MSC_VER) && (_MSC_VER < 1600)
25 //SR: taken from
26 //#include "msinttypes/stdint.h"
27 typedef unsigned int uint32_t;
28 #else
29 #include <stdint.h>
30 #endif
31
32 namespace clitk {
33
34     //====================================================================
35     // Class for reading gate ascii Image file format
36     class GateAsciiImageIO: public itk::ImageIOBase
37     {
38         public: 
39             /** Standard class typedefs. */
40             typedef GateAsciiImageIO        Self;
41             typedef itk::ImageIOBase        Superclass;
42             typedef itk::SmartPointer<Self> Pointer;    
43             typedef signed short int        PixelType;
44
45             struct GateAsciiHeader {
46                 double matrix_size[3];
47                 int resolution[3];
48                 double voxel_size[3];
49                 int nb_value;
50             };
51
52             GateAsciiImageIO():Superclass() {;}
53
54             /** Method for creation through the object factory. */
55             itkNewMacro(Self);
56
57             /** Run-time type information (and related methods). */
58             itkTypeMacro(GateAsciiImageIO, ImageIOBase);
59
60             /*-------- This part of the interface deals with reading data. ------ */
61             virtual void ReadImageInformation();
62             virtual bool CanReadFile( const char* FileNameToRead );
63             virtual void Read(void * buffer);
64
65             /*-------- This part of the interfaces deals with writing data. ----- */
66             virtual void WriteImageInformation();
67             virtual bool CanWriteFile(const char* filename);
68             virtual void Write(const void* buffer);
69
70             virtual bool SupportsDimension(unsigned long dim);
71
72         protected:
73
74             static bool ReadHeader(FILE* handle, GateAsciiHeader& header);
75             static bool ReadLine(FILE* handle, std::string& line);
76
77     }; // end class GateAsciiImageIO
78 } // end namespace
79
80 // explicit template instantiation
81 //template class itk::CreateObjectFunction<clitk::GateAsciiImageIO>;
82
83 #endif /* end #define CLITKGATEASCIIIMAGEIO_H */
84