Common/vtkUnsignedLongArray.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 __vtkUnsignedLongArray_h
00043 #define __vtkUnsignedLongArray_h
00044
00045 #include "vtkDataArray.h"
00046
00047 class VTK_COMMON_EXPORT vtkUnsignedLongArray : public vtkDataArray
00048 {
00049 public:
00050 static vtkUnsignedLongArray *New();
00051
00052 vtkTypeRevisionMacro(vtkUnsignedLongArray,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_UNSIGNED_LONG;};
00064
00066 int GetDataTypeSize() { return sizeof(unsigned long); }
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 unsigned long GetValue(const vtkIdType id) {return this->Array[id];};
00103
00105
00107 void SetValue(const vtkIdType id, const unsigned long value) {
00108 this->Array[id] = value;};
00110
00114 void SetNumberOfValues(const vtkIdType number);
00115
00117 void InsertValue(const vtkIdType id, const unsigned long i);
00118
00121 vtkIdType InsertNextValue(const unsigned long);
00122
00126 float GetComponent(const vtkIdType i, const int j);
00127
00132 void SetComponent(const vtkIdType i, const int j, float c);
00133
00137 virtual void InsertComponent(const vtkIdType i, const int j, float c);
00138
00140
00142 unsigned long *GetPointer(const vtkIdType id) {return this->Array + id;}
00143 void *GetVoidPointer(const vtkIdType id)
00144 {return (void *)this->GetPointer(id);};
00146
00150 unsigned long *WritePointer(const vtkIdType id, const vtkIdType number);
00151
00153 void DeepCopy(vtkDataArray *da);
00154
00156
00162 void SetArray(unsigned long* array, vtkIdType size, int save);
00163 void SetVoidArray(void *array, vtkIdType size, int save)
00164 {this->SetArray((unsigned long*)array, size, save);};
00166
00168 void Squeeze() {this->ResizeAndExtend (this->MaxId+1);};
00169
00171 virtual void Resize(vtkIdType numTuples);
00172
00173 protected:
00174 vtkUnsignedLongArray(vtkIdType numComp=1);
00175 ~vtkUnsignedLongArray();
00176
00177 unsigned long *Array;
00178 unsigned long *ResizeAndExtend(const vtkIdType sz);
00179
00180
00181 int TupleSize;
00182 float *Tuple;
00183
00184 int SaveUserArray;
00185 private:
00186 vtkUnsignedLongArray(const vtkUnsignedLongArray&);
00187 void operator=(const vtkUnsignedLongArray&);
00188 };
00189
00190 inline void vtkUnsignedLongArray::SetNumberOfValues(const vtkIdType number)
00191 {
00192 this->Allocate(number);
00193 this->MaxId = number - 1;
00194 }
00195
00196 inline unsigned long *vtkUnsignedLongArray::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 vtkUnsignedLongArray::InsertValue(const vtkIdType id,
00212 const unsigned long i)
00213 {
00214 if ( id >= this->Size )
00215 {
00216 this->ResizeAndExtend(id+1);
00217 }
00218 this->Array[id] = i;
00219 if ( id > this->MaxId )
00220 {
00221 this->MaxId = id;
00222 }
00223 }
00224
00225 inline vtkIdType vtkUnsignedLongArray::InsertNextValue(const unsigned long i)
00226 {
00227 this->InsertValue (++this->MaxId,i);
00228 return this->MaxId;
00229 }
00230
00231
00232 #endif
00233
00234
00235
00236