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 
24 namespace itk
25 {
26 
27 
28 namespace Functor
29 {
30 
31 template <typename TLabelObject>
33 {
34 public:
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 
72 template <typename TLabel, unsigned int VImageDimension, typename TAttributeValue>
73 class ITK_TEMPLATE_EXPORT AttributeLabelObject : public LabelObject<TLabel, VImageDimension>
74 {
75 public:
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 &
113  GetAttribute() const
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 
143 protected:
144  AttributeLabelObject() = default;
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 
155 private:
156  AttributeValueType m_Attribute{};
157 };
158 
159 } // end namespace itk
160 
161 #endif
itk::LabelObject::LengthType
typename LineType::LengthType LengthType
Definition: itkLabelObject.h:91
itk::Functor::AttributeLabelObjectAccessor::operator()
const AttributeValueType operator()(const LabelObjectType *labelObject)
Definition: itkAttributeLabelObject.h:39
itk::Functor::AttributeLabelObjectAccessor::AttributeValueType
typename LabelObjectType::AttributeValueType AttributeValueType
Definition: itkAttributeLabelObject.h:36
itk::AttributeLabelObject
A LabelObject with a generic attribute.
Definition: itkAttributeLabelObject.h:73
itk::AttributeLabelObject::AttributeValueType
TAttributeValue AttributeValueType
Definition: itkAttributeLabelObject.h:104
itk::AttributeLabelObject::CopyAllFrom
void CopyAllFrom(const TSourceLabelObject *src)
Definition: itkAttributeLabelObject.h:136
itk::SmartPointer< Self >
itk::AttributeLabelObject::LabelObjectType
typename Superclass::LabelObjectType LabelObjectType
Definition: itkAttributeLabelObject.h:82
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::Functor::AttributeLabelObjectAccessor
Definition: itkAttributeLabelObject.h:32
itk::LabelMap
Templated n-dimensional image to store labeled objects.
Definition: itkLabelMap.h:70
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itkLabelMap.h
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::LabelObject
The base class for the representation of a labeled binary object in an image.
Definition: itkLabelObject.h:65
itk::AttributeLabelObject::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkAttributeLabelObject.h:148
itk::Functor::AttributeLabelObjectAccessor::LabelObjectType
TLabelObject LabelObjectType
Definition: itkAttributeLabelObject.h:35
itk::AttributeLabelObject::GetAttribute
const AttributeValueType & GetAttribute() const
Definition: itkAttributeLabelObject.h:113
itk::AttributeLabelObject::SetAttribute
void SetAttribute(const AttributeValueType &v)
Definition: itkAttributeLabelObject.h:107
itkLabelObject.h
itk::AttributeLabelObject::LabelType
TLabel LabelType
Definition: itkAttributeLabelObject.h:98
itk::LabelObjectLine
Definition: itkLabelObjectLine.h:43
itk::WeakPointer
Implements a weak reference to an object.
Definition: itkWeakPointer.h:44
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::AttributeLabelObject::GetAttribute
AttributeValueType GetAttribute()
Definition: itkAttributeLabelObject.h:119
itk::AttributeLabelObject::CopyAttributesFrom
void CopyAttributesFrom(const TSourceLabelObject *src)
Definition: itkAttributeLabelObject.h:126
itk::Functor::AttributeLabelObjectAccessor::operator()
void operator()(LabelObjectType *labelObject, AttributeValueType value)
Definition: itkAttributeLabelObject.h:45