Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members Related Pages
Common/vtkShortArray.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00045 #ifndef __vtkShortArray_h
00046 #define __vtkShortArray_h
00047
00048 #include "vtkDataArray.h"
00049
00050 class VTK_COMMON_EXPORT vtkShortArray : public vtkDataArray
00051 {
00052 public:
00053 static vtkShortArray *New();
00054
00055 vtkTypeRevisionMacro(vtkShortArray,vtkDataArray);
00056 void PrintSelf(ostream& os, vtkIndent indent);
00057
00060 int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
00061
00063 void Initialize();
00064
00066 int GetDataType() {return VTK_SHORT;};
00067
00069 int GetDataTypeSize() { return sizeof(short); }
00070
00072 void SetNumberOfTuples(const vtkIdType number);
00073
00076 float *GetTuple(const vtkIdType i);
00077
00079
00080 void GetTuple(const vtkIdType i, float * tuple);
00081 void GetTuple(const vtkIdType i, double * tuple);
00083
00085
00086 void SetTuple(const vtkIdType i, const float * tuple);
00087 void SetTuple(const vtkIdType i, const double * tuple);
00089
00091
00093 void InsertTuple(const vtkIdType i, const float * tuple);
00094 void InsertTuple(const vtkIdType i, const double * tuple);
00096
00098
00100 vtkIdType InsertNextTuple(const float * tuple);
00101 vtkIdType InsertNextTuple(const double * tuple);
00103
00105 void Squeeze() {this->ResizeAndExtend (this->MaxId+1);};
00106
00108 virtual void Resize(vtkIdType numTuples);
00109
00113 float GetComponent(const vtkIdType i, const int j);
00114
00119 void SetComponent(const vtkIdType i, const int j, float c);
00120
00124 void InsertComponent(const vtkIdType i, const int j, float c);
00125
00127 short GetValue(const vtkIdType id) {return this->Array[id];};
00128
00130
00132 void SetValue(const vtkIdType id, const short value)
00133 {this->Array[id] = value;};
00135
00139 void SetNumberOfValues(const vtkIdType number);
00140
00142 void InsertValue(const vtkIdType id, const short i);
00143
00146 vtkIdType InsertNextValue(const short);
00147
00151 short *WritePointer(const vtkIdType id, const vtkIdType number);
00152
00154
00156 void *GetVoidPointer(const vtkIdType id)
00157 {return (void *)this->GetPointer(id);};
00158 short *GetPointer(const vtkIdType id) {return this->Array + id;}
00160
00162 void DeepCopy(vtkDataArray *da);
00163
00165
00171 void SetArray(short* array, vtkIdType size, int save);
00172 void SetVoidArray(void *array, vtkIdType size, int save)
00173 {this->SetArray((short*)array, size, save);};
00175
00176 protected:
00177 vtkShortArray(vtkIdType numComp=1);
00178 ~vtkShortArray();
00179
00180 short *Array;
00181 short *ResizeAndExtend(const vtkIdType sz);
00182
00183 int TupleSize;
00184 float *Tuple;
00185
00186 int SaveUserArray;
00187 private:
00188 vtkShortArray(const vtkShortArray&);
00189 void operator=(const vtkShortArray&);
00190 };
00191
00192 inline void vtkShortArray::SetNumberOfValues(const vtkIdType number)
00193 {
00194 this->Allocate(number);
00195 this->MaxId = number - 1;
00196 }
00197
00198
00199 inline short *vtkShortArray::WritePointer(const vtkIdType id,
00200 const vtkIdType number)
00201 {
00202 vtkIdType newSize=id+number;
00203 if ( newSize > this->Size )
00204 {
00205 this->ResizeAndExtend(newSize);
00206 }
00207 if ( (--newSize) > this->MaxId )
00208 {
00209 this->MaxId = newSize;
00210 }
00211 return this->Array + id;
00212 }
00213
00214 inline void vtkShortArray::InsertValue(const vtkIdType id, const 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 vtkShortArray::InsertNextValue(const short i)
00228 {
00229 this->InsertValue (++this->MaxId,i);
00230 return this->MaxId;
00231 }
00232
00233
00234 #endif