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

vtkIdTypeArray.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkIdTypeArray.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 =========================================================================*/
00030 #ifndef __vtkIdTypeArray_h
00031 #define __vtkIdTypeArray_h
00032 
00033 #include "vtkDataArray.h"
00034 
00035 class VTK_COMMON_EXPORT vtkIdTypeArray : public vtkDataArray
00036 {
00037 public:
00038   static vtkIdTypeArray *New();
00039 
00040   vtkTypeRevisionMacro(vtkIdTypeArray, vtkDataArray);
00041   void PrintSelf(ostream& os, vtkIndent indent);
00042 
00045   int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
00046   
00048   void Initialize();
00049 
00051 
00052   int GetDataType() 
00053     {return VTK_ID_TYPE;}
00055   
00057   int GetDataTypeSize() { return sizeof(vtkIdType); }
00058 
00060 
00061   void Squeeze() 
00062     {this->ResizeAndExtend (this->MaxId+1);}
00064 
00066   virtual void Resize(vtkIdType numTuples);
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 
00103   vtkIdType GetValue(const vtkIdType id) 
00104     {return this->Array[id];}
00106 
00108 
00110   void SetValue(const vtkIdType id, const vtkIdType value) 
00111     {this->Array[id] = value;}
00113 
00117   void SetNumberOfValues(const vtkIdType number);
00118 
00120   void InsertValue(const vtkIdType id, const vtkIdType i);
00121 
00124   vtkIdType InsertNextValue(const vtkIdType i);
00125 
00127 
00129   vtkIdType *GetPointer(const vtkIdType id) 
00130     {return this->Array + id;}
00131   void *GetVoidPointer(const vtkIdType id) 
00132     {return (void *)this->GetPointer(id);}
00134 
00138   vtkIdType *WritePointer(const vtkIdType id, const vtkIdType number);
00139 
00141   void DeepCopy(vtkDataArray *ia);
00142 
00144 
00150   void SetArray(vtkIdType* array, vtkIdType size, int save);
00151   void SetVoidArray(void *array, vtkIdType size, int save) 
00152     {this->SetArray((vtkIdType*)array, size, save);};
00154 
00155 protected:
00156   vtkIdTypeArray(vtkIdType numComp=1);
00157   ~vtkIdTypeArray();
00158 
00159   vtkIdType *Array;   // pointer to data
00160   vtkIdType *ResizeAndExtend(const vtkIdType sz);  // function to resize data
00161 
00162   int TupleSize; //used for data conversion
00163   float *Tuple;
00164 
00165   int SaveUserArray;
00166 private:
00167   vtkIdTypeArray(const vtkIdTypeArray&);  // Not implemented.
00168   void operator=(const vtkIdTypeArray&);  // Not implemented.
00169 };
00170 
00171 
00172 inline void vtkIdTypeArray::SetNumberOfValues(const vtkIdType number) 
00173 {
00174   this->Allocate(number);
00175   this->MaxId = number - 1;
00176 }
00177 
00178 inline vtkIdType *vtkIdTypeArray::WritePointer(const vtkIdType id,
00179                                                const vtkIdType number)
00180 {
00181   vtkIdType newSize=id+number;
00182   if ( newSize > this->Size )
00183     {
00184     this->ResizeAndExtend(newSize);
00185     }
00186   if ( (--newSize) > this->MaxId )
00187     {
00188     this->MaxId = newSize;
00189     }
00190   return this->Array + id;
00191 }
00192 
00193 inline void vtkIdTypeArray::InsertValue(const vtkIdType id, const vtkIdType i)
00194 {
00195   if ( id >= this->Size )
00196     {
00197     this->ResizeAndExtend(id+1);
00198     }
00199   this->Array[id] = i;
00200   if ( id > this->MaxId )
00201     {
00202     this->MaxId = id;
00203     }
00204 }
00205 
00206 inline vtkIdType vtkIdTypeArray::InsertNextValue(const vtkIdType i)
00207 {
00208   this->InsertValue (++this->MaxId,i); 
00209   return this->MaxId;
00210 }
00211 
00212 
00213 #endif