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
00044 #ifndef __vtkUnsignedShortArray_h
00045 #define __vtkUnsignedShortArray_h
00046
00047 #include "vtkDataArray.h"
00048
00049 class VTK_COMMON_EXPORT vtkUnsignedShortArray : public vtkDataArray
00050 {
00051 public:
00052 static vtkUnsignedShortArray *New();
00053
00054 vtkTypeRevisionMacro(vtkUnsignedShortArray,vtkDataArray);
00055 void PrintSelf(ostream& os, vtkIndent indent);
00056
00059 int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
00060
00062 void Initialize();
00063
00065 int GetDataType() {return VTK_UNSIGNED_SHORT;};
00066
00068 int GetDataTypeSize() { return sizeof(unsigned short); }
00069
00071 void SetNumberOfTuples(const vtkIdType number);
00072
00075 float *GetTuple(const vtkIdType i);
00076
00078
00079 void GetTuple(const vtkIdType i, float * tuple);
00080 void GetTuple(const vtkIdType i, double * tuple);
00082
00084
00085 void SetTuple(const vtkIdType i, const float * tuple);
00086 void SetTuple(const vtkIdType i, const double * tuple);
00088
00090
00092 void InsertTuple(const vtkIdType i, const float * tuple);
00093 void InsertTuple(const vtkIdType i, const double * tuple);
00095
00097
00099 vtkIdType InsertNextTuple(const float * tuple);
00100 vtkIdType InsertNextTuple(const double * tuple);
00102
00106 float GetComponent(const vtkIdType i, const int j);
00107
00112 void SetComponent(const vtkIdType i, const int j, float c);
00113
00117 void InsertComponent(const vtkIdType i, const int j, float c);
00118
00120 unsigned short GetValue(const vtkIdType id) {return this->Array[id];};
00121
00123
00125 void SetValue(const vtkIdType id, const unsigned short value) {
00126 this->Array[id] = value;};
00128
00132 void SetNumberOfValues(const vtkIdType number);
00133
00135 void InsertValue(const vtkIdType id, const unsigned short i);
00136
00139 vtkIdType InsertNextValue(const unsigned short);
00140
00142
00144 unsigned short *GetPointer(const vtkIdType id) {return this->Array + id;}
00145 void *GetVoidPointer(const vtkIdType id)
00146 {return (void *)this->GetPointer(id);};
00148
00152 unsigned short *WritePointer(const vtkIdType id, const vtkIdType number);
00153
00155 void DeepCopy(vtkDataArray *ia);
00156
00158
00164 void SetArray(unsigned short* array, vtkIdType size, int save);
00165 void SetVoidArray(void *array, vtkIdType size, int save)
00166 {this->SetArray((unsigned short*)array, size, save);};
00168
00170 void Squeeze() {this->ResizeAndExtend (this->MaxId+1);};
00171
00173 virtual void Resize(vtkIdType numTuples);
00174
00175 protected:
00176 vtkUnsignedShortArray(vtkIdType numComp=1);
00177 ~vtkUnsignedShortArray();
00178
00179 unsigned short *Array;
00180 unsigned short *ResizeAndExtend(const vtkIdType sz);
00181
00182
00183 int TupleSize;
00184 float *Tuple;
00185
00186 int SaveUserArray;
00187 private:
00188 vtkUnsignedShortArray(const vtkUnsignedShortArray&);
00189 void operator=(const vtkUnsignedShortArray&);
00190 };
00191
00192 inline void vtkUnsignedShortArray::SetNumberOfValues(const vtkIdType number)
00193 {
00194 this->Allocate(number);
00195 this->MaxId = number - 1;
00196 }
00197
00198 inline unsigned short *vtkUnsignedShortArray::WritePointer(const vtkIdType id,
00199 const vtkIdType number)
00200 {
00201 vtkIdType newSize=id+number;
00202 if ( newSize > this->Size )
00203 {
00204 this->ResizeAndExtend(newSize);
00205 }
00206 if ( (--newSize) > this->MaxId )
00207 {
00208 this->MaxId = newSize;
00209 }
00210 return this->Array + id;
00211 }
00212
00213 inline void vtkUnsignedShortArray::InsertValue(const vtkIdType id,
00214 const unsigned short i)
00215 {
00216 if ( id >= this->Size )
00217 {
00218 this->ResizeAndExtend(id+1);
00219 }
00220 this->Array[id] = i;
00221 if ( id > this->MaxId )
00222 {
00223 this->MaxId = id;
00224 }
00225 }
00226
00227 inline vtkIdType vtkUnsignedShortArray::InsertNextValue(const unsigned short i)
00228 {
00229 this->InsertValue (++this->MaxId,i);
00230 return this->MaxId;
00231 }
00232
00233 #endif
00234
00235
00236
00237