dox/Common/vtkUnsignedIntArray.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00030 #ifndef __vtkUnsignedIntArray_h
00031 #define __vtkUnsignedIntArray_h
00032
00033 #include "vtkDataArray.h"
00034
00035 class VTK_COMMON_EXPORT vtkUnsignedIntArray : public vtkDataArray
00036 {
00037 public:
00038 static vtkUnsignedIntArray *New();
00039
00040 vtkTypeRevisionMacro(vtkUnsignedIntArray,vtkDataArray);
00041 void PrintSelf(ostream& os, vtkIndent indent);
00042
00045 int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
00046
00048 void Initialize();
00049
00051 int GetDataType() {return VTK_UNSIGNED_INT;};
00052
00054 int GetDataTypeSize() { return sizeof(unsigned int); }
00055
00057 void SetNumberOfTuples(const vtkIdType number);
00058
00061 float *GetTuple(const vtkIdType i);
00062
00064
00065 void GetTuple(const vtkIdType i, float * tuple);
00066 void GetTuple(const vtkIdType i, double * tuple);
00068
00070
00071 void SetTuple(const vtkIdType i, const float * tuple);
00072 void SetTuple(const vtkIdType i, const double * tuple);
00074
00076
00078 void InsertTuple(const vtkIdType i, const float * tuple);
00079 void InsertTuple(const vtkIdType i, const double * tuple);
00081
00083
00085 vtkIdType InsertNextTuple(const float * tuple);
00086 vtkIdType InsertNextTuple(const double * tuple);
00088
00090 unsigned int GetValue(const vtkIdType id) {return this->Array[id];};
00091
00093
00095 void SetValue(const vtkIdType id, const unsigned int value) {
00096 this->Array[id] = value;};
00098
00102 void SetNumberOfValues(const vtkIdType number);
00103
00105 void InsertValue(const vtkIdType id, const unsigned int i);
00106
00109 vtkIdType InsertNextValue(const unsigned int);
00110
00114 float GetComponent(const vtkIdType i, const int j);
00115
00120 void SetComponent(const vtkIdType i, const int j, float c);
00121
00125 virtual void InsertComponent(const vtkIdType i, const int j, float c);
00126
00128
00130 unsigned int *GetPointer(const vtkIdType id) {return this->Array + id;}
00131 void *GetVoidPointer(const vtkIdType id)
00132 {return (void *)this->GetPointer(id);};
00134
00138 unsigned int *WritePointer(const vtkIdType id, const vtkIdType number);
00139
00141 void DeepCopy(vtkDataArray *da);
00142
00144
00150 void SetArray(unsigned int* array, vtkIdType size, int save);
00151 void SetVoidArray(void *array,vtkIdType size, int save)
00152 {this->SetArray((unsigned int*)array, size, save);};
00154
00156
00157 void Squeeze()
00158 {this->ResizeAndExtend (this->MaxId+1);};
00160
00162 virtual void Resize(vtkIdType numTuples);
00163
00164 protected:
00165 vtkUnsignedIntArray(vtkIdType numComp=1);
00166 ~vtkUnsignedIntArray();
00167
00168 unsigned int *Array;
00169 unsigned int *ResizeAndExtend(const vtkIdType sz);
00170
00171
00172 int TupleSize;
00173 float *Tuple;
00174
00175 int SaveUserArray;
00176 private:
00177 vtkUnsignedIntArray(const vtkUnsignedIntArray&);
00178 void operator=(const vtkUnsignedIntArray&);
00179 };
00180
00181
00182 inline void vtkUnsignedIntArray::SetNumberOfValues(const vtkIdType number)
00183 {
00184 this->Allocate(number);
00185 this->MaxId = number - 1;
00186 }
00187
00188 inline unsigned int *vtkUnsignedIntArray::WritePointer(const vtkIdType id,
00189 const vtkIdType number)
00190 {
00191 vtkIdType newSize=id+number;
00192 if ( newSize > this->Size )
00193 {
00194 this->ResizeAndExtend(newSize);
00195 }
00196 if ( (--newSize) > this->MaxId )
00197 {
00198 this->MaxId = newSize;
00199 }
00200 return this->Array + id;
00201 }
00202
00203 inline void vtkUnsignedIntArray::InsertValue(const vtkIdType id,
00204 const unsigned int i)
00205 {
00206 if ( id >= this->Size )
00207 {
00208 this->ResizeAndExtend(id+1);
00209 }
00210 this->Array[id] = i;
00211 if ( id > this->MaxId )
00212 {
00213 this->MaxId = id;
00214 }
00215 }
00216
00217 inline vtkIdType vtkUnsignedIntArray::InsertNextValue(const unsigned int i)
00218 {
00219 this->InsertValue (++this->MaxId,i);
00220 return this->MaxId;
00221 }
00222
00223
00224 #endif
00225
00226
00227
00228