ITK  6.0.0
Insight Toolkit
itkAttributeLabelObject.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 itkAttributeLabelObject_h
19#define itkAttributeLabelObject_h
20
21#include "itkLabelObject.h"
22#include "itkLabelMap.h"
23
24namespace itk
25{
26
27
28namespace Functor
29{
30
31template <typename TLabelObject>
33{
34public:
35 using LabelObjectType = TLabelObject;
36 using AttributeValueType = typename LabelObjectType::AttributeValueType;
37
38 inline const AttributeValueType
39 operator()(const LabelObjectType * labelObject)
40 {
41 return labelObject->GetAttribute();
42 }
43
44 inline void
46 {
47 labelObject->SetAttribute(value);
48 }
49};
50
51} // namespace Functor
52
53
72template <typename TLabel, unsigned int VImageDimension, typename TAttributeValue>
73class ITK_TEMPLATE_EXPORT AttributeLabelObject : public LabelObject<TLabel, VImageDimension>
74{
75public:
76 ITK_DISALLOW_COPY_AND_MOVE(AttributeLabelObject);
77
85
87 itkNewMacro(Self);
88
90 itkOverrideGetNameOfClassMacro(AttributeLabelObject);
91
93
94 static constexpr unsigned int ImageDimension = VImageDimension;
95
96 using typename Superclass::IndexType;
97
98 using LabelType = TLabel;
99
100 using typename Superclass::LineType;
101
102 using typename Superclass::LengthType;
103
104 using AttributeValueType = TAttributeValue;
105
106 void
108 {
109 m_Attribute = v;
110 }
111
112 const AttributeValueType &
114 {
115 return m_Attribute;
116 }
117
118 AttributeValueType
120 {
121 return m_Attribute;
122 }
123
124 template <typename TSourceLabelObject>
125 void
126 CopyAttributesFrom(const TSourceLabelObject * src)
127 {
128 itkAssertOrThrowMacro((src != nullptr), "Null Pointer");
129 Superclass::template CopyAttributesFrom<TSourceLabelObject>(src);
130
131 m_Attribute = src->GetAttribute();
132 }
133
134 template <typename TSourceLabelObject>
135 void
136 CopyAllFrom(const TSourceLabelObject * src)
137 {
138 itkAssertOrThrowMacro((src != nullptr), "Null Pointer");
139 this->template CopyLinesFrom<TSourceLabelObject>(src);
140 this->template CopyAttributesFrom<TSourceLabelObject>(src);
141 }
142
143protected:
145
146
147 void
148 PrintSelf(std::ostream & os, Indent indent) const override
149 {
150 Superclass::PrintSelf(os, indent);
151
152 os << indent << "Attribute: " << m_Attribute << std::endl;
153 }
154
155private:
156 AttributeValueType m_Attribute{};
157};
158
159} // end namespace itk
160
161#endif
A LabelObject with a generic attribute.
void CopyAllFrom(const TSourceLabelObject *src)
typename Superclass::LabelObjectType LabelObjectType
void PrintSelf(std::ostream &os, Indent indent) const override
void CopyAttributesFrom(const TSourceLabelObject *src)
void SetAttribute(const AttributeValueType &v)
const AttributeValueType & GetAttribute() const
void operator()(LabelObjectType *labelObject, AttributeValueType value)
const AttributeValueType operator()(const LabelObjectType *labelObject)
typename LabelObjectType::AttributeValueType AttributeValueType
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Templated n-dimensional image to store labeled objects.
Definition: itkLabelMap.h:71
The base class for the representation of a labeled binary object in an image.
typename LineType::LengthType LengthType
Light weight base class for most itk classes.
Implements a weak reference to an object.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....