dox/Common/vtkFloatArray.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00033 #ifndef __vtkFloatArray_h
00034 #define __vtkFloatArray_h
00035
00036 #include "vtkDataArray.h"
00037
00038 class VTK_COMMON_EXPORT vtkFloatArray : public vtkDataArray
00039 {
00040 public:
00041 static vtkFloatArray *New();
00042 vtkTypeRevisionMacro(vtkFloatArray,vtkDataArray);
00043 void PrintSelf(ostream& os, vtkIndent indent);
00044
00047 int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
00048
00050 void Initialize();
00051
00053
00054 int GetDataType()
00055 {return VTK_FLOAT;}
00057
00059 int GetDataTypeSize() { return sizeof(float); }
00060
00062 void SetNumberOfTuples(const vtkIdType number);
00063
00065 float *GetTuple(const vtkIdType i);
00066
00068
00069 void GetTuple(const vtkIdType i, float * tuple);
00070 void GetTuple(const vtkIdType i, double * tuple);
00072
00074
00075 void SetTuple(const vtkIdType i, const float * tuple);
00076 void SetTuple(const vtkIdType i, const double * tuple);
00078
00080
00082 void InsertTuple(const vtkIdType i, const float * tuple);
00083 void InsertTuple(const vtkIdType i, const double * tuple);
00085
00087
00089 vtkIdType InsertNextTuple(const float * tuple);
00090 vtkIdType InsertNextTuple(const double * tuple);
00092
00094 void Squeeze() {this->ResizeAndExtend(this->MaxId+1);};
00095
00097 virtual void Resize(vtkIdType numTuples);
00098
00102 float GetComponent(const vtkIdType i, const int j);
00103
00108 void SetComponent(const vtkIdType i, const int j, float c);
00109
00113 void InsertComponent(const vtkIdType i, const int j, float c);
00114
00116
00117 float GetValue(const vtkIdType id)
00118 {return this->Array[id];}
00120
00122
00124 void SetValue(const vtkIdType id, const float value)
00125 {this->Array[id] = value;}
00127
00131 void SetNumberOfValues(const vtkIdType number);
00132
00134 void InsertValue(const vtkIdType id, const float f);
00135
00138 vtkIdType InsertNextValue(const float f);
00139
00143 float *WritePointer(const vtkIdType id, const vtkIdType number);
00144
00146
00148 void *GetVoidPointer(const vtkIdType id)
00149 {return (void *)this->GetPointer(id);}
00150 float *GetPointer(const vtkIdType id)
00151 {return this->Array + id;}
00153
00155 void DeepCopy(vtkDataArray *fa);
00156
00158
00164 void SetArray(float* array, vtkIdType size, int save);
00165 void SetVoidArray(void *array, vtkIdType size, int save)
00166 {this->SetArray((float*)array, size, save);}
00168
00169
00170 protected:
00171 vtkFloatArray(vtkIdType numComp=1);
00172 ~vtkFloatArray();
00173
00174 float *Array;
00175 float *ResizeAndExtend(const vtkIdType sz);
00176
00177 int SaveUserArray;
00178 private:
00179 vtkFloatArray(const vtkFloatArray&);
00180 void operator=(const vtkFloatArray&);
00181 };
00182
00183 inline void vtkFloatArray::SetNumberOfValues(const vtkIdType number)
00184 {
00185 this->Allocate(number);
00186 this->MaxId = number - 1;
00187 }
00188
00189
00190 inline float *vtkFloatArray::WritePointer(const vtkIdType id,
00191 const vtkIdType number)
00192 {
00193 vtkIdType newSize=id+number;
00194 if ( newSize > this->Size )
00195 {
00196 this->ResizeAndExtend(newSize);
00197 }
00198 if ( (--newSize) > this->MaxId )
00199 {
00200 this->MaxId = newSize;
00201 }
00202 return this->Array + id;
00203 }
00204
00205 inline void vtkFloatArray::InsertValue(const vtkIdType id, const float f)
00206 {
00207 if ( id >= this->Size )
00208 {
00209 this->ResizeAndExtend(id+1);
00210 }
00211 this->Array[id] = f;
00212 if ( id > this->MaxId )
00213 {
00214 this->MaxId = id;
00215 }
00216 }
00217
00218 inline vtkIdType vtkFloatArray::InsertNextValue(const float f)
00219 {
00220 this->InsertValue (++this->MaxId,f);
00221 return this->MaxId;
00222 }
00223
00224 #endif