[wadalabfont-kit] / jis2prim / Matchers.h  

Diff of /jis2prim/Matchers.h

Parent Directory | Revision Log

version 1.2, Mon Mar 4 00:44:36 2002 UTC version 1.3, Tue Mar 19 00:33:14 2002 UTC
Line 13 
Line 13 
   int x,y;    int x,y;
   PatMatch pm;    PatMatch pm;
  public:   public:
   MatchResult(int xx, int yy,PatMatch& p) :x(xx),y(yy),pm(p){}    MatchResult(int xx, int yy,const PatMatch& p) :x(xx),y(yy),pm(p){}
   vector<pixel> getPixels() const {    vector<pixel> getPixels() const {
     return pm.getPixels(x,y);      return pm.getPixels(x,y);
   }    }
Line 46 
Line 46 
                           Assumption()                            Assumption()
                           .add(SimpleAssumption(YokoMask,Mid,1.5,1,0,0))                            .add(SimpleAssumption(YokoMask,Mid,1.5,1,0,0))
                           .add(SimpleAssumption((PtypeMask)(TateMask|TatehaneMask|TatehidariMask|HidariMask),JointStart,1.5,1,270,2))));                            .add(SimpleAssumption((PtypeMask)(TateMask|TatehaneMask|TatehidariMask|HidariMask),JointStart,1.5,1,270,2))));
       pm.push_back(PatMatch(5,3,
                             ".@@.."
                             "@@@@@"
                             ".....",
                             Assumption()
                             .add(SimpleAssumption(YokoMask,Mid,1.5,1,0,0))
                             .add(SimpleAssumption((PtypeMask)(TateMask|TatehaneMask|TatehidariMask|HidariMask),JointEnd,1.5,1,270,2))));
     pm.push_back(PatMatch(5,4,      pm.push_back(PatMatch(5,4,
                           "....?"                            "....?"
                           ".@@.."                            ".@@.."
Line 88 
Line 95 
                           .add(SimpleAssumption(YokoMask,JointEnd,1.5,2,0,0))                            .add(SimpleAssumption(YokoMask,JointEnd,1.5,2,0,0))
                           .add(SimpleAssumption(TateMask,JointEnd,1.5,1,270,2))));                            .add(SimpleAssumption(TateMask,JointEnd,1.5,1,270,2))));
   }    }
   vector<MatchResult> findMatch(const BitmapFont& bf){    vector<MatchResult> findMatch(const BitmapFont& bf) const{
     vector<MatchResult> mr;      vector<MatchResult> mr;
     vector<PatMatch>::iterator it;      vector<PatMatch>::const_iterator it;
     for(it=pm.begin();it!=pm.end();it++)      for(it=pm.begin();it!=pm.end();it++)
       for(int y= -1; y<bf.getHeight(); y++)        for(int y= -1; y<bf.getHeight(); y++)
         for(int x= -1;x<bf.getWidth();x++)          for(int x= -1;x<bf.getWidth();x++)
Line 98 
Line 105 
             mr.push_back(MatchResult(x,y,*it));              mr.push_back(MatchResult(x,y,*it));
     return mr;      return mr;
   }    }
   bool coverCheck(const BitmapFont& bf){    vector<pixel> notCovered(const BitmapFont& bf) const{
     vector<MatchResult> mr=findMatch(bf);      vector<MatchResult> mr=findMatch(bf);
     vector<set<int> > pixel2match(bf.getSize());      vector<set<int> > pixel2match(bf.getSize());
     vector<set<int> > match2pixel(mr.size());      vector<set<int> > match2pixel(mr.size());
Line 109 
Line 116 
       vector<pixel>::iterator ips;        vector<pixel>::iterator ips;
       for(ips=ps.begin();ips!=ps.end();ips++){        for(ips=ps.begin();ips!=ps.end();ips++){
         int m=bf.getIndex(*ips);          int m=bf.getIndex(*ips);
           cout << '(' << ips->first << ',' << ips->second << ")\n";
         assert(m != -1);          assert(m != -1);
         match2pixel[n].insert(m);          match2pixel[n].insert(m);
         pixel2match[m].insert(n);          pixel2match[m].insert(n);
       }        }
     }      }
       vector<pixel> ret;
     for(int i=0;i<bf.getPixelSize();i++){      for(int i=0;i<bf.getPixelSize();i++){
       if(pixel2match[i].empty()) return false;        if(pixel2match[i].empty()) {
           ret.push_back(bf.getPixelAt(i));
         }
     }      }
     return true;      return ret;
   }    }
 };  };
 ostream& operator<<(ostream &os,const Matchers &mt){  ostream& operator<<(ostream &os,const Matchers &mt){


Generate output suitable for use with a patch program
Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

ktanaka

Powered by ViewCVS 1.0-dev

ViewCVS and CVS Help