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: 2002/05/15 17:31:44 $
00007   Version:   $Revision: 1.1 $
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 __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()
00063   { m_Pointer=0; }
00064 
00065   ConstSparseFieldLayerIterator(TNodeType *p)
00066   { m_Pointer=p; }
00067 
00068   ~ConstSparseFieldLayerIterator() {}
00069 
00070 protected:
00071   TNodeType *m_Pointer;
00072 };
00073 
00077 template <class TNodeType>
00078 class SparseFieldLayerIterator
00079   : public ConstSparseFieldLayerIterator<TNodeType>
00080 {
00081 public:
00082   typedef ConstSparseFieldLayerIterator<TNodeType> Superclass;
00083 
00084   SparseFieldLayerIterator() : Superclass()
00085   { }
00086 
00087   SparseFieldLayerIterator(TNodeType *p) : Superclass(p)
00088   { }
00089 
00090   TNodeType &operator*()
00091   { return *m_Pointer; }
00092 
00093   TNodeType* operator->()
00094   { return m_Pointer; }
00095 
00096   TNodeType* GetPointer()
00097   { return m_Pointer; }
00098   
00099   SparseFieldLayerIterator &operator++()
00100   {
00101     m_Pointer = m_Pointer->Next;
00102     return *this;
00103   }
00104 
00105 };
00106 
00107 
00128 template <class TNodeType>
00129 class ITK_EXPORT SparseFieldLayer
00130     : public Object
00131 {
00132 public:
00134   typedef SparseFieldLayer Self;
00135   typedef Object  Superclass;
00136   typedef SmartPointer<Self>  Pointer;
00137   typedef SmartPointer<const Self>  ConstPointer;
00138 
00140   itkNewMacro(Self);
00141 
00143   itkTypeMacro(SparseFieldLayer, Object);
00144 
00146   typedef TNodeType NodeType;
00147   
00150   typedef NodeType ValueType;
00151 
00153   typedef SparseFieldLayerIterator<NodeType> Iterator;
00154 
00156   typedef ConstSparseFieldLayerIterator<NodeType> ConstIterator;
00157         
00159   NodeType *Front()
00160   { return m_HeadNode->Next; }
00161 
00163   const NodeType *Front() const
00164   { return m_HeadNode->Next; }
00165 
00167   void PopFront()
00168   {
00169     m_HeadNode->Next = m_HeadNode->Next->Next;
00170     m_HeadNode->Next->Previous = m_HeadNode;
00171   }
00172 
00174   void PushFront(NodeType *n)
00175   {
00176     n->Next = m_HeadNode->Next;
00177     n->Previous = m_HeadNode;
00178     m_HeadNode->Next->Previous = n;
00179     m_HeadNode->Next = n;
00180   }
00181 
00183   void Unlink(NodeType *n)
00184   {
00185     n->Previous->Next = n->Next;
00186     n->Next->Previous = n->Previous;
00187   }
00188   
00190   Iterator Begin()
00191   { return Iterator(m_HeadNode->Next); }
00192 
00194   ConstIterator Begin() const
00195   { return ConstIterator(m_HeadNode->Next); }
00196 
00198   Iterator End()
00199   { return Iterator(m_HeadNode); }
00200 
00202   ConstIterator End() const
00203   { return ConstIterator(m_HeadNode); }
00204   
00207   bool Empty() const
00208   {
00209     if (m_HeadNode->Next == m_HeadNode) return true;
00210     else return false;
00211   }
00212 
00217   unsigned int Size() const;
00218 
00221   //  void Splice (SparseFieldLayer &);
00222   
00223 protected:
00224   SparseFieldLayer();
00225   ~SparseFieldLayer();
00226   virtual void PrintSelf(std::ostream& os, Indent indent) const;
00227   
00228 private:
00229   SparseFieldLayer(const Self&);    //purposely not implemented
00230   void operator=(const Self&);      //purposely not implemented
00231   
00234   NodeType *m_HeadNode; 
00235 };
00236 
00237 
00238 } // end namespace itk
00239 
00240 #ifndef ITK_MANUAL_INSTANTIATION
00241 #include "itkSparseFieldLayer.txx"
00242 #endif
00243 
00244 #endif

Generated at Wed Mar 12 01:13:10 2003 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000