Orfeo Toolbox  3.16
itkSparseFieldLayer.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkSparseFieldLayer.h,v $
5  Language: C++
6  Date: $Date: 2009-01-14 18:39:05 $
7  Version: $Revision: 1.9 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 #ifndef __itkSparseFieldLayer_h
18 #define __itkSparseFieldLayer_h
19 
20 #include "itkObjectFactory.h"
21 #include "itkObject.h"
22 #include <vector>
23 
24 namespace itk {
25 
31 template <class TNodeType>
33 {
34 public:
35  const TNodeType& operator*() const
36  { return *m_Pointer; }
37 
38  const TNodeType* operator->() const
39  { return m_Pointer; }
40 
41  const TNodeType* GetPointer() const
42  { return m_Pointer; }
43 
45  {
46  if (m_Pointer == o.m_Pointer) return true;
47  else return false;
48  }
49 
51  {
52  if (m_Pointer != o.m_Pointer) return true;
53  else return false;
54  }
55 
57  {
58  m_Pointer = m_Pointer->Next;
59  return *this;
60  }
61 
63  {
64  m_Pointer = m_Pointer->Previous;
65  return *this;
66  }
67 
69  { m_Pointer=0; }
70 
72  { m_Pointer=p; }
73 
75 
76 protected:
77  TNodeType *m_Pointer;
78 };
79 
83 template <class TNodeType>
85  : public ConstSparseFieldLayerIterator<TNodeType>
86 {
87 public:
89 
91  {}
92 
94  {}
95 
96  TNodeType &operator*()
97  { return *this->m_Pointer; }
98 
99  TNodeType* operator->()
100  { return this->m_Pointer; }
101 
102  TNodeType* GetPointer()
103  { return this->m_Pointer; }
104 
106  {
107  this->m_Pointer = this->m_Pointer->Next;
108  return *this;
109  }
110 
112  {
113  this->m_Pointer = this->m_Pointer->Previous;
114  return *this;
115  }
116 
118  {
119  this->m_Pointer = const_cast<TNodeType*> (sc.GetPointer());
120  return *this;
121  }
122 };
123 
124 
145 template <class TNodeType>
147  : public Object
148 {
149 public:
155 
157  itkNewMacro(Self);
158 
160  itkTypeMacro(SparseFieldLayer, Object);
161 
163  typedef TNodeType NodeType;
164 
168 
171 
174 
176  struct RegionType
177  {
179  ConstIterator last; // this is one past the actual last element
180  };
181 
182  typedef std::vector<RegionType> RegionListType;
183 
186  NodeType *Front()
187  { return m_HeadNode->Next; }
188 
190  const NodeType *Front() const
191  { return m_HeadNode->Next; }
192 
194  void PopFront()
195  {
196  m_HeadNode->Next = m_HeadNode->Next->Next;
197  m_HeadNode->Next->Previous = m_HeadNode;
198  m_Size -= 1;
199  }
200 
202  void PushFront(NodeType *n)
203  {
204  n->Next = m_HeadNode->Next;
205  n->Previous = m_HeadNode;
206  m_HeadNode->Next->Previous = n;
207  m_HeadNode->Next = n;
208  m_Size += 1;
209  }
210 
212  void Unlink(NodeType *n)
213  {
214  n->Previous->Next = n->Next;
215  n->Next->Previous = n->Previous;
216  m_Size -= 1;
217  }
218 
220  Iterator Begin()
221  { return Iterator(m_HeadNode->Next); }
222 
225  ConstIterator Begin() const
226  { return ConstIterator(m_HeadNode->Next); }
227 
229  Iterator End()
230  { return Iterator(m_HeadNode); }
231 
233  ConstIterator End() const
234  { return ConstIterator(m_HeadNode); }
235 
238  bool Empty() const
239  {
240  if (m_HeadNode->Next == m_HeadNode) return true;
241  else return false;
242  }
243 
246  unsigned int Size() const;
247 
250  RegionListType SplitRegions(int num) const;
251 
252 protected:
254  ~SparseFieldLayer();
255  virtual void PrintSelf(std::ostream& os, Indent indent) const;
256 
257 private:
258  SparseFieldLayer(const Self&); //purposely not implemented
259  void operator=(const Self&); //purposely not implemented
260 
264  unsigned int m_Size;
265 };
266 
267 
268 } // end namespace itk
269 
270 #ifndef ITK_MANUAL_INSTANTIATION
271 #include "itkSparseFieldLayer.txx"
272 #endif
273 
274 #endif

Generated at Sun Feb 3 2013 00:07:53 for Orfeo Toolbox with doxygen 1.8.1.1