⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sansrgraph.cpp

📁 FreeFem++可以生成高质量的有限元网格。可以用于流体力学
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// a faire }void FlushEvent(){} void initgraphique(){  colortable=0;  ncolortable=0;  LastColor=2;// En couleur par default  fcolor=1;  /* des couleurs */  SetColorTable(8);  INITGRAPH = 1;  width = 1500;  height =  1060; // aspect ratio  \sqrt(2)}void closegraphique(){  if (INITGRAPH)    {      INITGRAPH = 0;      delete [] colortable;      closePS();    }}void cadre(reel xmin,reel xmax,reel ymin,reel ymax){  rxmin = xmin;  rxmax = xmax;  rymin = ymin;  rymax = ymax;  echx = width / (xmax - xmin);  echy = height / (ymax - ymin);}void getcadre(reel &xmin,reel &xmax,reel &ymin,reel &ymax){  xmin = rxmin;  xmax = rxmax;  ymin = rymin;  ymax = rymax;}int InRecScreen(reel x1, reel y1,reel x2, reel y2){    return (Max(x1,x2)>= rxmin) && (Min(x1,x2) <= rxmax) && (Max(y1,y2) >= rymin) && (Min(y1,y2)  <= rymax);}int InPtScreen( reel x, reel y){  return (x >= rxmin) && (x <= rxmax) && (y >= rymin) && (y <= rymax);}float scali(int i){  return i/echx  + rxmin;}float scalj(int j){  return -j/echy  + rymax;}int scalx(reel x){  return (int) Min(fMaxPixel,Max(fMinPixel,((x - rxmin) * echx)));} int scaly(reel y){  return (int)Min(fMaxPixel,Max(fMinPixel,((rymax - y) * echy)));}void pointe(reel , reel ){}void rmoveto(reel x, reel y){  currx = scalx(x);  curry = scaly(y);}void rlineto(reel x, reel y){  int newx = scalx(x), newy = scaly(y);  if (psfile)    fprintf(psfile,"%d %d %d %d L\n",currx, height-curry, newx, height-newy);  currx = newx; curry = newy;}void cadreortho(reel centrex, reel centrey, reel rayon){  if (height < width)  {    rymin = centrey - rayon;    rymax = centrey + rayon;    echx = echy= height / (2 * rayon);    rxmin= centrex - width / (2 * echx);    rxmax= centrex + width / (2 * echx);  }  else  {    rxmin = centrex - rayon;    rxmax = centrex + rayon;    echx = echy = width / (2 * rayon);    rymin = centrey - height / (2 * echy);    rymax = centrey + height / (2 * echy);  }}void plotstring (const char *  string){ //int l = strlen(string); if(psfile) fprintf(psfile,"(%s) %d %d  S\n",string,currx,height-curry);}void showgraphic(){}void x11draw3(int * ptype){  int type;  type=  *ptype;  if (psfile)     switch (type) {    case 0  : {fprintf(psfile,"[] setdash\n");break;}    case 1  : {fprintf(psfile,"[3]  setdash\n");break;}    default : {fprintf(psfile,"[4 1] setdash\n");break;}    }}  void penthickness(int pepais){  if (psfile) fprintf(psfile,"%d setlinewidth\n",pepais);}void x11linsrn(int * ,int * ,int * ,int * )  //int *x1,*x2,*y1,*y2;{   }   void viderbuff(){}void cercle(reel , reel , reel ){  //int r = (int) (rayon * echx);}void reffecran(){}void fillpoly(int n, float *poly){  int i;   if (psfile)     {     fprintf(psfile,"bF ");     for (i=0;i<n;i++)      fprintf(psfile,"%d %d ", scalx(poly[2*i]),height-scaly( poly[2*i+1]));     fprintf(psfile,"eF\n");    }}int  execute (const char * str){  cout << "exec: " << str << endl; return  system(str);}char Getijc(int *x1,int *y1){  //char char1;  *x1=0;  *y1=0;  //cout << "entre un caractere ? ";  //cin >>char1 ;  return 0;// char1;}   char Getxyc(float &x,float &y){   //  cout << " in Getxyc" << endl;  char c;  int i,j;  c = Getijc( &i,&j);  x = scali(i);  y = scalj(j);  //  cout << " out  Getxyc" << x << " " << y << " " << c << endl;  return c;}void rattente(int ){} void GetScreenSize(int &ix,int &iy){  ix = width;  iy = height;}void openPS(const char *filename ){   char ffff[32];  int count=0;  if(psfile_save) closePS();  time_t t_loc;  int  widthA4PS=596;  int heightA4PS=842;  float s= (double)widthA4PS/width;  char  username[10];  /*if (!cuserid(username)) */ strcpy(username,"inconnue");  time(&t_loc);  bool notfound;  if( !filename)    do {      struct stat buf;      sprintf(ffff,"rgraph_%.3d.ps",count++);      volatile int r= stat(ffff,&buf) ;      notfound = r !=0;      if(count>1000) break;    } while ( !notfound );     const char *fps (filename?filename:ffff);    psfile=fopen(fps,"w");  if(psfile) {    psfile_save=psfile;    fprintf(psfile,"%%!PS-Adobe-2.0 EPSF-2.0\n%%%%Creator: %s\n%%%%Title: FreeFem++\n","user");    fprintf(psfile,"%%%%CreationDate: %s",ctime(&t_loc));    fprintf(psfile,"%%%%Pages: 1\n");    fprintf(psfile,"%%%%BoundingBox:       0 0 %d %d\n",int(width*s),int(height*s));    fprintf(psfile,"%%%%EndComments\n");    fprintf(psfile," /L {newpath moveto lineto stroke} def\n");    fprintf(psfile," /C {setrgbcolor} def\n");    fprintf(psfile," /rec {newpath 4 copy 8 1 roll moveto 3 -1 roll lineto 4 2 roll exch lineto lineto closepath} def\n");    fprintf(psfile," %f %f  scale \n",s,s);    fprintf(psfile," 0 %d 0 %d rec clip\n",int(width),int(height));    fprintf(psfile," /Helvetica findfont 9 scalefont setfont\n");    fprintf(psfile," /S {moveto show} def\n");    fprintf(psfile," /bF  { mark} def \n");    fprintf(psfile," /eF {newpath moveto counttomark 2 idiv {lineto} repeat closepath fill cleartomark} def\n");    fprintf(psfile," /P { /yy exch def /xx exch def   xx xx 1 add yy yy 1 add  rec  fill } def\n");    fprintf(psfile," 0.5 setlinewidth\n");  }  else     cerr << " Err openning postscript file " << fps << endl;}void closePS(void){  if(psfile_save) {    fprintf(psfile_save,"showpage\n");    fclose(psfile_save);  }  psfile_save=0;  psfile=0;} void coutmode(short )  {}// bof bof ---  float  GetHeigthFont(){   return 5./echy;}  void Commentaire(const char * c)    {  if(psfile)   {    fprintf(psfile,"%% %s\n",c);   }  }  void NoirEtBlanc(int NB)  {    if(NB) LastColor=1;    else LastColor=ncolortable?ncolortable:2;  }   void MettreDansPostScript(int in)   {     if(in)  psfile=psfile_save;          else   psfile=0;   }static void     FillRect(float x0,float y0, float x1, float y1) {     float r[8];     r[0]=x0;r[1]=y0;     r[2]=x1;r[3]=y0;     r[4]=x1;r[5]=y1;     r[6]=x0;r[7]=y1;     fillpoly(4,r); }int PutLevel(int lineno, float xf, int col){  float xmin,xmax,ymin,ymax;  getcadre(xmin,xmax,ymin,ymax);  float xleft = xmax - (xmax-xmin)*0.1;  float ytop  = ymax;  float ydelta = (ymax-ymin)/40;  ydelta=GetHeigthFont();  xleft = xmax - 6*ydelta;    ytop -= ydelta*(col+2);  couleur(col);  FillRect(xleft+ydelta/8.,ytop+ydelta/8.,xleft+ydelta*7./8.,ytop+ydelta*7./8.);  rmoveto(xleft+ydelta*1.4,ytop+ydelta/4);  char buf[30];  sprintf(buf,"%g",xf);  couleur(1);  plotstring(buf);   return lineno;} void ShowHelp(const char * s,int k){  if(k) {    MettreDansPostScript(0);    couleur(1);    float xmin,xmax,ymin,ymax;    getcadre(xmin,xmax,ymin,ymax);    rmoveto(xmin+(xmax-xmin)/100,ymax-(k)*(ymax-ymin)/30);    plotstring(s);    MettreDansPostScript(1);       //  couleur(1);	  }}  void setgrey(bool gg ){grey=gg;}  int getgrey(){ return grey;}class Grid;void SaveMesh(Grid &){}void SavePlot(int , Grid& , double *){}void SavePlot(int , Grid& , float *){}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -