Common/vtkIdTypeArray.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00026 #ifndef __vtkIdTypeArray_h
00027 #define __vtkIdTypeArray_h
00028
00029 #include "vtkDataArray.h"
00030
00031 class VTK_COMMON_EXPORT vtkIdTypeArray : public vtkDataArray
00032 {
00033 public:
00034 static vtkIdTypeArray *New();
00035
00036 vtkTypeRevisionMacro(vtkIdTypeArray, vtkDataArray);
00037 void PrintSelf(ostream& os, vtkIndent indent);
00038
00041 int Allocate(vtkIdType sz, vtkIdType ext=1000);
00042
00044 void Initialize();
00045
00047
00048 int GetDataType()
00049 {return VTK_ID_TYPE;}
00051
00053 int GetDataTypeSize() { return sizeof(vtkIdType); }
00054
00056
00057 void Squeeze()
00058 {this->ResizeAndExtend (this->MaxId+1);}
00060
00062 virtual void Resize(vtkIdType numTuples);
00063
00065 void SetNumberOfTuples(vtkIdType number);
00066
00069 double *GetTuple(vtkIdType i);
00070
00072 void GetTuple(vtkIdType i, double * tuple);
00073
00075
00076 void SetTuple(vtkIdType i, const float * tuple);
00077 void SetTuple(vtkIdType i, const double * tuple);
00079
00081
00083 void InsertTuple(vtkIdType i, const float * tuple);
00084 void InsertTuple(vtkIdType i, const double * tuple);
00086
00088
00090 vtkIdType InsertNextTuple(const float * tuple);
00091 vtkIdType InsertNextTuple(const double * tuple);
00093
00095
00096 vtkIdType GetValue(vtkIdType id)
00097 {return this->Array[id];}
00099
00101
00103 void SetValue(vtkIdType id, vtkIdType value)
00104 {this->Array[id] = value;}
00106
00110 void SetNumberOfValues(vtkIdType number);
00111
00113 void InsertValue(vtkIdType id, vtkIdType i);
00114
00117 vtkIdType InsertNextValue(vtkIdType i);
00118
00120
00122 vtkIdType *GetPointer(vtkIdType id)
00123 {return this->Array + id;}
00124 void *GetVoidPointer(vtkIdType id)
00125 {return (void *)this->GetPointer(id);}
00127
00131 vtkIdType *WritePointer(vtkIdType id, vtkIdType number);
00132
00134 void DeepCopy(vtkDataArray *ia);
00135
00137
00143 void SetArray(vtkIdType* array, vtkIdType size, int save);
00144 void SetVoidArray(void *array, vtkIdType size, int save)
00145 {this->SetArray((vtkIdType*)array, size, save);};
00147
00148 protected:
00149 vtkIdTypeArray(vtkIdType numComp=1);
00150 ~vtkIdTypeArray();
00151
00152 vtkIdType *Array;
00153 vtkIdType *ResizeAndExtend(vtkIdType sz);
00154
00155 int TupleSize;
00156 double *Tuple;
00157
00158 int SaveUserArray;
00159 private:
00160 vtkIdTypeArray(const vtkIdTypeArray&);
00161 void operator=(const vtkIdTypeArray&);
00162 };
00163
00164
00165 inline void vtkIdTypeArray::SetNumberOfValues(vtkIdType number)
00166 {
00167 this->Allocate(number);
00168 this->MaxId = number - 1;
00169 }
00170
00171 inline vtkIdType *vtkIdTypeArray::WritePointer(vtkIdType id,
00172 vtkIdType number)
00173 {
00174 vtkIdType newSize=id+number;
00175 if ( newSize > this->Size )
00176 {
00177 this->ResizeAndExtend(newSize);
00178 }
00179 if ( (--newSize) > this->MaxId )
00180 {
00181 this->MaxId = newSize;
00182 }
00183 return this->Array + id;
00184 }
00185
00186 inline void vtkIdTypeArray::InsertValue(vtkIdType id, vtkIdType i)
00187 {
00188 if ( id >= this->Size )
00189 {
00190 this->ResizeAndExtend(id+1);
00191 }
00192 this->Array[id] = i;
00193 if ( id > this->MaxId )
00194 {
00195 this->MaxId = id;
00196 }
00197 }
00198
00199 inline vtkIdType vtkIdTypeArray::InsertNextValue(vtkIdType i)
00200 {
00201 this->InsertValue (++this->MaxId,i);
00202 return this->MaxId;
00203 }
00204
00205
00206 #endif