Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define VTX 3
- #define XYZ 3
- int main(int argc,char *argv[])
- {
- FILE *fpi1,*fpi2,*fpo;
- int i,j;
- int tri1,tri2,tri3; //number of triangles
- float dn1;
- int x,y;
- int re;
- int ix,iy;
- int iw,ih,iW,iH;
- int to_tri1,to_tri2,to_tri3;
- float *file1,*file2,*file3;
- if(argc!=6)
- {
- fprintf(stderr,"Usage: %s\n(2)Input_file1_filename\n(3)Input_file2_filename\n(4)Output_new_filename\n(5)triangles_1\n(6)triangles_2\n",argv[0]);
- exit(1);
- }
- printf("OPEN base FILE NAME:%s\n",argv[1]);
- printf("OPEN add FILE NAME:%s\n",argv[2]);
- printf("OPEN OUTPUT FILE NAME:%s\n",argv[3]); //for output
- tri1 = atoi(argv[4]); printf("triangles1 = %d,", tri1); //number of triangles1
- tri2 = atoi(argv[5]); printf("triangles2 = %d\n", tri2); //number of triangles2
- tri3=tri2+tri1;
- to_tri1=tri1*VTX*XYZ;
- to_tri2=tri2*VTX*XYZ;
- to_tri3=tri3*VTX*XYZ;
- printf("total_triangles = %d\n", tri3);
- printf("check00\n");
- file1= (float *)malloc(to_tri1*sizeof(float)); //memory for triangles1
- file2= (float *)malloc(to_tri2*sizeof(float)); //memory for triangles2
- file3= (float *)malloc(to_tri3*sizeof(float)); //memory for triangles3
- // printf("check0\n");
- //base
- if((fpi1=fopen(argv[1],"rb"))==NULL)
- {
- fprintf(stderr,"input file open error\n");
- exit(1);
- }
- printf("check0-1\n");
- fread((float *)file1,sizeof(float),to_tri1,fpi1);//large
- printf("check0-2\n");
- //add
- if((fpi2=fopen(argv[2],"rb"))==NULL)
- {
- fprintf(stderr,"input file open error\n");
- exit(1);
- }
- printf("check0-3\n");
- fread((float *)file2,sizeof(float),to_tri2,fpi2);//small
- printf("check0-4\n");
- if((fpo=fopen(argv[3],"wb"))==NULL)
- {
- fprintf(stderr,"input file open error\n");
- exit(1);
- }
- printf("check1\n");
- for(i=0;i<to_tri1;i++)
- {
- file3[i]=file1[i];
- }
- printf("check2\n");
- for(i=0;i<to_tri2;i++)
- {
- file3[i+to_tri1]=file2[i];
- }
- printf("check3\n");
- for(i=0;i<to_tri3;i++)
- {
- dn1=file3[i];
- fwrite(&dn1,sizeof(float),1,fpo);
- }
- printf("check4\n");
- free(file1);
- free(file2);
- free(file3);
- fclose(fpi1);
- fclose(fpi2);
- fclose(fpo);
- }
Advertisement
Add Comment
Please, Sign In to add comment