BRL-CAD
functab.h
Go to the documentation of this file.
1/* R T _ F U N C 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_functab
21 * @brief Object-oriented interface to BRL-CAD geometry.
22 *
23 * These are the methods for a notional object class "brlcad_solid".
24 * The data for each instance is found separately in struct soltab.
25 * This table is indexed by ID_xxx value of particular solid found in
26 * st_id, or directly pointed at by st_meth.
27 *
28 */
29/** @{ */
30/** @file rt/functab.h */
31
32#ifndef RT_FUNCTAB_H
33#define RT_FUNCTAB_H
34
35#include "common.h"
36#include "vmath.h"
37#include "bu/parse.h"
38#include "bu/vls.h"
39#include "bn/tol.h"
40#include "bv.h"
41#include "rt/geom.h"
42#include "rt/defines.h"
43#include "rt/application.h"
44#include "rt/db_internal.h"
45#include "rt/db_instance.h"
46#include "rt/hit.h"
47#include "rt/resource.h"
48#include "rt/rt_instance.h"
49#include "rt/seg.h"
50#include "rt/soltab.h"
51#include "rt/tol.h"
52#include "rt/view.h"
53#include "rt/xray.h"
54#include "pc.h"
55#include "nmg.h"
56#include "brep.h"
57
58
59__BEGIN_DECLS
60
61/**
62 * This needs to be at the end of the raytrace.h header file, so that
63 * all the structure names are known. The "union record" and "struct
64 * nmgregion" pointers are problematic, so generic pointers are used
65 * when those header files have not yet been seen.
66 *
67 * DEPRECATED: the size of this structure will likely change with new
68 * size for ft_label and new object callbacks.
69 */
70struct rt_functab {
71 uint32_t magic;
72 char ft_name[17]; /* current longest name is 16 chars, need one element for terminating NULL */
73 char ft_label[9]; /* current longest label is 8 chars, need one element for terminating NULL */
74
76
77 int (*ft_prep)(struct soltab *stp,
78 struct rt_db_internal *ip,
79 struct rt_i *rtip);
80#define RTFUNCTAB_FUNC_PREP_CAST(_func) ((int (*)(struct soltab *, struct rt_db_internal *, struct rt_i *))((void (*)(void))_func))
81
82 int (*ft_shot)(struct soltab *stp,
83 struct xray *rp,
84 struct application *ap, /* has resource */
85 struct seg *seghead);
86#define RTFUNCTAB_FUNC_SHOT_CAST(_func) ((int (*)(struct soltab *, struct xray *, struct application *, struct seg *))((void (*)(void))_func))
87
88 void (*ft_print)(const struct soltab *stp);
89#define RTFUNCTAB_FUNC_PRINT_CAST(_func) ((void (*)(const struct soltab *))((void (*)(void))_func))
90
91 void (*ft_norm)(struct hit *hitp,
92 struct soltab *stp,
93 struct xray *rp);
94#define RTFUNCTAB_FUNC_NORM_CAST(_func) ((void (*)(struct hit *, struct soltab *, struct xray *))((void (*)(void))_func))
95
96 int (*ft_piece_shot)(struct rt_piecestate *psp,
97 struct rt_piecelist *plp,
98 double dist, /* correction to apply to hit distances */
99 struct xray *ray, /* ray transformed to be near cut cell */
100 struct application *ap, /* has resource */
101 struct seg *seghead); /* used only for PLATE mode hits */
102#define RTFUNCTAB_FUNC_PIECE_SHOT_CAST(_func) ((int (*)(struct rt_piecestate *, struct rt_piecelist *, double dist, struct xray *, struct application *, struct seg *))((void (*)(void))_func))
103
104 void (*ft_piece_hitsegs)(struct rt_piecestate *psp,
105 struct seg *seghead,
106 struct application *ap); /* has resource */
107#define RTFUNCTAB_FUNC_PIECE_HITSEGS_CAST(_func) ((void (*)(struct rt_piecestate *, struct seg *, struct application *))((void (*)(void))_func))
108
109 void (*ft_uv)(struct application *ap, /* has resource */
110 struct soltab *stp,
111 struct hit *hitp,
112 struct uvcoord *uvp);
113#define RTFUNCTAB_FUNC_UV_CAST(_func) ((void (*)(struct application *, struct soltab *, struct hit *, struct uvcoord *))((void (*)(void))_func))
114
115 void (*ft_curve)(struct curvature *cvp,
116 struct hit *hitp,
117 struct soltab *stp);
118#define RTFUNCTAB_FUNC_CURVE_CAST(_func) ((void (*)(struct curvature *, struct hit *, struct soltab *))((void (*)(void))_func))
119
120 int (*ft_classify)(const struct soltab * /*stp*/, const vect_t /*min*/, const vect_t /*max*/, const struct bn_tol * /*tol*/);
121#define RTFUNCTAB_FUNC_CLASS_CAST(_func) ((int (*)(const struct soltab *, const vect_t, const vect_t, const struct bn_tol *))((void (*)(void))_func))
122
123 void (*ft_free)(struct soltab * /*stp*/);
124#define RTFUNCTAB_FUNC_FREE_CAST(_func) ((void (*)(struct soltab *))((void (*)(void))_func))
125
126 int (*ft_plot)(struct bu_list * /*vhead*/,
127 struct rt_db_internal * /*ip*/,
128 const struct bg_tess_tol * /*ttol*/,
129 const struct bn_tol * /*tol*/,
130 const struct bview * /*view info*/);
131#define RTFUNCTAB_FUNC_PLOT_CAST(_func) ((int (*)(struct bu_list *, struct rt_db_internal *, const struct bg_tess_tol *, const struct bn_tol *, const struct bview *))((void (*)(void))_func))
132
133 int (*ft_adaptive_plot)(struct bu_list * /*vhead*/,
134 struct rt_db_internal * /*ip*/,
135 const struct bn_tol * /*tol*/,
136 const struct bview * /* view info */,
137 fastf_t /* s_size */);
138#define RTFUNCTAB_FUNC_ADAPTIVE_PLOT_CAST(_func) ((int (*)(struct bu_list *, struct rt_db_internal *, const struct bn_tol *, const struct bview *, fastf_t))((void (*)(void))_func))
139
140 void (*ft_vshot)(struct soltab * /*stp*/[],
141 struct xray *[] /*rp*/,
142 struct seg * /*segp*/,
143 int /*n*/,
144 struct application * /*ap*/);
145#define RTFUNCTAB_FUNC_VSHOT_CAST(_func) ((void (*)(struct soltab *[], struct xray *[], struct seg *, int, struct application *))((void (*)(void))_func))
146
147 int (*ft_tessellate)(struct nmgregion ** /*r*/,
148 struct model * /*m*/,
149 struct rt_db_internal * /*ip*/,
150 const struct bg_tess_tol * /*ttol*/,
151 const struct bn_tol * /*tol*/);
152#define RTFUNCTAB_FUNC_TESS_CAST(_func) ((int (*)(struct nmgregion **, struct model *, struct rt_db_internal *, const struct bg_tess_tol *, const struct bn_tol *))((void (*)(void))_func))
153 int (*ft_tnurb)(struct nmgregion ** /*r*/,
154 struct model * /*m*/,
155 struct rt_db_internal * /*ip*/,
156 const struct bn_tol * /*tol*/);
157#define RTFUNCTAB_FUNC_TNURB_CAST(_func) ((int (*)(struct nmgregion **, struct model *, struct rt_db_internal *, const struct bn_tol *))((void (*)(void))_func))
158
159 void (*ft_brep)(ON_Brep ** /*b*/,
160 struct rt_db_internal * /*ip*/,
161 const struct bn_tol * /*tol*/);
162#define RTFUNCTAB_FUNC_BREP_CAST(_func) ((void (*)(ON_Brep **, struct rt_db_internal *, const struct bn_tol *))((void (*)(void))_func))
163
164 int (*ft_import5)(struct rt_db_internal * /*ip*/,
165 const struct bu_external * /*ep*/,
166 const mat_t /*mat*/,
167 const struct db_i * /*dbip*/,
168 struct resource * /*resp*/);
169#define RTFUNCTAB_FUNC_IMPORT5_CAST(_func) ((int (*)(struct rt_db_internal *, const struct bu_external *, const mat_t, const struct db_i *, struct resource *))((void (*)(void))_func))
170
171 int (*ft_export5)(struct bu_external * /*ep*/,
172 const struct rt_db_internal * /*ip*/,
173 double /*local2mm*/,
174 const struct db_i * /*dbip*/,
175 struct resource * /*resp*/);
176#define RTFUNCTAB_FUNC_EXPORT5_CAST(_func) ((int (*)(struct bu_external *, const struct rt_db_internal *, double, const struct db_i *, struct resource *))((void (*)(void))_func))
177
178 int (*ft_import4)(struct rt_db_internal * /*ip*/,
179 const struct bu_external * /*ep*/,
180 const mat_t /*mat*/,
181 const struct db_i * /*dbip*/,
182 struct resource * /*resp*/);
183#define RTFUNCTAB_FUNC_IMPORT4_CAST(_func) ((int (*)(struct rt_db_internal *, const struct bu_external *, const mat_t, const struct db_i *, struct resource *))((void (*)(void))_func))
184
185 int (*ft_export4)(struct bu_external * /*ep*/,
186 const struct rt_db_internal * /*ip*/,
187 double /*local2mm*/,
188 const struct db_i * /*dbip*/,
189 struct resource * /*resp*/);
190#define RTFUNCTAB_FUNC_EXPORT4_CAST(_func) ((int (*)(struct bu_external *, const struct rt_db_internal *, double, const struct db_i *, struct resource *))((void (*)(void))_func))
191
192 void (*ft_ifree)(struct rt_db_internal * /*ip*/);
193#define RTFUNCTAB_FUNC_IFREE_CAST(_func) ((void (*)(struct rt_db_internal *))((void (*)(void))_func))
194
195 int (*ft_describe)(struct bu_vls * /*str*/,
196 const struct rt_db_internal * /*ip*/,
197 int /*verbose*/,
198 double /*mm2local*/);
199#define RTFUNCTAB_FUNC_DESCRIBE_CAST(_func) ((int (*)(struct bu_vls *, const struct rt_db_internal *, int, double))((void (*)(void))_func))
200
201 int (*ft_xform)(struct rt_db_internal * /*op*/,
202 const mat_t /*mat*/, struct rt_db_internal * /*ip*/,
203 int /*free*/, struct db_i * /*dbip*/);
204#define RTFUNCTAB_FUNC_XFORM_CAST(_func) ((int (*)(struct rt_db_internal *, const mat_t, struct rt_db_internal *, int, struct db_i *))((void (*)(void))_func))
205
206 const struct bu_structparse *ft_parsetab; /**< @brief rt_xxx_parse */
207 size_t ft_internal_size; /**< @brief sizeof(struct rt_xxx_internal) */
208 uint32_t ft_internal_magic; /**< @brief RT_XXX_INTERNAL_MAGIC */
209
210 int (*ft_get)(struct bu_vls *, const struct rt_db_internal *, const char *item);
211#define RTFUNCTAB_FUNC_GET_CAST(_func) ((int (*)(struct bu_vls *, const struct rt_db_internal *, const char *))((void (*)(void))_func))
212
213 int (*ft_adjust)(struct bu_vls *, struct rt_db_internal *, int /*argc*/, const char ** /*argv*/);
214#define RTFUNCTAB_FUNC_ADJUST_CAST(_func) ((int (*)(struct bu_vls *, struct rt_db_internal *, int, const char **))((void (*)(void))_func))
215
216 int (*ft_form)(struct bu_vls *, const struct rt_functab *);
217#define RTFUNCTAB_FUNC_FORM_CAST(_func) ((int (*)(struct bu_vls *, const struct rt_functab *))((void (*)(void))_func))
218
219 void (*ft_make)(const struct rt_functab *, struct rt_db_internal * /*ip*/);
220#define RTFUNCTAB_FUNC_MAKE_CAST(_func) ((void (*)(const struct rt_functab *, struct rt_db_internal *))((void (*)(void))_func))
221
222 int (*ft_params)(struct pc_pc_set *, const struct rt_db_internal * /*ip*/);
223#define RTFUNCTAB_FUNC_PARAMS_CAST(_func) ((int (*)(struct pc_pc_set *, const struct rt_db_internal *))((void (*)(void))_func))
224
225 /* Axis aligned bounding box */
226 int (*ft_bbox)(struct rt_db_internal * /*ip*/,
227 point_t * /*min X, Y, Z of bounding RPP*/,
228 point_t * /*max X, Y, Z of bounding RPP*/,
229 const struct bn_tol *);
230#define RTFUNCTAB_FUNC_BBOX_CAST(_func) ((int (*)(struct rt_db_internal *, point_t *, point_t *, const struct bn_tol *))((void (*)(void))_func))
231
232 void (*ft_volume)(fastf_t * /*vol*/, const struct rt_db_internal * /*ip*/);
233#define RTFUNCTAB_FUNC_VOLUME_CAST(_func) ((void (*)(fastf_t *, const struct rt_db_internal *))((void (*)(void))_func))
234
235 void (*ft_surf_area)(fastf_t * /*area*/, const struct rt_db_internal * /*ip*/);
236#define RTFUNCTAB_FUNC_SURF_AREA_CAST(_func) ((void (*)(fastf_t *, const struct rt_db_internal *))((void (*)(void))_func))
237
238 void (*ft_centroid)(point_t * /*cent*/, const struct rt_db_internal * /*ip*/);
239#define RTFUNCTAB_FUNC_CENTROID_CAST(_func) ((void (*)(point_t *, const struct rt_db_internal *))((void (*)(void))_func))
240
241 int (*ft_oriented_bbox)(struct rt_arb_internal * /* bounding arb8 */,
242 struct rt_db_internal * /*ip*/,
243 const fastf_t);
244#define RTFUNCTAB_FUNC_ORIENTED_BBOX_CAST(_func) ((int (*)(struct rt_arb_internal *, struct rt_db_internal *, const fastf_t))((void (*)(void))_func))
245
246 /** get a list of the selections matching a query */
247 struct rt_selection_set *(*ft_find_selections)(const struct rt_db_internal *,
248 const struct rt_selection_query *);
249#define RTFUNCTAB_FUNC_FIND_SELECTIONS_CAST(_func) ((struct rt_selection_set *(*)(const struct rt_db_internal *, const struct rt_selection_query *))((void (*)(void))_func))
250
251 /**
252 * evaluate a logical selection expression (e.g. a INTERSECT b,
253 * NOT a) to create a new selection
254 */
255 struct rt_selection *(*ft_evaluate_selection)(const struct rt_db_internal *,
256 int op,
257 const struct rt_selection *,
258 const struct rt_selection *);
259#define RTFUNCTAB_FUNC_EVALUATE_SELECTION_CAST(_func) ((struct rt_selection *(*)(const struct rt_db_internal *, int op, const struct rt_selection *, const struct rt_selection *))((void (*)(void))_func))
260
261 /** apply an operation to a selected subset of a primitive */
263 struct db_i *,
264 const struct rt_selection *,
265 const struct rt_selection_operation *);
266#define RTFUNCTAB_FUNC_PROCESS_SELECTION_CAST(_func) ((int (*)(struct rt_db_internal *, struct db_i *, const struct rt_selection *, const struct rt_selection_operation *))((void (*)(void))_func))
267
268 /** cache and uncache prep data for faster future lookup */
269 int (*ft_prep_serialize)(struct soltab *stp, const struct rt_db_internal *ip, struct bu_external *external, size_t *version);
270#define RTFUNCTAB_FUNC_PREP_SERIALIZE_CAST(_func) ((int (*)(struct soltab *, const struct rt_db_internal *, struct bu_external *, size_t *))((void (*)(void))_func))
271
272 /** generate struct bv_scene_obj labels for the primitive */
273 void (*ft_labels)(struct bv_scene_obj *ps, const struct rt_db_internal *ip);
274#define RTFUNCTAB_FUNC_LABELS_CAST(_func) ((void (*)(struct bv_scene_obj *, const struct rt_db_internal *))((void (*)(void))_func))
275
276};
277
278
279RT_EXPORT extern const struct rt_functab OBJ[];
280
281#define RT_CK_FUNCTAB(_p) BU_CKMAG(_p, RT_FUNCTAB_MAGIC, "functab");
282
283RT_EXPORT extern const struct rt_functab *rt_get_functab_by_label(const char *label);
284
285__END_DECLS
286
287#endif /* RT_FUNCTAB_H */
288/** @} */
289/*
290 * Local Variables:
291 * tab-width: 8
292 * mode: C
293 * indent-tabs-mode: t
294 * c-file-style: "stroustrup"
295 * End:
296 * ex: shiftwidth=4 tabstop=8
297 */
Header file for the BRL-CAD common definitions.
const struct rt_functab * rt_get_functab_by_label(const char *label)
const struct rt_functab OBJ[]
fastf_t vect_t[ELEMENTS_PER_VECT]
3-tuple vector
Definition: vmath.h:345
double fastf_t
fastest 64-bit (or larger) floating point type
Definition: vmath.h:330
fastf_t mat_t[ELEMENTS_PER_MAT]
4x4 matrix
Definition: vmath.h:366
fastf_t point_t[ELEMENTS_PER_POINT]
3-tuple point
Definition: vmath.h:351
Main header file for the BRL-CAD Non-Manifold Geometry Library, LIBNMG.
Definition: tol.h:72
Definition: list.h:131
Definition: vls.h:53
Definition: defines.h:476
Definition: hit.h:118
Information about where a ray hits the surface.
Definition: hit.h:61
NMG topological model.
Definition: topology.h:289
NMG topological region.
Definition: topology.h:277
Definition: pc.h:105
uint32_t ft_internal_magic
RT_XXX_INTERNAL_MAGIC.
Definition: functab.h:208
void(* ft_make)(const struct rt_functab *, struct rt_db_internal *)
Definition: functab.h:219
size_t ft_internal_size
sizeof(struct rt_xxx_internal)
Definition: functab.h:207
int(* ft_get)(struct bu_vls *, const struct rt_db_internal *, const char *item)
Definition: functab.h:210
int(* ft_plot)(struct bu_list *, struct rt_db_internal *, const struct bg_tess_tol *, const struct bn_tol *, const struct bview *)
Definition: functab.h:126
void(* ft_surf_area)(fastf_t *, const struct rt_db_internal *)
Definition: functab.h:235
int(* ft_import5)(struct rt_db_internal *, const struct bu_external *, const mat_t, const struct db_i *, struct resource *)
Definition: functab.h:164
int(* ft_xform)(struct rt_db_internal *, const mat_t, struct rt_db_internal *, int, struct db_i *)
Definition: functab.h:201
int(* ft_params)(struct pc_pc_set *, const struct rt_db_internal *)
Definition: functab.h:222
int(* ft_export5)(struct bu_external *, const struct rt_db_internal *, double, const struct db_i *, struct resource *)
Definition: functab.h:171
int(* ft_export4)(struct bu_external *, const struct rt_db_internal *, double, const struct db_i *, struct resource *)
Definition: functab.h:185
const struct bu_structparse * ft_parsetab
rt_xxx_parse
Definition: functab.h:206
uint32_t magic
Definition: functab.h:71
int(* ft_shot)(struct soltab *stp, struct xray *rp, struct application *ap, struct seg *seghead)
Definition: functab.h:82
int(* ft_oriented_bbox)(struct rt_arb_internal *, struct rt_db_internal *, const fastf_t)
Definition: functab.h:241
void(* ft_curve)(struct curvature *cvp, struct hit *hitp, struct soltab *stp)
Definition: functab.h:115
void(* ft_brep)(ON_Brep **, struct rt_db_internal *, const struct bn_tol *)
Definition: functab.h:159
int(* ft_prep)(struct soltab *stp, struct rt_db_internal *ip, struct rt_i *rtip)
Definition: functab.h:77
int(* ft_form)(struct bu_vls *, const struct rt_functab *)
Definition: functab.h:216
void(* ft_piece_hitsegs)(struct rt_piecestate *psp, struct seg *seghead, struct application *ap)
Definition: functab.h:104
int(* ft_bbox)(struct rt_db_internal *, point_t *, point_t *, const struct bn_tol *)
Definition: functab.h:226
int ft_use_rpp
Definition: functab.h:75
int(* ft_adaptive_plot)(struct bu_list *, struct rt_db_internal *, const struct bn_tol *, const struct bview *, fastf_t)
Definition: functab.h:133
void(* ft_centroid)(point_t *, const struct rt_db_internal *)
Definition: functab.h:238
void(* ft_norm)(struct hit *hitp, struct soltab *stp, struct xray *rp)
Definition: functab.h:91
void(* ft_free)(struct soltab *)
Definition: functab.h:123
void(* ft_volume)(fastf_t *, const struct rt_db_internal *)
Definition: functab.h:232
int(* ft_classify)(const struct soltab *, const vect_t, const vect_t, const struct bn_tol *)
Definition: functab.h:120
int(* ft_process_selection)(struct rt_db_internal *, struct db_i *, const struct rt_selection *, const struct rt_selection_operation *)
Definition: functab.h:262
int(* ft_import4)(struct rt_db_internal *, const struct bu_external *, const mat_t, const struct db_i *, struct resource *)
Definition: functab.h:178
void(* ft_vshot)(struct soltab *[], struct xray *[], struct seg *, int, struct application *)
Definition: functab.h:140
void(* ft_labels)(struct bv_scene_obj *ps, const struct rt_db_internal *ip)
Definition: functab.h:273
int(* ft_tessellate)(struct nmgregion **, struct model *, struct rt_db_internal *, const struct bg_tess_tol *, const struct bn_tol *)
Definition: functab.h:147
void(* ft_ifree)(struct rt_db_internal *)
Definition: functab.h:192
char ft_name[17]
Definition: functab.h:72
int(* ft_piece_shot)(struct rt_piecestate *psp, struct rt_piecelist *plp, double dist, struct xray *ray, struct application *ap, struct seg *seghead)
Definition: functab.h:96
int(* ft_describe)(struct bu_vls *, const struct rt_db_internal *, int, double)
Definition: functab.h:195
int(* ft_adjust)(struct bu_vls *, struct rt_db_internal *, int, const char **)
Definition: functab.h:213
void(* ft_print)(const struct soltab *stp)
Definition: functab.h:88
int(* ft_tnurb)(struct nmgregion **, struct model *, struct rt_db_internal *, const struct bn_tol *)
Definition: functab.h:153
int(* ft_prep_serialize)(struct soltab *stp, const struct rt_db_internal *ip, struct bu_external *external, size_t *version)
Definition: functab.h:269
void(* ft_uv)(struct application *ap, struct soltab *stp, struct hit *hitp, struct uvcoord *uvp)
Definition: functab.h:109
char ft_label[9]
Definition: functab.h:73
Definition: seg.h:59
Definition: soltab.h:56
Definition: hit.h:152
Primary ray data structure.
Definition: xray.h:41
fundamental vector, matrix, quaternion math macros