PixelLine.h

00001 # ifndef Conjecture_PixelLine_h
00002 # define Conjecture_PixelLine_h Conjecture_PixelLine_h
00003 
00004 // Insert SVN header substitution variable here
00005 // Created by wade
00006 // Class Champion: Unassigned
00007 
00008 # include "Root.h"  // parent
00009 
00010 namespace Conjecture {
00011     class OptIm;  // friend declaration
00012     
00023     // IMPLEMENTATION NOTES:
00024     //   - this class is designed for highly efficient space utiliation,
00025     //     while also providing support for highly efficient feature
00026     //     analysis.
00027     //   - some "auxillary" methods are quite slow (i.e. 'set' and
00028     //     'clear' - this class is meant to be used primarily on
00029     //     frozen images, so setting and clearing bits is not a
00030     //     priority for efficient implementation.
00031     //   - does NOT store the size of the pixel line (assumed to be
00032     //     be maintained elsewhere). This implies that the number of
00033     //     white pixels cannot be reported without obtaining the size
00034     //     (#black is stored, and #white = total - #black).
00035     //   - not using setters internally in some situations because
00036     //     bit-specifiers cause temporaries to be used in returns
00037 
00038     class PixelLine : public Root {
00039       public:
00040         static const u1 MaxPixels = 31;
00041 
00042         // Constructors/Destructors
00043         PixelLine(u4 pixels);
00044         
00045         // Accessors
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         // Input/Output
00051         
00052         // Interface
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         // Accessors
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         // Methods 
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         // Accessors
00132         
00133         // Methods 
00134         void updateMeta();
00135 
00136         // State
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 

Generated on Thu Jun 15 19:56:10 2006 for Conjecture by  doxygen 1.4.6