Orfeo Toolbox  4.0
itkNarrowBandImageFilterBase.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 __itkNarrowBandImageFilterBase_h
19 #define __itkNarrowBandImageFilterBase_h
20 
22 #include "itkMultiThreader.h"
23 #include "itkNarrowBand.h"
24 #include "itkBarrier.h"
25 #include "itkObjectStore.h"
26 
27 namespace itk
28 {
67 template< typename TInputImage, typename TOutputImage >
69  public FiniteDifferenceImageFilter< TInputImage, TOutputImage >
70 {
71 public:
77 
80 
85 
88  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
89 
92  typedef typename Superclass::PixelType PixelType;
93 
96 
99 
103 
106 
112 
114  itkSetMacro(IsoSurfaceValue, ValueType);
115  itkGetConstMacro(IsoSurfaceValue, ValueType);
116 
118  // itkGetConstMacro( RMSChange, ValueType);
119 
125  {
126  m_NarrowBand->PushBack(node); // add new node
127  this->Modified();
128  }
129 
130  void InsertNarrowBandNode(const IndexType & index)
131  {
132  BandNodeType tmpnode;
133 
134  tmpnode.m_Index = index;
135  m_NarrowBand->PushBack(tmpnode);
136  this->Modified();
137  }
138 
139  void InsertNarrowBandNode(const IndexType & index,
140  const PixelType & value,
141  const signed char & nodestate)
142  {
143  BandNodeType tmpnode;
144 
145  tmpnode.m_Data = value;
146  tmpnode.m_Index = index;
147  tmpnode.m_NodeState = nodestate;
148 
149  m_NarrowBand->PushBack(tmpnode);
150  this->Modified();
151  }
152 
156  void SetNarrowBandTotalRadius(const float& val)
157  {
158  if ( m_NarrowBand->GetTotalRadius() != val )
159  {
160  m_NarrowBand->SetTotalRadius(val);
161  this->Modified();
162  }
163  }
164 
167  {
168  return m_NarrowBand->GetTotalRadius();
169  }
170 
173  void SetNarrowBandInnerRadius(const float& val)
174  {
175  if ( m_NarrowBand->GetInnerRadius() != val )
176  {
177  m_NarrowBand->SetInnerRadius(val);
178  this->Modified();
179  }
180  }
181 
184  {
185  return m_NarrowBand->GetInnerRadius();
186  }
187 
193  virtual void CreateNarrowBand(){}
194 
195  virtual void SetNarrowBand(NarrowBandType *ptr)
196  {
197  if ( m_NarrowBand != ptr )
198  {
199  m_NarrowBand = ptr;
200  this->Modified();
201  }
202  }
203 
204  virtual void CopyInputToOutput();
205 
206 protected:
208  {
210  m_NarrowBand->SetTotalRadius(4);
211  m_NarrowBand->SetInnerRadius(2);
213  m_IsoSurfaceValue = 0.0;
214  m_Step = 0;
215  m_Touched = false;
217  }
218 
220  void PrintSelf(std::ostream & os, Indent indent) const;
221 
223 
230 
233  };
234 
237  std::vector< RegionType > m_RegionList;
238 
241  void GetSplitRegion(const size_t& i, ThreadRegionType & splitRegion);
242 
247  virtual void Initialize();
248 
253  virtual void InitializeIteration();
254 
257  virtual void PostProcessOutput();
258 
259  /* This function clears all pixels from the narrow band */
260  void ClearNarrowBand();
261 
263  void WaitForAll();
264 
268  virtual void GenerateData();
269 
270  /* Variables to control reinitialization */
273 
274  bool m_Touched;
275 
276  std::vector< bool > m_TouchedForThread;
277 
279 
281 
282 private:
283  NarrowBandImageFilterBase(const Self &); //purposely not implemented
284  void operator=(const Self &); //purposely not implemented
285 
291  std::vector< TimeStepType > TimeStepList;
292  std::vector< bool > ValidTimeStepList;
293  };
294 
295  /* This class does not use AllocateUpdateBuffer to allocate memory for its
296  * narrow band. This is taken care of in SetNarrowBand, and InsertNarrowBandNode
297  * functions. This function is here for compatibility with the
298  * FiniteDifferenceSolver framework.
299  */
300  virtual void AllocateUpdateBuffer() {}
301 
304 
308  virtual void ThreadedIterate(void *arg, ThreadIdType threadId);
309 
313  virtual void ThreadedApplyUpdate(const TimeStepType& dt,
314  const ThreadRegionType & regionToProcess,
315  ThreadIdType threadId);
316 
317  virtual void ApplyUpdate(const TimeStepType&){}
318 
322  virtual TimeStepType ThreadedCalculateChange(const ThreadRegionType & regionToProcess,
323  ThreadIdType threadId);
324 
325  virtual TimeStepType CalculateChange() { return 0; }
326 };
327 } // end namespace itk
328 
329 #ifndef ITK_MANUAL_INSTANTIATION
331 #endif
332 
333 #endif

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