32#ifndef RT_RAY_PARTITION_H
33#define RT_RAY_PARTITION_H
68#define PT_NULL ((struct partition *)0)
70#define RT_CHECK_PT(_p) RT_CK_PT(_p)
71#define RT_CK_PT(_p) BU_CKMAG(_p, PT_MAGIC, "struct partition")
72#define RT_CK_PARTITION(_p) BU_CKMAG(_p, PT_MAGIC, "struct partition")
73#define RT_CK_PT_HD(_p) BU_CKMAG(_p, PT_HD_MAGIC, "struct partition list head")
76#define RT_PT_MIDDLE_START pt_inseg
77#define RT_PT_MIDDLE_END pt_seglist.l.magic
78#define RT_PT_MIDDLE_LEN(p) \
79 (((char *)&(p)->RT_PT_MIDDLE_END) - ((char *)&(p)->RT_PT_MIDDLE_START))
81#define RT_DUP_PT(ip, new, old, res) { \
82 GET_PT(ip, new, res); \
83 memcpy((char *)(&(new)->RT_PT_MIDDLE_START), (char *)(&(old)->RT_PT_MIDDLE_START), RT_PT_MIDDLE_LEN(old)); \
84 (new)->pt_overlap_reg = NULL; \
85 bu_ptbl_cat(&(new)->pt_seglist, &(old)->pt_seglist); }
88#define GET_PT_INIT(ip, p, res) {\
90 memset(((char *) &(p)->RT_PT_MIDDLE_START), 0, RT_PT_MIDDLE_LEN(p)); }
92#define GET_PT(ip, p, res) { \
93 if (BU_LIST_NON_EMPTY_P(p, partition, &res->re_parthead)) { \
94 BU_LIST_DEQUEUE((struct bu_list *)(p)); \
95 bu_ptbl_reset(&(p)->pt_seglist); \
97 BU_ALLOC((p), struct partition); \
98 (p)->pt_magic = PT_MAGIC; \
99 bu_ptbl_init(&(p)->pt_seglist, 42, "pt_seglist ptbl"); \
100 (res)->re_partlen++; \
104#define FREE_PT(p, res) { \
105 BU_LIST_APPEND(&(res->re_parthead), (struct bu_list *)(p)); \
106 if ((p)->pt_overlap_reg) { \
107 bu_free((void *)((p)->pt_overlap_reg), "pt_overlap_reg");\
108 (p)->pt_overlap_reg = NULL; \
110 res->re_partfree++; }
112#define RT_FREE_PT_LIST(_headp, _res) { \
113 register struct partition *_pp, *_zap; \
114 for (_pp = (_headp)->pt_forw; _pp != (_headp);) { \
116 _pp = _pp->pt_forw; \
117 BU_LIST_DEQUEUE((struct bu_list *)(_zap)); \
118 FREE_PT(_zap, _res); \
120 (_headp)->pt_forw = (_headp)->pt_back = (_headp); \
124#define INSERT_PT(_new, _old) BU_LIST_INSERT((struct bu_list *)_old, (struct bu_list *)_new)
127#define APPEND_PT(_new, _old) BU_LIST_APPEND((struct bu_list *)_old, (struct bu_list *)_new)
130#define DEQUEUE_PT(_cur) BU_LIST_DEQUEUE((struct bu_list *)_cur)
Header file for the BRL-CAD common definitions.
int rt_partition_len(const struct partition *partheadp)
Information about where a ray hits the surface.
struct partition_list * list
struct partition PartHeadp
struct seg * pt_inseg
IN seg ptr (gives stp)
struct region * pt_regionp
ptr to containing region
struct region ** pt_overlap_reg
NULL-terminated array of overlapping regions. NULL if no overlap.
uint32_t pt_magic
sanity check
struct partition * pt_back
backwards link
struct hit * pt_outhit
OUT hit ptr.
char pt_outflip
flip outhit->hit_normal
struct seg * pt_outseg
OUT seg pointer.
struct bu_ptbl pt_seglist
all segs in this partition
struct partition * pt_forw
forwards link
struct hit * pt_inhit
IN hit pointer.
char pt_inflip
flip inhit->hit_normal
fundamental vector, matrix, quaternion math macros