dox/Common/vtkUnsignedShortArray.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00030 #ifndef __vtkUnsignedShortArray_h
00031 #define __vtkUnsignedShortArray_h
00032
00033 #include "vtkDataArray.h"
00034
00035 class VTK_COMMON_EXPORT vtkUnsignedShortArray : public vtkDataArray
00036 {
00037 public:
00038 static vtkUnsignedShortArray *New();
00039
00040 vtkTypeRevisionMacro(vtkUnsignedShortArray,vtkDataArray);
00041 void PrintSelf(ostream& os, vtkIndent indent);
00042
00045 int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
00046
00048 void Initialize();
00049
00051 int GetDataType() {return VTK_UNSIGNED_SHORT;};
00052
00054 int GetDataTypeSize() { return sizeof(unsigned short); }
00055
00057 void SetNumberOfTuples(const vtkIdType number);
00058
00061 float *GetTuple(const vtkIdType i);
00062
00064
00065 void GetTuple(const vtkIdType i, float * tuple);
00066 void GetTuple(const vtkIdType i, double * tuple);
00068
00070
00071 void SetTuple(const vtkIdType i, const float * tuple);
00072 void SetTuple(const vtkIdType i, const double * tuple);
00074
00076
00078 void InsertTuple(const vtkIdType i, const float * tuple);
00079 void InsertTuple(const vtkIdType i, const double * tuple);
00081
00083
00085 vtkIdType InsertNextTuple(const float * tuple);
00086 vtkIdType InsertNextTuple(const double * tuple);
00088
00092 float GetComponent(const vtkIdType i, const int j);
00093
00098 void SetComponent(const vtkIdType i, const int j, float c);
00099
00103 void InsertComponent(const vtkIdType i, const int j, float c);
00104
00106 unsigned short GetValue(const vtkIdType id) {return this->Array[id];};
00107
00109
00111 void SetValue(const vtkIdType id, const unsigned short value) {
00112 this->Array[id] = value;};
00114
00118 void SetNumberOfValues(const vtkIdType number);
00119
00121 void InsertValue(const vtkIdType id, const unsigned short i);
00122
00125 vtkIdType InsertNextValue(const unsigned short);
00126
00128
00130 unsigned short *GetPointer(const vtkIdType id) {return this->Array + id;}
00131 void *GetVoidPointer(const vtkIdType id)
00132 {return (void *)this->GetPointer(id);};
00134
00138 unsigned short *WritePointer(const vtkIdType id, const vtkIdType number);
00139
00141 void DeepCopy(vtkDataArray *ia);
00142
00144
00150 void SetArray(unsigned short* array, vtkIdType size, int save);
00151 void SetVoidArray(void *array, vtkIdType size, int save)
00152 {this->SetArray((unsigned short*)array, size, save);};
00154
00156 void Squeeze() {this->ResizeAndExtend (this->MaxId+1);};
00157
00159 virtual void Resize(vtkIdType numTuples);
00160
00161 protected:
00162 vtkUnsignedShortArray(vtkIdType numComp=1);
00163 ~vtkUnsignedShortArray();
00164
00165 unsigned short *Array;
00166 unsigned short *ResizeAndExtend(const vtkIdType sz);
00167
00168
00169 int TupleSize;
00170 float *Tuple;
00171
00172 int SaveUserArray;
00173 private:
00174 vtkUnsignedShortArray(const vtkUnsignedShortArray&);
00175 void operator=(const vtkUnsignedShortArray&);
00176 };
00177
00178 inline void vtkUnsignedShortArray::SetNumberOfValues(const vtkIdType number)
00179 {
00180 this->Allocate(number);
00181 this->MaxId = number - 1;
00182 }
00183
00184 inline unsigned short *vtkUnsignedShortArray::WritePointer(const vtkIdType id,
00185 const vtkIdType number)
00186 {
00187 vtkIdType newSize=id+number;
00188 if ( newSize > this->Size )
00189 {
00190 this->ResizeAndExtend(newSize);
00191 }
00192 if ( (--newSize) > this->MaxId )
00193 {
00194 this->MaxId = newSize;
00195 }
00196 return this->Array + id;
00197 }
00198
00199 inline void vtkUnsignedShortArray::InsertValue(const vtkIdType id,
00200 const unsigned short i)
00201 {
00202 if ( id >= this->Size )
00203 {
00204 this->ResizeAndExtend(id+1);
00205 }
00206 this->Array[id] = i;
00207 if ( id > this->MaxId )
00208 {
00209 this->MaxId = id;
00210 }
00211 }
00212
00213 inline vtkIdType vtkUnsignedShortArray::InsertNextValue(const unsigned short i)
00214 {
00215 this->InsertValue (++this->MaxId,i);
00216 return this->MaxId;
00217 }
00218
00219 #endif
00220
00221
00222
00223