BRL-CAD
Loading...
Searching...
No Matches
nongeom.h
Go to the documentation of this file.
1/* N O N G E O M . H
2 * BRL-CAD
3 *
4 * Copyright (c) 1993-2025 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/** @file rt/nongeom.h
21 *
22 * In memory format for non-geometry objects in BRL-CAD databases.
23 */
24
25#ifndef RT_NONGEOM_H
26#define RT_NONGEOM_H
27
28#include "common.h"
29#include "vmath.h"
30#include "bu/vls.h"
31
33
34union tree; /* forward declaration */
35
36/**
37 * In-memory format for database "combination" record (non-leaf node).
38 * (Regions and Groups are both a kind of Combination). Perhaps move
39 * to wdb.h or rtgeom.h?
40 */
43 union tree * tree; /**< @brief Leading to tree_db_leaf leaves */
44 char region_flag; /**< @brief !0 ==> this COMB is a REGION */
45 char is_fastgen; /**< @brief REGION_NON_FASTGEN/_PLATE/_VOLUME */
46 /* Begin GIFT compatibility */
47 long region_id; /* DEPRECATED, use attribute */
48 long aircode; /* DEPRECATED, use attribute */
49 long GIFTmater; /* DEPRECATED, use attribute */
50 long los; /* DEPRECATED, use attribute */
51 /* End GIFT compatibility */
52 char rgb_valid; /**< @brief !0 ==> rgb[] has valid color */
53 unsigned char rgb[3];
54 float temperature; /**< @brief > 0 ==> region temperature */
55 struct bu_vls shader;
57 char inherit;
58
59 /* This holds the pointer to the parent database from which the comb
60 * definition has come. Combs are unlike most other BRL-CAD geometry
61 * definitions in that they are not self-contained - an rt_db_internal
62 * representation of a comb does not (by itself) have enough information
63 * for operations like plotting or tessellation. Hence, we store a pointer
64 * to the database as internal data of the comb, since other data contained
65 * in the database is generally an integral part of making the comb
66 * definition meaningful.
67 *
68 * Note that this has implications for how a comb rt_db_internal must be
69 * treated. Most rt_db_internal objects are independent of the original .g
70 * database they were loaded from, and can be used with a different dbip
71 * without worry. That is not true for combs - if a comb is to be copied
72 * to a new database, a new comb instance MUST be opened once the comb data
73 * is established in the new database context. Without the old dbip being
74 * valid, comb methods such as tess and plot will NOT work.
75 *
76 * Generally speaking this pointer should only be used internally for
77 * functab methods and not by calling codes. If there is another way to
78 * obtain dbip other than referencing this variable, that's what callers
79 * should do. Use this ONLY when you're sure it is the only way to get the
80 * job done, and ALWAYS validate it before use with RT_CK_DBI. */
81 const struct db_i *src_dbip;
82
83 /* Name of the original database object that produced the comb. If the
84 * database has changed this name may no longer identify a current object
85 * in the database - the caller is responsible for validating it. */
86 const char *src_objname;
87};
88#define RT_CHECK_COMB(_p) BU_CKMAG(_p, RT_COMB_MAGIC, "rt_comb_internal")
89#define RT_CK_COMB(_p) RT_CHECK_COMB(_p)
90
91/**
92 * initialize an rt_comb_internal to empty.
93 */
94#define RT_COMB_INTERNAL_INIT(_p) { \
95 (_p)->magic = RT_COMB_MAGIC; \
96 (_p)->tree = TREE_NULL; \
97 (_p)->region_flag = 0; \
98 (_p)->is_fastgen = REGION_NON_FASTGEN; \
99 (_p)->region_id = 0; \
100 (_p)->aircode = 0; \
101 (_p)->GIFTmater = 0; \
102 (_p)->los = 0; \
103 (_p)->rgb_valid = 0; \
104 (_p)->rgb[0] = 0; \
105 (_p)->rgb[1] = 0; \
106 (_p)->rgb[2] = 0; \
107 (_p)->temperature = 0.0; \
108 BU_VLS_INIT(&(_p)->shader); \
109 BU_VLS_INIT(&(_p)->material); \
110 (_p)->inherit = 0; \
111 (_p)->src_dbip = 0; \
112 (_p)->src_objname = 0; \
113 }
114
115/**
116 * deinitialize an rt_comb_internal. the tree pointer is not released
117 * so callers will need to call BU_PUT() or db_free_tree()
118 * directly if a tree is set. the shader and material strings are
119 * released. the comb itself will need to be released with bu_free()
120 * unless it resides on the stack.
121 */
122#define RT_FREE_COMB_INTERNAL(_p) { \
123 bu_vls_free(&(_p)->shader); \
124 bu_vls_free(&(_p)->material); \
125 (_p)->tree = TREE_NULL; \
126 (_p)->magic = 0; \
127 }
128
129
130/**
131 * In-memory format for database uniform-array binary object. Perhaps
132 * move to wdb.h or rtgeom.h?
133 */
136 int type;
137 size_t count;
138 union {
139 float *flt;
140 double *dbl;
141 char *int8;
142 short *int16;
143 int *int32;
144 long *int64;
145 unsigned char *uint8;
146 unsigned short *uint16;
147 unsigned int *uint32;
148 unsigned long *uint64;
149 } u;
150};
151#define RT_CHECK_BINUNIF(_p) BU_CKMAG(_p, RT_BINUNIF_INTERNAL_MAGIC, "rt_binunif_internal")
152#define RT_CK_BINUNIF(_p) RT_CHECK_BINUNIF(_p)
153
154/**
155 * In-memory format for database "constraint" record
156 */
163
164#define RT_CHECK_CONSTRAINT(_p) BU_CKMAG(_p, RT_CONSTRAINT_MAGIC, "rt_constraint_internal")
165#define RT_CK_CONSTRAINT(_p) RT_CHECK_CONSTRAINT(_p)
166
167/**
168 * In-memory format for database "material" record
169 */
181
182#define RT_CHECK_MATERIAL(_p) BU_CKMAG(_p, RT_MATERIAL_MAGIC, "rt_material_internal")
183#define RT_CK_MATERIAL(_p) RT_CHECK_MATERIAL(_p)
184
186
187#endif /* RT_NONGEOM_H */
188
189/*
190 * Local Variables:
191 * tab-width: 8
192 * mode: C
193 * indent-tabs-mode: t
194 * c-file-style: "stroustrup"
195 * End:
196 * ex: shiftwidth=4 tabstop=8
197 */
Definition dvec.h:74
Header file for the BRL-CAD common definitions.
Definition vls.h:53
unsigned long * uint64
Definition nongeom.h:148
union rt_binunif_internal::@12 u
unsigned short * uint16
Definition nongeom.h:146
unsigned int * uint32
Definition nongeom.h:147
unsigned char * uint8
Definition nongeom.h:145
const struct db_i * src_dbip
Definition nongeom.h:81
char rgb_valid
!0 ==> rgb[] has valid color
Definition nongeom.h:52
uint32_t magic
Definition nongeom.h:42
unsigned char rgb[3]
Definition nongeom.h:53
char region_flag
!0 ==> this COMB is a REGION
Definition nongeom.h:44
struct bu_vls shader
Definition nongeom.h:55
char is_fastgen
REGION_NON_FASTGEN/_PLATE/_VOLUME.
Definition nongeom.h:45
const char * src_objname
Definition nongeom.h:86
struct bu_vls material
Definition nongeom.h:56
float temperature
> 0 ==> region temperature
Definition nongeom.h:54
union tree * tree
Leading to tree_db_leaf leaves.
Definition nongeom.h:43
struct bu_vls expression
Definition nongeom.h:161
struct bu_attribute_value_set mechanicalProperties
Definition nongeom.h:177
struct bu_vls name
Definition nongeom.h:172
struct bu_attribute_value_set opticalProperties
Definition nongeom.h:178
struct bu_attribute_value_set thermalProperties
Definition nongeom.h:179
struct bu_vls parent
Definition nongeom.h:173
struct bu_vls source
Definition nongeom.h:174
struct bu_attribute_value_set physicalProperties
Definition nongeom.h:176
Definition tree.h:169
fundamental vector, matrix, quaternion math macros