ITK  6.0.0
Insight Toolkit
itkDefaultVectorPixelAccessor.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 itkDefaultVectorPixelAccessor_h
19#define itkDefaultVectorPixelAccessor_h
20
21#include "itkMacro.h"
23#include "itkIntTypes.h"
24
25namespace itk
26{
49template <typename TType>
50class ITK_TEMPLATE_EXPORT DefaultVectorPixelAccessor
51{
52public:
53 using VectorLengthType = unsigned int;
54
60
62 using InternalType = TType;
63
65 inline void
66 Set(InternalType & output, const ExternalType & input, const unsigned long offset) const
67 {
68 InternalType * truePixel = (&output) + offset * m_OffsetMultiplier;
69
70 for (VectorLengthType i = 0; i < m_VectorLength; ++i)
71 {
72 truePixel[i] = input[i];
73 }
74 }
75
77 inline ExternalType
78 Get(const InternalType & input, const SizeValueType offset) const
79 {
80 // Do not create a local for this method, to use return value
81 // optimization.
82 return ExternalType((&input) + (offset * m_OffsetMultiplier), m_VectorLength);
83 }
84
86 void
88 {
89 m_VectorLength = l;
90 m_OffsetMultiplier = (l - 1);
91 }
95 VectorLengthType
97 {
98 return m_VectorLength;
99 }
100
102
105 {
106 m_VectorLength = l;
107 m_OffsetMultiplier = l - 1;
108 }
109
111
112private:
113 VectorLengthType m_VectorLength{ 0 };
114 VectorLengthType m_OffsetMultiplier{ 0 };
115};
116} // end namespace itk
117
118#endif
Give access to partial aspects of a type.
void Set(InternalType &output, const ExternalType &input, const unsigned long offset) const
ExternalType Get(const InternalType &input, const SizeValueType offset) const
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition: itkIntTypes.h:86