1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
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
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.
13 It is distributed under dual licence
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
22 #include <itkImageIOBase.h>
23 #include <itksys/RegularExpression.hxx>
25 #if defined (_MSC_VER) && (_MSC_VER < 1600)
27 //#include "msinttypes/stdint.h"
28 typedef unsigned int uint32_t;
33 #include "clitkCommon.h"
38 //====================================================================
39 // Class for reading gate ascii Image file format
40 class GateAsciiImageIO: public itk::ImageIOBase
43 /** Standard class typedefs. */
44 typedef GateAsciiImageIO Self;
45 typedef itk::ImageIOBase Superclass;
46 typedef itk::SmartPointer<Self> Pointer;
48 struct GateAsciiHeader {
49 double matrix_size[3];
55 GateAsciiImageIO():Superclass() {}
57 /** Method for creation through the object factory. */
60 /** Run-time type information (and related methods). */
61 itkTypeMacro(GateAsciiImageIO, ImageIOBase);
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;
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;
73 virtual bool SupportsDimension(unsigned long dim) ITK_OVERRIDE;
76 static bool ReadHeader(FILE* handle, GateAsciiHeader& header);
77 static bool ReadLine(FILE* handle, std::string& line);
78 static bool FindRegularExpressionNextLine(itksys::RegularExpression ®, std::string &s, FILE* handle);
80 }; // end class GateAsciiImageIO
83 // explicit template instantiation
84 //template class itk::CreateObjectFunction<clitk::GateAsciiImageIO>;
86 #endif /* end #define CLITKGATEASCIIIMAGEIO_H */