Common/vtkDoubleArray.h Source File

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

# Common/vtkDoubleArray.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program:   Visualization Toolkit
    00004   Module:    $RCSfile: vtkDoubleArray.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 =========================================================================*/
    00048 #ifndef __vtkDoubleArray_h
    00049 #define __vtkDoubleArray_h
    00050
    00051 #include "vtkDataArray.h"
    00052
    00053 class VTK_COMMON_EXPORT vtkDoubleArray : public vtkDataArray
    00054 {
    00055 public:
    00056   static vtkDoubleArray *New();
    00057
    00058   vtkTypeRevisionMacro(vtkDoubleArray,vtkDataArray);
    00059   void PrintSelf(ostream& os, vtkIndent indent);
    00060
    00063   int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
    00064
    00066   void Initialize();
    00067
    00069   int GetDataType() {return VTK_DOUBLE;};
    00070
    00072   int GetDataTypeSize() { return sizeof(double); }
    00073
    00075   void SetNumberOfTuples(const vtkIdType number);
    00076
    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
    00114   double GetValue(const vtkIdType id) {return this->Array[id];}
    00115
    00117
    00119   void SetValue(const vtkIdType id, const double value)
    00120     { this->Array[id] = value;};
    00122
    00126   void SetNumberOfValues(const vtkIdType number);
    00127
    00129   void InsertValue(const vtkIdType id, const double f);
    00130
    00133   vtkIdType InsertNextValue(const double f);
    00134
    00138   float GetComponent(const vtkIdType i, const int j);
    00139
    00144   void SetComponent(const vtkIdType i, const int j, float c);
    00145
    00149   virtual void InsertComponent(const vtkIdType i, const int j, float c);
    00150
    00154   double *WritePointer(const vtkIdType id, const vtkIdType number);
    00155
    00157
    00159   double *GetPointer(const vtkIdType id) {return this->Array + id;}
    00160   void *GetVoidPointer(const vtkIdType id)
    00161     {return (void *)this->GetPointer(id);};
    00163
    00165   void DeepCopy(vtkDataArray *da);
    00166
    00168
    00174   void SetArray(double* array, vtkIdType size, int save);
    00175   void SetVoidArray(void *array, vtkIdType size, int save)
    00176     {this->SetArray((double*)array, size, save);};
    00178
    00179 protected:
    00180   vtkDoubleArray(vtkIdType numComp=1);
    00181   ~vtkDoubleArray();
    00182
    00183   double *Array;   // pointer to data
    00184   double *ResizeAndExtend(const vtkIdType sz);  // function to resize data
    00185
    00186   int TupleSize; //used for data conversion
    00187   float *Tuple;
    00188
    00189   int SaveUserArray;
    00190 private:
    00191   vtkDoubleArray(const vtkDoubleArray&);  // Not implemented.
    00192   void operator=(const vtkDoubleArray&);  // Not implemented.
    00193 };
    00194
    00195 inline void vtkDoubleArray::SetNumberOfValues(const vtkIdType number)
    00196 {
    00197   this->Allocate(number);
    00198   this->MaxId = number - 1;
    00199 }
    00200
    00201 inline double *vtkDoubleArray::WritePointer(const vtkIdType id,
    00202                                             const vtkIdType number)
    00203 {
    00204   vtkIdType newSize=id+number;
    00205   if ( newSize > this->Size )
    00206     {
    00207     this->ResizeAndExtend(newSize);
    00208     }
    00209   if ( (--newSize) > this->MaxId )
    00210     {
    00211     this->MaxId = newSize;
    00212     }
    00213   return this->Array + id;
    00214 }
    00215
    00216 inline void vtkDoubleArray::InsertValue(const vtkIdType id, const double f)
    00217 {
    00218   if ( id >= this->Size )
    00219     {
    00220     this->ResizeAndExtend(id+1);
    00221     }
    00222   this->Array[id] = f;
    00223   if ( id > this->MaxId )
    00224     {
    00225     this->MaxId = id;
    00226     }
    00227 }
    00228
    00229 inline vtkIdType vtkDoubleArray::InsertNextValue(const double f)
    00230 {
    00231   this->InsertValue (++this->MaxId,f);
    00232   return this->MaxId;
    00233 }
    00234
    00235
    00236 #endif