Common/vtkDoubleArray.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00045 #ifndef __vtkDoubleArray_h
00046 #define __vtkDoubleArray_h
00047
00048 #include "vtkDataArray.h"
00049
00050 class VTK_COMMON_EXPORT vtkDoubleArray : public vtkDataArray
00051 {
00052 public:
00053 static vtkDoubleArray *New();
00054
00055 vtkTypeRevisionMacro(vtkDoubleArray,vtkDataArray);
00056 void PrintSelf(ostream& os, vtkIndent indent);
00057
00060 int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
00061
00063 void Initialize();
00064
00066 int GetDataType() {return VTK_DOUBLE;};
00067
00069 int GetDataTypeSize() { return sizeof(double); }
00070
00072 void SetNumberOfTuples(const vtkIdType number);
00073
00076 float *GetTuple(const vtkIdType i);
00077
00079
00080 void GetTuple(const vtkIdType i, float * tuple);
00081 void GetTuple(const vtkIdType i, double * tuple);
00083
00085
00086 void SetTuple(const vtkIdType i, const float * tuple);
00087 void SetTuple(const vtkIdType i, const double * tuple);
00089
00091
00093 void InsertTuple(const vtkIdType i, const float * tuple);
00094 void InsertTuple(const vtkIdType i, const double * tuple);
00096
00098
00100 vtkIdType InsertNextTuple(const float * tuple);
00101 vtkIdType InsertNextTuple(const double * tuple);
00103
00105 void Squeeze() {this->ResizeAndExtend (this->MaxId+1);};
00106
00108 virtual void Resize(vtkIdType numTuples);
00109
00111 double GetValue(const vtkIdType id) {return this->Array[id];}
00112
00114
00116 void SetValue(const vtkIdType id, const double value)
00117 { this->Array[id] = value;};
00119
00123 void SetNumberOfValues(const vtkIdType number);
00124
00126 void InsertValue(const vtkIdType id, const double f);
00127
00130 vtkIdType InsertNextValue(const double f);
00131
00135 float GetComponent(const vtkIdType i, const int j);
00136
00141 void SetComponent(const vtkIdType i, const int j, float c);
00142
00146 virtual void InsertComponent(const vtkIdType i, const int j, float c);
00147
00151 double *WritePointer(const vtkIdType id, const vtkIdType number);
00152
00154
00156 double *GetPointer(const vtkIdType id) {return this->Array + id;}
00157 void *GetVoidPointer(const vtkIdType id)
00158 {return (void *)this->GetPointer(id);};
00160
00162 void DeepCopy(vtkDataArray *da);
00163
00165
00171 void SetArray(double* array, vtkIdType size, int save);
00172 void SetVoidArray(void *array, vtkIdType size, int save)
00173 {this->SetArray((double*)array, size, save);};
00175
00176 protected:
00177 vtkDoubleArray(vtkIdType numComp=1);
00178 ~vtkDoubleArray();
00179
00180 double *Array;
00181 double *ResizeAndExtend(const vtkIdType sz);
00182
00183 int TupleSize;
00184 float *Tuple;
00185
00186 int SaveUserArray;
00187 private:
00188 vtkDoubleArray(const vtkDoubleArray&);
00189 void operator=(const vtkDoubleArray&);
00190 };
00191
00192 inline void vtkDoubleArray::SetNumberOfValues(const vtkIdType number)
00193 {
00194 this->Allocate(number);
00195 this->MaxId = number - 1;
00196 }
00197
00198 inline double *vtkDoubleArray::WritePointer(const vtkIdType id,
00199 const vtkIdType number)
00200 {
00201 vtkIdType newSize=id+number;
00202 if ( newSize > this->Size )
00203 {
00204 this->ResizeAndExtend(newSize);
00205 }
00206 if ( (--newSize) > this->MaxId )
00207 {
00208 this->MaxId = newSize;
00209 }
00210 return this->Array + id;
00211 }
00212
00213 inline void vtkDoubleArray::InsertValue(const vtkIdType id, const double f)
00214 {
00215 if ( id >= this->Size )
00216 {
00217 this->ResizeAndExtend(id+1);
00218 }
00219 this->Array[id] = f;
00220 if ( id > this->MaxId )
00221 {
00222 this->MaxId = id;
00223 }
00224 }
00225
00226 inline vtkIdType vtkDoubleArray::InsertNextValue(const double f)
00227 {
00228 this->InsertValue (++this->MaxId,f);
00229 return this->MaxId;
00230 }
00231
00232
00233 #endif