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

Linux Cross Reference
Tina6/tina-libs/tina/file/fileAni_read_air16.c

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

  1 /**********
  2  * 
  3  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  4  * University of Manchester, UK.  All rights reserved.
  5  * 
  6  * Redistribution and use in source and binary forms, with or without modification, 
  7  * are permitted provided that the following conditions are met:
  8  * 
  9  *   . Redistributions of source code must retain the above copyright notice, 
 10  *     this list of conditions and the following disclaimer.
 11  *    
 12  *   . Redistributions in binary form must reproduce the above copyright notice,
 13  *     this list of conditions and the following disclaimer in the documentation 
 14  *     and/or other materials provided with the distribution.
 15  * 
 16  *   . Neither the name of the University of Manchester nor the names of its
 17  *     contributors may be used to endorse or promote products derived from this 
 18  *     software without specific prior written permission.
 19  * 
 20  * 
 21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 31  * POSSIBILITY OF SUCH DAMAGE.
 32  *
 33  **********
 34  * 
 35  * Program :    TINA
 36  * File    :  $Source: /home/tina/cvs/tina-libs/tina/file/fileAni_read_air16.c,v $
 37  * Date    :  $Date: 2005/01/09 17:49:25 $
 38  * Version :  $Revision: 1.3 $
 39  * CVS Id  :  $Id: fileAni_read_air16.c,v 1.3 2005/01/09 17:49:25 paul Exp $
 40  *
 41  * Author  :  Legacy TINA
 42  *
 43  * Notes   :
 44  * 
 45  *  Copyright 1995 Roger P. Woods, M.D. 
 46  *  Modified: 12/11/95 
 47  *
 48  *  int read_air16                                              
 49  *  reads an AIR reslice parameter file into an air struct      
 50  *  program will also attempt to convert old 12 parameter
 51  *  AIR files into new 15 parameter files
 52  *  returns:                                    
 53  *      1 if successful                         
 54  *      0 if unsuccessful                       
 55  *********
 56 */
 57 
 58 #include "fileAni_read_air16.h"
 59 
 60 #if HAVE_CONFIG_H
 61   #include <config.h>
 62 #endif
 63 
 64 #include <string.h>
 65 #include <stdio.h>
 66 #include <tina/file/file_AniDef.h>
 67 
 68 int read_air16(char *inputfile,struct air16 *air1)
 69 {
 70         FILE            *fp;
 71         char            filename[128];
 72         struct oldair   air2;
 73 
 74         strcpy(filename,inputfile);
 75 
 76         /*Open input file */
 77         if((fp=fopen(filename,"rb"))==NULL){
 78                 printf("cannot open file %s for input\n",filename);
 79                 return 0;
 80         }
 81         
 82         /*Read in AIR file*/
 83 
 84         if(fread((char *)air1,1,sizeof(struct air16),fp)!=sizeof(struct air16)){
 85 
 86                 /*Try reading it as an old 12 parameter air file*/
 87                 rewind(fp);
 88                 if(fread((char *)&air2,1,sizeof(struct oldair),fp)!=sizeof(struct oldair)){
 89                         printf("file read error for file %s\n",filename);
 90                         fclose(fp);
 91                         return 0;
 92                 }
 93                 strncpy(air1->s_file,air2.s_file,127);
 94                 strncpy(air1->r_file,air2.r_file,127);
 95                 strncpy(air1->comment,air2.comment,127);
 96                 strncpy(air1->reserved,air2.reserved,115);
 97                 air1->s.bits=air2.s.bits;
 98                 air1->s.x_dim=air2.s.x_dim;
 99                 air1->s.y_dim=air2.s.y_dim;
100                 air1->s.z_dim=air2.s.z_dim;
101                 air1->s.x_size=air2.s.x_size;
102                 air1->s.y_size=air2.s.y_size;
103                 air1->s.z_size=air2.s.z_size;
104                 air1->r.bits=air2.r.bits;
105                 air1->r.x_dim=air2.r.x_dim;
106                 air1->r.y_dim=air2.r.y_dim;
107                 air1->r.z_dim=air2.r.z_dim;
108                 air1->r.x_size=air2.r.x_size;
109                 air1->r.y_size=air2.r.y_size;
110                 air1->r.z_size=air2.r.z_size;
111                 air1->s_hash=air2.s_hash;
112                 air1->r_hash=air2.r_hash;
113                 air1->s_volume=air2.s_volume;
114                 air1->r_volume=air2.r_volume;
115                 air1->e[0][0]=air2.e[1][0];
116                 air1->e[0][1]=air2.e[1][1];
117                 air1->e[0][2]=air2.e[1][2];
118                 air1->e[0][3]=0;
119                 air1->e[1][0]=air2.e[2][0];
120                 air1->e[1][1]=air2.e[2][1];
121                 air1->e[1][2]=air2.e[2][2];
122                 air1->e[1][3]=0;
123                 air1->e[2][0]=air2.e[3][0];
124                 air1->e[2][1]=air2.e[3][1];
125                 air1->e[2][2]=air2.e[3][2];
126                 air1->e[2][3]=0;
127                 air1->e[3][0]=air2.e[0][0];
128                 air1->e[3][1]=air2.e[0][1];
129                 air1->e[3][2]=air2.e[0][2];
130                 air1->e[3][3]=1;
131 
132         }
133 
134         if(getc(fp)!=EOF){
135                 printf("file read error for file %s--EOF not at expected location\n",filename);
136                 fclose(fp);
137                 return 0;
138         }
139         fclose(fp);
140         
141         return 1;
142 }
143 

~ [ 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.