Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class 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 =========================================================================*/
00045 #ifndef __vtkFloatArray_h
00046 #define __vtkFloatArray_h
00047 
00048 #include "vtkDataArray.h"
00049 
00050 class VTK_COMMON_EXPORT vtkFloatArray : public vtkDataArray
00051 {
00052 public:
00053   static vtkFloatArray *New();
00054   vtkTypeRevisionMacro(vtkFloatArray,vtkDataArray);
00055   void PrintSelf(ostream& os, vtkIndent indent);
00056 
00059   int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
00060 
00062   void Initialize();
00063 
00065 
00066   int GetDataType()
00067     {return VTK_FLOAT;}
00069 
00071   int GetDataTypeSize() { return sizeof(float); }
00072   
00074   void SetNumberOfTuples(const vtkIdType number);
00075 
00077   float *GetTuple(const vtkIdType i);
00078 
00080 
00081   void GetTuple(const vtkIdType i, float * tuple);
00082   void GetTuple(const vtkIdType i, double * tuple);
00084 
00086 
00087   void SetTuple(const vtkIdType i, const float * tuple);
00088   void SetTuple(const vtkIdType i, const double * tuple);
00090 
00092 
00094   void InsertTuple(const vtkIdType i, const float * tuple);
00095   void InsertTuple(const vtkIdType i, const double * tuple);
00097 
00099 
00101   vtkIdType InsertNextTuple(const float * tuple);
00102   vtkIdType InsertNextTuple(const double * tuple);
00104 
00106   void Squeeze() {this->ResizeAndExtend(this->MaxId+1);};
00107 
00109   virtual void Resize(vtkIdType numTuples);
00110 
00114   float GetComponent(const vtkIdType i, const int j);
00115 
00120   void SetComponent(const vtkIdType i, const int j, float c);
00121 
00125   void InsertComponent(const vtkIdType i, const int j, float c);
00126 
00128 
00129   float GetValue(const vtkIdType id) 
00130     {return this->Array[id];}
00132 
00134 
00136   void SetValue(const vtkIdType id, const float value) 
00137     {this->Array[id] = value;}
00139 
00143   void SetNumberOfValues(const vtkIdType number);
00144 
00146   void InsertValue(const vtkIdType id, const float f);
00147 
00150   vtkIdType InsertNextValue(const float f);
00151 
00155   float *WritePointer(const vtkIdType id, const vtkIdType number);
00156 
00158 
00160   void *GetVoidPointer(const vtkIdType id) 
00161     {return (void *)this->GetPointer(id);}
00162   float *GetPointer(const vtkIdType id) 
00163     {return this->Array + id;}
00165 
00167   void DeepCopy(vtkDataArray *fa);
00168 
00170 
00176   void SetArray(float* array, vtkIdType size, int save);
00177   void SetVoidArray(void *array, vtkIdType size, int save) 
00178     {this->SetArray((float*)array, size, save);}
00180 
00181   
00182 protected:
00183   vtkFloatArray(vtkIdType numComp=1);
00184   ~vtkFloatArray();
00185 
00186   float *Array;  // pointer to data
00187   float *ResizeAndExtend(const vtkIdType sz);  // function to reallocate data
00188 
00189   int SaveUserArray;
00190 private:
00191   vtkFloatArray(const vtkFloatArray&);  // Not implemented.
00192   void operator=(const vtkFloatArray&);  // Not implemented.
00193 };
00194 
00195 inline void vtkFloatArray::SetNumberOfValues(const vtkIdType number) 
00196 {
00197   this->Allocate(number);
00198   this->MaxId = number - 1;
00199 }
00200 
00201 
00202 inline float *vtkFloatArray::WritePointer(const vtkIdType id,
00203                                           const vtkIdType number) 
00204 {
00205   vtkIdType newSize=id+number;
00206   if ( newSize > this->Size )
00207     {
00208     this->ResizeAndExtend(newSize);
00209     }
00210   if ( (--newSize) > this->MaxId )
00211     {
00212     this->MaxId = newSize;
00213     }
00214   return this->Array + id;
00215 }
00216 
00217 inline void vtkFloatArray::InsertValue(const vtkIdType id, const float f)
00218 {
00219   if ( id >= this->Size )
00220     {
00221     this->ResizeAndExtend(id+1);
00222     }
00223   this->Array[id] = f;
00224   if ( id > this->MaxId )
00225     {
00226     this->MaxId = id;
00227     }
00228 }
00229 
00230 inline vtkIdType vtkFloatArray::InsertNextValue(const float f)
00231 {
00232   this->InsertValue (++this->MaxId,f); 
00233   return this->MaxId;
00234 }
00235 
00236 #endif