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