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

Common/vtkLongArray.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkLongArray.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 __vtkLongArray_h
00043 #define __vtkLongArray_h
00044 
00045 #include "vtkDataArray.h"
00046 
00047 class VTK_COMMON_EXPORT vtkLongArray : public vtkDataArray
00048 {
00049 public:
00050   static vtkLongArray *New();
00051 
00052   vtkTypeRevisionMacro(vtkLongArray,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   void Squeeze() {this->ResizeAndExtend (this->MaxId+1);};
00064 
00066   virtual void Resize(vtkIdType numTuples);
00067 
00069   int GetDataType() {return VTK_LONG;};
00070   
00072   int GetDataTypeSize() { return sizeof(long); }
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   long GetValue(const vtkIdType id) {return this->Array[id];};
00109 
00113   void SetNumberOfValues(const vtkIdType number);
00114 
00116 
00118   void SetValue(const vtkIdType id, const long value)
00119     { this->Array[id] = value;};
00121 
00123   void InsertValue(const vtkIdType id, const long i);
00124 
00127   vtkIdType InsertNextValue(const long);
00128 
00132   float GetComponent(const vtkIdType i, const int j);
00133   
00138   void SetComponent(const vtkIdType i, const int j, float c);
00139   
00143   virtual void InsertComponent(const vtkIdType i, const int j, float c);
00144 
00146 
00148   long *GetPointer(const vtkIdType id) {return this->Array + id;}
00149   void *GetVoidPointer(const vtkIdType id)
00150     {return (void *)this->GetPointer(id);};
00152 
00156   long *WritePointer(const vtkIdType id, const vtkIdType number);
00157   
00159   void DeepCopy(vtkDataArray *da);
00160 
00162 
00168   void SetArray(long* array, vtkIdType size, int save);
00169   void SetVoidArray(void *array, vtkIdType size, int save) 
00170     {this->SetArray((long*)array, size, save);};
00172 
00173 protected:
00174   vtkLongArray(vtkIdType numComp=1);
00175   ~vtkLongArray();
00176 
00177   long *Array;   // pointer to data
00178   long *ResizeAndExtend(const vtkIdType sz);  // function to resize data
00179 
00180   int TupleSize; //used for data conversion
00181   float *Tuple;
00182 
00183   int SaveUserArray;
00184 private:
00185   vtkLongArray(const vtkLongArray&);  // Not implemented.
00186   void operator=(const vtkLongArray&);  // Not implemented.
00187 };
00188 
00189 inline void vtkLongArray::SetNumberOfValues(const vtkIdType number) 
00190 {
00191   this->Allocate(number);
00192   this->MaxId = number - 1;
00193 }
00194 
00195 inline long *vtkLongArray::WritePointer(const vtkIdType id,
00196                                         const vtkIdType number) 
00197 {
00198   vtkIdType newSize=id+number;
00199   if ( newSize > this->Size )
00200     {
00201     this->ResizeAndExtend(newSize);
00202     }
00203   if ( (--newSize) > this->MaxId )
00204     {
00205     this->MaxId = newSize;
00206     }
00207   return this->Array + id;
00208 }
00209 
00210 inline void vtkLongArray::InsertValue(const vtkIdType id, const long i)
00211 {
00212   if ( id >= this->Size )
00213     {
00214     this->ResizeAndExtend(id+1);
00215     }
00216   this->Array[id] = i;
00217   if ( id > this->MaxId )
00218     {
00219     this->MaxId = id;
00220     }
00221 }
00222 
00223 inline vtkIdType vtkLongArray::InsertNextValue(const long i)
00224 {
00225   this->InsertValue (++this->MaxId,i); 
00226   return this->MaxId;
00227 }
00228 
00229 
00230 #endif