Common/vtkIdTypeArray.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00041 #ifndef __vtkIdTypeArray_h
00042 #define __vtkIdTypeArray_h
00043
00044 #include "vtkDataArray.h"
00045
00046 class VTK_COMMON_EXPORT vtkIdTypeArray : public vtkDataArray
00047 {
00048 public:
00049 static vtkIdTypeArray *New();
00050
00051 vtkTypeRevisionMacro(vtkIdTypeArray, vtkDataArray);
00052 void PrintSelf(ostream& os, vtkIndent indent);
00053
00056 int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
00057
00059 void Initialize();
00060
00062
00063 int GetDataType()
00064 {return VTK_ID_TYPE;}
00066
00068 int GetDataTypeSize() { return sizeof(vtkIdType); }
00069
00071
00072 void Squeeze()
00073 {this->ResizeAndExtend (this->MaxId+1);}
00075
00077 virtual void Resize(vtkIdType numTuples);
00078
00080 void SetNumberOfTuples(const vtkIdType number);
00081
00084 float *GetTuple(const vtkIdType i);
00085
00087
00088 void GetTuple(const vtkIdType i, float * tuple);
00089 void GetTuple(const vtkIdType i, double * tuple);
00091
00093
00094 void SetTuple(const vtkIdType i, const float * tuple);
00095 void SetTuple(const vtkIdType i, const double * tuple);
00097
00099
00101 void InsertTuple(const vtkIdType i, const float * tuple);
00102 void InsertTuple(const vtkIdType i, const double * tuple);
00104
00106
00108 vtkIdType InsertNextTuple(const float * tuple);
00109 vtkIdType InsertNextTuple(const double * tuple);
00111
00113
00114 vtkIdType GetValue(const vtkIdType id)
00115 {return this->Array[id];}
00117
00119
00121 void SetValue(const vtkIdType id, const vtkIdType value)
00122 {this->Array[id] = value;}
00124
00128 void SetNumberOfValues(const vtkIdType number);
00129
00131 void InsertValue(const vtkIdType id, const vtkIdType i);
00132
00135 vtkIdType InsertNextValue(const vtkIdType i);
00136
00138
00140 vtkIdType *GetPointer(const vtkIdType id)
00141 {return this->Array + id;}
00142 void *GetVoidPointer(const vtkIdType id)
00143 {return (void *)this->GetPointer(id);}
00145
00149 vtkIdType *WritePointer(const vtkIdType id, const vtkIdType number);
00150
00152 void DeepCopy(vtkDataArray *ia);
00153
00155
00161 void SetArray(vtkIdType* array, vtkIdType size, int save);
00162 void SetVoidArray(void *array, vtkIdType size, int save)
00163 {this->SetArray((vtkIdType*)array, size, save);};
00165
00166 protected:
00167 vtkIdTypeArray(vtkIdType numComp=1);
00168 ~vtkIdTypeArray();
00169
00170 vtkIdType *Array;
00171 vtkIdType *ResizeAndExtend(const vtkIdType sz);
00172
00173 int TupleSize;
00174 float *Tuple;
00175
00176 int SaveUserArray;
00177 private:
00178 vtkIdTypeArray(const vtkIdTypeArray&);
00179 void operator=(const vtkIdTypeArray&);
00180 };
00181
00182
00183 inline void vtkIdTypeArray::SetNumberOfValues(const vtkIdType number)
00184 {
00185 this->Allocate(number);
00186 this->MaxId = number - 1;
00187 }
00188
00189 inline vtkIdType *vtkIdTypeArray::WritePointer(const vtkIdType id,
00190 const vtkIdType number)
00191 {
00192 vtkIdType newSize=id+number;
00193 if ( newSize > this->Size )
00194 {
00195 this->ResizeAndExtend(newSize);
00196 }
00197 if ( (--newSize) > this->MaxId )
00198 {
00199 this->MaxId = newSize;
00200 }
00201 return this->Array + id;
00202 }
00203
00204 inline void vtkIdTypeArray::InsertValue(const vtkIdType id, const vtkIdType 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 vtkIdTypeArray::InsertNextValue(const vtkIdType i)
00218 {
00219 this->InsertValue (++this->MaxId,i);
00220 return this->MaxId;
00221 }
00222
00223
00224 #endif