ITK  4.12.0
Insight Segmentation and Registration Toolkit
itkAttributeSelectionLabelMapFilter.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 itkAttributeSelectionLabelMapFilter_h
19 #define itkAttributeSelectionLabelMapFilter_h
20 
23 #include <set>
24 
25 
26 namespace itk {
49 template<typename TImage, typename TAttributeAccessor=
50  typename Functor::AttributeLabelObjectAccessor< typename TImage::LabelObjectType > >
51 class ITK_TEMPLATE_EXPORT AttributeSelectionLabelMapFilter :
52  public InPlaceLabelMapFilter<TImage>
53 {
54 public:
60 
62  typedef TImage ImageType;
63  typedef typename ImageType::Pointer ImagePointer;
65  typedef typename ImageType::PixelType PixelType;
66  typedef typename ImageType::IndexType IndexType;
67  typedef typename ImageType::LabelObjectType LabelObjectType;
68 
69  typedef TAttributeAccessor AttributeAccessorType;
71 
72  typedef typename std::set<AttributeValueType> AttributeSetType;
73 
75  itkStaticConstMacro(ImageDimension, unsigned int,
76  TImage::ImageDimension);
77 
79  itkNewMacro(Self);
80 
84 
85 #ifdef ITK_USE_CONCEPT_CHECKING
86  // Begin concept checking
87 /* itkConceptMacro(InputEqualityComparableCheck,
88  (Concept::EqualityComparable<InputImagePixelType>));
89  itkConceptMacro(IntConvertibleToInputCheck,
90  (Concept::Convertible<int, InputImagePixelType>));
91  itkConceptMacro(InputOStreamWritableCheck,
92  (Concept::OStreamWritable<InputImagePixelType>));*/
93  // End concept checking
94 #endif
95 
100  {
101  return m_AttributeSet;
102  }
103  void SetAttributeSet( const AttributeSetType & set )
104  {
105  m_AttributeSet = set;
106  this->Modified();
107  }
109 
114  itkGetConstMacro( Exclude, bool );
115  itkSetMacro( Exclude, bool );
116  itkBooleanMacro( Exclude );
118 
120  void SetAttribute( const AttributeValueType & attr )
121  {
122  this->ClearAttributeSet();
123  this->AddAttribute( attr );
124  }
126 
128  {
129  if( ! m_AttributeSet.empty() )
130  {
131  m_AttributeSet.clear();
132  this->Modified();
133  }
134  }
135 
136  void AddAttribute( const AttributeValueType & attr )
137  {
138  const typename AttributeSetType::size_type size = m_AttributeSet.size();
139  m_AttributeSet.insert( attr );
140  if( size != m_AttributeSet.size() )
141  {
142  this->Modified();
143  }
144  }
145 
146 protected:
149 
150  void GenerateData() ITK_OVERRIDE;
151 
152  void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE;
153 
154 private:
155  ITK_DISALLOW_COPY_AND_ASSIGN(AttributeSelectionLabelMapFilter);
156 
157  AttributeSetType m_AttributeSet;
158  bool m_Exclude;
159 
160 }; // end of class
161 
162 } // end namespace itk
163 
164 #ifndef ITK_MANUAL_INSTANTIATION
165 #include "itkAttributeSelectionLabelMapFilter.hxx"
166 #endif
167 
168 #endif
virtual void PrintSelf(std::ostream &os, Indent indent) const override
Light weight base class for most itk classes.
SmartPointer< Self > Pointer
Base class for filters that takes an image as input and overwrites that image as the output...
SmartPointer< const Self > ConstPointer
Control indentation during Print() invocation.
Definition: itkIndent.h:49
AttributeAccessorType::AttributeValueType AttributeValueType
remove the objects according to the value of their attribute