ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkIPLFileNameList.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
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 *
20 * Portions of this file are subject to the VTK Toolkit Version 3 copyright.
21 *
22 * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
23 *
24 * For complete copyright, license and disclaimer of warranty information
25 * please refer to the NOTICE file at the top of the ITK source tree.
26 *
27 *=========================================================================*/
28#ifndef itkIPLFileNameList_h
29#define itkIPLFileNameList_h
30#include "ITKIOIPLExport.h"
31
32#include "itkMath.h"
33#include "itkMacro.h"
34#include "itkObject.h"
35
36#include <cstdio>
37#include <string>
38#include <list>
40#define IPLSetMacroDeclaration(name, type) virtual void Set##name(const type _arg)
41
42#define IPLSetMacroDefinition(class, name, type) \
43 void class ::Set##name(const type _arg) \
44 { \
45 ITK_GCC_PRAGMA_PUSH \
46 ITK_GCC_SUPPRESS_Wfloat_equal \
47 if (this->m_##name != _arg) \
48 { \
49 this->m_##name = _arg; \
50 } \
51 ITK_GCC_PRAGMA_POP \
52 } \
53 ITK_MACROEND_NOOP_STATEMENT
54
56#define IPLGetMacroDeclaration(name, type) virtual type Get##name()
57
58#define IPLGetMacroDefinition(class, name, type) \
59 type class ::Get##name() { return this->m_##name; } \
60 ITK_MACROEND_NOOP_STATEMENT
61namespace itk
62{
69{
70public:
71 IPLFileSortInfo() = default;
72
73 IPLFileSortInfo(const char * const filename,
74 float sliceLocation,
75 int sliceOffset,
76 int echoNumber,
77 int imageNumber,
78 void * data = nullptr)
79 : m_ImageFileName(filename)
80 , m_SliceLocation(sliceLocation)
81 , m_SliceOffset(sliceOffset)
82 , m_EchoNumber(echoNumber)
83 , m_ImageNumber(imageNumber)
84 , m_Data(data)
85 {}
86
88
89 IPLSetMacroDeclaration(ImageFileName, std::string);
90 IPLGetMacroDeclaration(ImageFileName, std::string);
91 IPLSetMacroDeclaration(SliceLocation, float);
92 IPLGetMacroDeclaration(SliceLocation, float);
93 IPLSetMacroDeclaration(SliceOffset, int);
94 IPLGetMacroDeclaration(SliceOffset, int);
95 IPLSetMacroDeclaration(EchoNumber, int);
96 IPLGetMacroDeclaration(EchoNumber, int);
97 IPLSetMacroDeclaration(ImageNumber, int);
98 IPLGetMacroDeclaration(ImageNumber, int);
100 IPLGetMacroDeclaration(Data, const void *);
101
102private:
103 std::string m_ImageFileName{};
108 const void * m_Data{};
109};
110
116class ITKIOIPL_EXPORT IPLFileNameList
117{
118public:
119 using ListType = std::vector<IPLFileSortInfo *>;
120 using IteratorType = ListType::iterator;
121 using ListSizeType = size_t;
122
123 enum
124 {
129 };
130
139
141
144 {
145 return m_List.begin();
146 }
147
148 IteratorType
150 {
151 return m_List.end();
152 }
153
155 operator[](unsigned int __n)
156 {
157 auto it = begin();
158 auto itend = end();
159
160 for (unsigned int i = 0; it != itend && i != __n; it++, i++)
161 {
162 }
163 if (it == itend)
164 {
165 return nullptr;
166 }
167 return *it;
168 }
169
170 [[nodiscard]] ListSizeType
171 NumFiles() const
172 {
173 return m_List.size();
174 }
175
176 bool
177 AddElementToList(const char * const filename,
178 const float sliceLocation,
179 const int offset,
180 const int XDim,
181 const int YDim,
182 const float XRes,
183 const float YRes,
184 const int imageNumber,
185 const int Key1,
186 const int Key2)
187 {
188 if (m_List.empty())
189 {
190 m_XDim = XDim;
191 m_YDim = YDim;
192 m_XRes = XRes;
193 m_YRes = YRes;
194 m_Key1 = Key1;
195 m_Key2 = Key2;
196 }
197 else if (XDim != m_XDim || YDim != m_YDim)
198 {
199 return false;
200 }
202 {
203 return false;
204 }
205 else if (Key1 != m_Key1 || Key2 != m_Key2)
206 {
207 return true;
208 }
209 auto it = begin();
210 auto itend = end();
211 while (it != itend)
212 {
213 if (std::string(filename) == (*it)->GetImageFileName())
214 {
215 return true;
216 }
217 ++it;
218 }
219 m_List.push_back(new IPLFileSortInfo(filename,
220 sliceLocation,
221 offset,
222 0, // echo number
223 imageNumber));
224 return true;
225 }
226
227 void
228 RemoveElementFromList(const int ElementToRemove)
229 {
230 auto it = m_List.begin();
231 auto itend = m_List.end();
232
233 for (int i = 0; it != itend; i++, it++)
234 {
235 if (i != ElementToRemove)
236 {
237 break;
238 }
239 }
240 if (it == itend)
241 {
242 return;
243 }
244 m_List.erase(it);
245 }
246
247 void
249
250 void
252
253 void
255
256 [[nodiscard]] ListSizeType
258 {
259 return m_List.size();
260 }
261
274 IPLSetMacroDeclaration(SortOrder, int);
275
276private:
278 int m_XDim{};
279 int m_YDim{};
280 float m_XRes{};
281 float m_YRes{};
282 int m_Key1{};
284 int m_Key2{};
287};
288} // namespace itk
289#endif /* itkIPLFileNameList_h */
IPLGetMacroDeclaration(XRes, float)
std::vector< IPLFileSortInfo * > ListType
void RemoveElementFromList(const int ElementToRemove)
ListType::iterator IteratorType
IPLSetMacroDeclaration(SortOrder, int)
IPLSetMacroDeclaration(Key2, int)
IPLSetMacroDeclaration(XDim, int)
bool AddElementToList(const char *const filename, const float sliceLocation, const int offset, const int XDim, const int YDim, const float XRes, const float YRes, const int imageNumber, const int Key1, const int Key2)
IPLGetMacroDeclaration(Key1, int)
IPLGetMacroDeclaration(YDim, int)
IPLFileSortInfo * operator[](unsigned int __n)
ListSizeType NumFiles() const
IPLSetMacroDeclaration(Key1, int)
IPLGetMacroDeclaration(XDim, int)
virtual ~IPLFileNameList()
IPLGetMacroDeclaration(Key2, int)
IPLGetMacroDeclaration(YRes, float)
IPLSetMacroDeclaration(YRes, float)
IPLSetMacroDeclaration(YDim, int)
IPLSetMacroDeclaration(XRes, float)
ListSizeType GetnumImageInfoStructs() const
IPLGetMacroDeclaration(Data, const void *)
IPLFileSortInfo()=default
IPLSetMacroDeclaration(EchoNumber, int)
IPLSetMacroDeclaration(SliceLocation, float)
IPLGetMacroDeclaration(SliceOffset, int)
IPLGetMacroDeclaration(EchoNumber, int)
IPLSetMacroDeclaration(ImageNumber, int)
IPLSetMacroDeclaration(Data, void *)
virtual ~IPLFileSortInfo()
IPLGetMacroDeclaration(ImageFileName, std::string)
IPLGetMacroDeclaration(SliceLocation, float)
IPLSetMacroDeclaration(SliceOffset, int)
IPLGetMacroDeclaration(ImageNumber, int)
IPLSetMacroDeclaration(ImageFileName, std::string)
IPLFileSortInfo(const char *const filename, float sliceLocation, int sliceOffset, int echoNumber, int imageNumber, void *data=nullptr)
bool NotAlmostEquals(T1 x1, T2 x2)
Definition itkMath.h:686
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....