-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathitkFDFImageIO.h
130 lines (100 loc) · 3.76 KB
/
itkFDFImageIO.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/* Copyright (C) 2004 Glenn Pierce.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __itkFDFImageIO_h
#define __itkFDFImageIO_h
#include "itkImageIOBase.h"
namespace itk
{
/* \brief ImageIO object for reading and writing FDF images
*
* \ingroup IOFilters
*
*/
class ITK_EXPORT FDFImageIO : public ImageIOBase
{
public:
/** Standard class typedefs. */
typedef FDFImageIO Self;
typedef ImageIOBase Superclass;
typedef SmartPointer<Self> Pointer;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Run-time type information (and related methods). */
itkTypeMacro(FDFImageIO, ImageIOBase);
virtual bool SupportsDimension( unsigned long dim )
{
if( dim == 2 || dim == 3 )
{
return true;
}
else
{
return false;
}
}
/*-------- This part of the interface deals with reading data. ------ */
/** Determine the file type. Returns true if this ImageIO can read the
* file specified. */
virtual bool CanReadFile(const char*);
/** Set the spacing and diemention information for the set filename. */
virtual void ReadImageInformation();
/** Get the type of the pixel. */
// virtual const std::type_info& GetPixelType() const;
/** Reads the data from disk into the memory buffer provided. */
virtual void Read(void* buffer);
/** Reads 3D data from multiple files assuming one slice per file. */
virtual void ReadVolume(void* buffer);
/** Compute the size (in bytes) of the components of a pixel. For
* example, and RGB pixel of unsigned char would have a
* component size of 1 byte. */
// virtual unsigned int GetComponentSize() const;
/*-------- This part of the interfaces deals with writing data. ----- */
/** Determine the file type. Returns true if this ImageIO can read the
* file specified. */
virtual bool CanWriteFile(const char*);
/** Writes the spacing and dimentions of the image.
* Assumes SetFileName has been called with a valid file name. */
virtual void WriteImageInformation();
/** Writes the data to disk from the memory buffer provided. Make sure
* that the IORegion has been set properly. */
virtual void Write(const void* buffer);
protected:
FDFImageIO();
~FDFImageIO();
void PrintSelf(std::ostream& os, Indent indent) const;
void WriteSlice(std::string& fileName, const void* buffer);
int ReadHeader(const char *FileNameToRead);
private:
FDFImageIO(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
void SwapBytesIfNecessary(void* buffer, unsigned long numberOfPixels);
// Position after ReadImageInformation.
size_t m_InputPosition;
std::string m_SpatialRank;
std::string m_Checksum;
std::string m_Bits;
std::vector<int> m_Size;
std::vector<float> m_Location;
std::vector<float> m_Span;
std::vector<float> m_Roi;
};
} // end namespace itk
#define RAISE_EXCEPTION() \
{ ExceptionObject exception(__FILE__, __LINE__); \
exception.SetDescription("File cannot be read"); \
throw exception; }
#endif