ITK  4.3.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< class 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 < class TLabel, unsigned int VImageDimension, class TAttributeValue >
70 class ITK_EXPORT 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 
101  void SetAttribute( const AttributeValueType & v )
102  {
103  m_Attribute = v;
104  }
105 
106  const AttributeValueType & GetAttribute() const
107  {
108  return m_Attribute;
109  }
110 
111  AttributeValueType GetAttribute()
112  {
113  return m_Attribute;
114  }
115 
116 
117  virtual void CopyAttributesFrom( const LabelObjectType * lo )
118  {
119  Superclass::CopyAttributesFrom( lo );
120 
121  // copy the data of the current type if possible
122  const Self * src = dynamic_cast<const Self *>( lo );
123  if( src == NULL )
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
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
156