ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkAttributeSelectionLabelMapFilter.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkAttributeSelectionLabelMapFilter_h
00019 #define __itkAttributeSelectionLabelMapFilter_h
00020 
00021 #include "itkInPlaceLabelMapFilter.h"
00022 #include "itkAttributeLabelObject.h"
00023 #include <set>
00024 
00025 
00026 namespace itk {
00047 template<class TImage, class TAttributeAccessor=
00048     typename Functor::AttributeLabelObjectAccessor< typename TImage::LabelObjectType > >
00049 class ITK_EXPORT AttributeSelectionLabelMapFilter :
00050     public InPlaceLabelMapFilter<TImage>
00051 {
00052 public:
00054   typedef AttributeSelectionLabelMapFilter Self;
00055   typedef InPlaceLabelMapFilter<TImage>    Superclass;
00056   typedef SmartPointer<Self>               Pointer;
00057   typedef SmartPointer<const Self>         ConstPointer;
00058 
00060   typedef TImage                              ImageType;
00061   typedef typename ImageType::Pointer         ImagePointer;
00062   typedef typename ImageType::ConstPointer    ImageConstPointer;
00063   typedef typename ImageType::PixelType       PixelType;
00064   typedef typename ImageType::IndexType       IndexType;
00065   typedef typename ImageType::LabelObjectType LabelObjectType;
00066 
00067   typedef TAttributeAccessor                                 AttributeAccessorType;
00068   typedef typename AttributeAccessorType::AttributeValueType AttributeValueType;
00069 
00070   typedef typename std::set<AttributeValueType> AttributeSetType;
00071 
00073   itkStaticConstMacro(ImageDimension, unsigned int,
00074                       TImage::ImageDimension);
00075 
00077   itkNewMacro(Self);
00078 
00080   itkTypeMacro(AttributeSelectionLabelMapFilter,
00081                InPlaceLabelMapFilter);
00082 
00083 #ifdef ITK_USE_CONCEPT_CHECKING
00084 
00085 /*  itkConceptMacro(InputEqualityComparableCheck,
00086     (Concept::EqualityComparable<InputImagePixelType>));
00087   itkConceptMacro(IntConvertibleToInputCheck,
00088     (Concept::Convertible<int, InputImagePixelType>));
00089   itkConceptMacro(InputOStreamWritableCheck,
00090     (Concept::OStreamWritable<InputImagePixelType>));*/
00091 
00093 #endif
00094 
00098   const AttributeSetType & GetAttributeSet() const
00099     {
00100     return m_AttributeSet;
00101     }
00102   void SetAttributeSet( const AttributeSetType & set )
00103     {
00104     m_AttributeSet = set;
00105     this->Modified();
00106     }
00108 
00113   itkGetConstMacro( Exclude, bool );
00114   itkSetMacro( Exclude, bool );
00115   itkBooleanMacro( Exclude );
00117 
00119   void SetAttribute( const AttributeValueType & attr )
00120     {
00121     this->ClearAttributeSet();
00122     this->AddAttribute( attr );
00123     }
00125 
00126   void ClearAttributeSet()
00127     {
00128     if( ! m_AttributeSet.empty() )
00129       {
00130       m_AttributeSet.clear();
00131       this->Modified();
00132       }
00133     }
00134 
00135   void AddAttribute(  const AttributeValueType & attr )
00136     {
00137     const typename AttributeSetType::size_type size = m_AttributeSet.size();
00138     m_AttributeSet.insert( attr );
00139     if( size != m_AttributeSet.size() )
00140       {
00141       this->Modified();
00142       }
00143     }
00144 
00145 protected:
00146   AttributeSelectionLabelMapFilter();
00147   ~AttributeSelectionLabelMapFilter() {};
00148 
00149   void GenerateData();
00150 
00151   void PrintSelf(std::ostream& os, Indent indent) const;
00152 
00153 private:
00154   AttributeSelectionLabelMapFilter(const Self&); //purposely not implemented
00155   void operator=(const Self&); //purposely not implemented
00156 
00157   AttributeSetType m_AttributeSet;
00158   bool             m_Exclude;
00159 
00160 }; // end of class
00161 
00162 } // end namespace itk
00163 
00164 #ifndef ITK_MANUAL_INSTANTIATION
00165 #include "itkAttributeSelectionLabelMapFilter.hxx"
00166 #endif
00167 
00168 #endif
00169