Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkSparseFieldLayer.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkSparseFieldLayer.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/09/10 14:28:56 $ 00007 Version: $Revision: 1.6 $ 00008 00009 Copyright (c) Insight Software 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 __itkSparseFieldLayer_h 00018 #define __itkSparseFieldLayer_h 00019 00020 #include "itkObjectFactory.h" 00021 #include "itkObject.h" 00022 #include <vector> 00023 00024 namespace itk { 00025 00031 template <class TNodeType> 00032 class ConstSparseFieldLayerIterator 00033 { 00034 public: 00035 const TNodeType& operator*() const 00036 { return *m_Pointer; } 00037 00038 const TNodeType* operator->() const 00039 { return m_Pointer; } 00040 00041 const TNodeType* GetPointer() const 00042 { return m_Pointer; } 00043 00044 bool operator==(const ConstSparseFieldLayerIterator o) const 00045 { 00046 if (m_Pointer == o.m_Pointer) return true; 00047 else return false; 00048 } 00049 00050 bool operator!=(const ConstSparseFieldLayerIterator o) const 00051 { 00052 if (m_Pointer != o.m_Pointer) return true; 00053 else return false; 00054 } 00055 00056 ConstSparseFieldLayerIterator &operator++() 00057 { 00058 m_Pointer = m_Pointer->Next; 00059 return *this; 00060 } 00061 00062 ConstSparseFieldLayerIterator &operator--() 00063 { 00064 m_Pointer = m_Pointer->Previous; 00065 return *this; 00066 } 00067 00068 ConstSparseFieldLayerIterator() 00069 { m_Pointer=0; } 00070 00071 ConstSparseFieldLayerIterator(TNodeType *p) 00072 { m_Pointer=p; } 00073 00074 ~ConstSparseFieldLayerIterator() {} 00075 00076 protected: 00077 TNodeType *m_Pointer; 00078 }; 00079 00083 template <class TNodeType> 00084 class SparseFieldLayerIterator 00085 : public ConstSparseFieldLayerIterator<TNodeType> 00086 { 00087 public: 00088 typedef ConstSparseFieldLayerIterator<TNodeType> Superclass; 00089 00090 SparseFieldLayerIterator() : Superclass() 00091 { } 00092 00093 SparseFieldLayerIterator(TNodeType *p) : Superclass(p) 00094 { } 00095 00096 TNodeType &operator*() 00097 { return *m_Pointer; } 00098 00099 TNodeType* operator->() 00100 { return m_Pointer; } 00101 00102 TNodeType* GetPointer() 00103 { return m_Pointer; } 00104 00105 SparseFieldLayerIterator &operator++() 00106 { 00107 m_Pointer = m_Pointer->Next; 00108 return *this; 00109 } 00110 00111 SparseFieldLayerIterator &operator--() 00112 { 00113 m_Pointer = m_Pointer->Previous; 00114 return *this; 00115 } 00116 00117 SparseFieldLayerIterator &operator=(Superclass &sc) 00118 { 00119 m_Pointer = const_cast<TNodeType*> (sc.GetPointer()); 00120 return *this; 00121 } 00122 }; 00123 00124 00145 template <class TNodeType> 00146 class ITK_EXPORT SparseFieldLayer 00147 : public Object 00148 { 00149 public: 00151 typedef SparseFieldLayer Self; 00152 typedef Object Superclass; 00153 typedef SmartPointer<Self> Pointer; 00154 typedef SmartPointer<const Self> ConstPointer; 00155 00157 itkNewMacro(Self); 00158 00160 itkTypeMacro(SparseFieldLayer, Object); 00161 00163 typedef TNodeType NodeType; 00164 00167 typedef NodeType ValueType; 00168 00170 typedef SparseFieldLayerIterator<NodeType> Iterator; 00171 00173 typedef ConstSparseFieldLayerIterator<NodeType> ConstIterator; 00174 00176 struct RegionType 00177 { 00178 ConstIterator first; 00179 ConstIterator last; // this is one past the actual last element 00180 }; 00181 00182 typedef std::vector<RegionType> RegionListType; 00183 00185 NodeType *Front() 00186 { return m_HeadNode->Next; } 00187 00189 const NodeType *Front() const 00190 { return m_HeadNode->Next; } 00191 00193 void PopFront() 00194 { 00195 m_HeadNode->Next = m_HeadNode->Next->Next; 00196 m_HeadNode->Next->Previous = m_HeadNode; 00197 m_Size -= 1; 00198 } 00199 00201 void PushFront(NodeType *n) 00202 { 00203 n->Next = m_HeadNode->Next; 00204 n->Previous = m_HeadNode; 00205 m_HeadNode->Next->Previous = n; 00206 m_HeadNode->Next = n; 00207 m_Size += 1; 00208 } 00209 00211 void Unlink(NodeType *n) 00212 { 00213 n->Previous->Next = n->Next; 00214 n->Next->Previous = n->Previous; 00215 m_Size -= 1; 00216 } 00217 00219 Iterator Begin() 00220 { return Iterator(m_HeadNode->Next); } 00221 00223 ConstIterator Begin() const 00224 { return ConstIterator(m_HeadNode->Next); } 00225 00227 Iterator End() 00228 { return Iterator(m_HeadNode); } 00229 00231 ConstIterator End() const 00232 { return ConstIterator(m_HeadNode); } 00233 00236 bool Empty() const 00237 { 00238 if (m_HeadNode->Next == m_HeadNode) return true; 00239 else return false; 00240 } 00241 00244 unsigned int Size() const; 00245 00248 RegionListType SplitRegions(int num) const; 00249 00252 // void Splice (SparseFieldLayer &); 00253 00254 protected: 00255 SparseFieldLayer(); 00256 ~SparseFieldLayer(); 00257 virtual void PrintSelf(std::ostream& os, Indent indent) const; 00258 00259 private: 00260 SparseFieldLayer(const Self&); //purposely not implemented 00261 void operator=(const Self&); //purposely not implemented 00262 00265 NodeType *m_HeadNode; 00266 unsigned int m_Size; 00267 }; 00268 00269 00270 } // end namespace itk 00271 00272 #ifndef ITK_MANUAL_INSTANTIATION 00273 #include "itkSparseFieldLayer.txx" 00274 #endif 00275 00276 #endif

Generated at Sun Apr 1 02:44:55 2007 for ITK by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2000