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

dox/Common/vtkIntArray.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkIntArray.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 =========================================================================*/ 00033 #ifndef __vtkIntArray_h 00034 #define __vtkIntArray_h 00035 00036 #include "vtkDataArray.h" 00037 00038 class VTK_COMMON_EXPORT vtkIntArray : public vtkDataArray 00039 { 00040 public: 00041 static vtkIntArray *New(); 00042 00043 vtkTypeRevisionMacro(vtkIntArray,vtkDataArray); 00044 void PrintSelf(ostream& os, vtkIndent indent); 00045 00048 int Allocate(const vtkIdType sz, const vtkIdType ext=1000); 00049 00051 void Initialize(); 00052 00054 00055 int GetDataType() 00056 {return VTK_INT;} 00058 00060 int GetDataTypeSize() { return sizeof(int); } 00061 00063 00064 void Squeeze() 00065 {this->ResizeAndExtend (this->MaxId+1);} 00067 00069 virtual void Resize(vtkIdType numTuples); 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 00106 int GetValue(const vtkIdType id) 00107 {return this->Array[id];} 00109 00111 00113 void SetValue(const vtkIdType id, const int value) 00114 {this->Array[id] = value;} 00116 00120 void SetNumberOfValues(const vtkIdType number); 00121 00123 void InsertValue(const vtkIdType id, const int i); 00124 00127 vtkIdType InsertNextValue(const int i); 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 int *GetPointer(const vtkIdType id) 00149 {return this->Array + id;} 00150 void *GetVoidPointer(const vtkIdType id) 00151 {return (void *)this->GetPointer(id);} 00153 00157 int *WritePointer(const vtkIdType id, const vtkIdType number); 00158 00160 void DeepCopy(vtkDataArray *ia); 00161 00163 00169 void SetArray(int* array, vtkIdType size, int save); 00170 void SetVoidArray(void *array,vtkIdType size, int save) 00171 {this->SetArray((int*)array, size, save);}; 00173 00174 protected: 00175 vtkIntArray(vtkIdType numComp=1); 00176 ~vtkIntArray(); 00177 00178 int *Array; // pointer to data 00179 int *ResizeAndExtend(const vtkIdType sz); // function to resize data 00180 00181 int TupleSize; //used for data conversion 00182 float *Tuple; 00183 00184 int SaveUserArray; 00185 private: 00186 vtkIntArray(const vtkIntArray&); // Not implemented. 00187 void operator=(const vtkIntArray&); // Not implemented. 00188 }; 00189 00190 00191 inline void vtkIntArray::SetNumberOfValues(const vtkIdType number) 00192 { 00193 this->Allocate(number); 00194 this->MaxId = number - 1; 00195 } 00196 00197 inline int *vtkIntArray::WritePointer(const vtkIdType id, 00198 const vtkIdType number) 00199 { 00200 vtkIdType newSize=id+number; 00201 if ( newSize > this->Size ) 00202 { 00203 this->ResizeAndExtend(newSize); 00204 } 00205 if ( (--newSize) > this->MaxId ) 00206 { 00207 this->MaxId = newSize; 00208 } 00209 return this->Array + id; 00210 } 00211 00212 inline void vtkIntArray::InsertValue(const vtkIdType id, const int i) 00213 { 00214 if ( id >= this->Size ) 00215 { 00216 this->ResizeAndExtend(id+1); 00217 } 00218 this->Array[id] = i; 00219 if ( id > this->MaxId ) 00220 { 00221 this->MaxId = id; 00222 } 00223 } 00224 00225 inline vtkIdType vtkIntArray::InsertNextValue(const int i) 00226 { 00227 this->InsertValue (++this->MaxId,i); 00228 return this->MaxId; 00229 } 00230 00231 00232 #endif