ITK  4.8.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 
117  virtual void CopyAttributesFrom( const LabelObjectType * lo ) ITK_OVERRIDE
118  {
120 
121  // copy the data of the current type if possible
122  const Self * src = dynamic_cast<const Self *>( lo );
123  if( src == ITK_NULLPTR )
124  {
125  return;
126  }
127  m_Attribute = src->m_Attribute;
128  }
129 
130 protected:
132  {
133  // how to initialize the attribute ?
134  }
135 
136 
137  void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE
138  {
139  Superclass::PrintSelf( os, indent );
140 
141  os << indent << "Attribute: " << m_Attribute << std::endl;
142  }
143 
144 private:
145  AttributeLabelObject(const Self&); //purposely not implemented
146  void operator=(const Self&); //purposely not implemented
147 
149 
150 
151 };
152 
153 } // end namespace itk
154 
155 #endif
void operator()(LabelObjectType *labelObject, AttributeValueType value)
virtual void CopyAttributesFrom(const LabelObjectType *lo) override
Light weight base class for most itk classes.
virtual void CopyAttributesFrom(const Self *src)
Superclass::IndexType IndexType
Superclass::LabelObjectType LabelObjectType
A LabelObject with a generic attribute.
LabelObject< TLabel, VImageDimension > Superclass
void operator=(const Self &)
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