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

Common/vtkUnsignedLongArray.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkUnsignedLongArray.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 __vtkUnsignedLongArray_h
00046 #define __vtkUnsignedLongArray_h
00047 
00048 #include "vtkDataArray.h"
00049 
00050 class VTK_COMMON_EXPORT vtkUnsignedLongArray : public vtkDataArray 
00051 {
00052 public:
00053   static vtkUnsignedLongArray *New();
00054 
00055   vtkTypeRevisionMacro(vtkUnsignedLongArray,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_LONG;};
00067 
00069   int GetDataTypeSize() { return sizeof(unsigned long); }
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 long GetValue(const vtkIdType id) {return this->Array[id];};
00106   
00108 
00110   void SetValue(const vtkIdType id, const unsigned long value) {
00111     this->Array[id] = value;};
00113 
00117   void SetNumberOfValues(const vtkIdType number);
00118 
00120   void InsertValue(const vtkIdType id, const unsigned long i);
00121 
00124   vtkIdType InsertNextValue(const unsigned long);
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 long *GetPointer(const vtkIdType id) {return this->Array + id;}
00146   void *GetVoidPointer(const vtkIdType id)
00147     {return (void *)this->GetPointer(id);};
00149 
00153   unsigned long *WritePointer(const vtkIdType id, const vtkIdType number);
00154 
00156   void DeepCopy(vtkDataArray *da);
00157 
00159 
00165   void SetArray(unsigned long* array, vtkIdType size, int save);
00166   void SetVoidArray(void *array, vtkIdType size, int save) 
00167     {this->SetArray((unsigned long*)array, size, save);};
00169 
00171   void Squeeze() {this->ResizeAndExtend (this->MaxId+1);};
00172 
00174   virtual void Resize(vtkIdType numTuples);
00175 
00176 protected:
00177   vtkUnsignedLongArray(vtkIdType numComp=1);
00178   ~vtkUnsignedLongArray();
00179 
00180   unsigned long *Array;   // pointer to data
00181   unsigned long *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   vtkUnsignedLongArray(const vtkUnsignedLongArray&);  // Not implemented.
00190   void operator=(const vtkUnsignedLongArray&);  // Not implemented.
00191 };
00192 
00193 inline void vtkUnsignedLongArray::SetNumberOfValues(const vtkIdType number) 
00194 {
00195   this->Allocate(number);
00196   this->MaxId = number - 1;
00197 }
00198 
00199 inline unsigned long *vtkUnsignedLongArray::WritePointer(const vtkIdType id,
00200                                                          const vtkIdType number) 
00201 {
00202   vtkIdType newSize=id+number;
00203   if ( newSize > this->Size )
00204     {
00205     this->ResizeAndExtend(newSize);
00206     }
00207   if ( (--newSize) > this->MaxId )
00208     {
00209     this->MaxId = newSize;
00210     }
00211   return this->Array + id;
00212 }
00213 
00214 inline void vtkUnsignedLongArray::InsertValue(const vtkIdType id,
00215                                               const unsigned long i)
00216 {
00217   if ( id >= this->Size )
00218     {
00219     this->ResizeAndExtend(id+1);
00220     }
00221   this->Array[id] = i;
00222   if ( id > this->MaxId )
00223     {
00224     this->MaxId = id;
00225     }
00226 }
00227 
00228 inline vtkIdType vtkUnsignedLongArray::InsertNextValue(const unsigned long i)
00229 {
00230   this->InsertValue (++this->MaxId,i); 
00231   return this->MaxId;
00232 }
00233 
00234 
00235 #endif
00236 
00237 
00238 
00239