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

# Common/vtkUnsignedIntArray.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program:   Visualization Toolkit
    00004   Module:    $RCSfile: vtkUnsignedIntArray.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 __vtkUnsignedIntArray_h
    00046 #define __vtkUnsignedIntArray_h
    00047
    00048 #include "vtkDataArray.h"
    00049
    00050 class VTK_COMMON_EXPORT vtkUnsignedIntArray : public vtkDataArray
    00051 {
    00052 public:
    00053   static vtkUnsignedIntArray *New();
    00054
    00055   vtkTypeRevisionMacro(vtkUnsignedIntArray,vtkDataArray);
    00056   void PrintSelf(ostream& os, vtkIndent indent);
    00057
    00060   int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
    00061
    00063   void Initialize();
    00064
    00066   int GetDataType() {return VTK_UNSIGNED_INT;};
    00067
    00069   int GetDataTypeSize() { return sizeof(unsigned int); }
    00070
    00072   void SetNumberOfTuples(const vtkIdType number);
    00073
    00076   float *GetTuple(const vtkIdType i);
    00077
    00079
    00080   void GetTuple(const vtkIdType i, float * tuple);
    00081   void GetTuple(const vtkIdType i, double * tuple);
    00083
    00085
    00086   void SetTuple(const vtkIdType i, const float * tuple);
    00087   void SetTuple(const vtkIdType i, const double * tuple);
    00089
    00091
    00093   void InsertTuple(const vtkIdType i, const float * tuple);
    00094   void InsertTuple(const vtkIdType i, const double * tuple);
    00096
    00098
    00100   vtkIdType InsertNextTuple(const float * tuple);
    00101   vtkIdType InsertNextTuple(const double * tuple);
    00103
    00105   unsigned int GetValue(const vtkIdType id) {return this->Array[id];};
    00106
    00108
    00110   void SetValue(const vtkIdType id, const unsigned int value) {
    00111     this->Array[id] = value;};
    00113
    00117   void SetNumberOfValues(const vtkIdType number);
    00118
    00120   void InsertValue(const vtkIdType id, const unsigned int i);
    00121
    00124   vtkIdType InsertNextValue(const unsigned int);
    00125
    00129   float GetComponent(const vtkIdType i, const int j);
    00130
    00135   void SetComponent(const vtkIdType i, const int j, float c);
    00136
    00140   virtual void InsertComponent(const vtkIdType i, const int j, float c);
    00141
    00143
    00145   unsigned int *GetPointer(const vtkIdType id) {return this->Array + id;}
    00146   void *GetVoidPointer(const vtkIdType id)
    00147     {return (void *)this->GetPointer(id);};
    00149
    00153   unsigned int *WritePointer(const vtkIdType id, const vtkIdType number);
    00154
    00156   void DeepCopy(vtkDataArray *da);
    00157
    00159
    00165   void SetArray(unsigned int* array, vtkIdType size, int save);
    00166   void SetVoidArray(void *array,vtkIdType size, int save)
    00167     {this->SetArray((unsigned int*)array, size, save);};
    00169
    00171
    00172   void Squeeze()
    00173     {this->ResizeAndExtend (this->MaxId+1);};
    00175
    00177   virtual void Resize(vtkIdType numTuples);
    00178
    00179 protected:
    00180   vtkUnsignedIntArray(vtkIdType numComp=1);
    00181   ~vtkUnsignedIntArray();
    00182
    00183   unsigned int *Array;   // pointer to data
    00184   unsigned int *ResizeAndExtend(const vtkIdType sz);
    00185     // function to resize data
    00186
    00187   int TupleSize; //used for data conversion
    00188   float *Tuple;
    00189
    00190   int SaveUserArray;
    00191 private:
    00192   vtkUnsignedIntArray(const vtkUnsignedIntArray&);  // Not implemented.
    00193   void operator=(const vtkUnsignedIntArray&);  // Not implemented.
    00194 };
    00195
    00196
    00197 inline void vtkUnsignedIntArray::SetNumberOfValues(const vtkIdType number)
    00198 {
    00199   this->Allocate(number);
    00200   this->MaxId = number - 1;
    00201 }
    00202
    00203 inline unsigned int *vtkUnsignedIntArray::WritePointer(const vtkIdType id,
    00204                                                        const vtkIdType number)
    00205 {
    00206   vtkIdType newSize=id+number;
    00207   if ( newSize > this->Size )
    00208     {
    00209     this->ResizeAndExtend(newSize);
    00210     }
    00211   if ( (--newSize) > this->MaxId )
    00212     {
    00213     this->MaxId = newSize;
    00214     }
    00215   return this->Array + id;
    00216 }
    00217
    00218 inline void vtkUnsignedIntArray::InsertValue(const vtkIdType id,
    00219                                              const unsigned int i)
    00220 {
    00221   if ( id >= this->Size )
    00222     {
    00223     this->ResizeAndExtend(id+1);
    00224     }
    00225   this->Array[id] = i;
    00226   if ( id > this->MaxId )
    00227     {
    00228     this->MaxId = id;
    00229     }
    00230 }
    00231
    00232 inline vtkIdType vtkUnsignedIntArray::InsertNextValue(const unsigned int i)
    00233 {
    00234   this->InsertValue (++this->MaxId,i);
    00235   return this->MaxId;
    00236 }
    00237
    00238
    00239 #endif
    00240
    00241
    00242
    00243