Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members Related Pages

# Common/vtkFloatArray.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program:   Visualization Toolkit
    00004   Module:    $RCSfile: vtkFloatArray.h,v $
    00005   Language:  C++
    00006
    00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
    00008   All rights reserved.
    00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
    00010
    00011      This software is distributed WITHOUT ANY WARRANTY; without even
    00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00013      PURPOSE.  See the above copyright notice for more information.
    00014
    00015 =========================================================================*/
    00047 #ifndef __vtkFloatArray_h
    00048 #define __vtkFloatArray_h
    00049
    00050 #include "vtkDataArray.h"
    00051
    00052 class VTK_COMMON_EXPORT vtkFloatArray : public vtkDataArray
    00053 {
    00054 public:
    00055   static vtkFloatArray *New();
    00056   vtkTypeRevisionMacro(vtkFloatArray,vtkDataArray);
    00057   void PrintSelf(ostream& os, vtkIndent indent);
    00058
    00061   int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
    00062
    00064   void Initialize();
    00065
    00067
    00068   int GetDataType()
    00069     {return VTK_FLOAT;}
    00071
    00073   int GetDataTypeSize() { return sizeof(float); }
    00074
    00076   void SetNumberOfTuples(const vtkIdType number);
    00077
    00079   float *GetTuple(const vtkIdType i);
    00080
    00082
    00083   void GetTuple(const vtkIdType i, float * tuple);
    00084   void GetTuple(const vtkIdType i, double * tuple);
    00086
    00088
    00089   void SetTuple(const vtkIdType i, const float * tuple);
    00090   void SetTuple(const vtkIdType i, const double * tuple);
    00092
    00094
    00096   void InsertTuple(const vtkIdType i, const float * tuple);
    00097   void InsertTuple(const vtkIdType i, const double * tuple);
    00099
    00101
    00103   vtkIdType InsertNextTuple(const float * tuple);
    00104   vtkIdType InsertNextTuple(const double * tuple);
    00106
    00108   void Squeeze() {this->ResizeAndExtend(this->MaxId+1);};
    00109
    00111   virtual void Resize(vtkIdType numTuples);
    00112
    00116   float GetComponent(const vtkIdType i, const int j);
    00117
    00122   void SetComponent(const vtkIdType i, const int j, float c);
    00123
    00127   void InsertComponent(const vtkIdType i, const int j, float c);
    00128
    00130
    00131   float GetValue(const vtkIdType id)
    00132     {return this->Array[id];}
    00134
    00136
    00138   void SetValue(const vtkIdType id, const float value)
    00139     {this->Array[id] = value;}
    00141
    00145   void SetNumberOfValues(const vtkIdType number);
    00146
    00148   void InsertValue(const vtkIdType id, const float f);
    00149
    00152   vtkIdType InsertNextValue(const float f);
    00153
    00157   float *WritePointer(const vtkIdType id, const vtkIdType number);
    00158
    00160
    00162   void *GetVoidPointer(const vtkIdType id)
    00163     {return (void *)this->GetPointer(id);}
    00164   float *GetPointer(const vtkIdType id)
    00165     {return this->Array + id;}
    00167
    00169   void DeepCopy(vtkDataArray *fa);
    00170
    00172
    00178   void SetArray(float* array, vtkIdType size, int save);
    00179   void SetVoidArray(void *array, vtkIdType size, int save)
    00180     {this->SetArray((float*)array, size, save);}
    00182
    00183
    00184 protected:
    00185   vtkFloatArray(vtkIdType numComp=1);
    00186   ~vtkFloatArray();
    00187
    00188   float *Array;  // pointer to data
    00189   float *ResizeAndExtend(const vtkIdType sz);  // function to reallocate data
    00190
    00191   int SaveUserArray;
    00192 private:
    00193   vtkFloatArray(const vtkFloatArray&);  // Not implemented.
    00194   void operator=(const vtkFloatArray&);  // Not implemented.
    00195 };
    00196
    00197 inline void vtkFloatArray::SetNumberOfValues(const vtkIdType number)
    00198 {
    00199   this->Allocate(number);
    00200   this->MaxId = number - 1;
    00201 }
    00202
    00203
    00204 inline float *vtkFloatArray::WritePointer(const vtkIdType id,
    00205                                           const vtkIdType number)
    00206 {
    00207   vtkIdType newSize=id+number;
    00208   if ( newSize > this->Size )
    00209     {
    00210     this->ResizeAndExtend(newSize);
    00211     }
    00212   if ( (--newSize) > this->MaxId )
    00213     {
    00214     this->MaxId = newSize;
    00215     }
    00216   return this->Array + id;
    00217 }
    00218
    00219 inline void vtkFloatArray::InsertValue(const vtkIdType id, const float f)
    00220 {
    00221   if ( id >= this->Size )
    00222     {
    00223     this->ResizeAndExtend(id+1);
    00224     }
    00225   this->Array[id] = f;
    00226   if ( id > this->MaxId )
    00227     {
    00228     this->MaxId = id;
    00229     }
    00230 }
    00231
    00232 inline vtkIdType vtkFloatArray::InsertNextValue(const float f)
    00233 {
    00234   this->InsertValue (++this->MaxId,f);
    00235   return this->MaxId;
    00236 }
    00237
    00238 #endif