+++ /dev/null
-/*****************************************************************************
-** This is part of the CTSim program
-** Copyright (C) 1983-2000 Kevin Rosenberg
-**
-** $Id: sdf.h,v 1.3 2000/05/07 12:46:19 kevin Exp $
-** $Log: sdf.h,v $
-** Revision 1.3 2000/05/07 12:46:19 kevin
-** made c++ compatible
-**
-** Revision 1.2 2000/04/28 14:14:16 kevin
-** *** empty log message ***
-**
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License (version 2) as
-** published by the Free Software Foundation.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
-** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-******************************************************************************/
-/* FILE IDENTIFICATION
- *
- * Name: sdf.h Header file for Standard Data FIle system
- * Programmer: Kevin Rosenberg
- * Date Started: 9-18-84
- * Last Change: 12-24-84
- */
-
-#ifndef __H_SDF
-#define __H_SDF
-
-#include "kmath.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/*----------------*/
-/* SYSTEM ALIASES */
-/*----------------*/
-
-#define SDF_VERSION 2
-#define SDF_ID_STR "SDF"
-
-/*------------------*/
-/* DEFINITION BLOCK */
-/*------------------*/
-
-/* fixed system constants */
-
-#define BLK_SIZE 256 /* Size of a header block */
-#define NUM_DIRBLK 1 /* number of directory blocks */
-
-/* block types */
-
-#define BT_EMPTY 0 /* Not being used */
-#define BT_DIRECTORY 1 /* First blocks in file */
-#define BT_LABEL 2 /* Label block */
-
-/* label types */
-
-#define LT_EMPTY 0 /* label record is available for use */
-#define LT_TITLE 1 /* descriptive label given by user */
-#define LT_HISTORY 2 /* history label generated by application */
- /* program */
-#define LT_NOTE 3 /* A note created with a label editor */
-
-/* codes for open_sdf and create_sdf */
-
-#define SDF_RDONLY 0
-#define SDF_WRONLY 1
-#define SDF_RDWR 2
-
-/* function return codes */
-
-#define SDF_ERROR ERROR
-#define SDF_2D_ERROR SDF_ERROR
-#define SDF_OK OK
-
-/* types of sdf file, this area is EXPANDABLE */
-
-#define SDF_FTYPE_2D 10 /* Two-dimensional data file */
-
-
-/* BLOCK IDENTIFICATION
- *
- * Name: Directory Header Block
- * Size: Multiple of BLK_SIZE
- *
- * DESCRIPTION
- * This is the first block of a sdf file. It contains information on the
- * size of the users' data plus the number and type of header blocks.
- */
-
-struct dir_blk_st {
- int block_type; /* required at the beginning of every block */
- /* to identify type of block */
-
- char id_str[4]; /* identification string == SDF_ID_STR */
- int sdf_version; /* which version of sdf system == SDF_VERSION */
-
- int blk_size; /* size of a header block in bytes */
-
- int df_type; /* type of data file, used as identification */
- /* by application programs */
-
- unsigned int num_dirblk; /* number of directory header blocks */
- /* currently, only 1 block long */
-
-/* label directory */
-
- unsigned int start_label; /* starting position of label header blocks */
- unsigned int num_label; /* number of label header blocks */
-
-/* data header info */
-
- unsigned int start_dhead; /* block number of the start of the users' */
- /* data header blocks */
- unsigned int num_dhead; /* number of data header blocks */
- unsigned int dhead_len; /* length of data header in bytes */
-
-/* data record info */
-
- unsigned int start_drec; /* block number of start of data records */
- unsigned int num_drec; /* number of of user data records */
- unsigned int drec_size; /* size of users' record */
- int num_dval; /* number of values in each data record */
- int dval_size; /* size of data value in bytes */
- /* NOTE: drec_size = dval_size * num_dval */
-};
-
-
-/* BLOCK IDENTIFICATION
- *
- * Name: Label block
- * Size: BLK_SIZE
- *
- * DESCRIPTION
- * This block contains both user and history labels. Labels are alpha-
- * numeric. History labels include time & date stamp plus calculation time.
- */
-
-#define LABEL_LEN 159 /* size of alphanumeric label */
-#define LABELS_PER_BLOCK 1
- /* number of labels in each block */
-
-struct label_blk_st {
- int block_type; /* required at the beginning of every block */
- int label_type; /* type of label */
- char label_str[LABEL_LEN+1];/* alpha numeric label */
-
-/* history label time stamping */
-
- TIMEDATE timedate; /* time and date of operation */
- float calc_time; /* calculation time in seconds */
-};
-
-
-/* BLOCK IDENTIFICATION
- *
- * Name: Data Header Block
- * Size: Variable, but always integer multiple of BLK_SIZE
- *
- * DESCRIPTION
- * This block hold information entirely specific to the data in the sdf
- * file, such as the user coordinates of the extent of an image, or the
- * the rotation increment of raysum data. When an application program
- * reads or writes the data header, it passes the size in bytes of the
- * data header to be read or written. If the length of a data header
- * being read doesn't match the length of the data header in the file,
- * the header is still read, but a WARNING message is given.
- */
-
-
-
-/* STRUCTURE IDENTIFICATION
- *
- * Name: Data File Structure Contains all information on open files
- *
- * DESCRIPTION
- * This structure is generated by open_file() and create_file(), it is
- * passed to all subroutines of the sdf system.
- */
-
-struct sdfile_st {
- bool open; /* if file is open or not */
- int mode; /* read-write mode */
- int fd; /* file descriptor gotten from C library */
- bool error; /* TRUE if error occurred, all further */
- /* procesing is stopped */
- bool error_report; /* Error reporting flag */
-
- unsigned int blk_size; /* size of a header block */
- unsigned int num_dirblk; /* number of directory header blocks */
- char fname[MAXFULLNAME+1]; /* operating system filename */
-
- int df_type; /* identification type of data file */
-
-/* variables that are used when writing to a file, they define what parts
- * of the file have been written
- */
-
- struct wrt {
- unsigned dir : 1; /* 1 if directory header has been written */
- unsigned label : 1; /* 1 if labels have been written */
- unsigned dhead : 1; /* 1 if data header has been written */
- unsigned drec : 1; /* 1 when data records have been written */
- } written;
-
-/* Directory information to have about the file */
-
- unsigned int start_label; /* starting position of labels */
- unsigned int num_label; /* number of labels in file */
-
- unsigned int dhead_len; /* length of data header in bytes */
-
- unsigned int num_drec; /* number of data records */
- unsigned int drec_size; /* size of data records in bytes */
- int num_dval; /* number of values in each data record */
- int dval_size; /* size of data value in bytes */
- /* NOTE: drec_size = dval_size * num_dval */
-
-/* ffset pointers into sdf file */
-
- long int pos_dhead; /* starting position of data header */
- long int pos_drec; /* starting position of users' data */
-};
-
-
-union sdf_blk_un {
- char buf[BLK_SIZE];
- struct dir_blk_st dir;
- struct label_blk_st lab;
-};
-
-typedef struct dir_blk_st DIR_BLK;
-typedef struct label_blk_st LABEL_BLK;
-typedef struct sdfile_st SDFILE;
-typedef union sdf_blk_un SDF_BLK;
-
-
-/*----------------------------------------------------------------------*/
-/* 2-Dimensional Standard Data File Header */
-/*----------------------------------------------------------------------*/
-
-
-/* STRUCTURE IDENTIFICATION
- *
- * Name: sdf_2d_dhead_st Data header for 2d data files
- *
- * DESCRIPTION
- *
- * This structure holds the data that is stored in an image sdf file's
- * data header. It contains all data needed to use 2d data records
- */
-
-struct sdf_2d_dhead_st {
- int file_type; /* type of data making up this file */
- /* currenty, DFT_2D_IMAGE or DFT_2D_RAYSUM */
- int nx; /* number of rows */
- int ny; /* number of columns in row */
- int val_type; /* type of pixel value, eg, DT_FLOAT */
- int val_size; /* size of pixel value in bytes */
-
- bool axis_ext_kwn; /* TRUE if picture extent is known */
- /* stored in xmin,xmax,ymin,ymax */
- double xmin, ymin; /* position of lower left corner of picture */
- double xmax, ymax; /* position of upper right corner of picture */
-
- bool axis_incr_kwn; /* TRUE if increments are known */
- double xinc, yinc;
-
- bool val_ext_kwn; /* TRUE if pixel extent is known */
- double dvalmin, dvalmax;/* min & max data value for FLOAT & DOUBLE */
- long lvalmin, lvalmax; /* data extent for INT & LONG */
-};
-
-
-/* STRUCTURE IDENTIFICATION
- *
- * Name: sdf_2d_st Information about an sdf image
- *
- * DESCRIPTION
- *
- * This structure holds all the information need to access an sdf
- * image.
- */
-
-struct sdf_2d_st {
- struct sdf_2d_dhead_st dhead; /* image information that is stored in data header */
- SDFILE *dfp; /* pointer to image's standard data file */
- MTX *mtx; /* data values */
- int memory_only; /* TRUE if sdf_2d file is stored in memory only */
-};
-
-typedef struct sdf_2d_dhead_st SDF_2D_DHEAD;
-typedef struct sdf_2d_st SDF_2D;
-
-/* types of 2d data files */
-
-#define SDF_2D_IMAGE 100 /* data file type is an image */
-#define SDF_2D_RAYSUM 101 /* raysum data file type */
-
-
-/* sdf.c */
-SDFILE *sdf_open(const char *filename, const int mode);
-SDFILE *sdf_create(const char *filename, const int mode, const unsigned int num_drec, const unsigned int num_dval, const int dval_size, const int df_type);
-int sdf_read_label(LABEL_BLK *lrec, const int nlab, SDFILE *dfp);
-int sdf_write_label(LABEL_BLK *lrec, const int nlab, SDFILE *dfp);
-int sdf_add_label(const int ltype, const char *lstr, const double calc_time, SDFILE *dfp);
-int sdf_add_empty_label(SDFILE *dfp);
-int sdf_copy_labels(SDFILE *dfp_to, SDFILE *dfp_from);
-int sdf_read_dhead(void *dh_buf, const unsigned int dhead_len, SDFILE *dfp);
-int sdf_write_dhead(const void *dh_buf, const unsigned int dhead_len, SDFILE *dfp);
-int sdf_read_drec(void *drec, const int start_rec, const int num_rec, SDFILE *dfp);
-int sdf_write_drec(const void *drec, const int start_rec, const int num_rec, SDFILE *dfp);
-int sdf_read_dval(void *dval, const int rec, const int start_val, const int num_val, SDFILE *dfp);
-int sdf_write_dval(const void *dval, const int rec, const int start_val, const int num_val, SDFILE *dfp);
-int sdf_close(SDFILE *dfp);
-void sdf_error_report(SDFILE *dfp, const int flag);
-void sdf_error(const SDFILE *dfp, const char *str, ...);
-bool sdf_check_dfp(const SDFILE *dfp, const int mode, const char *name);
-void *sdf_alloc_blk(const int n, SDFILE *dfp, const char *name);
-int sdf_free_blk(void *hb, SDFILE *dfp, const char *name);
-/* sdf_2d.c */
-SDF_2D *sdf_2d_open(const char *fname, const int mode);
-SDF_2D *sdf_2d_create(const char *fname, const int mode, const int nx, const int ny, const int val_type, const int df_type);
-int sdf_2d_save(SDF_2D *imp);
-int sdf_2d_restore(SDF_2D *imp);
-int sdf_2d_alloc_mtx(SDF_2D *imp);
-int sdf_2d_free_mtx(SDF_2D *sdf_2d);
-int sdf_2d_read_row(char *row_buf, const unsigned int row, SDF_2D *imp);
-int sdf_2d_write_row(const char *row_buf, const unsigned int row, SDF_2D *imp);
-int sdf_2d_read_col(char *col_buf, const unsigned int col, SDF_2D *imp);
-int sdf_2d_write_col(const char *col_buf, const unsigned int col, SDF_2D *imp);
-int sdf_2d_close(SDF_2D *imp);
-char *sdf_2d_alloc_row(const int nrow, SDF_2D *imp);
-char *sdf_2d_alloc_col(const int ncol, SDF_2D *imp);
-void sdf_2d_error(const SDF_2D *imp, const char *str, ...);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif