Common/vtkIntArray.h Source File

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

# Common/vtkIntArray.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program:   Visualization Toolkit
    00004   Module:    $RCSfile: vtkIntArray.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 =========================================================================*/
    00046 #ifndef __vtkIntArray_h
    00047 #define __vtkIntArray_h
    00048
    00049 #include "vtkDataArray.h"
    00050
    00051 class VTK_COMMON_EXPORT vtkIntArray : public vtkDataArray
    00052 {
    00053 public:
    00054   static vtkIntArray *New();
    00055
    00056   vtkTypeRevisionMacro(vtkIntArray,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_INT;}
    00071
    00073   int GetDataTypeSize() { return sizeof(int); }
    00074
    00076
    00077   void Squeeze()
    00078     {this->ResizeAndExtend (this->MaxId+1);}
    00080
    00082   virtual void Resize(vtkIdType numTuples);
    00083
    00085   void SetNumberOfTuples(const vtkIdType number);
    00086
    00089   float *GetTuple(const vtkIdType i);
    00090
    00092
    00093   void GetTuple(const vtkIdType i, float * tuple);
    00094   void GetTuple(const vtkIdType i, double * tuple);
    00096
    00098
    00099   void SetTuple(const vtkIdType i, const float * tuple);
    00100   void SetTuple(const vtkIdType i, const double * tuple);
    00102
    00104
    00106   void InsertTuple(const vtkIdType i, const float * tuple);
    00107   void InsertTuple(const vtkIdType i, const double * tuple);
    00109
    00111
    00113   vtkIdType InsertNextTuple(const float * tuple);
    00114   vtkIdType InsertNextTuple(const double * tuple);
    00116
    00118
    00119   int GetValue(const vtkIdType id)
    00120     {return this->Array[id];}
    00122
    00124
    00126   void SetValue(const vtkIdType id, const int value)
    00127     {this->Array[id] = value;}
    00129
    00133   void SetNumberOfValues(const vtkIdType number);
    00134
    00136   void InsertValue(const vtkIdType id, const int i);
    00137
    00140   vtkIdType InsertNextValue(const int i);
    00141
    00145   float GetComponent(const vtkIdType i, const int j);
    00146
    00151   void SetComponent(const vtkIdType i, const int j, float c);
    00152
    00156   virtual void InsertComponent(const vtkIdType i, const int j, float c);
    00157
    00159
    00161   int *GetPointer(const vtkIdType id)
    00162     {return this->Array + id;}
    00163   void *GetVoidPointer(const vtkIdType id)
    00164     {return (void *)this->GetPointer(id);}
    00166
    00170   int *WritePointer(const vtkIdType id, const vtkIdType number);
    00171
    00173   void DeepCopy(vtkDataArray *ia);
    00174
    00176
    00182   void SetArray(int* array, vtkIdType size, int save);
    00183   void SetVoidArray(void *array,vtkIdType size, int save)
    00184     {this->SetArray((int*)array, size, save);};
    00186
    00187 protected:
    00188   vtkIntArray(vtkIdType numComp=1);
    00189   ~vtkIntArray();
    00190
    00191   int *Array;   // pointer to data
    00192   int *ResizeAndExtend(const vtkIdType sz);  // function to resize data
    00193
    00194   int TupleSize; //used for data conversion
    00195   float *Tuple;
    00196
    00197   int SaveUserArray;
    00198 private:
    00199   vtkIntArray(const vtkIntArray&);  // Not implemented.
    00200   void operator=(const vtkIntArray&);  // Not implemented.
    00201 };
    00202
    00203
    00204 inline void vtkIntArray::SetNumberOfValues(const vtkIdType number)
    00205 {
    00206   this->Allocate(number);
    00207   this->MaxId = number - 1;
    00208 }
    00209
    00210 inline int *vtkIntArray::WritePointer(const vtkIdType id,
    00211                                       const vtkIdType number)
    00212 {
    00213   vtkIdType newSize=id+number;
    00214   if ( newSize > this->Size )
    00215     {
    00216     this->ResizeAndExtend(newSize);
    00217     }
    00218   if ( (--newSize) > this->MaxId )
    00219     {
    00220     this->MaxId = newSize;
    00221     }
    00222   return this->Array + id;
    00223 }
    00224
    00225 inline void vtkIntArray::InsertValue(const vtkIdType id, const int i)
    00226 {
    00227   if ( id >= this->Size )
    00228     {
    00229     this->ResizeAndExtend(id+1);
    00230     }
    00231   this->Array[id] = i;
    00232   if ( id > this->MaxId )
    00233     {
    00234     this->MaxId = id;
    00235     }
    00236 }
    00237
    00238 inline vtkIdType vtkIntArray::InsertNextValue(const int i)
    00239 {
    00240   this->InsertValue (++this->MaxId,i);
    00241   return this->MaxId;
    00242 }
    00243
    00244
    00245 #endif