ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
rtkEdfImageIO.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright RTK Consortium
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18
19#ifndef rtkEdfImageIO_h
20#define rtkEdfImageIO_h
21
22#include <cstring>
23#include <fstream>
24#include <itkImageIOBase.h>
25
26#include "RTKExport.h"
27#include "rtkMacro.h"
28
29namespace rtk
30{
31
40class RTK_EXPORT EdfImageIO : public itk::ImageIOBase
41{
42public:
43 ITK_DISALLOW_COPY_AND_MOVE(EdfImageIO);
44
49
51
53 itkNewMacro(Self);
54
56 itkOverrideGetNameOfClassMacro(EdfImageIO);
57
58 /*-------- This part of the interface deals with reading data. ------ */
59 void
61
62 bool
63 CanReadFile(const char * FileNameToRead) override;
64
65 void
66 Read(void * buffer) override;
67
68 /*-------- This part of the interfaces deals with writing data. ----- */
69 virtual void
70 WriteImageInformation(bool keepOfStream);
71
72 void
74 {
76 }
77
78 bool
79 CanWriteFile(const char * filename) override;
80
81 void
82 Write(const void * buffer) override;
83
84protected:
85 std::string m_BinaryFileName;
87
88 static char *
89 edf_findInHeader(char * header, const char * key);
90
91 /* List of EDF supported datatypes
92 */
94 {
96 CHAR_DATATYPE = 1, // 8 bits = 1 B
98 SHORT_DATATYPE = 3, // 16 bits = 2 B
100 INT_DATATYPE = 5, // 32 bits = 4 B
102 L_INT_DATATYPE = 7, // 32 bits = 4 B
104 DOUBLE_DATATYPE = 9, // 4 B, 8 B
106 };
107
108 /* Note - compatibility:
109 Unsigned8 = 1,Signed8, Unsigned16, Signed16,
110 Unsigned32, Signed32, Unsigned64, Signed64,
111 FloatIEEE32, DoubleIEEE64
112 */
113
114 /***************************************************************************
115 * Tables
116 ***************************************************************************/
117
118 // table key-value structure
119 struct table
120 {
121 const char * key;
122 int value;
123 };
124
125 struct table3
126 {
127 const char * key;
128 int value;
129 short sajzof;
130 };
131
132 /* Returns index of the table tbl whose key matches the beginning of the
133 * search string search_str.
134 * It returns index into the table or -1 if there is no match.
135 */
136 static int
137 lookup_table_nth(const struct table * tbl, const char * search_str)
138 {
139 int k = -1;
140
141 while (tbl[++k].key)
142 if (tbl[k].key && !strncmp(search_str, tbl[k].key, strlen(tbl[k].key)))
143 return k;
144 return -1; // not found
145 }
146
147 static int
148 lookup_table3_nth(const struct table3 * tbl, const char * search_str)
149 {
150 int k = -1;
151
152 while (tbl[++k].key)
153 if (tbl[k].key && !strncmp(search_str, tbl[k].key, strlen(tbl[k].key)))
154 return k;
155 return -1; // not found
156 }
157
159 // * the file. (Determines the scanning direction, or the "fastest" index
160 // * of the matrix in the data file.)
161 // */
162 // enum EdfRasterAxes {
163 // RASTER_AXES_XrightYdown, // matricial format: rows, columns
164 // RASTER_AXES_XrightYup // cartesian coordinate system
165 // // other 6 combinations not available (not needed until now)
166 //};
167
168 // static const struct table rasteraxes_table[] =
169 //{
170 // { "XrightYdown", RASTER_AXES_XrightYdown },
171 // { "XrightYup", RASTER_AXES_XrightYup },
172 // { NULL, -1 }
173 //};
174
175}; // end class EdfImageIO
176
177} // namespace rtk
178
179#endif
Abstract superclass defines image IO interface.
Implements transparent reference counting.
void ReadImageInformation() override
void WriteImageInformation() override
EdfImageIO Self
itk::ImageIOBase Superclass
static int lookup_table3_nth(const struct table3 *tbl, const char *search_str)
void Write(const void *buffer) override
itk::SmartPointer< Self > Pointer
std::string m_BinaryFileName
static int lookup_table_nth(const struct table *tbl, const char *search_str)
void Read(void *buffer) override
static char * edf_findInHeader(char *header, const char *key)
bool CanWriteFile(const char *filename) override
bool CanReadFile(const char *FileNameToRead) override
virtual void WriteImageInformation(bool keepOfStream)