BRL-CAD
region.h
Go to the documentation of this file.
1 /* R E G I O N . H
2  * BRL-CAD
3  *
4  * Copyright (c) 1993-2024 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/region.h
21  *
22  */
23 
24 #ifndef RT_REGION_H
25 #define RT_REGION_H
26 
27 #include "common.h"
28 #include "vmath.h"
29 #include "bu/avs.h"
30 #include "bu/list.h"
31 #include "bu/magic.h"
32 #include "rt/defines.h"
33 #include "rt/mater.h"
34 
35 __BEGIN_DECLS
36 
37 union tree; /* forward declaration */
38 struct resource; /* forward declaration */
39 struct db_i; /* forward declaration */
40 
41 /**
42  * The region structure.
43  */
44 struct region {
45  struct bu_list l; /**< @brief magic # and doubly linked list */
46  const char * reg_name; /**< @brief Identifying string */
47  union tree * reg_treetop; /**< @brief Pointer to boolean tree */
48  int reg_bit; /**< @brief constant index into Regions[] */
49  int reg_regionid; /**< @brief Region ID code. If <=0, use reg_aircode */
50  int reg_aircode; /**< @brief Region ID AIR code */
51  int reg_gmater; /**< @brief GIFT Material code */
52  int reg_los; /**< @brief approximate line-of-sight thickness equivalence */
53  struct mater_info reg_mater; /**< @brief Real material information */
54  void * reg_mfuncs; /**< @brief User appl. funcs for material */
55  void * reg_udata; /**< @brief User appl. data for material */
56  int reg_transmit; /**< @brief flag: material transmits light */
57  long reg_instnum; /**< @brief instance number, from d_uses */
58  short reg_all_unions; /**< @brief 1=boolean tree is all unions */
59  short reg_is_fastgen; /**< @brief FASTGEN-compatibility mode? */
60 #define REGION_NON_FASTGEN 0
61 #define REGION_FASTGEN_PLATE 1
62 #define REGION_FASTGEN_VOLUME 2
63  struct bu_attribute_value_set attr_values; /**< @brief Attribute/value set */
64 };
65 #define REGION_NULL ((struct region *)0)
66 #define RT_CK_REGION(_p) BU_CKMAG(_p, RT_REGION_MAGIC, "struct region")
67 
68 #ifdef USE_OPENCL
69 struct cl_bool_region {
70  cl_uint btree_offset; /**< @brief index to the start of the bit tree */
71  cl_int reg_aircode; /**< @brief Region ID AIR code */
72  cl_int reg_bit; /**< @brief constant index into Regions[] */
73  cl_short reg_all_unions; /**< @brief 1=boolean tree is all unions */
74 };
75 
76 /*
77  * Values for Shader Function ID.
78  */
79 #define SH_NONE 0
80 #define SH_PHONG 1
81 
82 
83 struct cl_phong_specific {
84  cl_double wgt_specular;
85  cl_double wgt_diffuse;
86  cl_int shine;
87 };
88 
89 /**
90  * The region structure.
91  */
92 struct cl_region {
93  cl_float color[3]; /**< @brief explicit color: 0..1 */
94  cl_int mf_id;
95  union {
96  struct cl_phong_specific phg_spec;
97  }udata;
98 };
99 
100 #endif
101 
102 /* Print a region */
103 RT_EXPORT extern void rt_pr_region(const struct region *rp);
104 
105 /**
106  * Given the name of a region, return the matrix which maps model
107  * coordinates into "region" coordinates.
108  *
109  * Returns:
110  * 0 OK
111  * <0 Failure
112  */
113 RT_EXPORT extern int db_region_mat(mat_t m, /* result */
114  struct db_i *dbip,
115  const char *name,
116  struct resource *resp);
117 
118 
119 __END_DECLS
120 
121 #endif /* RT_REGION_H */
122 
123 /*
124  * Local Variables:
125  * tab-width: 8
126  * mode: C
127  * indent-tabs-mode: t
128  * c-file-style: "stroustrup"
129  * End:
130  * ex: shiftwidth=4 tabstop=8
131  */
Header file for the BRL-CAD common definitions.
fastf_t mat_t[ELEMENTS_PER_MAT]
4x4 matrix
Definition: vmath.h:370
Global registry of recognized magic numbers.
int db_region_mat(mat_t m, struct db_i *dbip, const char *name, struct resource *resp)
void rt_pr_region(const struct region *rp)
Definition: list.h:132
Definition: region.h:44
union tree * reg_treetop
Pointer to boolean tree.
Definition: region.h:47
short reg_is_fastgen
FASTGEN-compatibility mode?
Definition: region.h:59
void * reg_mfuncs
User appl. funcs for material.
Definition: region.h:54
int reg_aircode
Region ID AIR code.
Definition: region.h:50
int reg_gmater
GIFT Material code.
Definition: region.h:51
int reg_bit
constant index into Regions[]
Definition: region.h:48
int reg_los
approximate line-of-sight thickness equivalence
Definition: region.h:52
void * reg_udata
User appl. data for material.
Definition: region.h:55
short reg_all_unions
1=boolean tree is all unions
Definition: region.h:58
int reg_regionid
Region ID code. If <=0, use reg_aircode.
Definition: region.h:49
int reg_transmit
flag: material transmits light
Definition: region.h:56
struct bu_list l
magic # and doubly linked list
Definition: region.h:45
long reg_instnum
instance number, from d_uses
Definition: region.h:57
struct bu_attribute_value_set attr_values
Attribute/value set.
Definition: region.h:63
struct mater_info reg_mater
Real material information.
Definition: region.h:53
const char * reg_name
Identifying string.
Definition: region.h:46
Definition: tree.h:148
fundamental vector, matrix, quaternion math macros