ITK  4.9.0
Insight Segmentation and Registration Toolkit
itkLabelObjectAccessors.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 itkLabelObjectAccessors_h
19 #define itkLabelObjectAccessors_h
20 
21 #include "itkMacro.h"
22 
23 /*
24  *
25  * This code was contributed in the Insight Journal paper:
26  * "Label object representation and manipulation with ITK"
27  * by Lehmann G.
28  * http://hdl.handle.net/1926/584
29  * http://www.insight-journal.org/browse/publication/176
30  *
31  */
32 
33 namespace itk
34 {
35 namespace Functor
36 {
37 template< typename TLabelObject >
39 {
40 public:
41  typedef TLabelObject LabelObjectType;
42  typedef typename LabelObjectType::LabelType AttributeValueType;
43 
44  inline AttributeValueType operator()(const LabelObjectType *labelObject) const
45  {
46  return labelObject->GetLabel();
47  }
48 };
49 
50 template< typename TLabelObject >
52 {
53 public:
54  typedef TLabelObject LabelObjectType;
55  typedef int AttributeValueType;
56 
57  inline AttributeValueType operator()(const LabelObjectType *labelObject) const
58  {
59  return labelObject->GetNumberOfLines();
60  }
61 };
62 
63 template< typename TLabelObject, typename TAttributeAccessor >
65 {
66 public:
67  typedef TLabelObject LabelObjectType;
68  typedef TAttributeAccessor AttributeAccessorType;
69  bool operator()(const LabelObjectType *a, const LabelObjectType *b) const
70  {
71  return m_Accessor(a) > m_Accessor(b);
72  }
73 
76  {
77  m_Accessor = from.m_Accessor;
78  }
79 
80 private:
82 };
83 
84 template< typename TLabelObject, typename TAttributeAccessor >
86 {
87 public:
88  typedef TLabelObject LabelObjectType;
89  typedef TAttributeAccessor AttributeAccessorType;
90  bool operator()(const LabelObjectType *a, const LabelObjectType *b) const
91  {
92  return m_Accessor(a) < m_Accessor(b);
93  }
94 
97  {
98  m_Accessor = from.m_Accessor;
99  }
100 
101 private:
103 };
104 }
105 } // end namespace itk
106 
107 #endif
LabelObjectComparator(LabelObjectComparator const &from)
AttributeValueType operator()(const LabelObjectType *labelObject) const
AttributeValueType operator()(const LabelObjectType *labelObject) const
bool operator()(const LabelObjectType *a, const LabelObjectType *b) const
LabelObjectReverseComparator(LabelObjectReverseComparator const &from)
bool operator()(const LabelObjectType *a, const LabelObjectType *b) const