ITK  4.3.0
Insight Segmentation and Registration Toolkit
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< class TInputImage, class TOutputImage >
69  public FiniteDifferenceImageFilter< TInputImage, TOutputImage >
70 {
71 public:
72 
78 
81 
86 
89  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
90 
93  typedef typename Superclass::PixelType PixelType;
94 
97 
100 
104 
107 
113 
115  itkSetMacro(IsoSurfaceValue, ValueType);
116  itkGetConstMacro(IsoSurfaceValue, ValueType);
118 
120  // itkGetConstMacro( RMSChange, ValueType);
121 
127  {
128  m_NarrowBand->PushBack(node); // add new node
129  this->Modified();
130  }
132 
133  void InsertNarrowBandNode(const IndexType & index)
134  {
135  BandNodeType tmpnode;
136 
137  tmpnode.m_Index = index;
138  m_NarrowBand->PushBack(tmpnode);
139  this->Modified();
140  }
141 
142  void InsertNarrowBandNode(const IndexType & index,
143  const PixelType & value,
144  const signed char & nodestate)
145  {
146  BandNodeType tmpnode;
147 
148  tmpnode.m_Data = value;
149  tmpnode.m_Index = index;
150  tmpnode.m_NodeState = nodestate;
151 
152  m_NarrowBand->PushBack(tmpnode);
153  this->Modified();
154  }
155 
159  void SetNarrowBandTotalRadius(const float& val)
160  {
161  if ( m_NarrowBand->GetTotalRadius() != val )
162  {
163  m_NarrowBand->SetTotalRadius(val);
164  this->Modified();
165  }
166  }
168 
171  {
172  return m_NarrowBand->GetTotalRadius();
173  }
174 
177  void SetNarrowBandInnerRadius(const float& val)
178  {
179  if ( m_NarrowBand->GetInnerRadius() != val )
180  {
181  m_NarrowBand->SetInnerRadius(val);
182  this->Modified();
183  }
184  }
186 
189  {
190  return m_NarrowBand->GetInnerRadius();
191  }
192 
198  virtual void CreateNarrowBand(){}
199 
200  virtual void SetNarrowBand(NarrowBandType *ptr)
201  {
202  if ( m_NarrowBand != ptr )
203  {
204  m_NarrowBand = ptr;
205  this->Modified();
206  }
207  }
208 
209  virtual void CopyInputToOutput();
210 
211 protected:
213  {
215  m_NarrowBand->SetTotalRadius(4);
216  m_NarrowBand->SetInnerRadius(2);
218  m_IsoSurfaceValue = 0.0;
219  m_Step = 0;
220  m_Touched = false;
222  }
223 
225  void PrintSelf(std::ostream & os, Indent indent) const;
226 
228 
233 
236 
239  };
240 
243  std::vector< RegionType > m_RegionList;
244 
247  void GetSplitRegion(const size_t& i, ThreadRegionType & splitRegion);
248 
253  virtual void Initialize();
254 
259  virtual void InitializeIteration();
260 
263  virtual void PostProcessOutput();
264 
265  /* This function clears all pixels from the narrow band */
266  void ClearNarrowBand();
267 
269  void WaitForAll();
270 
274  virtual void GenerateData();
275 
276  /* Variables to control reinitialization */
279 
280  bool m_Touched;
281 
282  std::vector< bool > m_TouchedForThread;
283 
285 
287 
288 private:
289  NarrowBandImageFilterBase(const Self &); //purposely not implemented
290  void operator=(const Self &); //purposely not implemented
291 
297  std::vector< TimeStepType > TimeStepList;
298  std::vector< bool > ValidTimeStepList;
299  };
300 
301  /* This class does not use AllocateUpdateBuffer to allocate memory for its
302  * narrow band. This is taken care of in SetNarrowBand, and InsertNarrowBandNode
303  * functions. This function is here for compatibility with the
304  * FiniteDifferenceSolver framework.
305  */
306  virtual void AllocateUpdateBuffer() {}
307 
310 
314  virtual void ThreadedIterate(void *arg, ThreadIdType threadId);
315 
319  virtual void ThreadedApplyUpdate(const TimeStepType& dt,
320  const ThreadRegionType & regionToProcess,
321  ThreadIdType threadId);
322 
323  virtual void ApplyUpdate(const TimeStepType&){}
324 
328  virtual TimeStepType ThreadedCalculateChange(const ThreadRegionType & regionToProcess,
329  ThreadIdType threadId);
330 
331  virtual TimeStepType CalculateChange() { return 0; }
332 };
333 } // end namespace itk
334 
335 #ifndef ITK_MANUAL_INSTANTIATION
336 #include "itkNarrowBandImageFilterBase.hxx"
337 #endif
338 
339 #endif
340