ITK  5.0.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:
55  ITK_DISALLOW_COPY_AND_ASSIGN(AttributeSelectionLabelMapFilter);
56 
62 
64  using ImageType = TImage;
65  using ImagePointer = typename ImageType::Pointer;
66  using ImageConstPointer = typename ImageType::ConstPointer;
67  using PixelType = typename ImageType::PixelType;
68  using IndexType = typename ImageType::IndexType;
69  using LabelObjectType = typename ImageType::LabelObjectType;
70 
71  using AttributeAccessorType = TAttributeAccessor;
73 
74  using AttributeSetType = typename std::set<AttributeValueType>;
75 
77  static constexpr unsigned int ImageDimension = TImage::ImageDimension;
78 
80  itkNewMacro(Self);
81 
85 
86 #ifdef ITK_USE_CONCEPT_CHECKING
87  // Begin concept checking
88 /* itkConceptMacro(InputEqualityComparableCheck,
89  (Concept::EqualityComparable<InputImagePixelType>));
90  itkConceptMacro(IntConvertibleToInputCheck,
91  (Concept::Convertible<int, InputImagePixelType>));
92  itkConceptMacro(InputOStreamWritableCheck,
93  (Concept::OStreamWritable<InputImagePixelType>));*/
94  // End concept checking
95 #endif
96 
101  {
102  return m_AttributeSet;
103  }
104  void SetAttributeSet( const AttributeSetType & set )
105  {
106  m_AttributeSet = set;
107  this->Modified();
108  }
110 
115  itkGetConstMacro( Exclude, bool );
116  itkSetMacro( Exclude, bool );
117  itkBooleanMacro( Exclude );
119 
121  void SetAttribute( const AttributeValueType & attr )
122  {
123  this->ClearAttributeSet();
124  this->AddAttribute( attr );
125  }
127 
129  {
130  if( ! m_AttributeSet.empty() )
131  {
132  m_AttributeSet.clear();
133  this->Modified();
134  }
135  }
136 
137  void AddAttribute( const AttributeValueType & attr )
138  {
139  const typename AttributeSetType::size_type size = m_AttributeSet.size();
140  m_AttributeSet.insert( attr );
141  if( size != m_AttributeSet.size() )
142  {
143  this->Modified();
144  }
145  }
146 
147 protected:
149  ~AttributeSelectionLabelMapFilter() override = default;
150 
151  void GenerateData() override;
152 
153  void PrintSelf(std::ostream& os, Indent indent) const override;
154 
155 private:
157  bool m_Exclude;
158 
159 }; // end of class
160 
161 } // end namespace itk
162 
163 #ifndef ITK_MANUAL_INSTANTIATION
164 #include "itkAttributeSelectionLabelMapFilter.hxx"
165 #endif
166 
167 #endif
Light weight base class for most itk classes.
typename LabelObjectType::LabelType AttributeValueType
Base class for filters that takes an image as input and overwrites that image as the output...
Control indentation during Print() invocation.
Definition: itkIndent.h:49
remove the objects according to the value of their attribute