Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | 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 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00037 #ifndef __vtkIdTypeArray_h
00038 #define __vtkIdTypeArray_h
00039 
00040 #include "vtkDataArray.h"
00041 
00042 class VTK_COMMON_EXPORT vtkIdTypeArray : public vtkDataArray
00043 {
00044 public:
00045   static vtkIdTypeArray *New();
00046 
00047   vtkTypeRevisionMacro(vtkIdTypeArray, vtkDataArray);
00048   void PrintSelf(ostream& os, vtkIndent indent);
00049 
00052   int Allocate(vtkIdType sz, vtkIdType ext=1000);
00053   
00055   void Initialize();
00056 
00058 
00059   int GetDataType() 
00060     {return VTK_ID_TYPE;}
00062   
00064   int GetDataTypeSize() { return sizeof(vtkIdType); }
00065 
00067 
00068   void Squeeze() 
00069     {this->ResizeAndExtend (this->MaxId+1);}
00071 
00073   virtual void Resize(vtkIdType numTuples);
00074 
00076   void SetNumberOfTuples(vtkIdType number);
00077 
00080   double *GetTuple(vtkIdType i);
00081   
00083   void GetTuple(vtkIdType i, double * tuple);
00084 
00086 
00087   void SetTuple(vtkIdType i, const float * tuple);
00088   void SetTuple(vtkIdType i, const double * tuple);
00090 
00092 
00094   void InsertTuple(vtkIdType i, const float * tuple);
00095   void InsertTuple(vtkIdType i, const double * tuple);
00097 
00099 
00101   vtkIdType InsertNextTuple(const float * tuple);
00102   vtkIdType InsertNextTuple(const double * tuple);
00104 
00106 
00107   vtkIdType GetValue(vtkIdType id) 
00108     {return this->Array[id];}
00110 
00112 
00114   void SetValue(vtkIdType id, vtkIdType value) 
00115     {this->Array[id] = value;}
00117 
00121   void SetNumberOfValues(vtkIdType number);
00122 
00124   void InsertValue(vtkIdType id, vtkIdType i);
00125 
00128   vtkIdType InsertNextValue(vtkIdType i);
00129 
00131 
00133   vtkIdType *GetPointer(vtkIdType id) 
00134     {return this->Array + id;}
00135   void *GetVoidPointer(vtkIdType id) 
00136     {return (void *)this->GetPointer(id);}
00138 
00142   vtkIdType *WritePointer(vtkIdType id, vtkIdType number);
00143 
00145   void DeepCopy(vtkDataArray *ia);
00146 
00148 
00154   void SetArray(vtkIdType* array, vtkIdType size, int save);
00155   void SetVoidArray(void *array, vtkIdType size, int save) 
00156     {this->SetArray((vtkIdType*)array, size, save);};
00158 
00159 protected:
00160   vtkIdTypeArray(vtkIdType numComp=1);
00161   ~vtkIdTypeArray();
00162 
00163   vtkIdType *Array;   // pointer to data
00164   vtkIdType *ResizeAndExtend(vtkIdType sz);  // function to resize data
00165 
00166   int TupleSize; //used for data conversion
00167   double *Tuple;
00168 
00169   int SaveUserArray;
00170 private:
00171   vtkIdTypeArray(const vtkIdTypeArray&);  // Not implemented.
00172   void operator=(const vtkIdTypeArray&);  // Not implemented.
00173 };
00174 
00175 
00176 inline void vtkIdTypeArray::SetNumberOfValues(vtkIdType number) 
00177 {
00178   this->Allocate(number);
00179   this->MaxId = number - 1;
00180 }
00181 
00182 inline vtkIdType *vtkIdTypeArray::WritePointer(vtkIdType id,
00183                                                vtkIdType number)
00184 {
00185   vtkIdType newSize=id+number;
00186   if ( newSize > this->Size )
00187     {
00188     this->ResizeAndExtend(newSize);
00189     }
00190   if ( (--newSize) > this->MaxId )
00191     {
00192     this->MaxId = newSize;
00193     }
00194   return this->Array + id;
00195 }
00196 
00197 inline void vtkIdTypeArray::InsertValue(vtkIdType id, vtkIdType i)
00198 {
00199   if ( id >= this->Size )
00200     {
00201     this->ResizeAndExtend(id+1);
00202     }
00203   this->Array[id] = i;
00204   if ( id > this->MaxId )
00205     {
00206     this->MaxId = id;
00207     }
00208 }
00209 
00210 inline vtkIdType vtkIdTypeArray::InsertNextValue(vtkIdType i)
00211 {
00212   this->InsertValue (++this->MaxId,i); 
00213   return this->MaxId;
00214 }
00215 
00216 
00217 #endif