18#ifndef itkAnatomicalOrientation_h
19#define itkAnatomicalOrientation_h
21#include "ITKCommonExport.h"
23#ifndef ITK_FUTURE_LEGACY_REMOVE
58 static constexpr unsigned int ImageDimension =
Dimension;
60#ifndef ITK_FUTURE_LEGACY_REMOVE
71 PosteriorToAnterior = 4,
72 AnteriorToPosterior = 5,
73 InferiorToSuperior = 8,
74 SuperiorToInferior = 9,
85 template <CoordinateEnum VPrimary, CoordinateEnum VSecondary, CoordinateEnum VTertiary>
86 static constexpr uint32_t m_OrientationValue =
87 (
static_cast<uint32_t
>(VPrimary) <<
static_cast<uint8_t
>(CoordinateMajornessTermsEnum::PrimaryMinor)) +
88 (
static_cast<uint32_t
>(VSecondary) <<
static_cast<uint8_t
>(CoordinateMajornessTermsEnum::SecondaryMinor)) +
89 (
static_cast<uint32_t
>(VTertiary) <<
static_cast<uint8_t
>(CoordinateMajornessTermsEnum::TertiaryMinor));
101 RIP = m_OrientationValue<CoordinateEnum::LeftToRight,
102 CoordinateEnum::SuperiorToInferior,
103 CoordinateEnum::AnteriorToPosterior>,
104 LIP = m_OrientationValue<CoordinateEnum::RightToLeft,
105 CoordinateEnum::SuperiorToInferior,
106 CoordinateEnum::AnteriorToPosterior>,
107 RSP = m_OrientationValue<CoordinateEnum::LeftToRight,
108 CoordinateEnum::InferiorToSuperior,
109 CoordinateEnum::AnteriorToPosterior>,
110 LSP = m_OrientationValue<CoordinateEnum::RightToLeft,
111 CoordinateEnum::InferiorToSuperior,
112 CoordinateEnum::AnteriorToPosterior>,
113 RIA = m_OrientationValue<CoordinateEnum::LeftToRight,
114 CoordinateEnum::SuperiorToInferior,
115 CoordinateEnum::PosteriorToAnterior>,
116 LIA = m_OrientationValue<CoordinateEnum::RightToLeft,
117 CoordinateEnum::SuperiorToInferior,
118 CoordinateEnum::PosteriorToAnterior>,
119 RSA = m_OrientationValue<CoordinateEnum::LeftToRight,
120 CoordinateEnum::InferiorToSuperior,
121 CoordinateEnum::PosteriorToAnterior>,
122 LSA = m_OrientationValue<CoordinateEnum::RightToLeft,
123 CoordinateEnum::InferiorToSuperior,
124 CoordinateEnum::PosteriorToAnterior>,
126 IRP = m_OrientationValue<CoordinateEnum::SuperiorToInferior,
127 CoordinateEnum::LeftToRight,
128 CoordinateEnum::AnteriorToPosterior>,
129 ILP = m_OrientationValue<CoordinateEnum::SuperiorToInferior,
130 CoordinateEnum::RightToLeft,
131 CoordinateEnum::AnteriorToPosterior>,
132 SRP = m_OrientationValue<CoordinateEnum::InferiorToSuperior,
133 CoordinateEnum::LeftToRight,
134 CoordinateEnum::AnteriorToPosterior>,
135 SLP = m_OrientationValue<CoordinateEnum::InferiorToSuperior,
136 CoordinateEnum::RightToLeft,
137 CoordinateEnum::AnteriorToPosterior>,
138 IRA = m_OrientationValue<CoordinateEnum::SuperiorToInferior,
139 CoordinateEnum::LeftToRight,
140 CoordinateEnum::PosteriorToAnterior>,
141 ILA = m_OrientationValue<CoordinateEnum::SuperiorToInferior,
142 CoordinateEnum::RightToLeft,
143 CoordinateEnum::PosteriorToAnterior>,
144 SRA = m_OrientationValue<CoordinateEnum::InferiorToSuperior,
145 CoordinateEnum::LeftToRight,
146 CoordinateEnum::PosteriorToAnterior>,
147 SLA = m_OrientationValue<CoordinateEnum::InferiorToSuperior,
148 CoordinateEnum::RightToLeft,
149 CoordinateEnum::PosteriorToAnterior>,
151 RPI = m_OrientationValue<CoordinateEnum::LeftToRight,
152 CoordinateEnum::AnteriorToPosterior,
153 CoordinateEnum::SuperiorToInferior>,
154 LPI = m_OrientationValue<CoordinateEnum::RightToLeft,
155 CoordinateEnum::AnteriorToPosterior,
156 CoordinateEnum::SuperiorToInferior>,
157 RAI = m_OrientationValue<CoordinateEnum::LeftToRight,
158 CoordinateEnum::PosteriorToAnterior,
159 CoordinateEnum::SuperiorToInferior>,
160 LAI = m_OrientationValue<CoordinateEnum::RightToLeft,
161 CoordinateEnum::PosteriorToAnterior,
162 CoordinateEnum::SuperiorToInferior>,
163 RPS = m_OrientationValue<CoordinateEnum::LeftToRight,
164 CoordinateEnum::AnteriorToPosterior,
165 CoordinateEnum::InferiorToSuperior>,
166 LPS = m_OrientationValue<CoordinateEnum::RightToLeft,
167 CoordinateEnum::AnteriorToPosterior,
168 CoordinateEnum::InferiorToSuperior>,
169 RAS = m_OrientationValue<CoordinateEnum::LeftToRight,
170 CoordinateEnum::PosteriorToAnterior,
171 CoordinateEnum::InferiorToSuperior>,
172 LAS = m_OrientationValue<CoordinateEnum::RightToLeft,
173 CoordinateEnum::PosteriorToAnterior,
174 CoordinateEnum::InferiorToSuperior>,
176 PRI = m_OrientationValue<CoordinateEnum::AnteriorToPosterior,
177 CoordinateEnum::LeftToRight,
178 CoordinateEnum::SuperiorToInferior>,
179 PLI = m_OrientationValue<CoordinateEnum::AnteriorToPosterior,
180 CoordinateEnum::RightToLeft,
181 CoordinateEnum::SuperiorToInferior>,
182 ARI = m_OrientationValue<CoordinateEnum::PosteriorToAnterior,
183 CoordinateEnum::LeftToRight,
184 CoordinateEnum::SuperiorToInferior>,
185 ALI = m_OrientationValue<CoordinateEnum::PosteriorToAnterior,
186 CoordinateEnum::RightToLeft,
187 CoordinateEnum::SuperiorToInferior>,
188 PRS = m_OrientationValue<CoordinateEnum::AnteriorToPosterior,
189 CoordinateEnum::LeftToRight,
190 CoordinateEnum::InferiorToSuperior>,
191 PLS = m_OrientationValue<CoordinateEnum::AnteriorToPosterior,
192 CoordinateEnum::RightToLeft,
193 CoordinateEnum::InferiorToSuperior>,
194 ARS = m_OrientationValue<CoordinateEnum::PosteriorToAnterior,
195 CoordinateEnum::LeftToRight,
196 CoordinateEnum::InferiorToSuperior>,
197 ALS = m_OrientationValue<CoordinateEnum::PosteriorToAnterior,
198 CoordinateEnum::RightToLeft,
199 CoordinateEnum::InferiorToSuperior>,
201 IPR = m_OrientationValue<CoordinateEnum::SuperiorToInferior,
202 CoordinateEnum::AnteriorToPosterior,
203 CoordinateEnum::LeftToRight>,
204 SPR = m_OrientationValue<CoordinateEnum::InferiorToSuperior,
205 CoordinateEnum::AnteriorToPosterior,
206 CoordinateEnum::LeftToRight>,
207 IAR = m_OrientationValue<CoordinateEnum::SuperiorToInferior,
208 CoordinateEnum::PosteriorToAnterior,
209 CoordinateEnum::LeftToRight>,
210 SAR = m_OrientationValue<CoordinateEnum::InferiorToSuperior,
211 CoordinateEnum::PosteriorToAnterior,
212 CoordinateEnum::LeftToRight>,
213 IPL = m_OrientationValue<CoordinateEnum::SuperiorToInferior,
214 CoordinateEnum::AnteriorToPosterior,
215 CoordinateEnum::RightToLeft>,
216 SPL = m_OrientationValue<CoordinateEnum::InferiorToSuperior,
217 CoordinateEnum::AnteriorToPosterior,
218 CoordinateEnum::RightToLeft>,
219 IAL = m_OrientationValue<CoordinateEnum::SuperiorToInferior,
220 CoordinateEnum::PosteriorToAnterior,
221 CoordinateEnum::RightToLeft>,
222 SAL = m_OrientationValue<CoordinateEnum::InferiorToSuperior,
223 CoordinateEnum::PosteriorToAnterior,
224 CoordinateEnum::RightToLeft>,
226 PIR = m_OrientationValue<CoordinateEnum::AnteriorToPosterior,
227 CoordinateEnum::SuperiorToInferior,
228 CoordinateEnum::LeftToRight>,
229 PSR = m_OrientationValue<CoordinateEnum::AnteriorToPosterior,
230 CoordinateEnum::InferiorToSuperior,
231 CoordinateEnum::LeftToRight>,
232 AIR = m_OrientationValue<CoordinateEnum::PosteriorToAnterior,
233 CoordinateEnum::SuperiorToInferior,
234 CoordinateEnum::LeftToRight>,
235 ASR = m_OrientationValue<CoordinateEnum::PosteriorToAnterior,
236 CoordinateEnum::InferiorToSuperior,
237 CoordinateEnum::LeftToRight>,
238 PIL = m_OrientationValue<CoordinateEnum::AnteriorToPosterior,
239 CoordinateEnum::SuperiorToInferior,
240 CoordinateEnum::RightToLeft>,
241 PSL = m_OrientationValue<CoordinateEnum::AnteriorToPosterior,
242 CoordinateEnum::InferiorToSuperior,
243 CoordinateEnum::RightToLeft>,
244 AIL = m_OrientationValue<CoordinateEnum::PosteriorToAnterior,
245 CoordinateEnum::SuperiorToInferior,
246 CoordinateEnum::RightToLeft>,
247 ASL = m_OrientationValue<CoordinateEnum::PosteriorToAnterior,
248 CoordinateEnum::InferiorToSuperior,
249 CoordinateEnum::RightToLeft>
258 RIP = m_OrientationValue<CoordinateEnum::RightToLeft,
259 CoordinateEnum::InferiorToSuperior,
260 CoordinateEnum::PosteriorToAnterior>,
261 LIP = m_OrientationValue<CoordinateEnum::LeftToRight,
262 CoordinateEnum::InferiorToSuperior,
263 CoordinateEnum::PosteriorToAnterior>,
264 RSP = m_OrientationValue<CoordinateEnum::RightToLeft,
265 CoordinateEnum::SuperiorToInferior,
266 CoordinateEnum::PosteriorToAnterior>,
267 LSP = m_OrientationValue<CoordinateEnum::LeftToRight,
268 CoordinateEnum::SuperiorToInferior,
269 CoordinateEnum::PosteriorToAnterior>,
270 RIA = m_OrientationValue<CoordinateEnum::RightToLeft,
271 CoordinateEnum::InferiorToSuperior,
272 CoordinateEnum::AnteriorToPosterior>,
273 LIA = m_OrientationValue<CoordinateEnum::LeftToRight,
274 CoordinateEnum::InferiorToSuperior,
275 CoordinateEnum::AnteriorToPosterior>,
276 RSA = m_OrientationValue<CoordinateEnum::RightToLeft,
277 CoordinateEnum::SuperiorToInferior,
278 CoordinateEnum::AnteriorToPosterior>,
279 LSA = m_OrientationValue<CoordinateEnum::LeftToRight,
280 CoordinateEnum::SuperiorToInferior,
281 CoordinateEnum::AnteriorToPosterior>,
283 IRP = m_OrientationValue<CoordinateEnum::InferiorToSuperior,
284 CoordinateEnum::RightToLeft,
285 CoordinateEnum::PosteriorToAnterior>,
286 ILP = m_OrientationValue<CoordinateEnum::InferiorToSuperior,
287 CoordinateEnum::LeftToRight,
288 CoordinateEnum::PosteriorToAnterior>,
289 SRP = m_OrientationValue<CoordinateEnum::SuperiorToInferior,
290 CoordinateEnum::RightToLeft,
291 CoordinateEnum::PosteriorToAnterior>,
292 SLP = m_OrientationValue<CoordinateEnum::SuperiorToInferior,
293 CoordinateEnum::LeftToRight,
294 CoordinateEnum::PosteriorToAnterior>,
295 IRA = m_OrientationValue<CoordinateEnum::InferiorToSuperior,
296 CoordinateEnum::RightToLeft,
297 CoordinateEnum::AnteriorToPosterior>,
298 ILA = m_OrientationValue<CoordinateEnum::InferiorToSuperior,
299 CoordinateEnum::LeftToRight,
300 CoordinateEnum::AnteriorToPosterior>,
301 SRA = m_OrientationValue<CoordinateEnum::SuperiorToInferior,
302 CoordinateEnum::RightToLeft,
303 CoordinateEnum::AnteriorToPosterior>,
304 SLA = m_OrientationValue<CoordinateEnum::SuperiorToInferior,
305 CoordinateEnum::LeftToRight,
306 CoordinateEnum::AnteriorToPosterior>,
308 RPI = m_OrientationValue<CoordinateEnum::RightToLeft,
309 CoordinateEnum::PosteriorToAnterior,
310 CoordinateEnum::InferiorToSuperior>,
311 LPI = m_OrientationValue<CoordinateEnum::LeftToRight,
312 CoordinateEnum::PosteriorToAnterior,
313 CoordinateEnum::InferiorToSuperior>,
314 RAI = m_OrientationValue<CoordinateEnum::RightToLeft,
315 CoordinateEnum::AnteriorToPosterior,
316 CoordinateEnum::InferiorToSuperior>,
317 LAI = m_OrientationValue<CoordinateEnum::LeftToRight,
318 CoordinateEnum::AnteriorToPosterior,
319 CoordinateEnum::InferiorToSuperior>,
320 RPS = m_OrientationValue<CoordinateEnum::RightToLeft,
321 CoordinateEnum::PosteriorToAnterior,
322 CoordinateEnum::SuperiorToInferior>,
323 LPS = m_OrientationValue<CoordinateEnum::LeftToRight,
324 CoordinateEnum::PosteriorToAnterior,
325 CoordinateEnum::SuperiorToInferior>,
326 RAS = m_OrientationValue<CoordinateEnum::RightToLeft,
327 CoordinateEnum::AnteriorToPosterior,
328 CoordinateEnum::SuperiorToInferior>,
329 LAS = m_OrientationValue<CoordinateEnum::LeftToRight,
330 CoordinateEnum::AnteriorToPosterior,
331 CoordinateEnum::SuperiorToInferior>,
333 PRI = m_OrientationValue<CoordinateEnum::PosteriorToAnterior,
334 CoordinateEnum::RightToLeft,
335 CoordinateEnum::InferiorToSuperior>,
336 PLI = m_OrientationValue<CoordinateEnum::PosteriorToAnterior,
337 CoordinateEnum::LeftToRight,
338 CoordinateEnum::InferiorToSuperior>,
339 ARI = m_OrientationValue<CoordinateEnum::AnteriorToPosterior,
340 CoordinateEnum::RightToLeft,
341 CoordinateEnum::InferiorToSuperior>,
342 ALI = m_OrientationValue<CoordinateEnum::AnteriorToPosterior,
343 CoordinateEnum::LeftToRight,
344 CoordinateEnum::InferiorToSuperior>,
345 PRS = m_OrientationValue<CoordinateEnum::PosteriorToAnterior,
346 CoordinateEnum::RightToLeft,
347 CoordinateEnum::SuperiorToInferior>,
348 PLS = m_OrientationValue<CoordinateEnum::PosteriorToAnterior,
349 CoordinateEnum::LeftToRight,
350 CoordinateEnum::SuperiorToInferior>,
351 ARS = m_OrientationValue<CoordinateEnum::AnteriorToPosterior,
352 CoordinateEnum::RightToLeft,
353 CoordinateEnum::SuperiorToInferior>,
354 ALS = m_OrientationValue<CoordinateEnum::AnteriorToPosterior,
355 CoordinateEnum::LeftToRight,
356 CoordinateEnum::SuperiorToInferior>,
358 IPR = m_OrientationValue<CoordinateEnum::InferiorToSuperior,
359 CoordinateEnum::PosteriorToAnterior,
360 CoordinateEnum::RightToLeft>,
361 SPR = m_OrientationValue<CoordinateEnum::SuperiorToInferior,
362 CoordinateEnum::PosteriorToAnterior,
363 CoordinateEnum::RightToLeft>,
364 IAR = m_OrientationValue<CoordinateEnum::InferiorToSuperior,
365 CoordinateEnum::AnteriorToPosterior,
366 CoordinateEnum::RightToLeft>,
367 SAR = m_OrientationValue<CoordinateEnum::SuperiorToInferior,
368 CoordinateEnum::AnteriorToPosterior,
369 CoordinateEnum::RightToLeft>,
370 IPL = m_OrientationValue<CoordinateEnum::InferiorToSuperior,
371 CoordinateEnum::PosteriorToAnterior,
372 CoordinateEnum::LeftToRight>,
373 SPL = m_OrientationValue<CoordinateEnum::SuperiorToInferior,
374 CoordinateEnum::PosteriorToAnterior,
375 CoordinateEnum::LeftToRight>,
376 IAL = m_OrientationValue<CoordinateEnum::InferiorToSuperior,
377 CoordinateEnum::AnteriorToPosterior,
378 CoordinateEnum::LeftToRight>,
379 SAL = m_OrientationValue<CoordinateEnum::SuperiorToInferior,
380 CoordinateEnum::AnteriorToPosterior,
381 CoordinateEnum::LeftToRight>,
383 PIR = m_OrientationValue<CoordinateEnum::PosteriorToAnterior,
384 CoordinateEnum::InferiorToSuperior,
385 CoordinateEnum::RightToLeft>,
386 PSR = m_OrientationValue<CoordinateEnum::PosteriorToAnterior,
387 CoordinateEnum::SuperiorToInferior,
388 CoordinateEnum::RightToLeft>,
389 AIR = m_OrientationValue<CoordinateEnum::AnteriorToPosterior,
390 CoordinateEnum::InferiorToSuperior,
391 CoordinateEnum::RightToLeft>,
392 ASR = m_OrientationValue<CoordinateEnum::AnteriorToPosterior,
393 CoordinateEnum::SuperiorToInferior,
394 CoordinateEnum::RightToLeft>,
395 PIL = m_OrientationValue<CoordinateEnum::PosteriorToAnterior,
396 CoordinateEnum::InferiorToSuperior,
397 CoordinateEnum::LeftToRight>,
398 PSL = m_OrientationValue<CoordinateEnum::PosteriorToAnterior,
399 CoordinateEnum::SuperiorToInferior,
400 CoordinateEnum::LeftToRight>,
401 AIL = m_OrientationValue<CoordinateEnum::AnteriorToPosterior,
402 CoordinateEnum::InferiorToSuperior,
403 CoordinateEnum::LeftToRight>,
404 ASL = m_OrientationValue<CoordinateEnum::AnteriorToPosterior,
405 CoordinateEnum::SuperiorToInferior,
406 CoordinateEnum::LeftToRight>
417 SameOrientationAxes(primary, secondary) || SameOrientationAxes(primary, tertiary) ||
418 SameOrientationAxes(secondary, tertiary)
428 : m_Value(toOrientation)
433 : m_Value(
PositiveEnum(static_cast<uint32_t>(fromOrientation)))
436#ifndef ITK_FUTURE_LEGACY_REMOVE
441# if defined(ITK_LEGACY_REMOVE) && !defined(ITK_LEGACY_SILENT)
442 [[deprecated(
"Use the AnatomicalOrientation::FromEnum type instead.")]]
451 : m_Value(ConvertDirectionToPositiveEnum(d))
489 return ConvertPositiveEnumToDirection(m_Value);
507 return GetCoordinateTerm(CoordinateMajornessTermsEnum::PrimaryMinor);
513 return GetCoordinateTerm(CoordinateMajornessTermsEnum::SecondaryMinor);
519 return GetCoordinateTerm(CoordinateMajornessTermsEnum::TertiaryMinor);
522 std::array<CoordinateEnum, 3>
525 return { GetPrimaryTerm(), GetSecondaryTerm(), GetTertiaryTerm() };
528 static constexpr bool
531 const uint8_t AxisField = ~1;
532 return (
static_cast<uint8_t
>(a) & AxisField) == (
static_cast<uint8_t
>(b) & AxisField);
536 friend ITKCommon_EXPORT std::ostream &
553 static const std::map<PositiveEnum, std::string> &
558 static const std::map<std::string, PositiveEnum> &
565ITKCommon_EXPORT std::ostream &
569ITKCommon_EXPORT std::ostream &
574ITKCommon_EXPORT std::ostream &
577ITKCommon_EXPORT std::ostream &
Representations of anatomical orientations and methods to convert between conventions.
typename ImageBase< Dimension >::DirectionType DirectionType
std::string GetAsNegativeStringEncoding() const
CoordinateEnum GetSecondaryTerm() const
constexpr AnatomicalOrientation(PositiveEnum toOrientation)
std::array< CoordinateEnum, 3 > GetTerms() const
constexpr AnatomicalOrientation(NegativeEnum fromOrientation)
AnatomicalOrientation(const DirectionType &d)
NegativeEnum GetAsNegativeOrientation() const
CoordinateMajornessTermsEnum
static constexpr bool SameOrientationAxes(CoordinateEnum a, CoordinateEnum b)
DirectionType GetAsDirection() const
Return the direction cosine matrix for the orientation.
static PositiveEnum ConvertDirectionToPositiveEnum(const DirectionType &dir)
Return the closest orientation for a direction cosine matrix.
CoordinateEnum GetPrimaryTerm() const
constexpr AnatomicalOrientation(CoordinateEnum primary, CoordinateEnum secondary, CoordinateEnum tertiary)
Initialize with CoordinateEnum's from separate axes.
static DirectionType ConvertPositiveEnumToDirection(PositiveEnum)
Return the direction cosine matrix for a orientation.
std::string GetAsPositiveStringEncoding() const
PositiveEnum GetAsPositiveOrientation() const
static const std::map< std::string, PositiveEnum > & GetStringToCode()
Return the global instance of the map from string to orientation enum.
static const std::map< PositiveEnum, std::string > & GetCodeToString()
Return the global instance of the map from orientation enum to strings.
CoordinateEnum GetCoordinateTerm(CoordinateMajornessTermsEnum cmt) const
static std::string ConvertStringEncoding(std::string str)
CoordinateEnum GetTertiaryTerm() const
static AnatomicalOrientation CreateFromNegativeStringEncoding(std::string str)
static AnatomicalOrientation CreateFromPositiveStringEncoding(std::string str)
ValidCoordinateOrientations
constexpr unsigned int Dimension
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, typename AnatomicalOrientation::CoordinateEnum value)