vtkUnsignedCharArray.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00030 #ifndef __vtkUnsignedCharArray_h
00031 #define __vtkUnsignedCharArray_h
00032
00033 #include "vtkDataArray.h"
00034
00035 class VTK_COMMON_EXPORT vtkUnsignedCharArray : public vtkDataArray
00036 {
00037 public:
00038 static vtkUnsignedCharArray *New();
00039
00040 vtkTypeRevisionMacro(vtkUnsignedCharArray,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 int GetDataType() {return VTK_UNSIGNED_CHAR;};
00052
00054 int GetDataTypeSize() { return sizeof(unsigned char); }
00055
00057 void SetNumberOfTuples(const vtkIdType number);
00058
00061 float *GetTuple(const vtkIdType i);
00062
00064
00065 void GetTuple(const vtkIdType i, float * tuple);
00066 void GetTuple(const vtkIdType i, double * tuple);
00068
00070
00071 void SetTuple(const vtkIdType i, const float * tuple);
00072 void SetTuple(const vtkIdType i, const double * tuple);
00074
00076
00078 void InsertTuple(const vtkIdType i, const float * tuple);
00079 void InsertTuple(const vtkIdType i, const double * tuple);
00081
00083
00085 vtkIdType InsertNextTuple(const float * tuple);
00086 vtkIdType InsertNextTuple(const double * tuple);
00088
00090 void Squeeze() {this->ResizeAndExtend (this->MaxId+1);};
00091
00093 virtual void Resize(vtkIdType numTuples);
00094
00098 float GetComponent(const vtkIdType i, const int j);
00099
00104 void SetComponent(const vtkIdType i, const int j, float c);
00105
00109 void InsertComponent(const vtkIdType i, const int j, float c);
00110
00112 unsigned char GetValue(const vtkIdType id) {return this->Array[id];};
00113
00115
00117 void SetValue(const vtkIdType id, const unsigned char value) {
00118 this->Array[id] = value;};
00120
00124 void SetNumberOfValues(const vtkIdType number);
00125
00127 void InsertValue(const vtkIdType id, const unsigned char c);
00128
00131 vtkIdType InsertNextValue(const unsigned char c);
00132
00134
00136 unsigned char *GetPointer(const vtkIdType id) {return this->Array + id;}
00137 void *GetVoidPointer(const vtkIdType id)
00138 {return (void *)this->GetPointer(id);};
00140
00144 unsigned char *WritePointer(const vtkIdType id, const vtkIdType number);
00145
00147 void DeepCopy(vtkDataArray *da);
00148
00150
00156 void SetArray(unsigned char* array, vtkIdType size, int save);
00157 void SetVoidArray(void *array, vtkIdType size, int save)
00158 {this->SetArray((unsigned char*)array, size, save);};
00160
00161
00162 protected:
00163 vtkUnsignedCharArray(vtkIdType numComp=1);
00164 ~vtkUnsignedCharArray();
00165
00166 unsigned char *Array;
00167 unsigned char *ResizeAndExtend(const vtkIdType sz);
00168
00169
00170 int TupleSize;
00171 float *Tuple;
00172
00173 int SaveUserArray;
00174 private:
00175 vtkUnsignedCharArray(const vtkUnsignedCharArray&);
00176 void operator=(const vtkUnsignedCharArray&);
00177 };
00178
00179 inline void vtkUnsignedCharArray::SetNumberOfValues(const vtkIdType number)
00180 {
00181 this->Allocate(number);
00182 this->MaxId = number - 1;
00183 }
00184
00185 inline unsigned char *vtkUnsignedCharArray::WritePointer(const vtkIdType id,
00186 const vtkIdType number)
00187 {
00188 vtkIdType newSize=id+number;
00189 if ( newSize > this->Size )
00190 {
00191 this->ResizeAndExtend(newSize);
00192 }
00193 if ( (--newSize) > this->MaxId )
00194 {
00195 this->MaxId = newSize;
00196 }
00197 return this->Array + id;
00198 }
00199
00200 inline void vtkUnsignedCharArray::InsertValue(const vtkIdType id,
00201 const unsigned char c)
00202 {
00203 if ( id >= this->Size )
00204 {
00205 this->ResizeAndExtend(id+1);
00206 }
00207 this->Array[id] = c;
00208 if ( id > this->MaxId )
00209 {
00210 this->MaxId = id;
00211 }
00212 }
00213
00214 inline vtkIdType vtkUnsignedCharArray::InsertNextValue(const unsigned char c)
00215 {
00216 this->InsertValue (++this->MaxId,c);
00217 return this->MaxId;
00218 }
00219
00220
00221 #endif