Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/tools/sg/valop2sg is written in an unsupported language. File is not indexed.

0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003 
0004 #ifndef tools_sg_valop2sg
0005 #define tools_sg_valop2sg
0006 
0007 #include "bbox_action"
0008 #include "strings"
0009 #include "separator"
0010 #include "matrix"
0011 #include "vertices"
0012 #include "base_freetype"
0013 #include "mnmx"
0014 
0015 #include "../valop"
0016 #include "../smath"
0017 
0018 namespace tools {
0019 
0020 class valop2sg : public virtual valop_visitor {
0021 public:
0022   virtual bool binary(unsigned int a_type,const valop& a_1,const valop& a_2) {
0023     sg::separator* sep = new sg::separator;
0024 
0025     sg::separator* sep1 = new sg::separator;
0026     sep->add(sep1);
0027     sg::matrix* tsf1 = new sg::matrix;
0028     sep1->add(tsf1);
0029     vec3f mn1,mx1;
0030    {valop2sg v(m_out,*sep1,m_ttf);
0031     if(!v.visit(a_1)) {
0032       delete sep;
0033       return false;
0034     }
0035     mnmx(m_out,*sep1,mn1,mx1);}
0036 
0037     sg::separator* op_sep = new sg::separator;
0038     sep->add(op_sep);
0039     sg::matrix* op_tsf = new sg::matrix;
0040     op_sep->add(op_tsf);
0041 
0042     sg::separator* sep2 = new sg::separator;
0043     sep->add(sep2);
0044     sg::matrix* tsf2 = new sg::matrix;
0045     sep2->add(tsf2);
0046     vec3f mn2,mx2;
0047    {valop2sg v(m_out,*sep2,m_ttf);
0048     if(!v.visit(a_2)) {
0049       delete sep;
0050       return false;
0051     }
0052     mnmx(m_out,*sep2,mn2,mx2);}
0053 
0054     if((a_type==valop::ADD)   ||
0055        (a_type==valop::SUB)   ||
0056        (a_type==valop::MUL)   ||
0057        (a_type==valop::EQUAL) ){
0058 
0059       sg::base_freetype* tft = sg::base_freetype::create(m_ttf);
0060 
0061            if(a_type==valop::ADD)   unichar2sg(0x0002B,*tft); // +
0062       else if(a_type==valop::SUB)   unichar2sg(0x02212,*tft);
0063       else if(a_type==valop::MUL)   unichar2sg(0x02A2F,*tft); // x
0064       else if(a_type==valop::EQUAL) unichar2sg(0x0003D,*tft); // =
0065       op_sep->add(tft);
0066 
0067       vec3f omn,omx;
0068       mnmx(m_out,*tft,omn,omx);
0069 
0070       float odx = omx[0]-omn[0];
0071       float xmargin = odx*0.1f;
0072 
0073       op_tsf->mul_translate(-omn[0]+mx1[0]+xmargin,0,0);
0074 
0075       tsf2->mul_translate(-mn2[0]+mx1[0]+xmargin+odx+xmargin,0,0);
0076 
0077     } else if( (a_type==valop::ASIDE) ||
0078                (a_type==valop::NVMUL) ){
0079 
0080       float xspace = (mx1[0]-mn1[0])*0.1f;
0081 
0082       tsf2->mul_translate(-mn2[0]+mx1[0]+xspace,0,0);
0083 
0084     } else if(a_type==valop::DIV) {
0085 
0086       // the bar :
0087       sg::vertices* vtcs = new sg::vertices;
0088       op_sep->add(vtcs);
0089       float w2 = 0.5f;
0090       float h = 0.101f;
0091       vtcs->add(-w2,0,0);
0092       vtcs->add( w2,0,0);
0093       vtcs->add( w2,h,0);
0094       vtcs->add(-w2,h,0);
0095       if(m_wf) {
0096         vtcs->mode = gl::line_strip();
0097         vtcs->add(-w2,0,0);
0098       } else {
0099         vtcs->mode = gl::triangle_fan();
0100       }
0101 
0102       float ymargin = h;
0103 
0104       float osx = max_of(mx1[0]-mn1[0],mx2[0]-mn2[0]);
0105       osx *= 1.1f;
0106 
0107       op_tsf->mul_scale(osx,1,1);
0108 
0109       //put a_1 symbol in the middle of the bar.
0110       //put a_1 symbol on top of the bar (with an ymargin).
0111       float dx1 = -(mn1[0]+mx1[0])*0.5f;
0112       float dy1 = -mn1[1]+h+ymargin;
0113       tsf1->mul_translate(dx1,dy1,0);
0114 
0115       //put a_2 symbol in the middle of the bar.
0116       //put a_2 symbol under the bar (with an ymargin).
0117       float dx2 = -(mn2[0]+mx2[0])*0.5f;
0118       float dy2 = -mx2[1]-ymargin;
0119       tsf2->mul_translate(dx2,dy2,0);
0120 
0121     } else if(a_type==valop::SUPS) {
0122 
0123       if(mx2[0]==mn2[0]) {
0124         delete sep;
0125         return false;
0126       }
0127 
0128       float s2 = 0.5f*(mx1[0]-mn1[0])/(mx2[0]-mn2[0]); //half a_1 horiz size.
0129       tsf2->set_scale(s2,s2,1);
0130       mnmx(m_out,*sep2,mn2,mx2);
0131 
0132       float xshift = (mx1[0]-mn1[0])*0.1f;
0133       float dx2 = -mn2[0]+mx1[0]+xshift;
0134 
0135       float yshift = (mx1[1]-mn1[1])*0.3f;
0136       float dy2 = -mn2[1]+mx1[1]-yshift;
0137 
0138       tsf2->set_translate(dx2,dy2,0);
0139       tsf2->mul_scale(s2,s2,1); //applied first
0140 
0141     } else if(a_type==valop::SUBS) {
0142 
0143       if(mx2[0]==mn2[0]) {
0144         delete sep;
0145         return false;
0146       }
0147 
0148       float s2 = 0.5f*(mx1[0]-mn1[0])/(mx2[0]-mn2[0]); //half a_1 horiz size.
0149       tsf2->set_scale(s2,s2,1);
0150       mnmx(m_out,*sep2,mn2,mx2);
0151 
0152       float xshift = (mx1[0]-mn1[0])*0.1f;
0153       float dx2 = -mn2[0]+mx1[0]+xshift;
0154 
0155       float yshift = (mx1[1]-mn1[1])*0.3f;
0156       float dy2 = -mn2[1]-yshift;
0157 
0158       tsf2->set_translate(dx2,dy2,0);
0159       tsf2->mul_scale(s2,s2,1); //applied first
0160 
0161     } else {
0162       delete sep;
0163       return false;
0164     }
0165 
0166     m_group.add(sep);
0167 
0168     return true;
0169   }
0170 
0171   virtual bool unary(unsigned int a_type,const valop& a_1) {
0172     if(a_type==valop::MINUS) {
0173       sg::separator* sep = new sg::separator;
0174 
0175       sg::separator* sep1 = new sg::separator;
0176       sep->add(sep1);
0177       sg::matrix* tsf1 = new sg::matrix;
0178       sep1->add(tsf1);
0179       vec3f mn1,mx1;
0180      {valop2sg v(m_out,*sep1,m_ttf);
0181       if(!v.visit(a_1)) {
0182         delete sep;
0183         return false;
0184       }
0185       mnmx(m_out,*sep1,mn1,mx1);}
0186 
0187       m_group.add(sep);
0188 
0189       ////////////////////////////////////////////////////////
0190       /// minus symbol ///////////////////////////////////////
0191       ////////////////////////////////////////////////////////
0192       sg::separator* op_sep = new sg::separator;
0193       sep->add(op_sep);
0194 
0195       sg::base_freetype* tft = sg::base_freetype::create(m_ttf);
0196       unichar2sg(0x0002D,*tft);
0197       op_sep->add(tft);
0198       vec3f omn,omx;
0199       mnmx(m_out,*tft,omn,omx);
0200 
0201       float odx = omx[0]-omn[0];
0202       float xmargin = odx*0.1f;
0203 
0204       //push a_1 at right of minus symbol
0205       tsf1->mul_translate(-mn1[0]+omx[0]+xmargin,0,0);
0206 
0207       return true;
0208 
0209     } else {
0210       return false;
0211     }
0212   }
0213 
0214   virtual bool variable(unsigned int a_type,const value& a_var) {
0215 
0216     sg::base_freetype* tft = sg::base_freetype::create(m_ttf);
0217 
0218     if(a_type==valop::SYMBOL) {
0219       if(rcmp(a_var.get_string(),s_psi())) {
0220         unichar2sg(0x003C8,*tft);
0221         m_group.add(tft);
0222         return true;
0223       } else if(rcmp(a_var.get_string(),s_gamma())) {
0224         unichar2sg(0x003B3,*tft);
0225         m_group.add(tft);
0226         return true;
0227       } else if(rcmp(a_var.get_string(),s_mu())) {
0228         unichar2sg(0x003BC,*tft);
0229         m_group.add(tft);
0230         return true;
0231       } else if(rcmp(a_var.get_string(),s_upper_delta())) {
0232         unichar2sg(0x02206,*tft);
0233         m_group.add(tft);
0234         return true;
0235       } else if(rcmp(a_var.get_string(),s_partial_derivative())){
0236         unichar2sg(0x02202,*tft); //d ronde
0237         m_group.add(tft);
0238         return true;
0239       } else if(rcmp(a_var.get_string(),s_h_bar())){
0240         unichar2sg(0x0210F,*tft);
0241         m_group.add(tft);
0242         return true;
0243       }
0244 
0245     } else if(a_type==valop::REAL){
0246       s2sg(value::to_string(a_var),*tft);
0247       m_group.add(tft);
0248       return true;
0249 
0250     } else if(a_type==valop::STRING){
0251       if(a_var.type()==value::STRING){
0252         s2sg(a_var.get_string(),*tft);
0253         m_group.add(tft);
0254         return true;
0255       } else {
0256         m_out << "valop2sg::variable :"
0257               << " expected a value::STRING."
0258               << " Got " << a_var.stype() << "."
0259               << std::endl;
0260       }
0261     }
0262 
0263     delete tft;
0264     return false;
0265   }
0266 
0267   virtual bool option(const valop& a_node) {
0268     sg::base_freetype* tft = sg::base_freetype::create(m_ttf);
0269     s2sg(a_node.m_name,*tft);
0270     m_group.add(tft);
0271     return true;
0272   }
0273 
0274   virtual bool func_1(const valop& a_f,const valop& a_1) {
0275     if(rcmp(a_f.m_function->name(),s_sqrt())) {
0276 
0277       sg::separator* sep = new sg::separator;
0278 
0279       sg::separator* sep1 = new sg::separator;
0280       sep->add(sep1);
0281       vec3f mn1,mx1;
0282      {valop2sg v(m_out,*sep1,m_ttf);
0283       if(!v.visit(a_1)) {
0284         delete sep;
0285         return false;
0286       }
0287       mnmx(m_out,*sep1,mn1,mx1);}
0288 
0289       m_group.add(sep);
0290 
0291       ////////////////////////////////////////////////////////
0292       /// sqrt symbol ////////////////////////////////////////
0293       ////////////////////////////////////////////////////////
0294       sg::separator* op_sep = new sg::separator;
0295       sep->add(op_sep);
0296       sg::matrix* op_tsf = new sg::matrix;
0297       op_sep->add(op_tsf);
0298 
0299       sg::base_freetype* tft = sg::base_freetype::create(m_ttf);
0300       unichar2sg(0x0221A,*tft);
0301       op_sep->add(tft);
0302       vec3f omn,omx;
0303       mnmx(m_out,*tft,omn,omx);
0304 
0305       // upper bar :
0306       sg::vertices* vtcs = new sg::vertices;
0307       op_sep->add(vtcs);
0308       float dx = 0.05f; //to cover the top of the sqrt symbol.
0309       float w = mx1[0]-mn1[0];
0310       w *= 1.05f;
0311       float h = 0.09f;
0312       vtcs->add(omx[0]-dx ,omx[1]-h,0);
0313       vtcs->add(omx[0]+w  ,omx[1]-h,0);
0314       vtcs->add(omx[0]+w  ,omx[1]  ,0);
0315       vtcs->add(omx[0]-dx ,omx[1]  ,0);
0316       if(m_wf) {
0317         vtcs->mode = gl::line_strip();
0318         vtcs->add(omx[0]-dx ,omx[1]-h,0);
0319       } else {
0320         vtcs->mode = gl::triangle_fan();
0321       }
0322 
0323       float xmargin = 0;
0324 
0325       //push  sqrt-symbol at left of a_1
0326       //scale sqrt-symbol to match a_1 y height.
0327       //y translate sqrt-symbol so that a_1 is under the bar :
0328 
0329       float osy = (mx1[1]-mn1[1])/(omx[1]-omn[1]);
0330       float ody = -omn[1]*osy + mn1[1];
0331 
0332       osy *= 1.2f;
0333 
0334       op_tsf->mul_translate(-omx[0]+mn1[0]-xmargin,ody,0); //second
0335       op_tsf->mul_scale(1,osy,1);                          //first
0336 
0337       return true;
0338     } else {
0339       // generic case : <func_name>(rep of a_1)
0340 
0341       sg::separator* sep = new sg::separator;
0342 
0343       sg::separator* sep1 = new sg::separator;
0344       sep->add(sep1);
0345       vec3f mn1,mx1;
0346      {valop2sg v(m_out,*sep1,m_ttf);
0347       if(!v.visit(a_1)) {
0348         delete sep;
0349         return false;
0350       }
0351       mnmx(m_out,*sep1,mn1,mx1);}
0352 
0353       m_group.add(sep);
0354 
0355       ////////////////////////////////////////////////////////
0356       /// left func symbol : <func_name> (       /////////////
0357       ////////////////////////////////////////////////////////
0358      {sg::separator* op_sep = new sg::separator;
0359       sep->add(op_sep);
0360       sg::matrix* op_tsf = new sg::matrix;
0361       op_sep->add(op_tsf);
0362 
0363       sg::base_freetype* tft = sg::base_freetype::create(m_ttf);
0364       //TTNODE* tft = new TTNODE();
0365       s2sg(a_f.m_function->name(),*tft);
0366       tft->unitext[0].push_back(0x00028); // (
0367       op_sep->add(tft);
0368 
0369       vec3f omn,omx;
0370       mnmx(m_out,*tft,omn,omx);
0371 
0372       //push func-symbol at left of a_1 :
0373       float xmargin = 0;
0374       op_tsf->mul_translate(-omx[0]+mn1[0]-xmargin,0,0);
0375       } //end left op
0376 
0377       ////////////////////////////////////////////////////////
0378       /// right func symbol : )                  /////////////
0379       ////////////////////////////////////////////////////////
0380      {sg::separator* op_sep = new sg::separator;
0381       sep->add(op_sep);
0382       sg::matrix* op_tsf = new sg::matrix;
0383       op_sep->add(op_tsf);
0384 
0385       sg::base_freetype* tft = sg::base_freetype::create(m_ttf);
0386       unichar2sg(0x00029,*tft);
0387       op_sep->add(tft);
0388       vec3f omn,omx;
0389       mnmx(m_out,*tft,omn,omx);
0390 
0391       //push func-symbol at right of a_1 :
0392       float xmargin = 0;
0393       op_tsf->mul_translate(-omn[0]+mx1[0]+xmargin,0,0);
0394       } //end right op
0395 
0396       return true;
0397     }
0398   }
0399   virtual bool func_2(const valop& a_f,const valop& a_1,const valop& a_2) {
0400     if(rcmp(a_f.m_function->name(),s_pow())) {
0401 
0402       sg::separator* sep = new sg::separator;
0403 
0404       sg::separator* sep1 = new sg::separator;
0405       sep->add(sep1);
0406       sg::matrix* tsf1 = new sg::matrix;
0407       sep1->add(tsf1);
0408       vec3f mn1,mx1;
0409      {valop2sg v(m_out,*sep1,m_ttf);
0410       if(!v.visit(a_1)) {
0411         delete sep;
0412         return false;
0413       }
0414       mnmx(m_out,*sep1,mn1,mx1);}
0415 
0416       sg::separator* sep2 = new sg::separator;
0417       sep->add(sep2);
0418       sg::matrix* tsf2 = new sg::matrix;
0419       sep2->add(tsf2);
0420       vec3f mn2,mx2;
0421      {valop2sg v(m_out,*sep2,m_ttf);
0422       if(!v.visit(a_2)) {
0423         delete sep;
0424         return false;
0425       }
0426       mnmx(m_out,*sep2,mn2,mx2);}
0427 
0428       float s2 = 0.5f*(mx1[0]-mn1[0])/(mx2[0]-mn2[0]); //half a_1 horiz size.
0429       if(mx2[0]==mn2[0]) {
0430         delete sep;
0431         return false;
0432       }
0433       tsf2->set_scale(s2,s2,1);
0434       mnmx(m_out,*sep2,mn2,mx2);
0435 
0436       float xshift = (mx1[0]-mn1[0])*0.1f;
0437       float dx2 = -mn2[0]+mx1[0]+xshift;
0438 
0439       float yshift = (mx1[1]-mn1[1])*0.3f;
0440       float dy2 = -mn2[1]+mx1[1]-yshift;
0441 
0442       tsf2->set_identity();
0443       tsf2->mul_translate(dx2,dy2,0);
0444       tsf2->mul_scale(s2,s2,1); //applied first
0445 
0446       m_group.add(sep);
0447 
0448       return true;
0449 
0450     } else {
0451       // generic case : <func_name>(rep of a_1, rep of a_2)
0452 
0453       sg::separator* sep = new sg::separator;
0454 
0455       sg::separator* sep1 = new sg::separator;
0456       sep->add(sep1);
0457       vec3f mn1,mx1;
0458      {valop2sg v(m_out,*sep1,m_ttf);
0459       if(!v.visit(a_1)) {
0460         delete sep;
0461         return false;
0462       }
0463       mnmx(m_out,*sep1,mn1,mx1);}
0464 
0465       sg::separator* sep2 = new sg::separator;
0466       sep->add(sep2);
0467       sg::matrix* tsf2 = new sg::matrix;
0468       sep2->add(tsf2);
0469       vec3f mn2,mx2;
0470      {valop2sg v(m_out,*sep2,m_ttf);
0471       if(!v.visit(a_2)) {
0472         delete sep;
0473         return false;
0474       }
0475       mnmx(m_out,*sep2,mn2,mx2);}
0476 
0477       m_group.add(sep);
0478 
0479       ////////////////////////////////////////////////////////
0480       /// left func symbol : <func_name> (       /////////////
0481       ////////////////////////////////////////////////////////
0482      {sg::separator* op_sep = new sg::separator;
0483       sep->add(op_sep);
0484       sg::matrix* op_tsf = new sg::matrix;
0485       op_sep->add(op_tsf);
0486 
0487       sg::base_freetype* tft = sg::base_freetype::create(m_ttf);
0488       s2sg(a_f.m_function->name(),*tft);
0489       tft->unitext[0].push_back(0x00028); // (
0490       op_sep->add(tft);
0491 
0492       vec3f omn,omx;
0493       mnmx(m_out,*tft,omn,omx);
0494 
0495       //push func-symbol at left of a_1 :
0496       float xmargin = 0;
0497       op_tsf->mul_translate(-omx[0]+mn1[0]-xmargin,0,0);
0498       } //end left op
0499 
0500       ////////////////////////////////////////////////////////
0501       /// ,                                      /////////////
0502       ////////////////////////////////////////////////////////
0503       float xend2 = 0;
0504      {sg::separator* op_sep = new sg::separator;
0505       sep->add(op_sep);
0506       sg::matrix* op_tsf = new sg::matrix;
0507       op_sep->add(op_tsf);
0508 
0509       sg::base_freetype* tft = sg::base_freetype::create(m_ttf);
0510       unichar2sg(0x0002C,*tft); // ,
0511       op_sep->add(tft);
0512       vec3f omn,omx;
0513       mnmx(m_out,*tft,omn,omx);
0514 
0515       //push comma-symbol at right of a_1 :
0516       float odx = omx[0]-omn[0];
0517       float xmargin = odx*0.1f;
0518       op_tsf->mul_translate(-omn[0]+mx1[0]+xmargin,0,0);
0519 
0520       float xendcomma = mx1[0]+xmargin+(omx[0]-omn[0]);
0521 
0522       tsf2->mul_translate(-mn2[0]+xendcomma+xmargin,0,0);
0523 
0524       xend2 = xendcomma+(mx2[0]-mn2[0]);
0525       } //end comma
0526 
0527       ////////////////////////////////////////////////////////
0528       /// right func symbol : )                  /////////////
0529       ////////////////////////////////////////////////////////
0530      {sg::separator* op_sep = new sg::separator;
0531       sep->add(op_sep);
0532       sg::matrix* op_tsf = new sg::matrix;
0533       op_sep->add(op_tsf);
0534 
0535       sg::base_freetype* tft = sg::base_freetype::create(m_ttf);
0536       unichar2sg(0x00029,*tft);
0537       op_sep->add(tft);
0538       vec3f omn,omx;
0539       mnmx(m_out,*tft,omn,omx);
0540 
0541       //push ")" at right of a_2 :
0542       float xmargin = 0;
0543       op_tsf->mul_translate(-omn[0]+xend2+xmargin,0,0);
0544       } //end right op
0545 
0546       return true;
0547     }
0548   }
0549   virtual bool func_3(const valop&,const valop&,const valop&,const valop&) {
0550     return false;
0551   }
0552   virtual bool func_4(const valop&,const valop&,const valop&,const valop&,const valop&) {
0553     return false;
0554   }
0555   virtual bool func_5(const valop&,const valop&,const valop&,const valop&,const valop&,const valop&) {
0556     return false;
0557   }
0558   virtual bool func_6(const valop&,const valop&,const valop&,const valop&,const valop&,const valop&,const valop&) {
0559     return false;
0560   }
0561 public:
0562   valop2sg(std::ostream& a_out,
0563            sg::group& a_group,
0564            const sg::base_freetype& a_ttf)
0565   :m_out(a_out)
0566   ,m_group(a_group)
0567   //,m_wf(true)
0568   ,m_wf(false)
0569   ,m_ttf(a_ttf)
0570   {}
0571   virtual ~valop2sg() {}
0572 public:
0573   valop2sg(const valop2sg& a_from)
0574   :valop_visitor(a_from)
0575   ,m_out(a_from.m_out)
0576   ,m_group(a_from.m_group)
0577   ,m_wf(a_from.m_wf)
0578   ,m_ttf(a_from.m_ttf)
0579   {}
0580   valop2sg& operator=(const valop2sg& a_from){
0581     m_wf = a_from.m_wf;
0582     return *this;
0583   }
0584 protected:
0585   typedef unsigned int unichar;
0586 
0587   unichar char2stix(char a_c) {
0588     if(a_c=='-') return 0x0002D;
0589     if(a_c=='.') return 0x0002E;
0590 
0591     if(a_c=='0') return 0x00030;
0592     if(a_c=='1') return 0x00031;
0593     if(a_c=='2') return 0x00032;
0594     if(a_c=='3') return 0x00033;
0595     if(a_c=='4') return 0x00034;
0596     if(a_c=='5') return 0x00035;
0597     if(a_c=='6') return 0x00036;
0598     if(a_c=='7') return 0x00037;
0599     if(a_c=='8') return 0x00038;
0600     if(a_c=='9') return 0x00039;
0601 
0602     if(a_c=='A') return 0x00041;
0603     if(a_c=='B') return 0x00042;
0604     if(a_c=='C') return 0x00043;
0605     if(a_c=='D') return 0x00044;
0606     if(a_c=='E') return 0x00045;
0607     if(a_c=='F') return 0x00046;
0608     if(a_c=='G') return 0x00047;
0609     if(a_c=='H') return 0x00048;
0610     if(a_c=='I') return 0x00049;
0611     if(a_c=='J') return 0x0004A;
0612     if(a_c=='K') return 0x0004B;
0613     if(a_c=='L') return 0x0004C;
0614     if(a_c=='M') return 0x0004D;
0615     if(a_c=='N') return 0x0004E;
0616     if(a_c=='O') return 0x0004F;
0617     if(a_c=='P') return 0x00050;
0618     if(a_c=='Q') return 0x00051;
0619     if(a_c=='R') return 0x00052;
0620     if(a_c=='S') return 0x00053;
0621     if(a_c=='T') return 0x00054;
0622     if(a_c=='U') return 0x00055;
0623     if(a_c=='V') return 0x00056;
0624     if(a_c=='W') return 0x00057;
0625     if(a_c=='X') return 0x00058;
0626     if(a_c=='Y') return 0x00059;
0627     if(a_c=='Z') return 0x0005A;
0628 
0629     if(a_c=='a') return 0x00061;
0630     if(a_c=='b') return 0x00062;
0631     if(a_c=='c') return 0x00063;
0632     if(a_c=='d') return 0x00064;
0633     if(a_c=='e') return 0x00065;
0634     if(a_c=='f') return 0x00066;
0635     if(a_c=='g') return 0x00067;
0636     if(a_c=='h') return 0x00068;
0637     if(a_c=='i') return 0x00069;
0638     if(a_c=='j') return 0x0006A;
0639     if(a_c=='k') return 0x0006B;
0640     if(a_c=='l') return 0x0006C;
0641     if(a_c=='m') return 0x0006D;
0642     if(a_c=='n') return 0x0006E;
0643     if(a_c=='o') return 0x0006F;
0644     if(a_c=='p') return 0x00070;
0645     if(a_c=='q') return 0x00071;
0646     if(a_c=='r') return 0x00072;
0647     if(a_c=='s') return 0x00073;
0648     if(a_c=='t') return 0x00074;
0649     if(a_c=='u') return 0x00075;
0650     if(a_c=='v') return 0x00076;
0651     if(a_c=='w') return 0x00077;
0652     if(a_c=='x') return 0x00078;
0653     if(a_c=='y') return 0x00079;
0654     if(a_c=='z') return 0x0007A;
0655 
0656     if(a_c=='_') return 0x0005F;
0657 
0658     return 0x0003F; //?
0659   }
0660 
0661   void unichar2sg(unichar a_unichar,sg::base_freetype& a_node){
0662     if(m_wf) a_node.modeling = sg::font_outline;
0663 
0664     a_node.font = sg::font_stixgeneral_otf();
0665 
0666     std::vector<unichar> line;
0667     line.push_back(a_unichar);
0668 
0669     a_node.unitext.add(line);
0670   }
0671 
0672   void s2sg(const std::string& a_s,sg::base_freetype& a_node){
0673     if(m_wf) a_node.modeling = sg::font_outline;  //else font_filled, font_pixmap.
0674 
0675     a_node.font = sg::font_stixgeneral_otf();
0676 
0677     std::vector<unichar> line;
0678     for(auto it = a_s.cbegin(); it != a_s.cend(); ++it) line.push_back(char2stix(*it));
0679 
0680     a_node.unitext.add(line);
0681   }
0682 
0683 protected:
0684   std::ostream& m_out;
0685   sg::group& m_group;
0686   bool m_wf;
0687   const sg::base_freetype& m_ttf;
0688 };
0689 
0690 }
0691 
0692 #endif