#ifndef CRACKCODE_HH #define CRACKCODE_HH ////////////////////////////////////////////////////////////////////////// //! file="amma/StdType/Entity/CrackCod.hh" //! lib=Mentity //! userlevel=Normal //! author="Radek Marik" //! date="26.10.1992" //! docentry="Image.Pixel Representations" //! rcsid="$Id: CrackCod.hh,v 1.7 1999/10/11 12:17:35 ees1cg Exp $" #include "amma/Boolean.hh" #include "amma/StdType.hh" // ---------------------------------------------------------------------- // ********* CrackCodeT ************************************************* // ---------------------------------------------------------------------- // Symbol names of crack code. The code numer of symbols name must not // be changed without carefull examination of affecting of the class // CrackCodeC. enum CrackCodeT { CR_DOWN = 0, CR_RIGHT = 1, CR_UP = 2, CR_LEFT = 3, CR_NODIR = 4 }; enum RelativeCrackCodeT { CR_AHEAD = 0, CR_TO_LEFT = 1, CR_BACK = 2, CR_TO_RIGHT = 3, CR_RNODIR = 4 }; extern CrackCodeT clockWiseTurn[5]; extern CrackCodeT cClockWiseTurn[5]; extern CrackCodeT backTurn[5]; // ---------------------------------------------------------------------- // ******** CrackCodeC ************************************************** // ---------------------------------------------------------------------- //: Crackcode or Freeman code class CrackCodeC { public: CrackCodeC(); // Default constructor. CrackCodeC(const IntT i); // Constructs object from an integer 'i'. CrackCodeC(CrackCodeT cc); // Constructs and set value to be 'cc'. CrackCodeC(const CrackCodeC & cc); // Copy constructor. inline BooleanT operator==(const CrackCodeC & cc) const; // Returns TRUE if the object content is equal to 'cc'. inline BooleanT operator!=(const CrackCodeC & cc) const; // Returns TRUE if the object content is not equal to 'cc'. inline const CrackCodeC & operator+=(const CrackCodeC & cc); // The crackcode 'cc' is taken as a relative crackcode. The relative // crackcode is added to this crackcode. inline const CrackCodeC & operator-=(const CrackCodeC & cc); // The crackcode 'cc' is taken as a relative crackcode. The relative // crackcode is subtracted from this crackcode. inline void Set(CrackCodeT cc); // Sets object according to 'cc'. inline void Set(const CrackCodeC & cc); // Sets object according to 'cc'. inline CrackCodeT CCode() const; // Returns the code. // ---------- turning ----------------------- inline CrackCodeC & Clock(); // Turns the crackcode clockwise. inline CrackCodeC & CClock(); // Turns the crackcode counterclockwise. inline CrackCodeC & Back(); // Turns the crackcode backward. protected: CrackCodeT crackCode; // The code. friend class PixelC; }; // ------------------------------------------------------------------ // **************** CrackCodeC ************************************** // ------------------------------------------------------------------ inline CrackCodeT CrackCodeC::CCode() const //======================= { return crackCode; } inline BooleanT CrackCodeC::operator==(const CrackCodeC & cc) const //================================================= { return (BooleanT)(cc.CCode() == CCode()); } inline BooleanT CrackCodeC::operator!=(const CrackCodeC & cc) const //================================================= { return (BooleanT)(cc.CCode() != CCode()); } inline const CrackCodeC & CrackCodeC::operator+=(const CrackCodeC & cc) //=========================================== { IntT result = crackCode + cc.crackCode; crackCode = (CrackCodeT)(result % 4); return(*this); } inline const CrackCodeC & CrackCodeC::operator-=(const CrackCodeC & cc) //=========================================== { IntT result = crackCode - cc.crackCode + 4; crackCode = (CrackCodeT)(result % 4); return(*this); } inline void CrackCodeC::Set(CrackCodeT cc) //============================ { crackCode = cc; } inline void CrackCodeC::Set(const CrackCodeC & cc) //==================================== { crackCode = cc.crackCode; } inline CrackCodeC & CrackCodeC::Clock() //================= { crackCode = clockWiseTurn[crackCode]; return *this; } inline CrackCodeC & CrackCodeC::CClock() //================== { crackCode = cClockWiseTurn[crackCode]; return *this; } inline CrackCodeC & CrackCodeC::Back() //================ { crackCode = backTurn[crackCode]; return *this; } #endif // IAPS - Image analysis program system. // End of include file CrackCode.hh