Go to the documentation of this file.00001
00002 #ifndef vbl_bit_array_3d_h_
00003 #define vbl_bit_array_3d_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <vcl_iosfwd.h>
00023
00024 class vbl_bit_array_3d
00025 {
00026 public:
00027
00028
00029
00030 vbl_bit_array_3d(unsigned int sizex, unsigned int sizey, unsigned int sizez)
00031 { construct(sizex, sizey, sizez); }
00032
00033
00034 vbl_bit_array_3d(unsigned int sizex, unsigned int sizey, unsigned int sizez, bool v)
00035 { construct(sizex, sizey, sizez); fill(v); }
00036
00037 vbl_bit_array_3d(unsigned int sizex, unsigned int sizey, unsigned int sizez, bool v[]);
00038
00039 vbl_bit_array_3d(vbl_bit_array_3d const &);
00040
00041 ~vbl_bit_array_3d() { delete[] data_; }
00042
00043
00044 vbl_bit_array_3d& operator=(vbl_bit_array_3d const&);
00045
00046
00047 bool operator==(vbl_bit_array_3d const &a) const;
00048
00049 bool operator!=(vbl_bit_array_3d const &a) const { return ! operator==(a); }
00050
00051
00052
00053
00054 void fill(bool v);
00055
00056
00057 void resize(unsigned int m, unsigned int n, unsigned int p) { destruct(); construct(m,n,p); }
00058
00059
00060 void clear() { if (data_) { destruct(); row1_count_=row2_count_=row3_count_=0; } }
00061
00062
00063 void put(unsigned int i1, unsigned int i2, unsigned int i3, bool v);
00064
00065
00066 void set(unsigned int i1, unsigned int i2, unsigned int i3, bool v=true)
00067 { put(i1, i2, i3, v); }
00068
00069
00070 bool get(unsigned int i1, unsigned int i2, unsigned int i3) const;
00071
00072
00073 void flip(unsigned int i1, unsigned int i2, unsigned int i3);
00074
00075
00076 bool operator() (unsigned int i1, unsigned int i2, unsigned int i3) const;
00077
00078 unsigned int row1_count() const { return row1_count_; }
00079 unsigned int row2_count() const { return row2_count_; }
00080 unsigned int row3_count() const { return row3_count_; }
00081
00082 unsigned long size() const;
00083
00084 private:
00085
00086
00087 unsigned int row1_count_;
00088 unsigned int row2_count_;
00089 unsigned int row3_count_;
00090 unsigned char *data_;
00091
00092
00093
00094 void destruct() { delete[] data_; data_=0; }
00095 void construct(unsigned int m, unsigned int n, unsigned int p);
00096
00097 void index(unsigned int x, unsigned int y, unsigned int z,
00098 unsigned long &byteindex, unsigned char &bitindex) const;
00099 };
00100
00101 vcl_ostream &operator<<(vcl_ostream &os, vbl_bit_array_3d const&);
00102
00103 #endif // vbl_bit_array_3d_h_