ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkAnatomicalOrientation.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#ifndef itkAnatomicalOrientation_h
19#define itkAnatomicalOrientation_h
20
21#include "ITKCommonExport.h"
22#include "itkImageBase.h"
23#ifndef ITK_FUTURE_LEGACY_REMOVE
25#endif
26#include <map>
27#include <string>
28
29namespace itk
30{
31
53class ITKCommon_EXPORT AnatomicalOrientation
54{
55public:
56 static constexpr unsigned int Dimension = 3;
58 static constexpr unsigned int ImageDimension = Dimension;
59
60#ifndef ITK_FUTURE_LEGACY_REMOVE
61 using LegacyOrientationType = SpatialOrientationEnums::ValidCoordinateOrientations;
62#endif
63
64 // Anatomical names for an axis.
65 //
76
77protected:
84
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));
90
93
94public:
95 // Enumerated acronyms based on the positive or "To" direction of the anatomical coordinates.
96 enum class PositiveEnum : uint32_t
97
98 {
100
125
150
175
200
225
250 };
251
252 // Enumerated acronyms based on the negative or "From" direction of the anatomical coordinates.
253 enum class NegativeEnum : uint32_t
254
255 {
257
282
307
332
357
382
407
408 };
409
410
416 : m_Value(
417 SameOrientationAxes(primary, secondary) || SameOrientationAxes(primary, tertiary) ||
418 SameOrientationAxes(secondary, tertiary)
420 : static_cast<PositiveEnum>(
421 (static_cast<uint32_t>(primary) << static_cast<uint8_t>(CoordinateMajornessTermsEnum::PrimaryMinor)) +
422 (static_cast<uint32_t>(secondary) << static_cast<uint8_t>(CoordinateMajornessTermsEnum::SecondaryMinor)) +
423 (static_cast<uint32_t>(tertiary) << static_cast<uint8_t>(CoordinateMajornessTermsEnum::TertiaryMinor))))
424 {}
425
426
427 constexpr AnatomicalOrientation(PositiveEnum toOrientation)
428 : m_Value(toOrientation)
429 {}
430
431
432 constexpr AnatomicalOrientation(NegativeEnum fromOrientation)
433 : m_Value(PositiveEnum(static_cast<uint32_t>(fromOrientation)))
434 {}
435
436#ifndef ITK_FUTURE_LEGACY_REMOVE
441# if defined(ITK_LEGACY_REMOVE) && !defined(ITK_LEGACY_SILENT) && !defined(ITK_WRAPPING)
442 [[deprecated("Use the AnatomicalOrientation::FromEnum type instead.")]]
443# endif
444 AnatomicalOrientation(LegacyOrientationType legacyOrientation);
445#endif
446
453
459
460 // Same as CreateFromPositiveStringEncoding but for the NegativeEnum encoding.
463
464 operator PositiveEnum() const { return m_Value; }
465
467 std::string
469
471 std::string
473
482 static std::string
483 ConvertStringEncoding(std::string str);
484
488 {
490 }
491
492 PositiveEnum
494 {
495 return m_Value;
496 }
497
498 NegativeEnum
500 {
501 return NegativeEnum(uint32_t(this->m_Value));
502 }
503
504 CoordinateEnum
509
510 CoordinateEnum
515
516 CoordinateEnum
521
522 std::array<CoordinateEnum, 3>
523 GetTerms() const
524 {
526 }
527
528 static constexpr bool
530 {
531 const uint8_t AxisField = ~1; // mask the lowest bit
532 return (static_cast<uint8_t>(a) & AxisField) == (static_cast<uint8_t>(b) & AxisField);
533 }
534
535
536 friend ITKCommon_EXPORT std::ostream &
537 operator<<(std::ostream & out, PositiveEnum value);
538
539protected:
542
543
545 static PositiveEnum
547
548
553 static const std::map<PositiveEnum, std::string> &
555
558 static const std::map<std::string, PositiveEnum> &
560
562};
563
565ITKCommon_EXPORT std::ostream &
566 operator<<(std::ostream & out, typename AnatomicalOrientation::CoordinateEnum value);
567
569ITKCommon_EXPORT std::ostream &
570 operator<<(std::ostream & out, typename AnatomicalOrientation::PositiveEnum value);
571
572
574ITKCommon_EXPORT std::ostream &
575 operator<<(std::ostream & out, typename AnatomicalOrientation::NegativeEnum value);
576
577ITKCommon_EXPORT std::ostream &
578 operator<<(std::ostream & out, const AnatomicalOrientation & orientation);
579
580
581} // end namespace itk
582
583
584#endif
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
static constexpr uint32_t m_OrientationValue
constexpr AnatomicalOrientation(NegativeEnum fromOrientation)
static constexpr unsigned int Dimension
AnatomicalOrientation(const DirectionType &d)
NegativeEnum GetAsNegativeOrientation() const
static constexpr bool SameOrientationAxes(CoordinateEnum a, CoordinateEnum b)
DirectionType GetAsDirection() const
Return the direction cosine matrix for the orientation.
static constexpr unsigned int ImageDimension
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)
Matrix< SpacePrecisionType, VImageDimension, VImageDimension > DirectionType
ITKTransform_EXPORT std::ostream & operator<<(std::ostream &out, const TransformBaseTemplateEnums::TransformCategory value)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, typename AnatomicalOrientation::CoordinateEnum value)