Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(int argc, char *argv[])
- {
- //Decralation of variables
- int i;
- int r,g,b;
- unsigned long newline_count_1=0,newline_count_2=0,lines;
- FILE *fpi1,*fpo;
- float x,y,z;
- float nx,ny,nz;
- float fnx,fny,fnz;
- unsigned char ux,uy,uz;
- unsigned char unx,uny,unz;
- if(argc!=3)
- {
- fprintf(stderr,"Usage: %s (1)CSV1File\n(2)CSV2File\n(3)VTKFile\n",argv[0]);
- return 0;
- }
- printf("Open CSV1 File\n");
- //Open CSV1 file
- if((fpi1=fopen(argv[1],"r"))==NULL)
- {
- printf("The file can't be opened. The program is exit.\n");
- return 0;
- }
- //Open VTK file for save
- if((fpo=fopen(argv[2],"w"))==NULL)
- {
- printf("The file can't be opened. The program is exit.\n");
- return 0;
- }
- //count how many lines
- /*
- while((c==fgetc(fpi))!=EOF
- {
- if(c=='\n')
- newline_count++;
- }
- */
- printf("CSV1 File\n");
- while (fscanf(fpi1,"%f %f %f %d %d %d %f %f %f",&x, &y, &z, &r, &g, &b, &nx, &ny, &nz)!= EOF)
- {
- printf("%f %f %f\n",x,y,z);
- fnx=(nx+1)*255/2;
- fny=(ny+1)*255/2;
- fnz=(nz+1)*255/2;
- unx=(unsigned char)fnx;
- uny=(unsigned char)fny;
- unz=(unsigned char)fnz;
- fprintf(fpo,"%f %f %f %d %d %d\n",x,y,z,unx,uny,unz);
- }
- fclose(fpi1);
- fclose(fpo);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement