dox/Common/vtkBitArray.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00028
#ifndef __vtkBitArray_h
00029
#define __vtkBitArray_h
00030
00031
#include "vtkDataArray.h"
00032
00033 class VTK_COMMON_EXPORT vtkBitArray :
public vtkDataArray
00034 {
00035
public:
00036
static vtkBitArray *
New();
00037 vtkTypeRevisionMacro(vtkBitArray,
vtkDataArray);
00038
void PrintSelf(ostream& os,
vtkIndent indent);
00039
00042
int Allocate(
const vtkIdType sz,
const vtkIdType ext=1000);
00043
00045
void Initialize();
00046
00047
00048 int GetDataType() {
return VTK_BIT;};
00049 int GetDataTypeSize() {
return 0; }
00050
00052
void SetNumberOfTuples(
const vtkIdType number);
00053
00056
float *
GetTuple(
const vtkIdType i);
00057
00059
00060
void GetTuple(
const vtkIdType i,
float * tuple);
00061
void GetTuple(
const vtkIdType i,
double * tuple);
00063
00065
00066
void SetTuple(
const vtkIdType i,
const float * tuple);
00067
void SetTuple(
const vtkIdType i,
const double * tuple);
00069
00071
00073
void InsertTuple(
const vtkIdType i,
const float * tuple);
00074
void InsertTuple(
const vtkIdType i,
const double * tuple);
00076
00078
00080
vtkIdType InsertNextTuple(
const float * tuple);
00081
vtkIdType InsertNextTuple(
const double * tuple);
00083
00088
void SetComponent(
const vtkIdType i,
const int j,
float c);
00089
00091
void Squeeze();
00092
00094
virtual void Resize(
vtkIdType numTuples);
00095
00097
int GetValue(
const vtkIdType id);
00098
00104
void SetNumberOfValues(
const vtkIdType number);
00105
00108
void SetValue(
const vtkIdType id,
const int value);
00109
00111
00112
void InsertValue(
const vtkIdType id,
const int i);
00113
vtkIdType InsertNextValue(
const int i);
00115
00119
virtual void InsertComponent(
const vtkIdType i,
const int j,
float c);
00120
00122 unsigned char *GetPointer(
const vtkIdType id) {
return this->Array +
id/8;}
00123
00125
00128
unsigned char *WritePointer(
const vtkIdType id,
const vtkIdType number);
00129 void *
GetVoidPointer(
const vtkIdType id)
00130 {
return (
void *)this->GetPointer(
id);};
00132
00134
void DeepCopy(
vtkDataArray *da);
00135
00137
00143
void SetArray(
unsigned char* array,
vtkIdType size,
int save);
00144 void SetVoidArray(
void *array,
vtkIdType size,
int save)
00145 {this->SetArray((
unsigned char *)array, size, save);};
00147
00148
00149
protected:
00150 vtkBitArray(
vtkIdType numComp=1);
00151 ~vtkBitArray();
00152
00153 unsigned char *Array;
00154
unsigned char *ResizeAndExtend(
const vtkIdType sz);
00155
00156
00157 int TupleSize;
00158 float *Tuple;
00159
00160 int SaveUserArray;
00161
00162
private:
00163
00164
void DeepCopy(
vtkDataArray &da) {this->
vtkDataArray::DeepCopy(&da);}
00165
00166
private:
00167 vtkBitArray(
const vtkBitArray&);
00168
void operator=(
const vtkBitArray&);
00169 };
00170
00171 inline unsigned char *
vtkBitArray::WritePointer(
const vtkIdType id,
00172
const vtkIdType number)
00173 {
00174
vtkIdType newSize=
id+number;
00175
if ( newSize > this->Size )
00176 {
00177 this->
ResizeAndExtend(newSize);
00178 }
00179
if ( (--newSize) > this->MaxId )
00180 {
00181 this->MaxId = newSize;
00182 }
00183
return this->
Array +
id/8;
00184 }
00185
00186 inline void vtkBitArray::SetNumberOfValues(
const vtkIdType number)
00187 {
00188 this->
Allocate(number);
00189 this->MaxId = number - 1;
00190 }
00191
00192 inline void vtkBitArray::SetValue(
const vtkIdType id,
const int value)
00193 {
00194
if (value)
00195 {
00196 this->
Array[
id/8] |= (0x80 >>
id%8);
00197 }
00198
else
00199 {
00200 this->
Array[
id/8] &= (~(0x80 >>
id%8));
00201 }
00202 }
00203
00204 inline void vtkBitArray::InsertValue(
const vtkIdType id,
const int i)
00205 {
00206
if (
id >= this->Size )
00207 {
00208 this->
ResizeAndExtend(
id+1);
00209 }
00210
if (i)
00211 {
00212 this->
Array[
id/8] |= (0x80 >>
id%8);
00213 }
00214
else
00215 {
00216 this->
Array[
id/8] &= (~(0x80 >>
id%8));
00217 }
00218
if (
id > this->MaxId )
00219 {
00220 this->MaxId =
id;
00221 }
00222 }
00223
00224 inline vtkIdType vtkBitArray::InsertNextValue(
const int i)
00225 {
00226 this->
InsertValue (++this->MaxId,i);
return this->MaxId;
00227 }
00228
00229 inline void vtkBitArray::Squeeze() {this->
ResizeAndExtend (this->MaxId+1);}
00230
00231
#endif
00232