ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkAttributeRelabelLabelMapFilter.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 __itkAttributeRelabelLabelMapFilter_h
00019 #define __itkAttributeRelabelLabelMapFilter_h
00020 
00021 #include "itkInPlaceLabelMapFilter.h"
00022 #include "itkAttributeLabelObject.h"
00023 
00024 namespace itk {
00042 template<class TImage, class TAttributeAccessor=
00043     typename Functor::AttributeLabelObjectAccessor< typename TImage::LabelObjectType > >
00044 class ITK_EXPORT AttributeRelabelLabelMapFilter :
00045     public InPlaceLabelMapFilter<TImage>
00046 {
00047 public:
00049   typedef AttributeRelabelLabelMapFilter Self;
00050   typedef InPlaceLabelMapFilter<TImage>  Superclass;
00051   typedef SmartPointer<Self>             Pointer;
00052   typedef SmartPointer<const Self>       ConstPointer;
00053 
00055   typedef TImage                                       ImageType;
00056   typedef typename ImageType::Pointer                  ImagePointer;
00057   typedef typename ImageType::ConstPointer             ImageConstPointer;
00058   typedef typename ImageType::PixelType                PixelType;
00059   typedef typename ImageType::IndexType                IndexType;
00060   typedef typename ImageType::LabelObjectType          LabelObjectType;
00061 
00062   typedef TAttributeAccessor                                 AttributeAccessorType;
00063   typedef typename AttributeAccessorType::AttributeValueType AttributeValueType;
00064 
00066   itkStaticConstMacro(ImageDimension, unsigned int,
00067                       TImage::ImageDimension);
00068 
00070   itkNewMacro(Self);
00071 
00073   itkTypeMacro(AttributeRelabelLabelMapFilter,
00074                InPlaceLabelMapFilter);
00075 
00076 #ifdef ITK_USE_CONCEPT_CHECKING
00077 
00078 /*  itkConceptMacro(InputEqualityComparableCheck,
00079     (Concept::EqualityComparable<InputImagePixelType>));
00080   itkConceptMacro(IntConvertibleToInputCheck,
00081     (Concept::Convertible<int, InputImagePixelType>));
00082   itkConceptMacro(InputOStreamWritableCheck,
00083     (Concept::OStreamWritable<InputImagePixelType>));*/
00084 
00086 #endif
00087 
00093   itkSetMacro( ReverseOrdering, bool );
00094   itkGetConstReferenceMacro( ReverseOrdering, bool );
00095   itkBooleanMacro( ReverseOrdering );
00097 
00098 protected:
00099   AttributeRelabelLabelMapFilter();
00100   ~AttributeRelabelLabelMapFilter() {};
00101 
00102   void GenerateData();
00103 
00104   void PrintSelf(std::ostream& os, Indent indent) const;
00105 
00106   class ReverseComparator
00107     {
00108     public:
00109     bool operator()( const typename LabelObjectType::Pointer & a, const typename LabelObjectType::Pointer & b )
00110       {
00111       return m_Accessor( a ) < m_Accessor( b );
00112       }
00113     ReverseComparator(): m_Accessor() {}
00114     private:
00115      AttributeAccessorType m_Accessor;
00116     };
00117 
00118   class Comparator
00119     {
00120   public:
00121     bool operator()( const typename LabelObjectType::Pointer & a, const typename LabelObjectType::Pointer & b )
00122       {
00123       return m_Accessor( a ) > m_Accessor( b );
00124       }
00125     Comparator(): m_Accessor() {}
00126   private:
00127     AttributeAccessorType m_Accessor;
00128     };
00129 
00130 private:
00131   AttributeRelabelLabelMapFilter(const Self&); //purposely not implemented
00132   void operator=(const Self&); //purposely not implemented
00133 
00134   bool m_ReverseOrdering;
00135 
00136 }; // end of class
00137 
00138 } // end namespace itk
00139 
00140 #ifndef ITK_MANUAL_INSTANTIATION
00141 #include "itkAttributeRelabelLabelMapFilter.hxx"
00142 #endif
00143 
00144 #endif
00145