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;
36 //====================================================================
37 // Class for reading gate ascii Image file format
38 class GateAsciiImageIO: public itk::ImageIOBase
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;
47 struct GateAsciiHeader {
48 double matrix_size[3];
54 GateAsciiImageIO():Superclass() {}
56 /** Method for creation through the object factory. */
59 /** Run-time type information (and related methods). */
60 itkTypeMacro(GateAsciiImageIO, ImageIOBase);
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);
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);
72 virtual bool SupportsDimension(unsigned long dim);
75 static bool ReadHeader(FILE* handle, GateAsciiHeader& header);
76 static bool ReadLine(FILE* handle, std::string& line);
77 static bool FindRegularExpressionNextLine(itksys::RegularExpression ®, std::string &s, FILE* handle);
79 }; // end class GateAsciiImageIO
82 // explicit template instantiation
83 //template class itk::CreateObjectFunction<clitk::GateAsciiImageIO>;
85 #endif /* end #define CLITKGATEASCIIIMAGEIO_H */