00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkArray_h
00018 #define __itkArray_h
00019
00020 #include "itkMacro.h"
00021 #include "vnl/vnl_vector.h"
00022
00023 namespace itk
00024 {
00025
00026
00043 template <typename TValueType >
00044 class Array : public vnl_vector< TValueType >
00045 {
00046 public:
00047
00049 typedef TValueType ValueType;
00050 typedef Array Self;
00051 typedef vnl_vector<TValueType> VnlVectorType;
00052
00053 public:
00054
00057 Array();
00058
00060 Array(unsigned int dimension);
00061
00068 Array( ValueType* data, unsigned int sz, bool LetArrayManageMemory = false);
00069
00076 Array( const ValueType* data, unsigned int sz, bool LetArrayManageMemory = false);
00077
00078
00080 void Fill (TValueType const& v) { fill(v); }
00081
00083 const Self & operator=( const Self &rhs );
00084 const Self & operator=( const VnlVectorType & rhs );
00085
00087 unsigned int Size (void ) const
00088 { return static_cast<unsigned int>( this->size() ); }
00089 unsigned int GetNumberOfElements(void) const
00090 { return static_cast<unsigned int>( this->size() ); }
00091
00093 const TValueType & GetElement( unsigned int i ) const
00094 { return this->operator[]( i ); }
00095
00097 void SetElement( unsigned int i, const TValueType & value )
00098 { this->operator[]( i ) = value; }
00099
00101 void SetSize(unsigned int sz);
00102 unsigned int GetSize(void) const
00103 { return static_cast<unsigned int>( this->size() ); }
00104
00110 void SetData(TValueType* data,bool LetArrayManageMemory = false);
00111
00121 void SetData(TValueType* data, unsigned int sz, bool LetArrayManageMemory = false);
00122
00123
00126 ~Array();
00127
00128
00129
00130 private:
00131
00132 bool m_LetArrayManageMemory;
00133
00134 };
00135
00136
00137
00138 template <typename TValueType >
00139 std::ostream & operator<<(std::ostream &os, const Array<TValueType> &arr)
00140 {
00141 const unsigned int length = arr.size();
00142 const signed int last = (unsigned int) length - 1;
00143
00144 os << "[";
00145 for (signed int i=0; i < last; ++i)
00146 {
00147 os << arr[i] << ", ";
00148 }
00149 if (length >= 1)
00150 {
00151 os << arr[last];
00152 }
00153 os << "]";
00154 return os;
00155 }
00156
00157 }
00158
00159
00160
00161 #ifndef ITK_MANUAL_INSTANTIATION
00162 #include "itkArray.txx"
00163 #endif
00164
00165
00166 #endif