~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/file/ani/read_air16.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* Copyright 1995 Roger P. Woods, M.D. */
  2 /* Modified: 12/11/95 */
  3 
  4 /****************************************************************/
  5 /* int read_air16                                               */
  6 /*                                                              */
  7 /* reads an AIR reslice parameter file into an air struct       */
  8 /*                                                              */
  9 /* program will also attempt to convert old 12 parameter        */
 10 /* AIR files into new 15 parameter files                        */
 11 /*                                                              */
 12 /* returns:                                                     */
 13 /*      1 if successful                                         */
 14 /*      0 if unsuccessful                                       */
 15 /****************************************************************/
 16 
 17 #include "AIR.h"
 18 
 19 int read_air16(char *inputfile,struct air16 *air1)
 20 {
 21         FILE            *fp;
 22         char            filename[128];
 23         struct oldair   air2;
 24 
 25         strcpy(filename,inputfile);
 26 
 27         /*Open input file */
 28         if((fp=fopen(filename,"rb"))==NULL){
 29                 printf("cannot open file %s for input\n",filename);
 30                 return 0;
 31         }
 32         
 33         /*Read in AIR file*/
 34 
 35         if(fread((char *)air1,1,sizeof(struct air16),fp)!=sizeof(struct air16)){
 36 
 37                 /*Try reading it as an old 12 parameter air file*/
 38                 rewind(fp);
 39                 if(fread((char *)&air2,1,sizeof(struct oldair),fp)!=sizeof(struct oldair)){
 40                         printf("file read error for file %s\n",filename);
 41                         fclose(fp);
 42                         return 0;
 43                 }
 44                 strncpy(air1->s_file,air2.s_file,127);
 45                 strncpy(air1->r_file,air2.r_file,127);
 46                 strncpy(air1->comment,air2.comment,127);
 47                 strncpy(air1->reserved,air2.reserved,115);
 48                 air1->s.bits=air2.s.bits;
 49                 air1->s.x_dim=air2.s.x_dim;
 50                 air1->s.y_dim=air2.s.y_dim;
 51                 air1->s.z_dim=air2.s.z_dim;
 52                 air1->s.x_size=air2.s.x_size;
 53                 air1->s.y_size=air2.s.y_size;
 54                 air1->s.z_size=air2.s.z_size;
 55                 air1->r.bits=air2.r.bits;
 56                 air1->r.x_dim=air2.r.x_dim;
 57                 air1->r.y_dim=air2.r.y_dim;
 58                 air1->r.z_dim=air2.r.z_dim;
 59                 air1->r.x_size=air2.r.x_size;
 60                 air1->r.y_size=air2.r.y_size;
 61                 air1->r.z_size=air2.r.z_size;
 62                 air1->s_hash=air2.s_hash;
 63                 air1->r_hash=air2.r_hash;
 64                 air1->s_volume=air2.s_volume;
 65                 air1->r_volume=air2.r_volume;
 66                 air1->e[0][0]=air2.e[1][0];
 67                 air1->e[0][1]=air2.e[1][1];
 68                 air1->e[0][2]=air2.e[1][2];
 69                 air1->e[0][3]=0;
 70                 air1->e[1][0]=air2.e[2][0];
 71                 air1->e[1][1]=air2.e[2][1];
 72                 air1->e[1][2]=air2.e[2][2];
 73                 air1->e[1][3]=0;
 74                 air1->e[2][0]=air2.e[3][0];
 75                 air1->e[2][1]=air2.e[3][1];
 76                 air1->e[2][2]=air2.e[3][2];
 77                 air1->e[2][3]=0;
 78                 air1->e[3][0]=air2.e[0][0];
 79                 air1->e[3][1]=air2.e[0][1];
 80                 air1->e[3][2]=air2.e[0][2];
 81                 air1->e[3][3]=1;
 82 
 83         }
 84 
 85         if(getc(fp)!=EOF){
 86                 printf("file read error for file %s--EOF not at expected location\n",filename);
 87                 fclose(fp);
 88                 return 0;
 89         }
 90         fclose(fp);
 91         
 92         return 1;
 93 }
 94 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.