10 #ifndef RC_BITFIELD3D_H
11 #define RC_BITFIELD3D_H
31 void Initialize(
size_t new_b_size1,
size_t new_b_size2,
33 b_size1 = new_b_size1;
34 b_size2 = new_b_size2;
35 b_size3 = new_b_size3;
37 data =
Bitfield (b_size1 * b_size2 * b_size3);
55 explicit Bitfield3D(
size_t b_size1,
size_t b_size2,
size_t b_size3) {
56 Initialize(b_size1, b_size2, b_size3);
72 return ( (b_size1 == 0) || (b_size2 == 0) || (b_size3 == 0) );
86 return data[z*b_size2*b_size1 + y*b_size1 + x];
91 (
size_t x,
size_t y,
size_t z)
const {
93 return data[z*b_size2*b_size1 + y*b_size1 + x];
99 return data[z*b_size2*b_size1 + y*b_size1 + x];
105 return data[z*b_size2*b_size1 + y*b_size1 + x];
110 inline size_t size1()
const {
return b_size1; }
112 inline size_t size2()
const {
return b_size2; }
114 inline size_t size3()
const {
return b_size3; }
124 size_t z_start, z_fact;
128 z_fact = b_size2*b_size1;
129 z_start = z * z_fact;
131 data.ZeroRange(z_start, z_start+z_fact-1);
136 inline void Zero1D(
const size_t y,
const size_t z) {
141 y_start = z * b_size2 * b_size1 + y * b_size1;
143 data.ZeroRange(y_start, y_start + b_size1 - 1);
148 inline bool Check(
const size_t x,
const size_t y,
const size_t z)
const {
149 if ( ! ((x < b_size1) && (y < b_size2) && (z < b_size3)) ) {
159 inline void Assert(
const size_t x,
const size_t y,
const size_t z)
const {
160 if ( !
Check(x, y, z) ) {
171 swap(a.data, b.data);
194 for (k=0; k<b.
size3(); k++) {
195 for (j=0; j<b.
size2(); j++) {
196 for (i=0; i<b.
size1(); i++) {
Provides a two-dimensional structure of packed bits.
Provides a one-dimensional vector-like structure of packed bits.
Provides a one-dimensional vector-like structure.
Provides informative exception handling.
#define Throw_RC_Type(Type, err)
Use this to throw an RC:ErrorMsg subtype exception.
Definition: Errors.h:282
A bounds-safe three-dimensional structure of efficiently packed bits.
Definition: Bitfield3D.h:28
Bitfield3D()
Default constructor which initializes to size 0, 0, 0.
Definition: Bitfield3D.h:43
bool IsEmpty() const
True of the total size of the bits is 0.
Definition: Bitfield3D.h:71
Bitfield::BitfieldBoolConst At(size_t x, size_t y, size_t z) const
Const version of At()
Definition: Bitfield3D.h:103
void Zero1D(const size_t y, const size_t z)
Set all bits of dimension 1 to zero at y and z indexed dimensions 2 and 3.
Definition: Bitfield3D.h:136
size_t size1() const
Return the extent in bits of dimension 1.
Definition: Bitfield3D.h:110
friend void swap(Bitfield3D &a, Bitfield3D &b)
Swap the data in Bitfield3D a and b.
Definition: Bitfield3D.h:167
Bitfield::BitfieldBool operator()(size_t x, size_t y, size_t z)
Bounds-checked access of the indexed element.
Definition: Bitfield3D.h:84
void Delete()
Deletes the stored data, resets the sizes to 0, and releases the memory.
Definition: Bitfield3D.h:62
void Zero()
Set all bits to 0 / false.
Definition: Bitfield3D.h:118
bool Check(const size_t x, const size_t y, const size_t z) const
True of indices x, y, and z are all in bounds.
Definition: Bitfield3D.h:148
size_t size3() const
Return the extent in bits of dimension 3.
Definition: Bitfield3D.h:114
Bitfield::BitfieldBool At(size_t x, size_t y, size_t z)
Identical to operator()
Definition: Bitfield3D.h:97
void Assert(const size_t x, const size_t y, const size_t z) const
Throws ErrorMsgBounds if index x, y, or z is out of bounds.
Definition: Bitfield3D.h:159
size_t size2() const
Return the extent in bits of dimension 2.
Definition: Bitfield3D.h:112
Bitfield3D(size_t b_size1, size_t b_size2, size_t b_size3)
Cosntructor which sets the initial sizes.
Definition: Bitfield3D.h:55
void Zero2D(const size_t z)
Set all bits of dimensions 1 and 2 to zero at z indexed dimension 3.
Definition: Bitfield3D.h:123
A temporary return-type that serves as a const interface to specific bit values.
Definition: Bitfield.h:132
A temporary return-type that serves as an interface to specific bit values.
Definition: Bitfield.h:79
A bounds-safe one-dimensional vector-like structure of efficiently packed bits.
Definition: Bitfield.h:27
std::ostream & operator<<(std::ostream &out, APtr< T > obj)
A convenience stream output for displaying the enclosed object.
Definition: APtr.h:120
void swap(RC::Data1D< T > &a, RC::Data1D< T > &b)
Efficiently swap all the contents of a and b.
Definition: Data1D.h:1184