Common/vtkCharArray.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00043 #ifndef __vtkCharArray_h
00044 #define __vtkCharArray_h
00045
00046 #include "vtkDataArray.h"
00047
00048 class VTK_COMMON_EXPORT vtkCharArray : public vtkDataArray
00049 {
00050 public:
00051 static vtkCharArray *New();
00052
00053 vtkTypeRevisionMacro(vtkCharArray,vtkDataArray);
00054 void PrintSelf(ostream& os, vtkIndent indent);
00055
00058 int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
00059
00061 void Initialize();
00062
00064 int GetDataType() {return VTK_CHAR;};
00065
00067 int GetDataTypeSize() { return sizeof(char); }
00068
00071 void SetNumberOfTuples(const vtkIdType number);
00072
00075 float *GetTuple(const vtkIdType i);
00076
00078
00079 void GetTuple(const vtkIdType i, float * tuple);
00080 void GetTuple(const vtkIdType i, double * tuple);
00082
00084
00085 void SetTuple(const vtkIdType i, const float * tuple);
00086 void SetTuple(const vtkIdType i, const double * tuple);
00088
00090
00092 void InsertTuple(const vtkIdType i, const float * tuple);
00093 void InsertTuple(const vtkIdType i, const double * tuple);
00095
00097
00099 vtkIdType InsertNextTuple(const float * tuple);
00100 vtkIdType InsertNextTuple(const double * tuple);
00102
00104 void Squeeze() {this->ResizeAndExtend (this->MaxId+1);}
00105
00107 virtual void Resize(vtkIdType numTuples);
00108
00112 float GetComponent(const vtkIdType i, const int j);
00113
00118 void SetComponent(const vtkIdType i, const int j, float c);
00119
00123 void InsertComponent(const vtkIdType i, const int j, float c);
00124
00126 char GetValue(const vtkIdType id) {return this->Array[id];};
00127
00129
00131 void SetValue(const vtkIdType id, const char value)
00132 { this->Array[id] = value;}
00134
00138 void SetNumberOfValues(const vtkIdType number);
00139
00143 char *WritePointer(const vtkIdType id, const vtkIdType number);
00144
00146 void InsertValue(const vtkIdType id, const char c);
00147
00150 vtkIdType InsertNextValue(const char c);
00151
00153
00155 void *GetVoidPointer(const vtkIdType id)
00156 {return (void *)this->GetPointer(id);};
00157 char *GetPointer(const vtkIdType id) {return this->Array + id;}
00159
00161 void DeepCopy(vtkDataArray *ia);
00162
00164
00170 void SetArray(char* array, vtkIdType size, int save);
00171 void SetVoidArray(void *array, vtkIdType size, int save)
00172 {this->SetArray((char*)array, size, save);};
00174
00175 protected:
00176 vtkCharArray(vtkIdType numComp=1);
00177 ~vtkCharArray();
00178
00179 char *Array;
00180 char *ResizeAndExtend(const vtkIdType sz);
00181
00182 int TupleSize;
00183 float *Tuple;
00184
00185 int SaveUserArray;
00186 private:
00187 vtkCharArray(const vtkCharArray&);
00188 void operator=(const vtkCharArray&);
00189 };
00190
00191
00192
00193
00194
00195 inline void vtkCharArray::SetNumberOfValues(const vtkIdType number)
00196 {
00197 this->Allocate(number);
00198 this->MaxId = number - 1;
00199 }
00200
00201
00202
00203
00204
00205 inline char *vtkCharArray::WritePointer(const vtkIdType id,
00206 const vtkIdType number)
00207 {
00208 vtkIdType newSize=id+number;
00209 if ( newSize > this->Size )
00210 {
00211 this->ResizeAndExtend(newSize);
00212 }
00213 if ( (--newSize) > this->MaxId )
00214 {
00215 this->MaxId = newSize;
00216 }
00217 return this->Array + id;
00218 }
00219
00220 inline void vtkCharArray::InsertValue(const vtkIdType id, const char c)
00221 {
00222 if ( id >= this->Size )
00223 {
00224 this->ResizeAndExtend(id+1);
00225 }
00226 this->Array[id] = c;
00227 if ( id > this->MaxId )
00228 {
00229 this->MaxId = id;
00230 }
00231 }
00232
00233 inline vtkIdType vtkCharArray::InsertNextValue(const char c)
00234 {
00235 this->InsertValue (++this->MaxId,c);
00236 return this->MaxId;
00237 }
00238
00239
00240 #endif