00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkWatershedEquivalencyTable.h,v $ 00005 Language: C++ 00006 Date: $Date: 2002/07/11 21:36:07 $ 00007 Version: $Revision: 1.5 $ 00008 00009 Copyright (c) 2002 Insight Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef __itkWatershedEquivalencyTable_h 00018 #define __itkWatershedEquivalencyTable_h 00019 00020 #if defined(_MSC_VER) 00021 #pragma warning ( disable : 4786 ) 00022 #endif 00023 00024 #include "itkObjectFactory.h" 00025 #include "itkDataObject.h" 00026 #include "itkProcessObject.h" 00027 #include "itk_hash_map.h" 00028 00029 namespace itk 00030 { 00031 namespace watershed 00032 { 00033 00048 class EquivalencyTable : public DataObject 00049 { 00050 public: 00052 typedef EquivalencyTable Self; 00053 typedef DataObject Superclass; 00054 typedef SmartPointer<Self> Pointer; 00055 typedef SmartPointer<const Self> ConstPointer; 00056 itkNewMacro(Self); 00057 itkTypeMacro(EquivalencyTable, DataObject); 00058 00060 typedef itk::hash_map<unsigned long, unsigned long, 00061 itk::hash<unsigned long> > HashTableType; 00062 typedef HashTableType::iterator Iterator; 00063 typedef HashTableType::const_iterator ConstIterator; 00064 typedef HashTableType::value_type ValueType; 00065 00069 void Flatten(); 00070 00077 bool Add(unsigned long a, unsigned long b); 00078 00082 unsigned long Lookup(const unsigned long a) const 00083 { 00084 ConstIterator result = m_HashMap.find(a); 00085 if ( result == m_HashMap.end() ) return a; 00086 else return (*result).second; 00087 } 00088 00092 unsigned long RecursiveLookup(const unsigned a) const; 00093 00096 bool IsEntry(const unsigned long a) const 00097 { 00098 if ( m_HashMap.find(a) == m_HashMap.end() ) return false; 00099 else return true; 00100 } 00101 00103 void Erase(const unsigned long a) 00104 { m_HashMap.erase(a); } 00105 00107 void Clear() 00108 { m_HashMap.clear(); } 00109 00111 bool Empty() const 00112 { return m_HashMap.empty(); } 00113 00115 HashTableType::size_type Size() const 00116 { return m_HashMap.size(); } 00117 00120 Iterator Begin() { return m_HashMap.begin(); } 00121 00124 Iterator End() { return m_HashMap.end(); } 00125 00127 // void PrintHashTable(); 00128 protected: 00129 EquivalencyTable() {} 00130 virtual ~EquivalencyTable() {} 00131 EquivalencyTable(const Self&) {} 00132 void operator=(const Self&) {} 00133 void PrintSelf(std::ostream& os, Indent indent) const; 00134 00135 HashTableType m_HashMap; 00136 00137 void UpdateOutputInformation(); 00138 bool VerifyRequestedRegion() { return true; } 00139 void SetRequestedRegionToLargestPossibleRegion () {} 00140 bool RequestedRegionIsOutsideOfTheBufferedRegion () { return false; } 00141 00142 void SetRequestedRegion (itk::DataObject *) {} 00143 }; 00144 }// end namespace watershed 00145 }// end namespace itk 00146 00147 #endif 00148