ITK  4.9.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  typedef TLabelObject LabelObjectType;
35  typedef typename LabelObjectType::AttributeValueType 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:
80 
82  itkNewMacro(Self);
83 
86 
88 
89  itkStaticConstMacro(ImageDimension, unsigned int, VImageDimension);
90 
91  typedef typename Superclass::IndexType IndexType;
92 
93  typedef TLabel LabelType;
94 
95  typedef typename Superclass::LineType LineType;
96 
98 
99  typedef TAttributeValue AttributeValueType;
100 
102  {
103  m_Attribute = v;
104  }
105 
107  {
108  return m_Attribute;
109  }
110 
112  {
113  return m_Attribute;
114  }
115 
116  template< typename TSourceLabelObject >
117  void CopyAttributesFrom( const TSourceLabelObject * src )
118  {
119  itkAssertOrThrowMacro ( ( src != ITK_NULLPTR ), "Null Pointer" );
120  Superclass::template CopyAttributesFrom<TSourceLabelObject>( src );
121 
122  m_Attribute = src->GetAttribute();
123  }
124 
125  template< typename TSourceLabelObject >
126  void CopyAllFrom(const TSourceLabelObject *src)
127  {
128  itkAssertOrThrowMacro ( ( src != ITK_NULLPTR ), "Null Pointer" );
129  this->template CopyLinesFrom<TSourceLabelObject>( src );
130  this->template CopyAttributesFrom<TSourceLabelObject>( src );
131  }
132 
133 protected:
135  {
136  // how to initialize the attribute ?
137  }
138 
139 
140  void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE
141  {
142  Superclass::PrintSelf( os, indent );
143 
144  os << indent << "Attribute: " << m_Attribute << std::endl;
145  }
146 
147 private:
148  AttributeLabelObject(const Self&) ITK_DELETE_FUNCTION;
149  void operator=(const Self&) ITK_DELETE_FUNCTION;
150 
152 
153 
154 };
155 
156 } // end namespace itk
157 
158 #endif
void operator()(LabelObjectType *labelObject, AttributeValueType value)
void CopyAttributesFrom(const TSourceLabelObject *src)
Light weight base class for most itk classes.
Superclass::IndexType IndexType
Superclass::LabelObjectType LabelObjectType
A LabelObject with a generic attribute.
LabelObject< TLabel, VImageDimension > Superclass
Implements a weak reference to an object.
SmartPointer< const Self > ConstPointer
void SetAttribute(const AttributeValueType &v)
LineType::LengthType LengthType
void PrintSelf(std::ostream &os, Indent indent) const override
static const unsigned int ImageDimension
LabelObjectType::AttributeValueType AttributeValueType
const AttributeValueType & GetAttribute() const
virtual void PrintSelf(std::ostream &os, Indent indent) const override
const AttributeValueType operator()(const LabelObjectType *labelObject)
Superclass::LengthType LengthType
WeakPointer< const Self > ConstWeakPointer
The base class for the representation of an labeled binary object in an image.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Templated n-dimensional image to store labeled objects.
Definition: itkLabelMap.h:70
void CopyAllFrom(const TSourceLabelObject *src)