home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
vis-ftp.cs.umass.edu
/
vis-ftp.cs.umass.edu.tar
/
vis-ftp.cs.umass.edu
/
pub
/
Software
/
universal_plane_file_format
/
format_plane.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-11-05
|
4KB
|
103 lines
/* -*-c-mode-*- */
/*------------------------------------------------------
* FORMAT_PLANE.C - program that reads in a LLVS plane and formats (to
* stdout) a section of it.
* Robert Heller Created on Mon Jul 10 11:16:09 1989
* Last mod -
*--------------------------------------------------------
* Contents:
*--------------------------------------------------------
* (c) Copyright 1989 by The University of Massachusetts
*------------------------------------------------------*/
#include <stdio.h>
#include <llvs_per_plane.h>
main(argc,argv)
int argc;
char *argv[];
{
LIMITS pl_lims;
PLANE *inpl;
PLANE_INFO *inpl_info;
char *assoc;
char *format;
char *infile;
register int iargc;
static char *default_formats[] = {"%01d", " %3d", " %5d", " %10d", " %10.3f"};
register int irow, icol, currow, curcol;
register float fpixel;
register int ipixel;
infile = NULL;
for (iargc = 1; iargc < argc; iargc++) {
if (*argv[iargc] != '-') {
if (infile != NULL) usage();
infile = argv[iargc];
}
}
if (infile == NULL) usage();
if (read_plane(&inpl,&inpl_info,&assoc,infile) < 0) {
perror(argv[0]);
exit(12);
}
pl_lims.level = inpl_info->level;
pl_lims.deltarow = 1;
pl_lims.deltacol = 1;
pl_lims.startrow = inpl_info->row_location;
pl_lims.startcol = inpl_info->column_location;
pl_lims.endrow = inpl_info->row_location + inpl_info->row_dimension - 1;
pl_lims.endcol = inpl_info->column_location + inpl_info->column_dimension - 1;
format = default_formats[inpl_info->datatype];
for (iargc = 1; iargc < argc; iargc++) {
if (*argv[iargc] != '-') continue;
if (strncmp(argv[iargc],"-start-row=",11) == 0)
pl_lims.startrow = atoi(argv[iargc]+11);
else if (strncmp(argv[iargc],"-start-col=",11) == 0)
pl_lims.startcol = atoi(argv[iargc]+11);
else if (strncmp(argv[iargc],"-end-row=",9) == 0)
pl_lims.endrow = atoi(argv[iargc]+9);
else if (strncmp(argv[iargc],"-end-col=",9) == 0)
pl_lims.endcol = atoi(argv[iargc]+9);
else if (strncmp(argv[iargc],"-format=",8) == 0)
format = argv[iargc]+8;
else {
fprintf(stderr,"format_plane: unknown option: %s\n",argv[iargc]);
usage();
}
}
printf("Plane file: %s\nAssoc List: %s\nStart (%d,%d), End (%d,%d)\n\n",
infile,assoc,pl_lims.startrow,pl_lims.startcol,pl_lims.endrow,
pl_lims.endcol);
for (currow = pl_lims.startrow; currow <= pl_lims.endrow; currow++) {
TRANSLEVEL(irow,currow,0,inpl_info->row_location);
for (curcol = pl_lims.startcol; curcol <= pl_lims.endcol; curcol++) {
TRANSLEVEL(icol,curcol,0,inpl_info->column_location);
if (inpl_info->datatype == LLVS_FLOAT) {
GET_PIXEL(fpixel,inpl_info->background.flonum,inpl,irow,icol,(*inpl_info));
printf(format,fpixel);
}
else {
GET_PIXEL(ipixel,inpl_info->background.fixnum,inpl,irow,icol,(*inpl_info));
printf(format,ipixel);
}
}
printf("\n");
}
}
static usage()
{
fprintf(stderr,"SYNOPIS: format_plane <opts> plane_file <opts>\n");
fprintf(stderr,"This program prints out the numerical values in a LLVS plane\n");
fprintf(stderr,"on the standard output stream.\n\n");
fprintf(stderr,"Options are:\n");
fprintf(stderr,"-start-row=n\tRow to start printing\n");
fprintf(stderr,"-start-col=n\tColumn to start printing\n");
fprintf(stderr,"-end-row=n\tRow to end printing\n");
fprintf(stderr,"-end-col=n\tColumn to end printing\n");
fprintf(stderr,"-format=s\tFormat string to use for each pixel.\n\n");
exit(12);
}