ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkAttributeLabelObject.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 template< typename TLabelObject >
32 {
33 public:
34  using LabelObjectType = TLabelObject;
35  using AttributeValueType = typename LabelObjectType::AttributeValueType;
36 
37  inline const AttributeValueType operator()( const LabelObjectType * labelObject )
38  {
39  return labelObject->GetAttribute();
40  }
41 
42  inline void operator()( LabelObjectType * labelObject, AttributeValueType value )
43  {
44  labelObject->SetAttribute( value );
45  }
46 };
47 
48 }
49 
50 
69 template < typename TLabel, unsigned int VImageDimension, typename TAttributeValue >
70 class AttributeLabelObject : public LabelObject< TLabel, VImageDimension >
71 {
72 public:
73  ITK_DISALLOW_COPY_AND_ASSIGN(AttributeLabelObject);
74 
82 
84  itkNewMacro(Self);
85 
87  itkTypeMacro(AttributeLabelObject, LabelObject);
88 
90 
91  static constexpr unsigned int ImageDimension = VImageDimension;
92 
93  using IndexType = typename Superclass::IndexType;
94 
95  using LabelType = TLabel;
96 
97  using LineType = typename Superclass::LineType;
98 
100 
101  using AttributeValueType = TAttributeValue;
102 
104  {
105  m_Attribute = v;
106  }
107 
109  {
110  return m_Attribute;
111  }
112 
114  {
115  return m_Attribute;
116  }
117 
118  template< typename TSourceLabelObject >
119  void CopyAttributesFrom( const TSourceLabelObject * src )
120  {
121  itkAssertOrThrowMacro ( ( src != nullptr ), "Null Pointer" );
122  Superclass::template CopyAttributesFrom<TSourceLabelObject>( src );
123 
124  m_Attribute = src->GetAttribute();
125  }
126 
127  template< typename TSourceLabelObject >
128  void CopyAllFrom(const TSourceLabelObject *src)
129  {
130  itkAssertOrThrowMacro ( ( src != nullptr ), "Null Pointer" );
131  this->template CopyLinesFrom<TSourceLabelObject>( src );
132  this->template CopyAttributesFrom<TSourceLabelObject>( src );
133  }
134 
135 protected:
137  {
138  // how to initialize the attribute ?
139  }
140 
141 
142  void PrintSelf(std::ostream& os, Indent indent) const override
143  {
144  Superclass::PrintSelf( os, indent );
145 
146  os << indent << "Attribute: " << m_Attribute << std::endl;
147  }
148 
149 private:
151 
152 
153 };
154 
155 } // end namespace itk
156 
157 #endif
void operator()(LabelObjectType *labelObject, AttributeValueType value)
void CopyAttributesFrom(const TSourceLabelObject *src)
Light weight base class for most itk classes.
LabelObjectLine< VImageDimension > LineType
typename Superclass::IndexType IndexType
A LabelObject with a generic attribute.
Index< VImageDimension > IndexType
typename LabelObjectType::AttributeValueType AttributeValueType
Implements a weak reference to an object.
void PrintSelf(std::ostream &os, Indent indent) const override
void SetAttribute(const AttributeValueType &v)
void PrintSelf(std::ostream &os, Indent indent) const override
const AttributeValueType & GetAttribute() const
typename Superclass::LengthType LengthType
const AttributeValueType operator()(const LabelObjectType *labelObject)
typename Superclass::LabelObjectType LabelObjectType
typename LineType::LengthType LengthType
The base class for the representation of an labeled binary object in an image.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
static constexpr unsigned int ImageDimension
Templated n-dimensional image to store labeled objects.
Definition: itkLabelMap.h:70
void CopyAllFrom(const TSourceLabelObject *src)
typename Superclass::LineType LineType