/**
* @file addZero.c
* @author Robert S Laramee
* @version 1.0
* @see ARrenderer, MarchingCubesReader
*
* start date Sun 23 May 99
* finish date none
*
* Description This program is meant to read in raw data, preferably
* ASCII floats, with fixed dimensions e.g. 64 X 64 X 64,
* and output that same data with a zero prepended to the number.
*/
#include
/* dimensions constants */
#define ZLAYERS 64
#define YCOLUMNS 64
#define XROWS 64
#define NUMBER 9 /* 5 digits + 1 period + 1 dash + 1 return + 1 extra */
void parseFile(FILE *inputFile);
/**
* The main() function starts the prependZero filter.
* @param -the name of the file to read from
*/
int main (int argc, char *argv[]) {
FILE *inputFile;
if (( inputFile = fopen(argv[1],"r")) == NULL) {
perror("***Error, couldn't open input file");
exit(1);
}
parseFile(inputFile);
fclose(inputFile);
}
/**
* This method parses the data file
* @param fd -a file descriptor
*/
void parseFile(FILE *inputFile) {
int x,y,z;
char string[NUMBER];
for (z = 0; z < ZLAYERS; z++) { /* FOR EACH ZLAYER */
for (y = 0; y < YCOLUMNS; y++) { /* FOR EACH YCOLUMN */
for (x = 0; x < XROWS; x++) { /* FOR EACH XROW */
fscanf(inputFile, "%s\n", string);
if (string[0] == '-')
printf("-0%s\n",
strstr(string, ".")); /* string library function */
else
printf("0%s\n", string);
}
}
}
}