[wadalabfont-kit] / jis2prim / PatMatch.h  

Diff of /jis2prim/PatMatch.h

Parent Directory | Revision Log

version 1.3, Tue Mar 19 00:33:14 2002 UTC version 1.4, Tue Aug 6 06:30:44 2002 UTC
Line 2 
Line 2 
 #define  _PAT_MATCH_H  #define  _PAT_MATCH_H
   
 #include <string>  #include <string>
   #include <iostream>
 #include "BitmapFont.h"  #include "BitmapFont.h"
 #include "Assumption.h"  #include "Assumption.h"
   #include <vector>
   
 /* @ : 黒 */  /* @ : 黒 */
 /* . : 白 */  /* . : 白 */
 /* else(?) : どちらでも */  /* else(?) : どちらでも */
 class PatMatch{  class PatMatch{
   friend ostream& operator<<(ostream &os,const PatMatch &pm);    friend std::ostream& operator<<(std::ostream &os,const PatMatch &pm);
  protected:   protected:
   int width, height;    int width, height;
   string pat;    std::string pat;
   Assumption assumption;    Assumption assumption;
  public:   public:
   PatMatch(int w,int h,string s,const Assumption &as)    PatMatch(int w,int h,std::string s,const Assumption &as)
     :width(w), height(h), pat(s), assumption(as){      :width(w), height(h), pat(s), assumption(as){
     assert(pat.length() == (unsigned int)width*height);      assert(pat.length() == (unsigned int)width*height);
   }    }
   PatMatch(int w,int h,string s, const SimpleAssumption &sa)    PatMatch(int w,int h,std::string s, const SimpleAssumption &sa)
     :width(w), height(h), pat(s), assumption(){      :width(w), height(h), pat(s), assumption(){
     assumption.add(sa);      assumption.add(sa);
     assert(pat.length() == (unsigned int)width*height);      assert(pat.length() == (unsigned int)width*height);
Line 27 
Line 29 
   int get(int x,int y) const{    int get(int x,int y) const{
     return pat[y*width+x];      return pat[y*width+x];
   }    }
   #if 0
   bool isMatch(const BitmapFont& bf, int x, int y) const{    bool isMatch(const BitmapFont& bf, int x, int y) const{
     for(int i=0;i<width;i++)      for(int i=0;i<width;i++)
       for(int j=0;j<height;j++){        for(int j=0;j<height;j++){
Line 37 
Line 40 
       }        }
     return true;      return true;
   }    }
   vector<pixel> getPixels(int x, int y) const{  #endif
     vector<pixel> pixels;    int matchPenalty(const BitmapFont& bf, int x, int y) const{
       int penalty=0;
       for(int i=0;i<width;i++)
         for(int j=0;j<height;j++){
           if(bf.get(x+i,y+j)){
             if(get(i,j)=='.') return -1;
             else if(get(i,j)=='*') penalty++;
           }
           else if(get(i,j)=='@') return -1;
         }
       return penalty;
     }
     std::vector<pixel> getPixels(int x, int y) const{
       std::vector<pixel> pixels;
     for(int i=0;i<width;i++)      for(int i=0;i<width;i++)
       for(int j=0;j<height;j++){        for(int j=0;j<height;j++){
         if(get(i,j)=='@'){          if(get(i,j)=='@'){
Line 48 
Line 64 
     return pixels;      return pixels;
   }    }
 };  };
 ostream& operator<<(ostream &os,const PatMatch &pm){  std::ostream& operator<<(std::ostream &os,const PatMatch &pm){
   return os << "PatMatch(width=" << pm.width << ",height=" << pm.height <<    return os << "PatMatch(width=" << pm.width << ",height=" << pm.height <<
     ",pat=" << pm.pat << "," << pm.assumption << ")";      ",pat=" << pm.pat << "," << pm.assumption << ")";
 }  }


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

ktanaka

Powered by ViewCVS 1.0-dev

ViewCVS and CVS Help