[wadalabfont-kit] / jis2prim / Assumption.h  

Annotation of /jis2prim/Assumption.h

Parent Directory | Revision Log

Revision: 1.3 - (view) (download) (as text)

1 : ktanaka 1.1 #ifndef _ASSUMPTION_H
2 :     #define _ASSUMPTION_H
3 : ktanaka 1.3 #include <vector>
4 :     #include <iostream>
5 : ktanaka 1.1
6 :     enum PtypeMask{
7 :     TenMask=1<<0,
8 :     YokoMask=1<<1,
9 :     TateMask=1<<2,
10 : ktanaka 1.2 HidariMask=1<<3,
11 :     TatehaneMask=1<<4,
12 :     TatehidariMask=1<<5,
13 : ktanaka 1.1 };
14 :     enum JointType{
15 :     Start,
16 :     JointStart,
17 :     Mid,
18 :     End,
19 :     JointEnd,
20 :     };
21 :    
22 :     class SimpleAssumption{
23 : ktanaka 1.3 friend std::ostream& operator<<(std::ostream &os,const SimpleAssumption &sa);
24 : ktanaka 1.1 protected:
25 :     PtypeMask pmask;
26 :     JointType jtype;
27 : ktanaka 1.2 double x, y;
28 : ktanaka 1.1 int angle;
29 : ktanaka 1.2 int hint;
30 : ktanaka 1.1 public:
31 : ktanaka 1.2 SimpleAssumption(PtypeMask pm, JointType jt,double xx,double yy, int a,int h)
32 :     :pmask(pm), jtype(jt), x(xx), y(yy), angle(a), hint(h){}
33 : ktanaka 1.1 };
34 :     class AndAssumption{
35 : ktanaka 1.3 friend std::ostream& operator<<(std::ostream &os,const AndAssumption &aa);
36 : ktanaka 1.1 protected:
37 : ktanaka 1.3 std::vector<SimpleAssumption> saList;
38 : ktanaka 1.1 public:
39 :     AndAssumption& add(const SimpleAssumption &sa){
40 :     saList.push_back(sa);
41 :     return *this;
42 :     }
43 :     };
44 :     class Assumption{
45 : ktanaka 1.3 friend std::ostream& operator<<(std::ostream &os,const Assumption &as);
46 : ktanaka 1.1 private:
47 : ktanaka 1.3 std::vector<AndAssumption> aaList;
48 : ktanaka 1.1 public:
49 :     Assumption& add(const AndAssumption &sa){
50 :     aaList.push_back(sa);
51 :     return *this;
52 :     }
53 : ktanaka 1.2 Assumption& add(const SimpleAssumption &sa){
54 :     aaList.push_back(AndAssumption().add(sa));
55 :     return *this;
56 :     }
57 : ktanaka 1.1 };
58 : ktanaka 1.3 std::ostream& operator<<(std::ostream &os,const SimpleAssumption &sa){
59 : ktanaka 1.1 os << "SimpleAssumption(pmask=" << (int)(sa.pmask) << ",jtype=" << (int)(sa.jtype)
60 : ktanaka 1.2 << ",x=" << sa.x << ",y=" << sa.y << ",angle=" << sa.angle
61 :     << ",hint=" << sa.hint << ")";
62 : ktanaka 1.1 return os;
63 :     }
64 : ktanaka 1.3 std::ostream& operator<<(std::ostream &os,const AndAssumption &aa){
65 :     std::vector<SimpleAssumption>::const_iterator it;
66 : ktanaka 1.2 if(aa.saList.size()==1){
67 :     return os << *(aa.saList.begin());
68 :     }
69 : ktanaka 1.1 os << "AndAssumption(";
70 :     for(it=aa.saList.begin(); it!=aa.saList.end(); it++){
71 :     os << *it << ' ';
72 :     }
73 :     os << ")";
74 :     return os;
75 :     }
76 : ktanaka 1.3 std::ostream& operator<<(std::ostream &os,const Assumption &a){
77 :     std::vector<AndAssumption>::const_iterator it;
78 : ktanaka 1.2 if(a.aaList.size()==1){
79 :     return os << *(a.aaList.begin());
80 :     }
81 : ktanaka 1.1 os << "Assumption(";
82 :     for(it=a.aaList.begin(); it!=a.aaList.end(); it++){
83 :     os << *it << ' ';
84 :     }
85 :     os << ")";
86 :     return os;
87 :     }
88 :    
89 :     #endif /* _ASSUMPTION_H */

ktanaka

Powered by ViewCVS 1.0-dev

ViewCVS and CVS Help