Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <time.h>
- int main(int argc,char *argv[])
- {
- FILE *fpi,*fpo;
- int i,j,k,nums/*,face,vertex,point*/;
- float data;
- float *file1;
- float x,y,z;
- char line[7];
- if(argc!=4)
- {
- fprintf(stderr,"Usage: %s 5m_mesh_data.lem,5m_mesh_data.raw\n",argv[0]);
- exit(1);
- }
- printf("OPEN FILE NAME:%s\n",argv[1]);
- if((fpi=fopen(argv[1],"r"))==NULL)
- {
- fprintf(stderr,"Can not open\n");
- exit(1);
- }
- if((fpo=fopen(argv[2],"wb"))==NULL)
- {
- fprintf(stderr,"Can not open\n");
- exit(1);
- }
- nums=atoi(argv[3]);
- file1= (float *)malloc(nums*3*3*sizeof(float));
- //vertex=atoi(argv[4]);
- //point=atoi(argv[5]);
- /*
- for(i=0;i<nums;i++)
- {
- for (j=0;j<3;j++)
- {
- //for (k=0;k<point;k++)
- //{
- //fseek(fpi,6*k+j*20+i*68,SEEK_SET);
- fseek(fpi,j*6+i*20,SEEK_SET);
- fgets(line, 7, fpi);
- data=atof(line);
- //printf("%f\n",data);
- fwrite(&data,sizeof(float),1,fpo);
- //fseek(fpi,2,SEEK_CUR);
- //}
- }
- }
- */
- int count=0;
- while (fscanf(fpi,"%f %f %f ",&x, &y, &z )!= EOF)
- {
- file1[3*count]=x;
- file1[3*count+1]=y;
- file1[3*count+2]=z;
- count=count+1;
- }
- fwrite(file1,sizeof(float),nums*3*3,fpo);
- fclose(fpi);
- fclose(fpo);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement