Advertisement
hasegawa

☆text2binary-vtk-polygons3

Feb 6th, 2014
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.96 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5.  
  6. int main(int argc,char *argv[])
  7. {
  8.     FILE *fpi,*fpo;
  9.     int i,j,k,nums/*,face,vertex,point*/;
  10.     int data;
  11.     char line[8];
  12.  
  13.     if(argc!=4)
  14.     {
  15.         fprintf(stderr,"Usage: %s 5m_mesh_data.lem,5m_mesh_data.raw\n",argv[0]);
  16.         exit(1);
  17.     }
  18.     printf("OPEN FILE NAME:%s\n",argv[1]);
  19.  
  20.     if((fpi=fopen(argv[1],"r"))==NULL)
  21.     {
  22.         fprintf(stderr,"Can not open\n");
  23.         exit(1);
  24.     }
  25.  
  26.     if((fpo=fopen(argv[2],"wb"))==NULL)
  27.     {
  28.         fprintf(stderr,"Can not open\n");
  29.         exit(1);
  30.     }
  31.  
  32.     nums=atoi(argv[3]);
  33.     //vertex=atoi(argv[4]);
  34.     //point=atoi(argv[5]);
  35.     for(i=0;i<nums;i++)
  36.     {
  37.         for (j=0;j<3;j++)
  38.         {
  39.             //for (k=0;k<point;k++)
  40.             //{
  41.                 //fseek(fpi,6*k+j*20+i*68,SEEK_SET);
  42.                 fseek(fpi,j*7+i*23,SEEK_SET);
  43.                 fgets(line, 8, fpi);
  44.                 data=atoi(line);
  45.                 printf("%d\n",data);
  46.                 fwrite(&data,sizeof(int),1,fpo);
  47.                 //fseek(fpi,2,SEEK_CUR);
  48.             //}
  49.         }
  50.     }
  51.  
  52.     fclose(fpi);
  53.     fclose(fpo);
  54.  
  55.     return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement