Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class 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 =========================================================================*/
00042 #ifndef __vtkUnsignedIntArray_h
00043 #define __vtkUnsignedIntArray_h
00044 
00045 #include "vtkDataArray.h"
00046 
00047 class VTK_COMMON_EXPORT vtkUnsignedIntArray : public vtkDataArray 
00048 {
00049 public:
00050   static vtkUnsignedIntArray *New();
00051 
00052   vtkTypeRevisionMacro(vtkUnsignedIntArray,vtkDataArray);
00053   void PrintSelf(ostream& os, vtkIndent indent);
00054 
00057   int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
00058 
00060   void Initialize();
00061 
00063   int GetDataType() {return VTK_UNSIGNED_INT;};
00064   
00066   int GetDataTypeSize() { return sizeof(unsigned int); }
00067   
00069   void SetNumberOfTuples(const vtkIdType number);
00070 
00073   float *GetTuple(const vtkIdType i);
00074 
00076 
00077   void GetTuple(const vtkIdType i, float * tuple);
00078   void GetTuple(const vtkIdType i, double * tuple);
00080   
00082 
00083   void SetTuple(const vtkIdType i, const float * tuple);
00084   void SetTuple(const vtkIdType i, const double * tuple);
00086 
00088 
00090   void InsertTuple(const vtkIdType i, const float * tuple);
00091   void InsertTuple(const vtkIdType i, const double * tuple);
00093 
00095 
00097   vtkIdType InsertNextTuple(const float * tuple);
00098   vtkIdType InsertNextTuple(const double * tuple);
00100 
00102   unsigned int GetValue(const vtkIdType id) {return this->Array[id];};
00103 
00105 
00107   void SetValue(const vtkIdType id, const unsigned int value) {
00108     this->Array[id] = value;};
00110 
00114   void SetNumberOfValues(const vtkIdType number);
00115 
00117   void InsertValue(const vtkIdType id, const unsigned int i);
00118 
00121   vtkIdType InsertNextValue(const unsigned int);
00122 
00126   float GetComponent(const vtkIdType i, const int j);
00127   
00132   void SetComponent(const vtkIdType i, const int j, float c);
00133   
00137   virtual void InsertComponent(const vtkIdType i, const int j, float c);
00138 
00140 
00142   unsigned int *GetPointer(const vtkIdType id) {return this->Array + id;}
00143   void *GetVoidPointer(const vtkIdType id)
00144     {return (void *)this->GetPointer(id);};
00146 
00150   unsigned int *WritePointer(const vtkIdType id, const vtkIdType number);
00151 
00153   void DeepCopy(vtkDataArray *da);
00154 
00156 
00162   void SetArray(unsigned int* array, vtkIdType size, int save);
00163   void SetVoidArray(void *array,vtkIdType size, int save) 
00164     {this->SetArray((unsigned int*)array, size, save);};
00166 
00168 
00169   void Squeeze() 
00170     {this->ResizeAndExtend (this->MaxId+1);};
00172 
00174   virtual void Resize(vtkIdType numTuples);  
00175 
00176 protected:
00177   vtkUnsignedIntArray(vtkIdType numComp=1);
00178   ~vtkUnsignedIntArray();
00179 
00180   unsigned int *Array;   // pointer to data
00181   unsigned int *ResizeAndExtend(const vtkIdType sz);
00182     // function to resize data
00183 
00184   int TupleSize; //used for data conversion
00185   float *Tuple;
00186 
00187   int SaveUserArray;
00188 private:
00189   vtkUnsignedIntArray(const vtkUnsignedIntArray&);  // Not implemented.
00190   void operator=(const vtkUnsignedIntArray&);  // Not implemented.
00191 };
00192 
00193 
00194 inline void vtkUnsignedIntArray::SetNumberOfValues(const vtkIdType number) 
00195 {
00196   this->Allocate(number);
00197   this->MaxId = number - 1;
00198 }
00199 
00200 inline unsigned int *vtkUnsignedIntArray::WritePointer(const vtkIdType id,
00201                                                        const vtkIdType number) 
00202 {
00203   vtkIdType newSize=id+number;
00204   if ( newSize > this->Size )
00205     {
00206     this->ResizeAndExtend(newSize);
00207     }
00208   if ( (--newSize) > this->MaxId )
00209     {
00210     this->MaxId = newSize;
00211     }
00212   return this->Array + id;
00213 }
00214 
00215 inline void vtkUnsignedIntArray::InsertValue(const vtkIdType id,
00216                                              const unsigned int i)
00217 {
00218   if ( id >= this->Size )
00219     {
00220     this->ResizeAndExtend(id+1);
00221     }
00222   this->Array[id] = i;
00223   if ( id > this->MaxId )
00224     {
00225     this->MaxId = id;
00226     }
00227 }
00228 
00229 inline vtkIdType vtkUnsignedIntArray::InsertNextValue(const unsigned int i)
00230 {
00231   this->InsertValue (++this->MaxId,i); 
00232   return this->MaxId;
00233 }
00234 
00235 
00236 #endif
00237 
00238 
00239 
00240