#include #include #include extern "C" { __declspec(dllexport) void TRSAVESUFFIX(char*); __declspec(dllexport) void TRSAVEKIND(int*,char*); __declspec(dllexport) void TRSAVEGETBASICMODEL(float*); __declspec(dllexport) void TRSAVESAVEWORK(char*,double*,double*,double*, int*,int*,float*,unsigned char*,int*); } float *top0; //====================================================================== void TRSAVESUFFIX(char *suffix) //[- O] 拡張子文字 //複数指定する場合は";"で区切って下さい { strcpy(suffix,".SA"); } //====================================================================== void TRSAVEKIND(int *lang, //[I -] =0 標準時 =1 他言語時 char *item) //[- O] 項目名 { strcpy(item,"差分情報リスト(*.SA)"); } //====================================================================== void TRSAVEGETBASICMODEL(float *topb) //[I -] 基準形状のZ値先頭アドレス // topb=NULLの場合は設定されて // いません。 { top0=topb; } //====================================================================== void TRSAVESAVEWORK(char *filename,//[I -] ファイル名 double *bmax, //[I -] ワークの最大値XY double *bmin, //[I -] ワークの最小値XYZ double *wpitch, //[I -] ワークのピッチ(精度) int *xmax, //[I -] X方向格子数 int *ymax, //[I -] Y方向格子数 float *top, //[I -] Z値列(X*Y個)の先頭アドレス unsigned char *topc, //[I -] 属性(PENKI,PENなど)の先頭アドレス int *topn) //[I -] 切削ブロック番号の先頭アドレス { FILE *sfp; int i,j,k; int ip,im; double wpitch2,height,volp,volm,area; double pmax,mmax; double pmaxx,pmaxy; double mmaxx,mmaxy; sfp=fopen(filename,"w"); k=0; ip=im=0; volp=volm=0.0; mmax=pmax=0.0; wpitch2=(*wpitch)*(*wpitch); for(j=0;j<*ymax;j++) { for(i=0;i<*xmax;i++) { height=top[k]-top0[k]; area=wpitch2; if( i == 0 || i == *xmax-1 ) { area=area/2; if( j == 0 || j == *ymax-1 ) area=area/2; } if( height > 0.0 ) { ip++; if( height > pmax ) { pmax =height; pmaxx=bmin[0]+i*(*wpitch); pmaxy=bmin[1]+j*(*wpitch); } volp+=(area*height); } else if( height < 0.0 ) { im++; if( fabs(height) > mmax ) { mmax=fabs(height); mmaxx=bmin[0]+i*(*wpitch); mmaxy=bmin[1]+j*(*wpitch); } volm+=(area*fabs(height)); } k++; } } fprintf(sfp,"/// 差分情報リスト\n"); fprintf(sfp,"-----------------------------------------\n"); if( ip > 0 ) { fprintf(sfp,"+側差分体積=%f 対象格子数=%d\n",volp,ip); fprintf(sfp,"+側最大差分=%f 位置 X=%10.3f,Y=%10.3f\n",pmax,pmaxx,pmaxy); } else { fprintf(sfp,"+側差分はありません\n"); fprintf(sfp,"\n"); } fprintf(sfp,"-----------------------------------------\n"); if( im > 0 ) { fprintf(sfp,"-側差分体積=%f 対象格子数=%d\n",volm,im); fprintf(sfp,"-側最大差分=%f 位置 X=%10.3f,Y=%10.3f\n",mmax,mmaxx,mmaxy); } else { fprintf(sfp,"-側差分はありません\n"); fprintf(sfp,"\n"); } fclose(sfp); }