00001 # ifndef Conjecture_PixelLine_h
00002 # define Conjecture_PixelLine_h Conjecture_PixelLine_h
00003
00004
00005
00006
00007
00008 # include "Root.h"
00009
00010 namespace Conjecture {
00011 class OptIm;
00012
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 class PixelLine : public Root {
00039 public:
00040 static const u1 MaxPixels = 31;
00041
00042
00043 PixelLine(u4 pixels);
00044
00045
00046 inline u1 holes() const { return this->_holes; }
00047 inline u4 pixels() const { return this->_pixels; }
00048 inline u1 black() const { return this->_black; }
00049
00050
00051
00052
00053
00062 inline bool get(unsigned i) const {
00063 return (this->pixels() & (1<<i)) ? true : false;
00064 }
00065
00075 void set(unsigned i);
00076
00086 void clear(unsigned i);
00087
00093 std::string str(char on = '#', char off = '.', u1 size = 31) const;
00094 inline std::string str(u1 size) const { return this->str('#','.',size); }
00095
00106 void assign(const PixelLine& other, u1 rightdel = 0);
00107
00108 static void test(int argc = 0, const char* argv[] = NULL);
00109
00110 protected:
00111
00112 inline const bool & updated() const { return this->_updated; }
00113 inline void updatedIs(const bool & updated) { this->_updated = updated; }
00114 inline void blackIs(const u1 & black) { this->_black = black; }
00115 inline void holesIs(const u1 & holes) { this->_holes = holes; }
00116 inline void pixelsIs(const u4 & pixels) { this->_pixels = pixels; }
00117
00118
00119 inline void rawset(unsigned i) { this->_pixels |= (1<<i); }
00120 inline void rawclear(unsigned i) { this->_pixels &= ~(1<<i); }
00121
00122 inline void rawline(u4 pixels) { this->_pixels = pixels; this->updatedIs(false); }
00123
00124
00125 private:
00126 * PixFilt needs access to rawset and rawclear for efficiency
00127 friend class PixFilt;
00128 * OptIm needs to set the pixel data
00129 friend class OptIm;
00130
00131
00132
00133
00134 void updateMeta();
00135
00136
00137
00148 u4 _pixels;
00149
00163 unsigned int _holes:4;
00164
00172 u1 _black:5;
00173
00182 bool _updated;
00183
00193 };
00194 }
00195
00196 # endif // Conjecture_PixelLine_h
00197