VTK
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
dox
Common
vtkBitArray.h
Go to the documentation of this file.
1
/*=========================================================================
2
3
Program: Visualization Toolkit
4
Module: vtkBitArray.h
5
6
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7
All rights reserved.
8
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10
This software is distributed WITHOUT ANY WARRANTY; without even
11
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12
PURPOSE. See the above copyright notice for more information.
13
14
=========================================================================*/
27
#ifndef __vtkBitArray_h
28
#define __vtkBitArray_h
29
30
#include "
vtkDataArray.h
"
31
32
class
vtkBitArrayLookup;
33
34
class
VTK_COMMON_EXPORT
vtkBitArray
:
public
vtkDataArray
35
{
36
public
:
37
static
vtkBitArray
*
New
();
38
vtkTypeMacro(
vtkBitArray
,
vtkDataArray
);
39
void
PrintSelf
(ostream& os,
vtkIndent
indent);
40
43
int
Allocate
(
vtkIdType
sz,
vtkIdType
ext=1000);
44
46
void
Initialize
();
47
48
// satisfy vtkDataArray API
49
int
GetDataType
() {
return
VTK_BIT
;};
50
int
GetDataTypeSize
() {
return
0; }
51
53
void
SetNumberOfTuples
(
vtkIdType
number);
54
60
virtual
void
SetTuple
(
vtkIdType
i,
vtkIdType
j,
vtkAbstractArray
*
source
);
61
65
virtual
void
InsertTuple
(
vtkIdType
i,
vtkIdType
j,
vtkAbstractArray
*
source
);
66
70
virtual
vtkIdType
InsertNextTuple
(
vtkIdType
j,
vtkAbstractArray
*
source
);
71
74
double
*
GetTuple
(
vtkIdType
i);
75
77
void
GetTuple
(
vtkIdType
i,
double
* tuple);
78
80
81
void
SetTuple
(
vtkIdType
i,
const
float
* tuple);
82
void
SetTuple
(
vtkIdType
i,
const
double
* tuple);
84
86
88
void
InsertTuple
(
vtkIdType
i,
const
float
* tuple);
89
void
InsertTuple
(
vtkIdType
i,
const
double
* tuple);
91
93
95
vtkIdType
InsertNextTuple
(
const
float
* tuple);
96
vtkIdType
InsertNextTuple
(
const
double
* tuple);
98
100
103
virtual
void
RemoveTuple
(
vtkIdType
id
);
104
virtual
void
RemoveFirstTuple
();
105
virtual
void
RemoveLastTuple
();
107
112
void
SetComponent
(
vtkIdType
i,
int
j,
double
c);
113
115
void
Squeeze
();
116
118
virtual
int
Resize
(
vtkIdType
numTuples);
119
121
int
GetValue(
vtkIdType
id
);
122
128
void
SetNumberOfValues(
vtkIdType
number);
129
132
void
SetValue(
vtkIdType
id
,
int
value
);
133
135
void
InsertValue(
vtkIdType
id
,
int
i);
136
138
void
SetVariantValue
(
vtkIdType
idx,
vtkVariant
value
);
139
140
vtkIdType
InsertNextValue(
int
i);
141
145
virtual
void
InsertComponent
(
vtkIdType
i,
int
j,
double
c);
146
148
unsigned
char
*
GetPointer
(
vtkIdType
id
) {
return
this->Array +
id
/8;}
149
151
154
unsigned
char
*WritePointer(
vtkIdType
id
,
vtkIdType
number);
155
void
*
WriteVoidPointer
(
vtkIdType
id
,
vtkIdType
number)
156
{
return
this->WritePointer(
id
, number); }
157
void
*
GetVoidPointer
(
vtkIdType
id
)
158
{
159
return
static_cast<
void
*
>
(this->GetPointer(
id
));
160
}
162
164
165
void
DeepCopy
(
vtkDataArray
*da);
166
void
DeepCopy
(
vtkAbstractArray
* aa)
167
{ this->Superclass::DeepCopy(aa); }
169
171
178
void
SetArray(
unsigned
char
* array,
vtkIdType
size
,
int
save
);
179
void
SetVoidArray
(
void
*array,
vtkIdType
size
,
int
save
)
180
{
181
this->SetArray(static_cast<unsigned char *>(array), size, save);
182
}
184
186
vtkArrayIterator
*
NewIterator
();
187
189
190
virtual
vtkIdType
LookupValue
(
vtkVariant
value
);
191
virtual
void
LookupValue
(
vtkVariant
value
,
vtkIdList
* ids);
192
vtkIdType
LookupValue
(
int
value
);
193
void
LookupValue
(
int
value
,
vtkIdList
* ids);
195
202
virtual
void
DataChanged
();
203
207
virtual
void
ClearLookup
();
208
209
protected
:
210
vtkBitArray
(
vtkIdType
numComp=1);
211
~
vtkBitArray
();
212
213
unsigned
char
*
Array
;
// pointer to data
214
unsigned
char
*ResizeAndExtend(
vtkIdType
sz);
215
// function to resize data
216
217
int
TupleSize
;
//used for data conversion
218
double
*
Tuple
;
219
220
int
SaveUserArray
;
221
222
private
:
223
// hide superclass' DeepCopy() from the user and the compiler
224
void
DeepCopy
(
vtkDataArray
&da) {this->
vtkDataArray::DeepCopy
(&da);}
225
226
private
:
227
vtkBitArray
(
const
vtkBitArray
&);
// Not implemented.
228
void
operator=(
const
vtkBitArray
&);
// Not implemented.
229
230
//BTX
231
vtkBitArrayLookup* Lookup;
232
void
UpdateLookup();
233
//ETX
234
};
235
236
inline
void
vtkBitArray::SetNumberOfValues
(
vtkIdType
number)
237
{
238
this->
Allocate
(number);
239
this->
MaxId
= number - 1;
240
this->
DataChanged
();
241
}
242
243
inline
void
vtkBitArray::SetValue
(
vtkIdType
id
,
int
value
)
244
{
245
if
(value)
246
{
247
this->
Array
[
id
/8] =
static_cast<
unsigned
char
>
(
248
this->
Array
[
id
/8] | (0x80 >>
id
%8));
249
}
250
else
251
{
252
this->
Array
[
id
/8] =
static_cast<
unsigned
char
>
(
253
this->
Array
[
id
/8] & (~(0x80 >>
id
%8)));
254
}
255
this->
DataChanged
();
256
}
257
258
inline
void
vtkBitArray::InsertValue
(
vtkIdType
id
,
int
i)
259
{
260
if
(
id
>= this->
Size
)
261
{
262
this->
ResizeAndExtend
(
id
+1);
263
}
264
if
(i)
265
{
266
this->
Array
[
id
/8] =
static_cast<
unsigned
char
>
(
267
this->
Array
[
id
/8] | (0x80 >>
id
%8));
268
}
269
else
270
{
271
this->
Array
[
id
/8] =
static_cast<
unsigned
char
>
(
272
this->
Array
[
id
/8] & (~(0x80 >>
id
%8)));
273
}
274
if
(
id
> this->
MaxId
)
275
{
276
this->
MaxId
= id;
277
}
278
this->
DataChanged
();
279
}
280
281
inline
void
vtkBitArray::SetVariantValue
(
vtkIdType
id
,
vtkVariant
value
)
282
{
283
this->
SetValue
(
id
, value.
ToInt
());
284
}
285
286
inline
vtkIdType
vtkBitArray::InsertNextValue
(
int
i)
287
{
288
this->
InsertValue
(++this->
MaxId
,i);
289
this->
DataChanged
();
290
return
this->
MaxId
;
291
}
292
293
inline
void
vtkBitArray::Squeeze
() {this->
ResizeAndExtend
(this->
MaxId
+1);}
294
295
#endif
296
Generated on Wed May 30 2012 13:21:50 for VTK by
1.8.1