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
00042 #ifndef __vtkShortArray_h
00043 #define __vtkShortArray_h
00044
00045 #include "vtkDataArray.h"
00046
00047 class VTK_COMMON_EXPORT vtkShortArray : public vtkDataArray
00048 {
00049 public:
00050 static vtkShortArray *New();
00051
00052 vtkTypeRevisionMacro(vtkShortArray,vtkDataArray);
00053 void PrintSelf(ostream& os, vtkIndent indent);
00054
00057 int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
00058
00060 void Initialize();
00061
00063 int GetDataType() {return VTK_SHORT;};
00064
00066 int GetDataTypeSize() { return sizeof(short); }
00067
00069 void SetNumberOfTuples(const vtkIdType number);
00070
00073 float *GetTuple(const vtkIdType i);
00074
00076
00077 void GetTuple(const vtkIdType i, float * tuple);
00078 void GetTuple(const vtkIdType i, double * tuple);
00080
00082
00083 void SetTuple(const vtkIdType i, const float * tuple);
00084 void SetTuple(const vtkIdType i, const double * tuple);
00086
00088
00090 void InsertTuple(const vtkIdType i, const float * tuple);
00091 void InsertTuple(const vtkIdType i, const double * tuple);
00093
00095
00097 vtkIdType InsertNextTuple(const float * tuple);
00098 vtkIdType InsertNextTuple(const double * tuple);
00100
00102 void Squeeze() {this->ResizeAndExtend (this->MaxId+1);};
00103
00105 virtual void Resize(vtkIdType numTuples);
00106
00110 float GetComponent(const vtkIdType i, const int j);
00111
00116 void SetComponent(const vtkIdType i, const int j, float c);
00117
00121 void InsertComponent(const vtkIdType i, const int j, float c);
00122
00124 short GetValue(const vtkIdType id) {return this->Array[id];};
00125
00127
00129 void SetValue(const vtkIdType id, const short value)
00130 {this->Array[id] = value;};
00132
00136 void SetNumberOfValues(const vtkIdType number);
00137
00139 void InsertValue(const vtkIdType id, const short i);
00140
00143 vtkIdType InsertNextValue(const short);
00144
00148 short *WritePointer(const vtkIdType id, const vtkIdType number);
00149
00151
00153 void *GetVoidPointer(const vtkIdType id)
00154 {return (void *)this->GetPointer(id);};
00155 short *GetPointer(const vtkIdType id) {return this->Array + id;}
00157
00159 void DeepCopy(vtkDataArray *da);
00160
00162
00168 void SetArray(short* array, vtkIdType size, int save);
00169 void SetVoidArray(void *array, vtkIdType size, int save)
00170 {this->SetArray((short*)array, size, save);};
00172
00173 protected:
00174 vtkShortArray(vtkIdType numComp=1);
00175 ~vtkShortArray();
00176
00177 short *Array;
00178 short *ResizeAndExtend(const vtkIdType sz);
00179
00180 int TupleSize;
00181 float *Tuple;
00182
00183 int SaveUserArray;
00184 private:
00185 vtkShortArray(const vtkShortArray&);
00186 void operator=(const vtkShortArray&);
00187 };
00188
00189 inline void vtkShortArray::SetNumberOfValues(const vtkIdType number)
00190 {
00191 this->Allocate(number);
00192 this->MaxId = number - 1;
00193 }
00194
00195
00196 inline short *vtkShortArray::WritePointer(const vtkIdType id,
00197 const vtkIdType number)
00198 {
00199 vtkIdType newSize=id+number;
00200 if ( newSize > this->Size )
00201 {
00202 this->ResizeAndExtend(newSize);
00203 }
00204 if ( (--newSize) > this->MaxId )
00205 {
00206 this->MaxId = newSize;
00207 }
00208 return this->Array + id;
00209 }
00210
00211 inline void vtkShortArray::InsertValue(const vtkIdType id, const short i)
00212 {
00213 if ( id >= this->Size )
00214 {
00215 this->ResizeAndExtend(id+1);
00216 }
00217 this->Array[id] = i;
00218 if ( id > this->MaxId )
00219 {
00220 this->MaxId = id;
00221 }
00222 }
00223
00224 inline vtkIdType vtkShortArray::InsertNextValue(const short i)
00225 {
00226 this->InsertValue (++this->MaxId,i);
00227 return this->MaxId;
00228 }
00229
00230
00231 #endif