| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkSpecialCoordinatesImage.txx.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:48 $ |
| 7 |
|
Version: $Revision: 1.4 $ |
| 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 |
|
Portions of this code are covered under the VTK copyright. |
| 13 |
|
See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details. |
| 14 |
|
|
| 15 |
|
This software is distributed WITHOUT ANY WARRANTY; without even |
| 16 |
IND |
*****the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 17 |
IND |
*****PURPOSE. See the above copyright notices for more information. |
| 18 |
|
|
| 19 |
|
=========================================================================*/ |
| 20 |
DEF |
#ifndef _itkSpecialCoordinatesImage_txx |
| 21 |
DEF |
#define _itkSpecialCoordinatesImage_txx |
| 22 |
|
#include "itkSpecialCoordinatesImage.h" |
| 23 |
|
#include "itkProcessObject.h" |
| 24 |
|
#include "itkAffineTransform.h" |
| 25 |
|
|
| 26 |
|
namespace itk |
| 27 |
|
{ |
| 28 |
|
|
| 29 |
|
/** |
| 30 |
|
* |
| 31 |
|
*/ |
| 32 |
|
template<class TPixel, unsigned int VImageDimension> |
| 33 |
|
SpecialCoordinatesImage<TPixel, VImageDimension> |
| 34 |
|
::SpecialCoordinatesImage() |
| 35 |
|
{ |
| 36 |
|
m_Buffer = PixelContainer::New(); |
| 37 |
|
} |
| 38 |
|
|
| 39 |
|
|
| 40 |
|
//---------------------------------------------------------------------------- |
| 41 |
|
template<class TPixel, unsigned int VImageDimension> |
| 42 |
|
void |
| 43 |
|
SpecialCoordinatesImage<TPixel, VImageDimension> |
| 44 |
|
::Allocate() |
| 45 |
|
{ |
| 46 |
|
unsigned long num; |
| 47 |
|
|
| 48 |
|
this->ComputeOffsetTable(); |
| 49 |
|
num = this->GetOffsetTable()[VImageDimension]; |
| 50 |
|
|
| 51 |
|
m_Buffer->Reserve(num); |
| 52 |
|
} |
| 53 |
|
|
| 54 |
|
template<class TPixel, unsigned int VImageDimension> |
| 55 |
|
void |
| 56 |
|
SpecialCoordinatesImage<TPixel, VImageDimension> |
| 57 |
|
::Initialize() |
| 58 |
|
{ |
| 59 |
|
// |
| 60 |
|
// We don't modify ourselves because the "ReleaseData" methods depend upon |
| 61 |
|
// no modification when initialized. |
| 62 |
|
// |
| 63 |
|
|
| 64 |
|
// Call the superclass which should initialize the BufferedRegion ivar. |
| 65 |
|
Superclass::Initialize(); |
| 66 |
|
|
| 67 |
|
// Replace the handle to the buffer. This is the safest thing to do, |
| 68 |
|
// since the same container can be shared by multiple images (e.g. |
| 69 |
|
// Grafted outputs and in place filters). |
| 70 |
|
m_Buffer = PixelContainer::New(); |
| 71 |
|
} |
| 72 |
|
|
| 73 |
|
|
| 74 |
|
template<class TPixel, unsigned int VImageDimension> |
| 75 |
|
void |
| 76 |
|
SpecialCoordinatesImage<TPixel, VImageDimension> |
| 77 |
|
::FillBuffer (const TPixel& value) |
| 78 |
|
{ |
| 79 |
|
const unsigned long numberOfPixels = |
| 80 |
IND |
****this->GetBufferedRegion().GetNumberOfPixels(); |
| 81 |
|
|
| 82 |
|
for(unsigned int i=0; i<numberOfPixels; i++) |
| 83 |
|
{ |
| 84 |
|
(*m_Buffer)[i] = value; |
| 85 |
|
} |
| 86 |
|
} |
| 87 |
|
|
| 88 |
|
template<class TPixel, unsigned int VImageDimension> |
| 89 |
|
void |
| 90 |
|
SpecialCoordinatesImage<TPixel, VImageDimension> |
| 91 |
|
::SetPixelContainer(PixelContainer *container) |
| 92 |
|
{ |
| 93 |
|
if (m_Buffer != container) |
| 94 |
|
{ |
| 95 |
|
m_Buffer = container; |
| 96 |
|
this->Modified(); |
| 97 |
|
} |
| 98 |
|
} |
| 99 |
|
|
| 100 |
|
|
| 101 |
|
/** |
| 102 |
|
* |
| 103 |
|
*/ |
| 104 |
|
template<class TPixel, unsigned int VImageDimension> |
| 105 |
|
void |
| 106 |
|
SpecialCoordinatesImage<TPixel, VImageDimension> |
| 107 |
|
::PrintSelf(std::ostream& os, Indent indent) const |
| 108 |
|
{ |
| 109 |
|
Superclass::PrintSelf(os,indent); |
| 110 |
|
|
| 111 |
|
os << indent << "PixelContainer: " << std::endl; |
| 112 |
|
m_Buffer->Print(os, indent.GetNextIndent()); |
| 113 |
|
|
| 114 |
IND |
// m_Origin and m_Spacing are printed in the Superclass |
| 115 |
|
} |
| 116 |
|
|
| 117 |
|
|
| 118 |
|
} // end namespace itk |
| 119 |
|
|
| 120 |
|
#endif |
| 121 |
|
|