ITK  5.2.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  * http://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 AttributeLabelObject : public LabelObject<TLabel, VImageDimension>
74 {
75 public:
76  ITK_DISALLOW_COPY_AND_MOVE(AttributeLabelObject);
77 
85 
87  itkNewMacro(Self);
88 
90  itkTypeMacro(AttributeLabelObject, LabelObject);
91 
93 
94  static constexpr unsigned int ImageDimension = VImageDimension;
95 
96  using IndexType = typename Superclass::IndexType;
97 
98  using LabelType = TLabel;
99 
100  using LineType = typename Superclass::LineType;
101 
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 
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:
145  {
146  // how to initialize the attribute ?
147  }
148 
149 
150  void
151  PrintSelf(std::ostream & os, Indent indent) const override
152  {
153  Superclass::PrintSelf(os, indent);
154 
155  os << indent << "Attribute: " << m_Attribute << std::endl;
156  }
157 
158 private:
160 };
161 
162 } // end namespace itk
163 
164 #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::AttributeLabelObject
AttributeLabelObject()
Definition: itkAttributeLabelObject.h:144
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::AttributeLabelObject::ImageDimension
static constexpr unsigned int ImageDimension
Definition: itkAttributeLabelObject.h:94
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::AttributeLabelObject::IndexType
typename Superclass::IndexType IndexType
Definition: itkAttributeLabelObject.h:96
itk::Functor::AttributeLabelObjectAccessor
Definition: itkAttributeLabelObject.h:32
itk::LabelMap
Templated n-dimensional image to store labeled objects.
Definition: itkLabelMap.h:70
itkLabelMap.h
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::LabelObject
The base class for the representation of an labeled binary object in an image.
Definition: itkLabelObject.h:65
itk::AttributeLabelObject::LengthType
typename Superclass::LengthType LengthType
Definition: itkAttributeLabelObject.h:102
itk::AttributeLabelObject::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkAttributeLabelObject.h:151
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
itk::LabelObject::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
itk::AttributeLabelObject::LineType
typename Superclass::LineType LineType
Definition: itkAttributeLabelObject.h:100
itkLabelObject.h
itk::AttributeLabelObject::LabelType
TLabel LabelType
Definition: itkAttributeLabelObject.h:98
itk::LabelObject::LineType
LabelObjectLine< VImageDimension > LineType
Definition: itkLabelObject.h:90
itk::WeakPointer
Implements a weak reference to an object.
Definition: itkWeakPointer.h:44
itk::LabelObject::IndexType
Index< VImageDimension > IndexType
Definition: itkLabelObject.h:87
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::AttributeLabelObject::GetAttribute
AttributeValueType GetAttribute()
Definition: itkAttributeLabelObject.h:119
itk::AttributeLabelObject::m_Attribute
AttributeValueType m_Attribute
Definition: itkAttributeLabelObject.h:159
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
itk::LabelObject::LabelObjectType
Self LabelObjectType
Definition: itkLabelObject.h:74