Orfeo Toolbox  3.16
itkImageAdaptor.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkImageAdaptor.txx,v $
5  Language: C++
6  Date: $Date: 2008-10-19 12:33:32 $
7  Version: $Revision: 1.44 $
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 __itkImageAdaptor_txx
18 #define __itkImageAdaptor_txx
19 #include "itkImageAdaptor.h"
20 #include "itkProcessObject.h"
21 
22 namespace itk
23 {
24 
28 template <class TImage, class TAccessor >
31 {
32  // Allocate an internal image. A process object might try to allocate an
33  // temporary image that is the same type as its input or output. If that
34  // image type is an adaptor, we need to make sure that an internal image is
35  // available because the process object will not know to call SetImage on
36  // the adaptor.
37  m_Image = TImage::New();
38 }
39 
43 template <class TImage, class TAccessor >
46 {
47 }
48 
49 //----------------------------------------------------------------------------
50 template <class TImage, class TAccessor >
51 void
54 {
55  // call the superclass' method first; then delegate
56  Superclass::Initialize();
57 
58  // delegation to internal image
59  m_Image->Initialize();
60 }
61 
62 template <class TImage, class TAccessor >
63 void
66 {
67  if (this->GetPixelContainer() != container)
68  {
69  m_Image->SetPixelContainer( container );
70  this->Modified();
71  }
72 }
73 
74 //----------------------------------------------------------------------------
75 template<class TImage, class TAccessor>
76 void
78 ::Graft(const DataObject *data)
79 {
80  // call the superclass' implementation
81  Superclass::Graft( data );
82 
83  if ( data )
84  {
85  // Attempt to cast data to an ImageAdaptor
86  const Self *imgData;
87 
88  try
89  {
90  imgData = dynamic_cast<const Self *>(data);
91  }
92  catch( ... )
93  {
94  return;
95  }
96 
97  if( imgData )
98  {
99  // Now copy anything remaining that is needed
100  this->SetPixelContainer(
101  const_cast<Self *>(imgData)->GetPixelContainer() );
102  }
103  else
104  {
105  // pointer could not be cast back down
106  itkExceptionMacro( << "itk::ImageAdaptor::Graft() cannot cast "
107  << typeid(data).name() << " to "
108  << typeid(const Self *).name() );
109  }
110  }
111 }
112 
116 template <class TImage, class TAccessor >
117 void
119 ::PrintSelf(std::ostream& os, Indent indent) const
120 {
121  Superclass::PrintSelf(os,indent);
122 }
123 
124 //----------------------------------------------------------------------------
125 template <class TImage, class TAccessor >
128 ::GetOffsetTable( void ) const
129 {
130  return m_Image->GetOffsetTable();
131 }
132 
133 //----------------------------------------------------------------------------
134 template <class TImage, class TAccessor >
138 {
139  return m_Image->ComputeIndex( offset );
140 }
141 
142 //----------------------------------------------------------------------------
143 template <class TImage, class TAccessor >
144 void
147 {
148  Superclass::Update();
149 
150  m_Image->Update();
151 }
152 
153 //----------------------------------------------------------------------------
154 template <class TImage, class TAccessor >
155 void
158 {
159  // call the superclass' method first, then delegate
160  Superclass::UpdateOutputInformation();
161 
162  // delegation to internal image
163  m_Image->UpdateOutputInformation();
164 }
165 
166 //----------------------------------------------------------------------------
167 template <class TImage, class TAccessor >
168 void
171 {
172  // call the superclass' method first, then delegate
173  Superclass::UpdateOutputData();
174 
175  // delegation to internal image
176  m_Image->UpdateOutputData();
177  SetBufferedRegion( m_Image->GetBufferedRegion() );
178 }
179 
180 //----------------------------------------------------------------------------
181 template <class TImage, class TAccessor >
182 void
185 {
186  // call the superclass' method first, then delegate
187  Superclass::PropagateRequestedRegion();
188 
189  // delegation to internal image
190  m_Image->PropagateRequestedRegion();
191 }
192 
193 //----------------------------------------------------------------------------
194 template <class TImage, class TAccessor >
195 void
198 {
199  // call the superclass' method first, then delegate
200  Superclass::SetRequestedRegionToLargestPossibleRegion();
201 
202  // delegation to internal image
203  m_Image->SetRequestedRegionToLargestPossibleRegion();
204 }
205 
206 //----------------------------------------------------------------------------
207 template <class TImage, class TAccessor >
208 void
211 {
212  // call the superclass' method first, then delegate
213  Superclass::CopyInformation( data );
214 
215  // delegation to internal image
216  m_Image->CopyInformation( data );
217 }
218 
219 //----------------------------------------------------------------------------
220 template <class TImage, class TAccessor >
223 ::GetSpacing( void ) const
224 {
225  return m_Image->GetSpacing();
226 }
227 
228 //----------------------------------------------------------------------------
229 template <class TImage, class TAccessor >
230 void
232 ::SetSpacing(const SpacingType &spacing )
233 {
234  // delegation to internal image
235  m_Image->SetSpacing( spacing );
236 }
237 
238 //----------------------------------------------------------------------------
239 template <class TImage, class TAccessor >
240 void
242 ::SetSpacing(const double* spacing /*[Self::ImageDimension]*/ )
243 {
244  // delegation to internal image
245  m_Image->SetSpacing( spacing );
246 }
247 
248 //----------------------------------------------------------------------------
249 template <class TImage, class TAccessor >
250 void
252 ::SetSpacing(const float* spacing /*[Self::ImageDimension]*/ )
253 {
254  // delegation to internal image
255  m_Image->SetSpacing( spacing );
256 }
257 
258 //----------------------------------------------------------------------------
259 template <class TImage, class TAccessor >
260 void
262 ::SetOrigin(const PointType origin )
263 {
264  // delegation to internal image
265  m_Image->SetOrigin( origin );
266 }
267 
268 //----------------------------------------------------------------------------
269 template <class TImage, class TAccessor >
270 void
272 ::SetOrigin(const double* origin /*[Self::ImageDimension]*/ )
273 {
274  // delegation to internal image
275  m_Image->SetOrigin( origin );
276 }
277 
278 //----------------------------------------------------------------------------
279 template <class TImage, class TAccessor >
280 void
282 ::SetOrigin(const float* origin /*[Self::ImageDimension]*/ )
283 {
284  // delegation to internal image
285  m_Image->SetOrigin( origin );
286 }
287 
288 //----------------------------------------------------------------------------
289 template <class TImage, class TAccessor >
292 ::GetOrigin( void ) const
293 {
294  return m_Image->GetOrigin();
295 }
296 
297 //----------------------------------------------------------------------------
298 template <class TImage, class TAccessor >
299 void
301 ::SetDirection(const DirectionType direction )
302 {
303  // delegation to internal image
304  m_Image->SetDirection( direction );
305 }
306 
307 //----------------------------------------------------------------------------
308 template <class TImage, class TAccessor >
311 ::GetDirection( void ) const
312 {
313  return m_Image->GetDirection();
314 }
315 
316 //----------------------------------------------------------------------------
317 template <class TImage, class TAccessor >
318 void
320 ::SetImage( TImage * image )
321 {
322  m_Image = image;
323  Superclass::SetLargestPossibleRegion( m_Image->GetLargestPossibleRegion() );
324  Superclass::SetBufferedRegion( m_Image->GetBufferedRegion() );
325  Superclass::SetRequestedRegion( m_Image->GetRequestedRegion() );
326 }
327 
328 //----------------------------------------------------------------------------
329 template <class TImage, class TAccessor >
333 {
334  return m_Image->GetBufferPointer();
335 }
336 
337 //----------------------------------------------------------------------------
338 template <class TImage, class TAccessor >
342 {
343  return m_Image->GetBufferPointer();
344 }
345 
346 //----------------------------------------------------------------------------
347 template <class TImage, class TAccessor >
348 void
350 ::Modified() const
351 {
352  Superclass::Modified();
353 
354  m_Image->Modified();
355 }
356 
357 //----------------------------------------------------------------------------
358 template <class TImage, class TAccessor >
359 unsigned long
361 ::GetMTime() const
362 {
363  unsigned long mtime1, mtime2;
364 
365  mtime1 = Superclass::GetMTime();
366  mtime2 = m_Image->GetMTime();
367 
368  return (mtime1 >= mtime2 ? mtime1 : mtime2);
369 }
370 
371 //----------------------------------------------------------------------------
372 template <class TImage, class TAccessor >
373 void
376 {
377  // call the superclass' method first, then delegate
378  Superclass::SetBufferedRegion( region );
379 
380  // delegation to internal image
381  m_Image->SetBufferedRegion( region );
382 }
383 
384 //----------------------------------------------------------------------------
385 template <class TImage, class TAccessor >
388 ::GetBufferedRegion( void ) const
389 {
390  // delegation to internal image
391  return m_Image->GetBufferedRegion();
392 }
393 
394 //----------------------------------------------------------------------------
395 template <class TImage, class TAccessor >
396 void
399 {
400  // call the superclass' method first, then delegate
401  Superclass::SetLargestPossibleRegion( region );
402 
403  // delegation to internal image
404  m_Image->SetLargestPossibleRegion( region );
405 }
406 
407 //----------------------------------------------------------------------------
408 template <class TImage, class TAccessor >
412 {
413  // delegation to internal image
414  return m_Image->GetLargestPossibleRegion();
415 }
416 
417 //----------------------------------------------------------------------------
418 template <class TImage, class TAccessor >
419 void
422 {
423  // call the superclass' method first, then delegate
424  Superclass::SetRequestedRegion( region );
425 
426  // delegation to internal image
427  m_Image->SetRequestedRegion( region );
428 }
429 
430 //----------------------------------------------------------------------------
431 template<class TImage, class TAccessor>
432 void
435 {
436  // call the superclass' method first, then delegate
437  Superclass::SetRequestedRegion( data );
438 
439  // delegation to internal image
440  m_Image->SetRequestedRegion( data );
441 }
442 
443 //----------------------------------------------------------------------------
444 template<class TImage, class TAccessor>
445 bool
448 {
449  // call the superclass' method first, then delegate
450  Superclass::VerifyRequestedRegion();
451 
452  // delegation to internal image
453  return m_Image->VerifyRequestedRegion();
454 }
455 
456 //----------------------------------------------------------------------------
457 template <class TImage, class TAccessor >
460 ::GetRequestedRegion( void ) const
461 {
462  // delegation to internal image
463  return m_Image->GetRequestedRegion();
464 }
465 
466 } // end namespace itk
467 
468 #endif

Generated at Sat Feb 2 2013 23:42:34 for Orfeo Toolbox with doxygen 1.8.1.1