Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members Related Pages
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
00046 #ifndef __vtkUnsignedShortArray_h
00047 #define __vtkUnsignedShortArray_h
00048
00049 #include "vtkDataArray.h"
00050
00051 class VTK_COMMON_EXPORT vtkUnsignedShortArray : public vtkDataArray
00052 {
00053 public:
00054 static vtkUnsignedShortArray *New();
00055
00056 vtkTypeRevisionMacro(vtkUnsignedShortArray,vtkDataArray);
00057 void PrintSelf(ostream& os, vtkIndent indent);
00058
00061 int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
00062
00064 void Initialize();
00065
00067 int GetDataType() {return VTK_UNSIGNED_SHORT;};
00068
00070 int GetDataTypeSize() { return sizeof(unsigned short); }
00071
00073 void SetNumberOfTuples(const vtkIdType number);
00074
00077 float *GetTuple(const vtkIdType i);
00078
00080
00081 void GetTuple(const vtkIdType i, float * tuple);
00082 void GetTuple(const vtkIdType i, double * tuple);
00084
00086
00087 void SetTuple(const vtkIdType i, const float * tuple);
00088 void SetTuple(const vtkIdType i, const double * tuple);
00090
00092
00094 void InsertTuple(const vtkIdType i, const float * tuple);
00095 void InsertTuple(const vtkIdType i, const double * tuple);
00097
00099
00101 vtkIdType InsertNextTuple(const float * tuple);
00102 vtkIdType InsertNextTuple(const double * tuple);
00104
00108 float GetComponent(const vtkIdType i, const int j);
00109
00114 void SetComponent(const vtkIdType i, const int j, float c);
00115
00119 void InsertComponent(const vtkIdType i, const int j, float c);
00120
00122 unsigned short GetValue(const vtkIdType id) {return this->Array[id];};
00123
00125
00127 void SetValue(const vtkIdType id, const unsigned short value) {
00128 this->Array[id] = value;};
00130
00134 void SetNumberOfValues(const vtkIdType number);
00135
00137 void InsertValue(const vtkIdType id, const unsigned short i);
00138
00141 vtkIdType InsertNextValue(const unsigned short);
00142
00144
00146 unsigned short *GetPointer(const vtkIdType id) {return this->Array + id;}
00147 void *GetVoidPointer(const vtkIdType id)
00148 {return (void *)this->GetPointer(id);};
00150
00154 unsigned short *WritePointer(const vtkIdType id, const vtkIdType number);
00155
00157 void DeepCopy(vtkDataArray *ia);
00158
00160
00166 void SetArray(unsigned short* array, vtkIdType size, int save);
00167 void SetVoidArray(void *array, vtkIdType size, int save)
00168 {this->SetArray((unsigned short*)array, size, save);};
00170
00172 void Squeeze() {this->ResizeAndExtend (this->MaxId+1);};
00173
00175 virtual void Resize(vtkIdType numTuples);
00176
00177 protected:
00178 vtkUnsignedShortArray(vtkIdType numComp=1);
00179 ~vtkUnsignedShortArray();
00180
00181 unsigned short *Array;
00182 unsigned short *ResizeAndExtend(const vtkIdType sz);
00183
00184
00185 int TupleSize;
00186 float *Tuple;
00187
00188 int SaveUserArray;
00189 private:
00190 vtkUnsignedShortArray(const vtkUnsignedShortArray&);
00191 void operator=(const vtkUnsignedShortArray&);
00192 };
00193
00194 inline void vtkUnsignedShortArray::SetNumberOfValues(const vtkIdType number)
00195 {
00196 this->Allocate(number);
00197 this->MaxId = number - 1;
00198 }
00199
00200 inline unsigned short *vtkUnsignedShortArray::WritePointer(const vtkIdType id,
00201 const vtkIdType number)
00202 {
00203 vtkIdType newSize=id+number;
00204 if ( newSize > this->Size )
00205 {
00206 this->ResizeAndExtend(newSize);
00207 }
00208 if ( (--newSize) > this->MaxId )
00209 {
00210 this->MaxId = newSize;
00211 }
00212 return this->Array + id;
00213 }
00214
00215 inline void vtkUnsignedShortArray::InsertValue(const vtkIdType id,
00216 const unsigned short i)
00217 {
00218 if ( id >= this->Size )
00219 {
00220 this->ResizeAndExtend(id+1);
00221 }
00222 this->Array[id] = i;
00223 if ( id > this->MaxId )
00224 {
00225 this->MaxId = id;
00226 }
00227 }
00228
00229 inline vtkIdType vtkUnsignedShortArray::InsertNextValue(const unsigned short i)
00230 {
00231 this->InsertValue (++this->MaxId,i);
00232 return this->MaxId;
00233 }
00234
00235 #endif
00236
00237
00238
00239