BRL-CAD
db5.h
Go to the documentation of this file.
1/* D B 5 . H
2 * BRL-CAD
3 *
4 * Copyright (c) 2004-2023 United States Government as represented by
5 * the U.S. Army Research Laboratory.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * version 2.1 as published by the Free Software Foundation.
10 *
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this file; see the file named COPYING for more
18 * information.
19 */
20/** @addtogroup db5 */
21/** @{ */
22/** @file db5.h
23 *
24 * @brief
25 * Definition of the BRL-CAD "v5" database format used for new ".g" files.
26 *
27 */
28
29#ifndef RT_DB5_H
30#define RT_DB5_H
31
32#include "common.h"
33
34#include "bu/parse.h" /* for bu_external */
35#include "./rt/defines.h"
36#include "./rt/op.h"
37
38__BEGIN_DECLS
39
40#ifndef RT_EXPORT
41# if defined(RT_DLL_EXPORTS) && defined(RT_DLL_IMPORTS)
42# error "Only RT_DLL_EXPORTS or RT_DLL_IMPORTS can be defined, not both."
43# elif defined(RT_DLL_EXPORTS)
44# define RT_EXPORT COMPILER_DLLEXPORT
45# elif defined(RT_DLL_IMPORTS)
46# define RT_EXPORT COMPILER_DLLIMPORT
47# else
48# define RT_EXPORT
49# endif
50#endif
51
52/**
53 * The format of an object's header as it exists on disk,
54 * as best we can describe its variable size with a "C" structure.
55 */
57 unsigned char db5h_magic1; /* [0] */
58 unsigned char db5h_hflags; /* [1] */
59 unsigned char db5h_aflags; /* [2] */
60 unsigned char db5h_bflags; /* [3] */
61 unsigned char db5h_major_type; /* [4] */
62 unsigned char db5h_minor_type; /* [5] */
63 /* Next is a mandatory variable-size length field starting at [6] */
64 /* Next are optional object name length & data fields */
65};
66
67#define DB5HDR_MAGIC1 0x76 /* 'v' */
68#define DB5HDR_MAGIC2 0x35 /* '5' */
69
70/* hflags */
71#define DB5HDR_HFLAGS_DLI_MASK 0x03
72#define DB5HDR_HFLAGS_DLI_APPLICATION_DATA_OBJECT 0
73#define DB5HDR_HFLAGS_DLI_HEADER_OBJECT 1
74#define DB5HDR_HFLAGS_DLI_FREE_STORAGE 2
75#define DB5HDR_HFLAGS_HIDDEN_OBJECT 0x4
76#define DB5HDR_HFLAGS_NAME_PRESENT 0x20
77#define DB5HDR_HFLAGS_OBJECT_WIDTH_MASK 0xc0
78#define DB5HDR_HFLAGS_OBJECT_WIDTH_SHIFT 6
79#define DB5HDR_HFLAGS_NAME_WIDTH_MASK 0x18
80#define DB5HDR_HFLAGS_NAME_WIDTH_SHIFT 3
81
82#define DB5HDR_WIDTHCODE_8BIT 0
83#define DB5HDR_WIDTHCODE_16BIT 1
84#define DB5HDR_WIDTHCODE_32BIT 2
85#define DB5HDR_WIDTHCODE_64BIT 3
86
87/* aflags */
88#define DB5HDR_AFLAGS_ZZZ_MASK 0x07
89#define DB5HDR_AFLAGS_PRESENT 0x20
90#define DB5HDR_AFLAGS_WIDTH_MASK 0xc0
91#define DB5HDR_AFLAGS_WIDTH_SHIFT 6
92
93/* bflags */
94#define DB5HDR_BFLAGS_ZZZ_MASK 0x07
95#define DB5HDR_BFLAGS_PRESENT 0x20
96#define DB5HDR_BFLAGS_WIDTH_MASK 0xc0
97#define DB5HDR_BFLAGS_WIDTH_SHIFT 6
98
99/*************************************************************************
100 *
101 * What follows is the C programming API for the routines
102 * implementing the v5 database.
103 * It may want to live in a different header file.
104 *
105 ************************************************************************/
106
107/* Name of global attribute-only object for storing database title & units */
108#define DB5_GLOBAL_OBJECT_NAME "_GLOBAL"
109
110/* Kinds of compression */
111#define DB5_ZZZ_UNCOMPRESSED 0
112#define DB5_ZZZ_GNU_GZIP 1
113#define DB5_ZZZ_BURROUGHS_WHEELER 2
114
115
116/* major_type */
117#define DB5_MAJORTYPE_RESERVED 0
118#define DB5_MAJORTYPE_BRLCAD 1
119#define DB5_MAJORTYPE_ATTRIBUTE_ONLY 2
120#define DB5_MAJORTYPE_BINARY_MASK 0x18
121#define DB5_MAJORTYPE_BINARY_UNIF 9
122#define DB5_MAJORTYPE_BINARY_MIME 10
123
124/*
125 * Minor types
126 */
127/* BRL-CAD */
128#define DB5_MINORTYPE_RESERVED 0
129#define DB5_MINORTYPE_BRLCAD_TOR 1
130#define DB5_MINORTYPE_BRLCAD_TGC 2
131#define DB5_MINORTYPE_BRLCAD_ELL 3
132#define DB5_MINORTYPE_BRLCAD_ARB8 4
133#define DB5_MINORTYPE_BRLCAD_ARS 5
134#define DB5_MINORTYPE_BRLCAD_HALF 6
135#define DB5_MINORTYPE_BRLCAD_REC 7
136#define DB5_MINORTYPE_BRLCAD_POLY 8
137#define DB5_MINORTYPE_BRLCAD_BSPLINE 9
138#define DB5_MINORTYPE_BRLCAD_SPH 10
139#define DB5_MINORTYPE_BRLCAD_NMG 11
140#define DB5_MINORTYPE_BRLCAD_EBM 12
141#define DB5_MINORTYPE_BRLCAD_VOL 13
142#define DB5_MINORTYPE_BRLCAD_ARBN 14
143#define DB5_MINORTYPE_BRLCAD_PIPE 15
144#define DB5_MINORTYPE_BRLCAD_PARTICLE 16
145#define DB5_MINORTYPE_BRLCAD_RPC 17
146#define DB5_MINORTYPE_BRLCAD_RHC 18
147#define DB5_MINORTYPE_BRLCAD_EPA 19
148#define DB5_MINORTYPE_BRLCAD_EHY 20
149#define DB5_MINORTYPE_BRLCAD_ETO 21
150#define DB5_MINORTYPE_BRLCAD_GRIP 22
151#define DB5_MINORTYPE_BRLCAD_JOINT 23
152#define DB5_MINORTYPE_BRLCAD_HF 24
153#define DB5_MINORTYPE_BRLCAD_DSP 25
154#define DB5_MINORTYPE_BRLCAD_SKETCH 26
155#define DB5_MINORTYPE_BRLCAD_EXTRUDE 27
156#define DB5_MINORTYPE_BRLCAD_SUBMODEL 28
157#define DB5_MINORTYPE_BRLCAD_CLINE 29
158#define DB5_MINORTYPE_BRLCAD_BOT 30
159#define DB5_MINORTYPE_BRLCAD_COMBINATION 31
160/* UNUSED 32 */
161/* BINUNIF (erroneous) 33 */
162/* UNUSED 34 */
163#define DB5_MINORTYPE_BRLCAD_SUPERELL 35
164#define DB5_MINORTYPE_BRLCAD_METABALL 36
165#define DB5_MINORTYPE_BRLCAD_BREP 37
166#define DB5_MINORTYPE_BRLCAD_HYP 38
167
168#define DB5_MINORTYPE_BRLCAD_CONSTRAINT 39
169
170#define DB5_MINORTYPE_BRLCAD_REVOLVE 40
171#define DB5_MINORTYPE_BRLCAD_PNTS 41
172#define DB5_MINORTYPE_BRLCAD_ANNOT 42
173#define DB5_MINORTYPE_BRLCAD_HRT 43
174#define DB5_MINORTYPE_BRLCAD_DATUM 44
175#define DB5_MINORTYPE_BRLCAD_SCRIPT 45
176#define DB5_MINORTYPE_BRLCAD_MATERIAL 46
177
178/* Uniform-array binary */
179#define DB5_MINORTYPE_BINU_WID_MASK 0x30
180#define DB5_MINORTYPE_BINU_SGN_MASK 0x08
181#define DB5_MINORTYPE_BINU_ATM_MASK 0x07
182#define DB5_MINORTYPE_BINU_FLOAT 0x02
183#define DB5_MINORTYPE_BINU_DOUBLE 0x03
184#define DB5_MINORTYPE_BINU_8BITINT_U 0x04
185#define DB5_MINORTYPE_BINU_16BITINT_U 0x05
186#define DB5_MINORTYPE_BINU_32BITINT_U 0x06
187#define DB5_MINORTYPE_BINU_64BITINT_U 0x07
188#define DB5_MINORTYPE_BINU_8BITINT 0x0c
189#define DB5_MINORTYPE_BINU_16BITINT 0x0d
190#define DB5_MINORTYPE_BINU_32BITINT 0x0e
191#define DB5_MINORTYPE_BINU_64BITINT 0x0f
192
193/* this array depends on the values of the above definitions and is defined in db5_bin.c */
194RT_EXPORT extern const char *binu_types[];
195
196/**
197 * The "raw internal" form of one database object.
198 * This is what the low-level database routines will operate on.
199 * Magic number1 has already been checked, and is not stored.
200 */
202 uint32_t magic;
203 unsigned char h_object_width; /* DB5HDR_WIDTHCODE_x */
204 unsigned char h_name_hidden;
205 unsigned char h_name_present;
206 unsigned char h_name_width; /* DB5HDR_WIDTHCODE_x */
207 unsigned char h_dli;
208 unsigned char a_width; /* DB5HDR_WIDTHCODE_x */
209 unsigned char a_present;
210 unsigned char a_zzz;
211 unsigned char b_width; /* DB5HDR_WIDTHCODE_x */
212 unsigned char b_present;
213 unsigned char b_zzz;
214 unsigned char major_type;
215 unsigned char minor_type;
216 size_t object_length; /* in bytes, on disk */
217 /* These three MUST NOT be passed to bu_free_external()! */
221 unsigned char *buf; /* if non-null needs to be bu_free()ed */
222};
223#define RT_CK_RIP(_ptr) BU_CKMAG( _ptr, DB5_RAW_INTERNAL_MAGIC, "db5_raw_internal" )
224
225
226__END_DECLS
227
228#endif /* RT_DB5_H */
229
230/** @} */
231/*
232 * Local Variables:
233 * mode: C
234 * tab-width: 8
235 * indent-tabs-mode: t
236 * c-file-style: "stroustrup"
237 * End:
238 * ex: shiftwidth=4 tabstop=8
239 */
Header file for the BRL-CAD common definitions.
const char * binu_types[]
unsigned char db5h_magic1
Definition: db5.h:57
unsigned char db5h_hflags
Definition: db5.h:58
unsigned char db5h_major_type
Definition: db5.h:61
unsigned char db5h_aflags
Definition: db5.h:59
unsigned char db5h_bflags
Definition: db5.h:60
unsigned char db5h_minor_type
Definition: db5.h:62
unsigned char a_zzz
Definition: db5.h:210
unsigned char major_type
Definition: db5.h:214
size_t object_length
Definition: db5.h:216
struct bu_external attributes
Definition: db5.h:220
unsigned char h_name_present
Definition: db5.h:205
uint32_t magic
Definition: db5.h:202
struct bu_external body
Definition: db5.h:219
unsigned char h_object_width
Definition: db5.h:203
unsigned char b_present
Definition: db5.h:212
unsigned char h_dli
Definition: db5.h:207
unsigned char b_width
Definition: db5.h:211
unsigned char a_width
Definition: db5.h:208
struct bu_external name
Definition: db5.h:218
unsigned char b_zzz
Definition: db5.h:213
unsigned char h_name_width
Definition: db5.h:206
unsigned char * buf
Definition: db5.h:221
unsigned char a_present
Definition: db5.h:209
unsigned char minor_type
Definition: db5.h:215
unsigned char h_name_hidden
Definition: db5.h:204