Orfeo Toolbox  4.0
itkSparseFieldLayer.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkSparseFieldLayer_h
19 #define __itkSparseFieldLayer_h
20 
21 #include "itkObjectFactory.h"
22 #include "itkObject.h"
23 #include <vector>
24 
25 namespace itk
26 {
35 template< typename TNodeType >
37 {
38 public:
39  const TNodeType & operator*() const
40  { return *m_Pointer; }
41 
42  const TNodeType * operator->() const
43  { return m_Pointer; }
44 
45  const TNodeType * GetPointer() const
46  { return m_Pointer; }
47 
49  {
50  if ( m_Pointer == o.m_Pointer ) { return true; }
51  else { return false; }
52  }
53 
55  {
56  if ( m_Pointer != o.m_Pointer ) { return true; }
57  else { return false; }
58  }
59 
61  {
62  m_Pointer = m_Pointer->Next;
63  return *this;
64  }
65 
67  {
68  m_Pointer = m_Pointer->Previous;
69  return *this;
70  }
71 
73  { m_Pointer = 0; }
74 
76  { m_Pointer = p; }
77 
79 
80 protected:
81  TNodeType *m_Pointer;
82 };
83 
88 template< typename TNodeType >
90  public ConstSparseFieldLayerIterator< TNodeType >
91 {
92 public:
94 
96  {}
97 
99  {}
100 
101  TNodeType & operator*()
102  { return *this->m_Pointer; }
103 
104  TNodeType * operator->()
105  { return this->m_Pointer; }
106 
107  TNodeType * GetPointer()
108  { return this->m_Pointer; }
109 
111  {
112  this->m_Pointer = this->m_Pointer->Next;
113  return *this;
114  }
115 
117  {
118  this->m_Pointer = this->m_Pointer->Previous;
119  return *this;
120  }
121 
123  {
124  this->m_Pointer = const_cast< TNodeType * >( sc.GetPointer() );
125  return *this;
126  }
127 };
128 
151 template< typename TNodeType >
153  public Object
154 {
155 public:
161 
163  itkNewMacro(Self);
164 
166  itkTypeMacro(SparseFieldLayer, Object);
167 
169  typedef TNodeType NodeType;
170 
174 
177 
180 
182  struct RegionType {
184  ConstIterator last; // this is one past the actual last element
185  };
186 
187  typedef std::vector< RegionType > RegionListType;
188 
192  { return m_HeadNode->Next; }
193 
195  const NodeType * Front() const
196  { return m_HeadNode->Next; }
197 
199  void PopFront()
200  {
201  m_HeadNode->Next = m_HeadNode->Next->Next;
202  m_HeadNode->Next->Previous = m_HeadNode;
203  m_Size -= 1;
204  }
205 
208  {
209  n->Next = m_HeadNode->Next;
210  n->Previous = m_HeadNode;
211  m_HeadNode->Next->Previous = n;
212  m_HeadNode->Next = n;
213  m_Size += 1;
214  }
215 
217  void Unlink(NodeType *n)
218  {
219  n->Previous->Next = n->Next;
220  n->Next->Previous = n->Previous;
221  m_Size -= 1;
222  }
223 
226  { return Iterator(m_HeadNode->Next); }
227 
231  { return ConstIterator(m_HeadNode->Next); }
232 
235  { return Iterator(m_HeadNode); }
236 
239  { return ConstIterator(m_HeadNode); }
240 
243  bool Empty() const
244  {
245  if ( m_HeadNode->Next == m_HeadNode ) { return true; }
246  else { return false; }
247  }
248 
251  unsigned int Size() const;
252 
255  RegionListType SplitRegions(int num) const;
256 
257 protected:
260  virtual void PrintSelf(std::ostream & os, Indent indent) const;
261 
262 private:
263  SparseFieldLayer(const Self &); //purposely not implemented
264  void operator=(const Self &); //purposely not implemented
265 
269  unsigned int m_Size;
270 };
271 } // end namespace itk
272 
273 #ifndef ITK_MANUAL_INSTANTIATION
274 #include "itkSparseFieldLayer.hxx"
275 #endif
276 
277 #endif

Generated at Sat Mar 8 2014 15:34:03 for Orfeo Toolbox with doxygen 1.8.3.1