00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00054 #ifndef __vtkCharArray_h
00055 #define __vtkCharArray_h
00056
00057 #include "vtkDataArray.h"
00058
00059 class VTK_COMMON_EXPORT vtkCharArray : public vtkDataArray
00060 {
00061 public:
00062 static vtkCharArray *New();
00063
00064 vtkTypeMacro(vtkCharArray,vtkDataArray);
00065 void PrintSelf(ostream& os, vtkIndent indent);
00066
00069 int Allocate(const vtkIdType sz, const vtkIdType ext=1000);
00070
00072 void Initialize();
00073
00075 vtkDataArray *MakeObject();
00076
00078 int GetDataType() {return VTK_CHAR;};
00079
00082 void SetNumberOfTuples(const vtkIdType number);
00083
00086 float *GetTuple(const vtkIdType i);
00087
00089
00090 void GetTuple(const vtkIdType i, float * tuple);
00091 void GetTuple(const vtkIdType i, double * tuple);
00093
00095
00096 void SetTuple(const vtkIdType i, const float * tuple);
00097 void SetTuple(const vtkIdType i, const double * tuple);
00099
00101
00103 void InsertTuple(const vtkIdType i, const float * tuple);
00104 void InsertTuple(const vtkIdType i, const double * tuple);
00106
00108
00110 vtkIdType InsertNextTuple(const float * tuple);
00111 vtkIdType InsertNextTuple(const double * tuple);
00113
00115 void Squeeze() {this->ResizeAndExtend (this->MaxId+1);}
00116
00118 virtual void Resize(vtkIdType numTuples);
00119
00123 float GetComponent(const vtkIdType i, const int j);
00124
00129 void SetComponent(const vtkIdType i, const int j, const float c);
00130
00134 void InsertComponent(const vtkIdType i, const int j, const float c);
00135
00137 char GetValue(const vtkIdType id) {return this->Array[id];};
00138
00140
00142 void SetValue(const vtkIdType id, const char value)
00143 { this->Array[id] = value;}
00145
00149 void SetNumberOfValues(const vtkIdType number);
00150
00154 char *WritePointer(const vtkIdType id, const vtkIdType number);
00155
00157 void InsertValue(const vtkIdType id, const char c);
00158
00161 vtkIdType InsertNextValue(const char c);
00162
00164
00166 void *GetVoidPointer(const vtkIdType id)
00167 {return (void *)this->GetPointer(id);};
00168 char *GetPointer(const vtkIdType id) {return this->Array + id;}
00170
00172 void DeepCopy(vtkDataArray *ia);
00173
00175
00181 void SetArray(char* array, vtkIdType size, int save);
00182 void SetVoidArray(void *array, vtkIdType size, int save)
00183 {this->SetArray((char*)array, size, save);};
00185
00186 protected:
00187 vtkCharArray(vtkIdType numComp=1);
00188 ~vtkCharArray();
00189
00190 char *Array;
00191 char *ResizeAndExtend(const vtkIdType sz);
00192
00193 int TupleSize;
00194 float *Tuple;
00195
00196 int SaveUserArray;
00197 private:
00198 vtkCharArray(const vtkCharArray&);
00199 void operator=(const vtkCharArray&);
00200 };
00201
00202
00203
00204
00205
00206 inline void vtkCharArray::SetNumberOfValues(const vtkIdType number)
00207 {
00208 this->Allocate(number);
00209 this->MaxId = number - 1;
00210 }
00211
00212
00213
00214
00215
00216 inline char *vtkCharArray::WritePointer(const vtkIdType id,
00217 const vtkIdType number)
00218 {
00219 vtkIdType newSize=id+number;
00220 if ( newSize > this->Size )
00221 {
00222 this->ResizeAndExtend(newSize);
00223 }
00224 if ( (--newSize) > this->MaxId )
00225 {
00226 this->MaxId = newSize;
00227 }
00228 return this->Array + id;
00229 }
00230
00231 inline void vtkCharArray::InsertValue(const vtkIdType id, const char c)
00232 {
00233 if ( id >= this->Size )
00234 {
00235 this->ResizeAndExtend(id+1);
00236 }
00237 this->Array[id] = c;
00238 if ( id > this->MaxId )
00239 {
00240 this->MaxId = id;
00241 }
00242 }
00243
00244 inline vtkIdType vtkCharArray::InsertNextValue(const char c)
00245 {
00246 this->InsertValue (++this->MaxId,c);
00247 return this->MaxId;
00248 }
00249
00250
00251 #endif