BRL-CAD
soltab.h
Go to the documentation of this file.
1/* S O L T A B . H
2 * BRL-CAD
3 *
4 * Copyright (c) 1993-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 rt_soltab
21 * @brief The LIBRT Solids Table
22 */
23/** @{ */
24/** @file soltab.h */
25
26#ifndef RT_SOLTAB_H
27#define RT_SOLTAB_H
28
29#include "common.h"
30#include "vmath.h"
31#include "bu/magic.h"
32#include "bu/list.h"
33#include "bu/ptbl.h"
34#include "rt/defines.h"
35#include "rt/db_fullpath.h"
36
37__BEGIN_DECLS
38
39/**
40 * Macros to operate on Right Rectangular Parallelepipeds (RPPs).
41 * TODO: move to vmath.h
42 */
43struct bound_rpp {
46};
47
48struct rt_functab; /* forward declaration */
49struct directory; /* forward declaration */
50
51/**
52 * Internal information used to keep track of solids in the model.
53 * Leaf name and Xform matrix are unique identifier. Note that all
54 * objects store dimensional values in millimeters (mm).
55 */
56struct soltab {
57 struct bu_list l; /**< @brief links, headed by rti_headsolid */
58 struct bu_list l2; /**< @brief links, headed by st_dp->d_use_hd */
59 const struct rt_functab * st_meth; /**< @brief pointer to per-solid methods */
60 struct rt_i * st_rtip; /**< @brief "up" pointer to rt_i */
61 long st_uses; /**< @brief Usage count, for instanced solids */
62 int st_id; /**< @brief Solid ident */
63 point_t st_center; /**< @brief Centroid of solid */
64 fastf_t st_aradius; /**< @brief Radius of APPROXIMATING sphere */
65 fastf_t st_bradius; /**< @brief Radius of BOUNDING sphere */
66 void * st_specific; /**< @brief -> ID-specific (private) struct */
67 const struct directory * st_dp; /**< @brief Directory entry of solid */
68 point_t st_min; /**< @brief min X, Y, Z of bounding RPP */
69 point_t st_max; /**< @brief max X, Y, Z of bounding RPP */
70 long st_bit; /**< @brief solids bit vector index (const) */
71 struct bu_ptbl st_regions; /**< @brief ptrs to regions using this solid (const) */
72 matp_t st_matp; /**< @brief solid coords to model space, NULL=identity */
73 struct db_full_path st_path; /**< @brief path from region to leaf */
74 /* Experimental stuff for accelerating "pieces" of solids */
75 long st_npieces; /**< @brief # pieces used by this solid */
76 long st_piecestate_num; /**< @brief re_pieces[] subscript */
77 struct bound_rpp * st_piece_rpps; /**< @brief bounding RPP of each piece of this solid */
78};
79#define st_name st_dp->d_namep
80#define RT_SOLTAB_NULL ((struct soltab *)0)
81#define SOLTAB_NULL RT_SOLTAB_NULL /**< @brief backwards compat */
82
83#define RT_CHECK_SOLTAB(_p) BU_CKMAG(_p, RT_SOLTAB_MAGIC, "struct soltab")
84#define RT_CK_SOLTAB(_p) BU_CKMAG(_p, RT_SOLTAB_MAGIC, "struct soltab")
85
86/**
87 * Decrement use count on soltab structure. If no longer needed,
88 * release associated storage, and free the structure.
89 *
90 * This routine semaphore protects against other copies of itself
91 * running in parallel, and against other routines (such as
92 * _rt_find_identical_solid()) which might also be modifying the
93 * linked list heads.
94 *
95 * Called by -
96 * db_free_tree()
97 * rt_clean()
98 * rt_gettrees()
99 * rt_kill_deal_solid_refs()
100 */
101RT_EXPORT extern void rt_free_soltab(struct soltab *stp);
102
103/* Print a soltab */
104RT_EXPORT extern void rt_pr_soltab(const struct soltab *stp);
105
106
107__END_DECLS
108
109#endif /* RT_SOLTAB_H */
110/** @} */
111/*
112 * Local Variables:
113 * tab-width: 8
114 * mode: C
115 * indent-tabs-mode: t
116 * c-file-style: "stroustrup"
117 * End:
118 * ex: shiftwidth=4 tabstop=8
119 */
Header file for the BRL-CAD common definitions.
void rt_free_soltab(struct soltab *stp)
void rt_pr_soltab(const struct soltab *stp)
double fastf_t
fastest 64-bit (or larger) floating point type
Definition: vmath.h:330
fastf_t * matp_t
pointer to a 4x4 matrix
Definition: vmath.h:369
fastf_t point_t[ELEMENTS_PER_POINT]
3-tuple point
Definition: vmath.h:351
Global registry of recognized magic numbers.
point_t max
Definition: soltab.h:45
point_t min
Definition: soltab.h:44
Definition: list.h:131
Definition: ptbl.h:53
Definition: soltab.h:56
point_t st_min
min X, Y, Z of bounding RPP
Definition: soltab.h:68
long st_bit
solids bit vector index (const)
Definition: soltab.h:70
fastf_t st_aradius
Radius of APPROXIMATING sphere.
Definition: soltab.h:64
struct rt_i * st_rtip
"up" pointer to rt_i
Definition: soltab.h:60
point_t st_center
Centroid of solid.
Definition: soltab.h:63
point_t st_max
max X, Y, Z of bounding RPP
Definition: soltab.h:69
const struct directory * st_dp
Directory entry of solid.
Definition: soltab.h:67
long st_piecestate_num
re_pieces[] subscript
Definition: soltab.h:76
int st_id
Solid ident.
Definition: soltab.h:62
fastf_t st_bradius
Radius of BOUNDING sphere.
Definition: soltab.h:65
void * st_specific
-> ID-specific (private) struct
Definition: soltab.h:66
struct bound_rpp * st_piece_rpps
bounding RPP of each piece of this solid
Definition: soltab.h:77
long st_uses
Usage count, for instanced solids.
Definition: soltab.h:61
struct bu_list l2
links, headed by st_dp->d_use_hd
Definition: soltab.h:58
long st_npieces
# pieces used by this solid
Definition: soltab.h:75
struct db_full_path st_path
path from region to leaf
Definition: soltab.h:73
struct bu_ptbl st_regions
ptrs to regions using this solid (const)
Definition: soltab.h:71
const struct rt_functab * st_meth
pointer to per-solid methods
Definition: soltab.h:59
struct bu_list l
links, headed by rti_headsolid
Definition: soltab.h:57
matp_t st_matp
solid coords to model space, NULL=identity
Definition: soltab.h:72
fundamental vector, matrix, quaternion math macros