#ifndef _ASSUMPTION_H #define _ASSUMPTION_H #include #include enum PtypeMask{ TenMask=1<<0, YokoMask=1<<1, TateMask=1<<2, HidariMask=1<<3, TatehaneMask=1<<4, TatehidariMask=1<<5, }; enum JointType{ Start, JointStart, Mid, End, JointEnd, }; class SimpleAssumption{ friend std::ostream& operator<<(std::ostream &os,const SimpleAssumption &sa); protected: PtypeMask pmask; JointType jtype; double x, y; int angle; int hint; public: SimpleAssumption(PtypeMask pm, JointType jt,double xx,double yy, int a,int h) :pmask(pm), jtype(jt), x(xx), y(yy), angle(a), hint(h){} }; class AndAssumption{ friend std::ostream& operator<<(std::ostream &os,const AndAssumption &aa); protected: std::vector saList; public: AndAssumption& add(const SimpleAssumption &sa){ saList.push_back(sa); return *this; } }; class Assumption{ friend std::ostream& operator<<(std::ostream &os,const Assumption &as); private: std::vector aaList; public: Assumption& add(const AndAssumption &sa){ aaList.push_back(sa); return *this; } Assumption& add(const SimpleAssumption &sa){ aaList.push_back(AndAssumption().add(sa)); return *this; } }; std::ostream& operator<<(std::ostream &os,const SimpleAssumption &sa){ os << "SimpleAssumption(pmask=" << (int)(sa.pmask) << ",jtype=" << (int)(sa.jtype) << ",x=" << sa.x << ",y=" << sa.y << ",angle=" << sa.angle << ",hint=" << sa.hint << ")"; return os; } std::ostream& operator<<(std::ostream &os,const AndAssumption &aa){ std::vector::const_iterator it; if(aa.saList.size()==1){ return os << *(aa.saList.begin()); } os << "AndAssumption("; for(it=aa.saList.begin(); it!=aa.saList.end(); it++){ os << *it << ' '; } os << ")"; return os; } std::ostream& operator<<(std::ostream &os,const Assumption &a){ std::vector::const_iterator it; if(a.aaList.size()==1){ return os << *(a.aaList.begin()); } os << "Assumption("; for(it=a.aaList.begin(); it!=a.aaList.end(); it++){ os << *it << ' '; } os << ")"; return os; } #endif /* _ASSUMPTION_H */