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