db5.h

Go to the documentation of this file.
00001 /*                           D B 5 . H
00002  * BRL-CAD
00003  *
00004  * Copyright (c) 2004-2006 United States Government as represented by
00005  * the U.S. Army Research Laboratory.
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public License
00009  * as published by the Free Software Foundation; either version 2.1 of
00010  * the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Library General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this file; see the file named COPYING for more
00019  * information.
00020  */
00021 /** @addtogroup db5 */
00022 /*@{*/
00023 /** @file db5.h
00024  *@brief
00025  *  Definition of the BRL-CAD "v5" database format used for new ".g" files.
00026  *  
00027  * @author      Michael John Muuss
00028  * @author      Lee A. Butler
00029  * @author      Paul J. Tanenbaum
00030  * @author      John R. Anderson
00031  *
00032  *  @par Source
00033  *      The U. S. Army Research Laboratory
00034  *@n    Aberdeen Proving Ground, Maryland  21005-5068  USA
00035  *
00036  *  $Header: /cvsroot/brlcad/brlcad/include/db5.h,v 14.10 2006/09/18 05:24:07 lbutler Exp $
00037  */
00038 #ifndef DB5_H
00039 #define DB5_H seen
00040 
00041 __BEGIN_DECLS
00042 
00043 #ifndef DB5_EXPORT
00044 #  if defined(_WIN32) && !defined(__CYGWIN__) && defined(BRLCAD_DLL)
00045 #    ifdef DB5_EXPORT_DLL
00046 #      define DB5_EXPORT __declspec(dllexport)
00047 #    else
00048 #      define DB5_EXPORT __declspec(dllimport)
00049 #    endif
00050 #  else
00051 #    define DB5_EXPORT
00052 #  endif
00053 #endif
00054 
00055 /**
00056  * The format of an object's header as it exists on disk,
00057  * as best we can describe its variable size with a "C" structure.
00058  */
00059 struct db5_ondisk_header {
00060         unsigned char   db5h_magic1;            /* [0] */
00061         unsigned char   db5h_hflags;            /* [1] */
00062         unsigned char   db5h_aflags;            /* [2] */
00063         unsigned char   db5h_bflags;            /* [3] */
00064         unsigned char   db5h_major_type;        /* [4] */
00065         unsigned char   db5h_minor_type;        /* [5] */
00066         /* Next is a mandatory variable-size length field starting at [6] */
00067         /* Next are optional object name length & data fields */
00068 };
00069 
00070 #define DB5HDR_MAGIC1   0x76            /* 'v' */
00071 #define DB5HDR_MAGIC2   0x35            /* '5' */
00072 
00073 /* hflags */
00074 #define DB5HDR_HFLAGS_DLI_MASK                          0x03
00075 #define DB5HDR_HFLAGS_DLI_APPLICATION_DATA_OBJECT       0
00076 #define DB5HDR_HFLAGS_DLI_HEADER_OBJECT                 1
00077 #define DB5HDR_HFLAGS_DLI_FREE_STORAGE                  2
00078 #define DB5HDR_HFLAGS_HIDDEN_OBJECT                     0x4
00079 #define DB5HDR_HFLAGS_NAME_PRESENT                      0x20
00080 #define DB5HDR_HFLAGS_OBJECT_WIDTH_MASK                 0xc0
00081 #define DB5HDR_HFLAGS_OBJECT_WIDTH_SHIFT                6
00082 #define DB5HDR_HFLAGS_NAME_WIDTH_MASK                   0x18
00083 #define DB5HDR_HFLAGS_NAME_WIDTH_SHIFT                  3
00084 
00085 #define DB5HDR_WIDTHCODE_8BIT           0
00086 #define DB5HDR_WIDTHCODE_16BIT          1
00087 #define DB5HDR_WIDTHCODE_32BIT          2
00088 #define DB5HDR_WIDTHCODE_64BIT          3
00089 
00090 /* aflags */
00091 #define DB5HDR_AFLAGS_ZZZ_MASK                          0x07
00092 #define DB5HDR_AFLAGS_PRESENT                           0x20
00093 #define DB5HDR_AFLAGS_WIDTH_MASK                        0xc0
00094 #define DB5HDR_AFLAGS_WIDTH_SHIFT                       6
00095 
00096 /* bflags */
00097 #define DB5HDR_BFLAGS_ZZZ_MASK                          0x07
00098 #define DB5HDR_BFLAGS_PRESENT                           0x20
00099 #define DB5HDR_BFLAGS_WIDTH_MASK                        0xc0
00100 #define DB5HDR_BFLAGS_WIDTH_SHIFT                       6
00101 
00102 /*************************************************************************
00103  *
00104  *      What follows is the C programming API for the routines
00105  *      implementing the v5 database.
00106  *      It may want to live in a different header file.
00107  *
00108  ************************************************************************/
00109 
00110 /* Name of global attribute-only object for storing database title & units */
00111 #define DB5_GLOBAL_OBJECT_NAME                  "_GLOBAL"
00112 
00113 /* Kinds of compression */
00114 #define DB5_ZZZ_UNCOMPRESSED                    0
00115 #define DB5_ZZZ_GNU_GZIP                        1
00116 #define DB5_ZZZ_BURROUGHS_WHEELER               2
00117 
00118 
00119 /* major_type */
00120 #define DB5_MAJORTYPE_RESERVED                   0
00121 #define DB5_MAJORTYPE_BRLCAD                     1
00122 #define DB5_MAJORTYPE_ATTRIBUTE_ONLY             2
00123 #define DB5_MAJORTYPE_BINARY_MASK                0x18
00124 #define DB5_MAJORTYPE_BINARY_EXPM                8
00125 #define DB5_MAJORTYPE_BINARY_UNIF                9
00126 #define DB5_MAJORTYPE_BINARY_MIME               10
00127 
00128 /*
00129  *      Minor types
00130  */
00131 /* BRL-CAD */
00132 #define DB5_MINORTYPE_RESERVED                   0
00133 #define DB5_MINORTYPE_BRLCAD_TOR                 1
00134 #define DB5_MINORTYPE_BRLCAD_TGC                 2
00135 #define DB5_MINORTYPE_BRLCAD_ELL                 3
00136 #define DB5_MINORTYPE_BRLCAD_ARB8                4
00137 #define DB5_MINORTYPE_BRLCAD_ARS                 5
00138 #define DB5_MINORTYPE_BRLCAD_HALF                6
00139 #define DB5_MINORTYPE_BRLCAD_REC                 7
00140 #define DB5_MINORTYPE_BRLCAD_POLY                8
00141 #define DB5_MINORTYPE_BRLCAD_BSPLINE             9
00142 #define DB5_MINORTYPE_BRLCAD_SPH                10
00143 #define DB5_MINORTYPE_BRLCAD_NMG                11
00144 #define DB5_MINORTYPE_BRLCAD_EBM                12
00145 #define DB5_MINORTYPE_BRLCAD_VOL                13
00146 #define DB5_MINORTYPE_BRLCAD_ARBN               14
00147 #define DB5_MINORTYPE_BRLCAD_PIPE               15
00148 #define DB5_MINORTYPE_BRLCAD_PARTICLE           16
00149 #define DB5_MINORTYPE_BRLCAD_RPC                17
00150 #define DB5_MINORTYPE_BRLCAD_RHC                18
00151 #define DB5_MINORTYPE_BRLCAD_EPA                19
00152 #define DB5_MINORTYPE_BRLCAD_EHY                20
00153 #define DB5_MINORTYPE_BRLCAD_ETO                21
00154 #define DB5_MINORTYPE_BRLCAD_GRIP               22
00155 #define DB5_MINORTYPE_BRLCAD_JOINT              23
00156 #define DB5_MINORTYPE_BRLCAD_HF                 24
00157 #define DB5_MINORTYPE_BRLCAD_DSP                25
00158 #define DB5_MINORTYPE_BRLCAD_SKETCH             26
00159 #define DB5_MINORTYPE_BRLCAD_EXTRUDE            27
00160 #define DB5_MINORTYPE_BRLCAD_SUBMODEL           28
00161 #define DB5_MINORTYPE_BRLCAD_CLINE              29
00162 #define DB5_MINORTYPE_BRLCAD_BOT                30
00163 #define DB5_MINORTYPE_BRLCAD_COMBINATION        31
00164 #define DB5_MINORTYPE_BRLCAD_SUPERELL           32
00165 #define DB5_MINORTYPE_BRLCAD_METABALL           33
00166 
00167 /* Uniform-array binary */
00168 #define DB5_MINORTYPE_BINU_WID_MASK             0x30
00169 #define DB5_MINORTYPE_BINU_SGN_MASK             0x08
00170 #define DB5_MINORTYPE_BINU_ATM_MASK             0x07
00171 #define DB5_MINORTYPE_BINU_FLOAT                0x02
00172 #define DB5_MINORTYPE_BINU_DOUBLE               0x03
00173 #define DB5_MINORTYPE_BINU_8BITINT_U            0x04
00174 #define DB5_MINORTYPE_BINU_16BITINT_U           0x05
00175 #define DB5_MINORTYPE_BINU_32BITINT_U           0x06
00176 #define DB5_MINORTYPE_BINU_64BITINT_U           0x07
00177 #define DB5_MINORTYPE_BINU_8BITINT              0x0c
00178 #define DB5_MINORTYPE_BINU_16BITINT             0x0d
00179 #define DB5_MINORTYPE_BINU_32BITINT             0x0e
00180 #define DB5_MINORTYPE_BINU_64BITINT             0x0f
00181 
00182 /* this array depends on the values of the above definitions and is defined in db5_bin.c */
00183 extern const char *binu_types[];
00184 
00185 /**
00186  *  The "raw internal" form of one database object.
00187  *  This is what the low-level database routines will operate on.
00188  *  Magic number1 has already been checked, and is not stored.
00189  */
00190 struct db5_raw_internal {
00191         long            magic;
00192         unsigned char   h_object_width;         /* DB5HDR_WIDTHCODE_x */
00193         unsigned char   h_name_hidden;
00194         unsigned char   h_name_present;
00195         unsigned char   h_name_width;           /* DB5HDR_WIDTHCODE_x */
00196         unsigned char   h_dli;
00197         unsigned char   a_width;                /* DB5HDR_WIDTHCODE_x */
00198         unsigned char   a_present;
00199         unsigned char   a_zzz;
00200         unsigned char   b_width;                /* DB5HDR_WIDTHCODE_x */
00201         unsigned char   b_present;
00202         unsigned char   b_zzz;
00203         unsigned char   major_type;
00204         unsigned char   minor_type;
00205         long            object_length;          /* in bytes, on disk */
00206         /* These three MUST NOT be passed to bu_free_external()! */
00207         struct bu_external name;
00208         struct bu_external body;
00209         struct bu_external attributes;
00210         unsigned char   *buf;           /* if non-null needs to be bu_free()ed */
00211 };
00212 #define DB5_RAW_INTERNAL_MAGIC  0x64357269      /* "d5ri" */
00213 #define RT_CK_RIP(_ptr)         BU_CKMAG( _ptr, DB5_RAW_INTERNAL_MAGIC, "db5_raw_internal" )
00214 
00215 DB5_EXPORT extern const int db5_enc_len[4];     /* convert wid to nbytes */
00216 
00217 DB5_EXPORT BU_EXTERN(unsigned char *db5_encode_length,
00218                      (unsigned char     *cp,
00219                       long              val,
00220                       int               format));
00221 DB5_EXPORT BU_EXTERN(const unsigned char *db5_get_raw_internal_ptr,
00222                      (struct db5_raw_internal *rip,
00223                       const unsigned char *ip));
00224 
00225 
00226 __END_DECLS
00227 
00228 #endif  /* DB5_H */
00229 
00230 
00231 /*@}*/
00232 /*
00233  * Local Variables:
00234  * mode: C
00235  * tab-width: 8
00236  * c-basic-offset: 4
00237  * indent-tabs-mode: t
00238  * End:
00239  * ex: shiftwidth=4 tabstop=8
00240  */
00241 

Generated on Mon Sep 18 01:24:40 2006 for BRL-CAD by  doxygen 1.4.6