BRL-CAD
piece.h
Go to the documentation of this file.
1/* P I E C E . 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/** @file rt/piece.h
21 *
22 */
23
24#ifndef RT_PIECE_H
25#define RT_PIECE_H
26
27#include "common.h"
28#include "bu/list.h"
29#include "bu/magic.h"
30#include "bu/bitv.h"
31#include "rt/hit.h"
32#include "rt/soltab.h"
33#include "rt/space_partition.h" /* cutter */
34
35__BEGIN_DECLS
36
37/**
38 * Support for variable length arrays of "struct hit". Patterned
39 * after the libbu/ptbl.c idea.
40 */
41struct rt_htbl {
42 struct bu_list l; /**< @brief linked list for caller's use */
43 size_t end; /**< @brief index of first available location */
44 size_t blen; /**< @brief # of struct's of storage at *hits */
45 struct hit * hits; /**< @brief hits[blen] data storage area */
46};
47#define RT_CK_HTBL(_p) BU_CKMAG(_p, RT_HTBL_MAGIC, "rt_htbl")
48
49/**
50 * Holds onto memory re-used by rt_shootray() from shot to shot. One
51 * of these for each solid which uses pieces. There is a separate
52 * array of these for each cpu. Storage for the bit vectors is
53 * pre-allocated at prep time. The array is subscripted by
54 * st_piecestate_num. The bit vector is subscripted by values found
55 * in rt_piecelist pieces[].
56 */
58 uint32_t magic;
59 long ray_seqno; /**< @brief res_nshootray */
60 struct soltab * stp;
61 struct bu_bitv * shot;
62 fastf_t mindist; /**< @brief dist ray enters solids bounding volume */
63 fastf_t maxdist; /**< @brief dist ray leaves solids bounding volume */
64 struct rt_htbl htab; /**< @brief accumulating hits here */
65 const union cutter *cutp; /**< @brief current bounding volume */
66};
67#define RT_CK_PIECESTATE(_p) BU_CKMAG(_p, RT_PIECESTATE_MAGIC, "struct rt_piecestate")
68
69/**
70 * For each space partitioning cell, there is one of these for each
71 * solid in that cell which uses pieces. Storage for the array is
72 * allocated at cut time, and never changes.
73 *
74 * It is expected that the indices allocated by any solid range from
75 * 0..(npieces-1).
76 *
77 * The piece indices are used as a subscript into a solid-specific
78 * table, and also into the 'shot' bitv of the corresponding
79 * rt_piecestate.
80 *
81 * The values (subscripts) in pieces[] are specific to a single solid
82 * (stp).
83 */
85 uint32_t magic;
86 size_t npieces; /**< @brief number of pieces in pieces[] array */
87 long *pieces; /**< @brief pieces[npieces], piece indices */
88 struct soltab *stp; /**< @brief ref back to solid */
89};
90#define RT_CK_PIECELIST(_p) BU_CKMAG(_p, RT_PIECELIST_MAGIC, "struct rt_piecelist")
91
92
93__END_DECLS
94
95#endif /* RT_PIECE_H */
96
97/*
98 * Local Variables:
99 * tab-width: 8
100 * mode: C
101 * indent-tabs-mode: t
102 * c-file-style: "stroustrup"
103 * End:
104 * ex: shiftwidth=4 tabstop=8
105 */
Header file for the BRL-CAD common definitions.
double fastf_t
fastest 64-bit (or larger) floating point type
Definition: vmath.h:330
Global registry of recognized magic numbers.
Definition: bitv.h:108
Definition: list.h:131
Information about where a ray hits the surface.
Definition: hit.h:61
Definition: piece.h:41
size_t blen
# of struct's of storage at *hits
Definition: piece.h:44
struct bu_list l
linked list for caller's use
Definition: piece.h:42
struct hit * hits
hits[blen] data storage area
Definition: piece.h:45
size_t end
index of first available location
Definition: piece.h:43
uint32_t magic
Definition: piece.h:85
size_t npieces
number of pieces in pieces[] array
Definition: piece.h:86
struct soltab * stp
ref back to solid
Definition: piece.h:88
long * pieces
pieces[npieces], piece indices
Definition: piece.h:87
struct bu_bitv * shot
Definition: piece.h:61
fastf_t maxdist
dist ray leaves solids bounding volume
Definition: piece.h:63
fastf_t mindist
dist ray enters solids bounding volume
Definition: piece.h:62
const union cutter * cutp
current bounding volume
Definition: piece.h:65
uint32_t magic
Definition: piece.h:58
struct soltab * stp
Definition: piece.h:60
struct rt_htbl htab
accumulating hits here
Definition: piece.h:64
long ray_seqno
res_nshootray
Definition: piece.h:59
Definition: soltab.h:56