dox/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
00030
#ifndef __vtkCharArray_h
00031
#define __vtkCharArray_h
00032
00033
#include "vtkDataArray.h"
00034
00035 class VTK_COMMON_EXPORT vtkCharArray :
public vtkDataArray
00036 {
00037
public:
00038
static vtkCharArray *
New();
00039
00040 vtkTypeRevisionMacro(vtkCharArray,
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_CHAR;};
00052
00054 int GetDataTypeSize() {
return sizeof(
char); }
00055
00058
void SetNumberOfTuples(
const vtkIdType number);
00059
00062
float *
GetTuple(
const vtkIdType i);
00063
00065
00066
void GetTuple(
const vtkIdType i,
float * tuple);
00067
void GetTuple(
const vtkIdType i,
double * tuple);
00069
00071
00072
void SetTuple(
const vtkIdType i,
const float * tuple);
00073
void SetTuple(
const vtkIdType i,
const double * tuple);
00075
00077
00079
void InsertTuple(
const vtkIdType i,
const float * tuple);
00080
void InsertTuple(
const vtkIdType i,
const double * tuple);
00082
00084
00086
vtkIdType InsertNextTuple(
const float * tuple);
00087
vtkIdType InsertNextTuple(
const double * tuple);
00089
00091 void Squeeze() {this->ResizeAndExtend (this->MaxId+1);}
00092
00094
virtual void Resize(
vtkIdType numTuples);
00095
00099
float GetComponent(
const vtkIdType i,
const int j);
00100
00105
void SetComponent(
const vtkIdType i,
const int j,
float c);
00106
00110
void InsertComponent(
const vtkIdType i,
const int j,
float c);
00111
00113 char GetValue(
const vtkIdType id) {
return this->Array[
id];};
00114
00116
00118 void SetValue(
const vtkIdType id,
const char value)
00119 { this->Array[
id] = value;}
00121
00125
void SetNumberOfValues(
const vtkIdType number);
00126
00130
char *WritePointer(
const vtkIdType id,
const vtkIdType number);
00131
00133
void InsertValue(
const vtkIdType id,
const char c);
00134
00137
vtkIdType InsertNextValue(
const char c);
00138
00140
00142 void *
GetVoidPointer(
const vtkIdType id)
00143 {
return (
void *)this->GetPointer(
id);};
00144 char *GetPointer(
const vtkIdType id) {
return this->Array +
id;}
00146
00148
void DeepCopy(
vtkDataArray *ia);
00149
00151
00157
void SetArray(
char* array,
vtkIdType size,
int save);
00158 void SetVoidArray(
void *array,
vtkIdType size,
int save)
00159 {this->SetArray((
char*)array, size, save);};
00161
00162
protected:
00163 vtkCharArray(
vtkIdType numComp=1);
00164 ~vtkCharArray();
00165
00166 char *Array;
00167
char *ResizeAndExtend(
const vtkIdType sz);
00168
00169 int TupleSize;
00170 float *Tuple;
00171
00172 int SaveUserArray;
00173
private:
00174 vtkCharArray(
const vtkCharArray&);
00175
void operator=(
const vtkCharArray&);
00176 };
00177
00178
00179
00180
00181
00182 inline void vtkCharArray::SetNumberOfValues(
const vtkIdType number)
00183 {
00184 this->
Allocate(number);
00185 this->MaxId = number - 1;
00186 }
00187
00188
00189
00190
00191
00192 inline char *
vtkCharArray::WritePointer(
const vtkIdType id,
00193
const vtkIdType number)
00194 {
00195
vtkIdType newSize=
id+number;
00196
if ( newSize > this->Size )
00197 {
00198 this->
ResizeAndExtend(newSize);
00199 }
00200
if ( (--newSize) > this->MaxId )
00201 {
00202 this->MaxId = newSize;
00203 }
00204
return this->
Array +
id;
00205 }
00206
00207 inline void vtkCharArray::InsertValue(
const vtkIdType id,
const char c)
00208 {
00209
if (
id >= this->Size )
00210 {
00211 this->
ResizeAndExtend(
id+1);
00212 }
00213 this->
Array[
id] = c;
00214
if (
id > this->MaxId )
00215 {
00216 this->MaxId =
id;
00217 }
00218 }
00219
00220 inline vtkIdType vtkCharArray::InsertNextValue(
const char c)
00221 {
00222 this->
InsertValue (++this->MaxId,c);
00223
return this->MaxId;
00224 }
00225
00226
00227
#endif