home *** CD-ROM | disk | FTP | other *** search
/ vis-ftp.cs.umass.edu / vis-ftp.cs.umass.edu.tar / vis-ftp.cs.umass.edu / pub / Miscellaneous / utah_range_database / whitescan.c < prev   
C/C++ Source or Header  |  1992-07-08  |  2KB  |  71 lines

  1. /* -*-c-mode-*- */
  2. /*------------------------------------------------------
  3.  *  WHITESCAN.C - read WHite scanner data file
  4.  *  Robert Heller Created on Mon May 18 11:09:12 1987
  5.  *  Last mod - 
  6.  *--------------------------------------------------------
  7.  *  Contents:
  8.  *--------------------------------------------------------
  9.  * (c) Copyright 1987 by The University of Massachusetts
  10.  *------------------------------------------------------*/
  11.  
  12. #include <stdio.h>
  13.  
  14. main(argc,argv)
  15. int argc;
  16. char *argv[];
  17. {
  18.     FILE *infile;
  19.     static short int sl[240][5];
  20.     int INT, STATUS,i,lines;
  21.     float x,y,z;
  22.     short int swap();
  23.  
  24.     if (argc != 2) {
  25.     fprintf(stderr,"usage: whitescan file\n");
  26.     abort(argc);
  27.     }
  28.     infile = fopen(argv[1],"r");
  29.     if (infile == NULL) {
  30.     perror("whitescan");
  31.     fprintf(stderr,"whitescan: could not open %s\n",argv[1]);
  32.     abort(0);
  33.     }
  34.  
  35.     while ((lines = fread(sl,sizeof(sl),1,infile)) > 0) {
  36.     for (i=0; i < 240; i++) {
  37. #ifdef SWAP
  38.         x = swap(sl[i][0]) / 1000.0;
  39.         y = swap(sl[i][1]) / 1000.0;
  40.         z = swap(sl[i][2]) / 1000.0;
  41.         STATUS = (swap(sl[i][3]) & 0x0044);
  42.         INT = swap(sl[i][4]);
  43. #else
  44.         x = sl[i][0] / 1000.0;
  45.         y = sl[i][1] / 1000.0;
  46.         z = sl[i][2] / 1000.0;
  47.         STATUS = (sl[i][3] & 44);
  48.         INT = sl[i][4];
  49. #endif
  50.         if ((STATUS == 4) && (INT > 50) && (i != 230) && (i != 159)) {
  51.         printf("   %9.3f  %9.3f  %9.3f  %10d  %10d  \n",x,y,z,INT,i);
  52.         }
  53.         }
  54.     }
  55.     }
  56.  
  57. short int swap(val)
  58. short int val;
  59. {
  60.     union {
  61.     struct { unsigned char lo,hi; } bytes;
  62.     short int word;
  63.     } a,b;
  64.  
  65.    a.word = val;
  66.    b.bytes.lo = a.bytes.hi;
  67.    b.bytes.hi = a.bytes.lo;
  68.    return(b.word);
  69.    }
  70.   
  71.