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 
73 template <typename TLabel, unsigned int VImageDimension, typename TAttributeValue>
74 class AttributeLabelObject : public LabelObject<TLabel, VImageDimension>
75 {
76 public:
77  ITK_DISALLOW_COPY_AND_ASSIGN(AttributeLabelObject);
78 
86 
88  itkNewMacro(Self);
89 
91  itkTypeMacro(AttributeLabelObject, LabelObject);
92 
94 
95  static constexpr unsigned int ImageDimension = VImageDimension;
96 
97  using IndexType = typename Superclass::IndexType;
98 
99  using LabelType = TLabel;
100 
101  using LineType = typename Superclass::LineType;
102 
104 
105  using AttributeValueType = TAttributeValue;
106 
107  void
109  {
110  m_Attribute = v;
111  }
112 
113  const AttributeValueType &
114  GetAttribute() const
115  {
116  return m_Attribute;
117  }
118 
121  {
122  return m_Attribute;
123  }
124 
125  template <typename TSourceLabelObject>
126  void
127  CopyAttributesFrom(const TSourceLabelObject * src)
128  {
129  itkAssertOrThrowMacro((src != nullptr), "Null Pointer");
130  Superclass::template CopyAttributesFrom<TSourceLabelObject>(src);
131 
132  m_Attribute = src->GetAttribute();
133  }
134 
135  template <typename TSourceLabelObject>
136  void
137  CopyAllFrom(const TSourceLabelObject * src)
138  {
139  itkAssertOrThrowMacro((src != nullptr), "Null Pointer");
140  this->template CopyLinesFrom<TSourceLabelObject>(src);
141  this->template CopyAttributesFrom<TSourceLabelObject>(src);
142  }
143 
144 protected:
146  {
147  // how to initialize the attribute ?
148  }
149 
150 
151  void
152  PrintSelf(std::ostream & os, Indent indent) const override
153  {
154  Superclass::PrintSelf(os, indent);
155 
156  os << indent << "Attribute: " << m_Attribute << std::endl;
157  }
158 
159 private:
161 };
162 
163 } // end namespace itk
164 
165 #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:74
itk::AttributeLabelObject::AttributeValueType
TAttributeValue AttributeValueType
Definition: itkAttributeLabelObject.h:105
itk::AttributeLabelObject::AttributeLabelObject
AttributeLabelObject()
Definition: itkAttributeLabelObject.h:145
itk::AttributeLabelObject::CopyAllFrom
void CopyAllFrom(const TSourceLabelObject *src)
Definition: itkAttributeLabelObject.h:137
itk::SmartPointer< Self >
itk::AttributeLabelObject::LabelObjectType
typename Superclass::LabelObjectType LabelObjectType
Definition: itkAttributeLabelObject.h:83
itk::AttributeLabelObject::ImageDimension
static constexpr unsigned int ImageDimension
Definition: itkAttributeLabelObject.h:95
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::AttributeLabelObject::IndexType
typename Superclass::IndexType IndexType
Definition: itkAttributeLabelObject.h:97
itk::Functor::AttributeLabelObjectAccessor
Definition: itkAttributeLabelObject.h:32
itk::LabelMap
Templated n-dimensional image to store labeled objects.
Definition: itkLabelMap.h:71
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:103
itk::AttributeLabelObject::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
Definition: itkAttributeLabelObject.h:152
itk::Functor::AttributeLabelObjectAccessor::LabelObjectType
TLabelObject LabelObjectType
Definition: itkAttributeLabelObject.h:35
itk::AttributeLabelObject::GetAttribute
const AttributeValueType & GetAttribute() const
Definition: itkAttributeLabelObject.h:114
itk::AttributeLabelObject::SetAttribute
void SetAttribute(const AttributeValueType &v)
Definition: itkAttributeLabelObject.h:108
itk::LabelObject::PrintSelf
void PrintSelf(std::ostream &os, Indent indent) const override
itk::AttributeLabelObject::LineType
typename Superclass::LineType LineType
Definition: itkAttributeLabelObject.h:101
itkLabelObject.h
itk::AttributeLabelObject::LabelType
TLabel LabelType
Definition: itkAttributeLabelObject.h:99
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:120
itk::AttributeLabelObject::m_Attribute
AttributeValueType m_Attribute
Definition: itkAttributeLabelObject.h:160
itk::AttributeLabelObject::CopyAttributesFrom
void CopyAttributesFrom(const TSourceLabelObject *src)
Definition: itkAttributeLabelObject.h:127
itk::Functor::AttributeLabelObjectAccessor::operator()
void operator()(LabelObjectType *labelObject, AttributeValueType value)
Definition: itkAttributeLabelObject.h:45
itk::LabelObject::LabelObjectType
Self LabelObjectType
Definition: itkLabelObject.h:74