BRL-CAD
wdb.h
Go to the documentation of this file.
1/* W D B . H
2 * BRL-CAD
3 *
4 * Copyright (c) 1988-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 libwdb
21 *
22 * @brief
23 * Interface structures and routines for libwdb
24
25 * Library for writing MGED database objects from arbitrary procedures.
26 * Assumes that some of the structure of such databases are known by
27 * the calling routines.
28 *
29 * It is expected that this library will grow as experience is gained.
30 * Routines for writing every permissible solid do not yet exist.
31 *
32 * Note that routines which are passed point_t or vect_t or mat_t
33 * parameters (which are call-by-address) must be VERY careful to
34 * leave those parameters unmodified (e.g., by scaling), so that the
35 * calling routine is not surprised.
36 *
37 * Return codes of 0 are OK, -1 signal an error.
38 *
39 * Note - Rather than using a stdio (FILE *), we now use a (struct rt_wdb *)
40 * parameter. Rather than calling fopen(), call wdb_fopen();
41 */
42
43#ifndef WDB_H
44#define WDB_H
45
46#include "common.h"
47
48#include "bu/magic.h"
49#include "bu/bitv.h"
50#include "bu/list.h"
51#include "bn.h"
52#include "raytrace.h"
53#include "rt/geom.h"
54
55
56__BEGIN_DECLS
57
58#ifndef WDB_EXPORT
59# if defined(WDB_DLL_EXPORTS) && defined(WDB_DLL_IMPORTS)
60# error "Only WDB_DLL_EXPORTS or WDB_DLL_IMPORTS can be defined, not both."
61# elif defined(WDB_DLL_EXPORTS)
62# define WDB_EXPORT COMPILER_DLLEXPORT
63# elif defined(WDB_DLL_IMPORTS)
64# define WDB_EXPORT COMPILER_DLLIMPORT
65# else
66# define WDB_EXPORT
67# endif
68#endif
69
70/** @addtogroup libwdb */
71/** @{ */
72/** @file include/wdb.h */
73
74/**
75 * In-memory form of database combinations
76 */
77struct wmember {
78 struct bu_list l;
79 int wm_op; /**< @brief Boolean operation */
80 mat_t wm_mat; /**< @brief FIXME: Should be a matp_t */
81 char *wm_name;
82};
83
84
85#define WMEMBER_INIT_ZERO { BU_LIST_INIT_ZERO, 0, MAT_INIT_IDN, NULL }
86#define WMEMBER_INIT(x) { BU_LIST_INIT(&((x)->l)); (x)->wm_op = 0; MAT_IDN((x)->wm_mat); (x)->wm_name = NULL; }
87#define WMEMBER_NULL ((struct wmember *)0)
88#define WDB_CK_WMEMBER(_p) BU_CKMAG(_p, WMEMBER_MAGIC, "wmember");
89
90/**
91 * Make a database header (ID) record.
92 */
93WDB_EXPORT extern int mk_id(struct rt_wdb *fp, const char *title);
94
95/**
96 * Make a database header (ID) record, and note the user's preferred
97 * editing units (specified as a string).
98 *
99 * @return <0 error, 0 success
100 */
101WDB_EXPORT extern int mk_id_units(struct rt_wdb *fp, const char *title, const char *units);
102
103
104/**
105 * Make a database header (ID) record, and note the user's preferred
106 * editing units (specified as a conversion factor).
107 *
108 * Note that the v4 database format offers only a limited number of
109 * choices for the preferred editing units. If the user is editing in
110 * unusual units (like 2.5feet), don't fail to create the database
111 * header.
112 *
113 * In the v5 database, the conversion factor will be stored intact.
114 *
115 * Note that the database-layer header record will have already been
116 * written by db_create(). All we have to do here is update it.
117 *
118 * @return <0 error, 0 success
119 */
120WDB_EXPORT int mk_id_editunits(
121 struct rt_wdb *fp,
122 const char *title,
123 double local2mm);
124
125/**
126 * Make a halfspace. Specified by distance from origin, and outward
127 * pointing normal vector.
128 */
129WDB_EXPORT extern int mk_half(struct rt_wdb *fp, const char *name, const vect_t norm, fastf_t d);
130
131/**
132 * Make a grip pseudo solid. Specified by a center, normal vector,
133 * and magnitude.
134 */
135WDB_EXPORT int mk_grip(
136 struct rt_wdb *wdbp,
137 const char *name,
138 const point_t center,
139 const vect_t normal,
140 const fastf_t magnitude);
141
142/**
143 * Make a right parallelepiped. Specified by minXYZ, maxXYZ.
144 */
145WDB_EXPORT extern int mk_rpp(struct rt_wdb *fp, const char *name, const point_t min, const point_t max);
146
147/**
148 * Makes a right angular wedge given a starting vertex located in the,
149 * lower left corner, an x and a z direction vector, x, y, and z
150 * lengths, and an x length for the top. The y direction vector is x
151 * cross z.
152 */
153WDB_EXPORT extern int mk_wedge(struct rt_wdb *fp, const char *name, const point_t vert,
154 const vect_t xdirv, const vect_t zdirv,
155 fastf_t xlen, fastf_t ylen, fastf_t zlen,
156 fastf_t x_top_len);
157
158WDB_EXPORT extern int mk_arb4(struct rt_wdb *fp, const char *name, const fastf_t *pts4);
159
160WDB_EXPORT extern int mk_arb5(struct rt_wdb *fp, const char *name, const fastf_t *pts5);
161
162WDB_EXPORT extern int mk_arb6(struct rt_wdb *fp, const char *name, const fastf_t *pts6);
163
164WDB_EXPORT extern int mk_arb7(struct rt_wdb *fp, const char *name, const fastf_t *pts7);
165
166/**
167 * All plates with 4 points must be co-planar. If there are
168 * degeneracies (i.e., all 8 vertices are not distinct), then certain
169 * requirements must be met. If we think of the ARB8 as having a top
170 * and a bottom plate, the first four points listed must lie on one
171 * plate, and the second four points listed must lie on the other
172 * plate.
173 */
174WDB_EXPORT extern int mk_arb8(struct rt_wdb *fp, const char *name, const fastf_t *pts8);
175
176/**
177 * Make a sphere with the given center point and radius.
178 */
179WDB_EXPORT extern int mk_sph(struct rt_wdb *fp, const char *name, const point_t center,
180 fastf_t radius);
181
182/**
183 * Make an ellipsoid at the given center point with 3 perp. radius
184 * vectors. The eccentricity of the ellipsoid is controlled by the
185 * relative lengths of the three radius vectors.
186 */
187WDB_EXPORT extern int mk_ell(struct rt_wdb *fp, const char *name, const point_t center,
188 const vect_t a, const vect_t b, const vect_t c);
189
190/**
191 * Make a torus. Specify center, normal, r1: distance from center
192 * point to center of solid part, r2: radius of solid part.
193 */
194WDB_EXPORT extern int mk_tor(struct rt_wdb *fp, const char *name, const point_t center,
195 const vect_t inorm, double r1, double r2);
196
197/**
198 * Make a Right Circular Cylinder (special case of the TGC).
199 */
200WDB_EXPORT extern int mk_rcc(struct rt_wdb *fp, const char *name, const point_t base,
201 const vect_t height, fastf_t radius);
202
203/**
204 * Make a Truncated General Cylinder.
205 */
206WDB_EXPORT extern int mk_tgc(struct rt_wdb *fp, const char *name, const point_t base,
207 const vect_t height, const vect_t a, const vect_t b,
208 const vect_t c, const vect_t d);
209
210/**
211 * Makes a right circular cone given the center point of the base
212 * circle, a direction vector, a scalar height, and the radii at each
213 * end of the cone.
214 */
215WDB_EXPORT extern int mk_cone(struct rt_wdb *fp, const char *name, const point_t base, const vect_t dirv, fastf_t height, fastf_t base_radius, fastf_t nose_radius);
216
217/**
218 * Make a truncated right cylinder, with base and height. Not just
219 * called mk_trc() to avoid conflict with a previous routine of that
220 * name with different calling sequence.
221 */
222WDB_EXPORT extern int mk_trc_h(struct rt_wdb *fp, const char *name, const point_t base,
223 const vect_t height, fastf_t radbase, fastf_t radtop);
224
225/**
226 * Convenience wrapper for mk_trc_h().
227 */
228WDB_EXPORT extern int mk_trc_top(struct rt_wdb *fp, const char *name, const point_t ibase,
229 const point_t itop, fastf_t radbase, fastf_t radtop);
230
231/**
232 * Makes a right parabolic cylinder given the origin, or main vertex,
233 * a height vector, a breadth vector (B . H must be 0), and a scalar
234 * rectangular half-width (for the top of the rpc).
235 */
236WDB_EXPORT int mk_rpc(
237 struct rt_wdb *wdbp,
238 const char *name,
239 const point_t vert,
240 const vect_t height,
241 const vect_t breadth,
242 double half_w);
243
244/**
245 * Makes a right hyperbolic cylinder given the origin, or main vertex,
246 * a height vector, a breadth vector (B . H must be 0), a scalar
247 * rectangular half-width (for the top of the rpc), and the scalar
248 * distance from the tip of the hyperbola to the intersection of the
249 * asymptotes.
250 */
251WDB_EXPORT int mk_rhc(
252 struct rt_wdb *wdbp,
253 const char *name,
254 const point_t vert,
255 const vect_t height,
256 const vect_t breadth,
257 fastf_t half_w,
258 fastf_t asymp);
259
260/**
261 * Makes an elliptical paraboloid given the origin, a height vector H,
262 * a unit vector A along the semi-major axis (A . H must equal 0), and
263 * the scalar lengths, r1 and r2, of the semi-major and -minor axes.
264 */
265WDB_EXPORT int mk_epa(
266 struct rt_wdb *wdbp,
267 const char *name,
268 const point_t vert,
269 const vect_t height,
270 const vect_t breadth,
271 fastf_t r1,
272 fastf_t r2);
273
274/**
275 * Makes an elliptical hyperboloid given the origin, a height vector
276 * H, a unit vector A along the semi-major axis (A . H must equal 0),
277 * the scalar lengths, r1 and r2, of the semi-major and -minor axes,
278 * and the distance c between the tip of the hyperboloid and the
279 * vertex of the asymptotic cone.
280 */
281WDB_EXPORT int mk_ehy(
282 struct rt_wdb *wdbp,
283 const char *name,
284 const point_t vert,
285 const vect_t height,
286 const vect_t breadth,
287 fastf_t r1,
288 fastf_t r2,
289 fastf_t c);
290
291/**
292 * Make a hyperboloid at the given center point with a vertex, height
293 * vector, A vector, magnitude of the B vector, and neck to base
294 * ratio.
295 */
296WDB_EXPORT int mk_hyp(
297 struct rt_wdb *wdbp,
298 const char *name,
299 const point_t vert,
300 const vect_t height_vector,
301 const vect_t vectA,
302 fastf_t magB,
303 fastf_t base_neck_ratio);
304
305/**
306 * Makes an elliptical torus given the origin, a plane normal vector
307 * N, a vector C along the semi-major axis of the elliptical
308 * cross-section, the scalar lengths r and rd, of the radius of
309 * revolution and length of semi-minor axis of the elliptical cross
310 * section.
311 */
312WDB_EXPORT int mk_eto(
313 struct rt_wdb *wdbp,
314 const char *name,
315 const point_t vert,
316 const vect_t norm,
317 const vect_t smajor,
318 fastf_t rrot,
319 fastf_t sminor);
320
321
322/**
323 * Makes a metaball.
324 */
325WDB_EXPORT int mk_metaball(
326 struct rt_wdb *wdbp,
327 const char *name,
328 const size_t nctlpt, /* number of control points */
329 const int method, /* metaball rendering method */
330 const fastf_t threshold,
331 const fastf_t *verts[5]); /* X, Y, Z, fldstr, goo/Beta */
332
333/**
334 * Caller is responsible for freeing eqn[]
335 *
336 * @return <0 error, 0 success
337 */
338WDB_EXPORT extern int mk_arbn(struct rt_wdb *fp, const char *name, size_t neqn, const plane_t *eqn);
339
340WDB_EXPORT extern int mk_ars(struct rt_wdb *fp, const char *name, size_t ncurves, size_t pts_per_curve, fastf_t *curves[]);
341
342/**
343 * Given the appropriate parameters, makes the non-geometric
344 * constraint object and writes it to the database using
345 * wdb_put_internal. Only supported on database version 5 or above
346 */
347WDB_EXPORT extern int mk_constraint(struct rt_wdb *wdbp, const char *name, const char *expr);
348
349
350WDB_EXPORT extern int mk_material(struct rt_wdb *wdbp,
351 const char *db_name,
352 const char *name,
353 const char *parent,
354 const char *source,
355 struct bu_attribute_value_set *physicalProperties,
356 struct bu_attribute_value_set *mechanicalProperties,
357 struct bu_attribute_value_set *opticalProperties,
358 struct bu_attribute_value_set *thermalProperties);
359
360
361/* FIXME: are the variable-sized types actually necessary? should be
362 * able to rely on stdint types. the file+nonfile duplication seems
363 * silly too.
364 */
365typedef enum {
407
408
409/**
410 * Make a uniform binary data object from an array or a data file.
411 * Read 'count' values from 'data'. If 'data_type' is a file, 'count'
412 * may be used to only read a subset of a file's contents. If 'data'
413 * is already an in-memory buffer of memory, 'count' values will be
414 * copied (which is count * sizeof(data_type) bytes).
415 *
416 * Files can use a non-positive 'count' to mean "read the whole file",
417 * pre-loaded data, however, must provide a positive 'count' otherwise
418 * an empty binunif will be created.
419 */
420WDB_EXPORT extern int mk_binunif(struct rt_wdb *fp, const char *name, const void *data, wdb_binunif data_type, long count);
421
422
423/**
424 * Create a BOT (Bag O'Triangles) solid
425 */
426WDB_EXPORT int mk_bot(
427 struct rt_wdb *fp, /**< database file pointer to write to */
428 const char *name, /**< name of bot object to write out */
429 unsigned char mode, /**< bot mode */
430 unsigned char orientation, /**< bot orientation */
431 unsigned char error_mode, /**< may be used to indicate error handling (ignored for now) */
432 size_t num_vertices, /**< number of vertices */
433 size_t num_faces, /**< number of faces */
434 fastf_t *vertices, /**< array of floats for vertices [num_vertices*3] */
435 int *faces, /**< array of ints for faces [num_faces*3] */
436 fastf_t *thickness, /**< array of plate mode
437 * thicknesses (corresponds to
438 * array of faces) NULL for
439 * modes RT_BOT_SURFACE and
440 * RT_BOT_SOLID.
441 */
442 struct bu_bitv *face_mode /**< a flag for each face
443 * indicating thickness is
444 * appended to hit point,
445 * otherwise thickness is
446 * centered about hit point
447 */
448 );
449
450/**
451 * Create a BOT (Bag O'Triangles) solid with face normals
452 */
453WDB_EXPORT int mk_bot_w_normals(
454 struct rt_wdb *fp, /**< database file pointer to write to */
455 const char *name, /**< name of bot object to write out */
456 unsigned char mode, /**< bot mode */
457 unsigned char orientation, /**< bot orientation */
458 unsigned char flags, /**< additional bot flags */
459 size_t num_vertices, /**< number of bot vertices */
460 size_t num_faces, /**< number of bot faces */
461 const fastf_t *vertices, /**< array of floats for vertices [num_vertices*3] */
462 const int *faces, /**< array of ints for faces [num_faces*3] */
463 const fastf_t *thickness, /**< array of plate mode
464 * thicknesses (corresponds to
465 * array of faces) NULL for
466 * modes RT_BOT_SURFACE and
467 * RT_BOT_SOLID.
468 */
469 struct bu_bitv *face_mode, /**< a flag for each face
470 * indicating thickness is
471 * appended to hit point,
472 * otherwise thickness is
473 * centered about hit point
474 */
475 size_t num_normals, /**< number of unit normals in normals array */
476 fastf_t *normals, /**< array of floats for normals [num_normals*3] */
477 int *face_normals /**< array of ints (indices
478 * into normals array), must
479 * have 3*num_faces entries
480 */
481 );
482
483/**
484 * Create a BOT (Bag O'Triangles) solid with face normals and uv texture coordinates
485 */
487 struct rt_wdb *fp, /**< database file pointer to write to */
488 const char *name, /**< name of bot object to write out */
489 unsigned char mode, /**< bot mode */
490 unsigned char orientation, /**< bot orientation */
491 unsigned char flags, /**< additional bot flags */
492 size_t num_vertices, /**< number of bot vertices */
493 size_t num_faces, /**< number of bot faces */
494 const fastf_t *vertices, /**< array of floats for vertices [num_vertices*3] */
495 const int *faces, /**< array of ints for faces [num_faces*3] */
496 const fastf_t *thickness, /**< array of plate mode
497 * thicknesses (corresponds to
498 * array of faces) NULL for
499 * modes RT_BOT_SURFACE and
500 * RT_BOT_SOLID.
501 */
502 struct bu_bitv *face_mode, /**< a flag for each face
503 * indicating thickness is
504 * appended to hit point,
505 * otherwise thickness is
506 * centered about hit point
507 */
508 size_t num_normals, /**< number of unit normals in normals array */
509 fastf_t *normals, /**< array of floats for normals [num_normals*3] */
510 int *face_normals, /**< array of ints (indices
511 * into normals array), must
512 * have 3*num_faces entries
513 */
514 size_t num_uvs, /**< number of uv texture coordinates in uvs array */
515 fastf_t *uvs, /**< array of floats for uv texture coordinates [num_uvs*3] */
516 int *face_uvs /**< array of ints (indices into uvs array), must have 3*num_faces entries */
517 );
518
519/**
520 * Create a brep in the geometry file. vbrep must be a void cast pointer to
521 * an ON_Brep shape.
522 */
523WDB_EXPORT int mk_brep(struct rt_wdb* wdbp, const char* name, void* vbrep);
524
525/**
526 * Output an array of B-spline (NURBS) surfaces which comprise a
527 * solid. The surface is freed when it is written.
528 *
529 * Note: unless there is a specific need to work with the older BRL-CAD
530 * NURBS objects, mk_brep should be used instead of this routine.
531 */
532WDB_EXPORT int mk_bspline(struct rt_wdb *wdbp, const char *name, struct face_g_snurb **surfs);
533
534/**
535 * The NMG is freed after being written.
536 *
537 * @return <0 error, 0 success
538 */
539WDB_EXPORT int mk_nmg(struct rt_wdb *filep, const char *name, struct model *m);
540
541/**
542 * For ray-tracing speed, many database conversion routines like to
543 * offer the option of converting NMG objects to bags of triangles
544 * (BoT). Here is a convenience routine to replace the old routine
545 * write_shell_as_polysolid. (obsolete since BRL-CAD 6.0)
546 */
547WDB_EXPORT int mk_bot_from_nmg(struct rt_wdb *ofp, const char *name, struct shell *s);
548
549
550/**
551 * Make a sketch
552 */
553WDB_EXPORT int mk_sketch(
554 struct rt_wdb *fp,
555 const char *name,
556 const struct rt_sketch_internal *skt);
557
558/**
559 * Make a annotation
560 */
561WDB_EXPORT int mk_annot(
562 struct rt_wdb *fp,
563 const char *name,
564 const struct rt_annot_internal *ann);
565
566/**
567 * Make a script
568 */
569WDB_EXPORT int mk_script(
570 struct rt_wdb *fp,
571 const char *name,
572 const struct rt_script_internal *scr );
573
574/**
575 * Make an extrusion solid
576 */
577WDB_EXPORT int mk_extrusion(
578 struct rt_wdb *fp,
579 const char *name,
580 const char *sketch_name,
581 const point_t V,
582 const vect_t h,
583 const vect_t u_vec,
584 const vect_t v_vec,
585 int keypoint);
586
587/**
588 * Support for cline solids (kludges from FASTGEN)
589 *
590 * Note: cline should not be used in .g models unless specifically needed for
591 * FASTGEN compatibility.
592 */
593WDB_EXPORT int mk_cline(
594 struct rt_wdb *fp,
595 const char *name,
596 const point_t V,
597 const vect_t height,
598 fastf_t radius,
599 fastf_t thickness);
600
601/**
602 * Make a particle primitive.
603 *
604 * @return <0 error, 0 success
605 */
606WDB_EXPORT extern int mk_particle(struct rt_wdb *fp, const char *name, point_t vertex,
607 vect_t height, double vradius, double hradius);
608
609/**
610 * Make a pipe primitive.
611 *
612 * Note that the linked list of pipe segments headed by 'headp' must
613 * be freed by the caller. mk_pipe_free() can be used.
614 *
615 * @return <0 error, 0 success
616 */
617WDB_EXPORT extern int mk_pipe(struct rt_wdb *fp, const char *name, struct bu_list *headp);
618
619/**
620 * Release the storage from a list of pipe segments. The head is left
621 * in initialized state (i.e., forward & back point to head).
622 */
623WDB_EXPORT void mk_pipe_free(struct bu_list *headp);
624
625/**
626 * Add another pipe segment to the linked list of pipe segments.
627 */
628WDB_EXPORT void mk_add_pipe_pnt(
629 struct bu_list *headp,
630 const point_t coord,
631 double od,
632 double id,
633 double bendradius);
634
635/**
636 * initialize a linked list of pipe segments with the first segment
637 */
638WDB_EXPORT void mk_pipe_init(struct bu_list *headp);
639
640
641/**
642 * Displacement map primitive.
643 */
644WDB_EXPORT extern int mk_dsp(struct rt_wdb *fp, const char *name, const char *file,
645 size_t xdim, size_t ydim, const matp_t mat);
646
647/**
648 * Extruded bitmap primitive.
649 */
650WDB_EXPORT extern int mk_ebm(struct rt_wdb *fp, const char *name, const char *file,
651 size_t xdim, size_t ydim, fastf_t tallness, const matp_t mat);
652
653/**
654 * Heart primitive.
655 */
656WDB_EXPORT extern int mk_hrt(struct rt_wdb *fp, const char *name, const point_t center,
657 const vect_t x, const vect_t y, const vect_t z, const fastf_t dist);
658
659/**
660 * 3-D Volume primitive.
661 */
662WDB_EXPORT extern int mk_vol(struct rt_wdb *fp, const char *name, char datasrc, const char *file,
663 size_t xdim, size_t ydim, size_t zdim, size_t lo, size_t hi,
664 const vect_t cellsize, const matp_t mat);
665
666
667/**
668 * Create a submodel solid. If file is NULL or "", the treetop refers
669 * to the current database. Treetop is the name of a single database
670 * object in 'file'. meth is normally 0 (RT_PART_NUBSPT) and unused.
671 */
672WDB_EXPORT extern int mk_submodel(struct rt_wdb *fp, const char *name, const char *file,
673 const char *treetop, int meth);
674
675/**
676 * Interface for writing region-id-based color tables to the database.
677 * Given that the color table has been built up by successive calls to
678 * rt_color_addrec(), write it into the database.
679 *
680 */
681WDB_EXPORT int mk_write_color_table(struct rt_wdb *ofp);
682
683/**
684 * Obtain dynamic storage for a new wmember structure, fill in the
685 * name, default the operation and matrix, and add to doubly linked
686 * list. In typical use, a one-line call is sufficient. To change
687 * the defaults, catch the pointer that is returned, and adjust the
688 * structure to taste.
689 *
690 * The name must be a non-zero length string.
691 *
692 * The caller is responsible for initializing the header structures
693 * forward and backward links.
694 */
695WDB_EXPORT extern struct wmember *mk_addmember(const char *name,
696 struct bu_list *headp,
697 mat_t mat,
698 int op);
699
700#define mk_lcomb(_fp, _name, _headp, _rf, _shadername, _shaderargs, _rgb, _inh) \
701 mk_comb(_fp, _name, &((_headp)->l), _rf, _shadername, _shaderargs, \
702 _rgb, 0, 0, 0, 0, _inh, 0, 0)
703
704/* mk_lrcomb() would not append, and did not have GIFT semantics
705 mk_lrcomb() had (struct wmember *) head, need (struct bu_list *) */
706#define mk_lrcomb(fp, name, _headp, region_flag, shadername, shaderargs, rgb, id, air, material, los, inherit_flag) \
707 mk_comb(fp, name, &((_headp)->l), region_flag, shadername, shaderargs, \
708 rgb, id, air, material, los, inherit_flag, 0, 0)
709
710
711/**
712 * @brief
713 * Combination (region and group) construction: first you build a list of nodes with mk_addmember,
714 * then you output the combination.
715 *
716 * The members are described by a linked list of wmember structs.
717 *
718 * The linked list is freed when it has been output.
719 *
720 * Has many operating modes.
721 *
722 * @return <0 error, 0 success
723 */
724WDB_EXPORT int mk_comb(
725 struct rt_wdb *wdbp, /**< database to write to */
726 const char *combname, /**< name of the combination */
727 struct bu_list *headp, /**< Made by mk_addmember() */
728 int region_kind, /**< 1 => region. 'P' and 'V' for FASTGEN */
729 const char *shadername, /**< shader name, or NULL */
730 const char *shaderargs, /**< shader args, or NULL */
731 const unsigned char *rgb, /**< NULL => no color */
732 int id, /**< region_id */
733 int air, /**< aircode */
734 int material, /**< GIFTmater */
735 int los, /**< line-of-sight thickness equivalence */
736 int inherit, /**< whether objects below inherit from this comb */
737 int append_ok, /**< 0 = obj must not exit */
738 int gift_semantics /**< 0 = pure, 1 = gift */
739 );
740
741/**
742 * Convenience interface to make a combination with a single member.
743 */
744WDB_EXPORT int mk_comb1(struct rt_wdb *fp,
745 const char *combname,
746 const char *membname,
747 int regflag);
748
749
750/**
751 * Convenience routine to make a region with shader and rgb possibly
752 * set.
753 */
754WDB_EXPORT int mk_region1(
755 struct rt_wdb *fp,
756 const char *combname,
757 const char *membname,
758 const char *shadername,
759 const char *shaderargs,
760 const unsigned char *rgb);
761
762#define WMOP_INTERSECT DB_OP_INTERSECT /**< @brief must track db.h */
763#define WMOP_SUBTRACT DB_OP_SUBTRACT /**< @brief must track db.h */
764#define WMOP_UNION DB_OP_UNION /**< @brief must track db.h */
765
766/* Convenient definitions */
767#define mk_lfcomb(fp, name, headp, region) \
768 mk_lcomb(fp, name, headp, region, (char *)0, (char *)0, (unsigned char *)0, 0);
769
770/**
771 * Given a string conversion value, find the appropriate factor, and
772 * establish it.
773 *
774 * @return -1 error, 0 OK
775 */
776WDB_EXPORT extern int mk_conversion(char *units_string);
777
778/**
779 * Establish a new conversion factor for LIBWDB routines.
780 *
781 * @return -1 error, 0 success
782 */
783WDB_EXPORT extern int mk_set_conversion(double val);
784
785/**
786 * This internal variable should not be directly modified;
787 * call mk_conversion() or mk_set_conversion() instead.
788 */
789WDB_EXPORT extern double mk_conv2mm; /**< @brief Conversion factor to mm */
790
791/**
792 * Set this variable to either 4 or 5, depending on which version of
793 * the database you wish to write.
794 */
795WDB_EXPORT extern int mk_version; /**< @brief Which version database to write */
796
797/**
798 * TODO - document this...
799 */
800WDB_EXPORT void mk_freemembers(struct bu_list *headp);
801
802#define mk_export_fwrite(wdbp, name, gp, id) wdb_export(wdbp, name, gp, id, mk_conv2mm)
803
804/**
805 * @brief
806 * This routine is intended to be used to make a hole in some
807 * geometry.
808 *
809 * The hole is described using the same parameters as an
810 * RCC, and the hole is represented as an RCC. The objects to be
811 * "holed" are passed in as a list of "struct directory" pointers. The
812 * objects pointed at by this list must be combinations. The "struct
813 * rt_wdb" pointer passed in indicates what model this hole should
814 * appear in.
815 *
816 * The end state after this routine runs is a modified model with a
817 * new RCC primitive having a name of the form "make_hole_X" (where X
818 * is some integer). The combinations specified in the list will be
819 * modified as follows:
820 *
821 * before after
822 * | /\
823 * u u -
824 * orig_comb_tree orig_comb_tree make_hole_X
825 *
826 * The modified combination is written to the struct rt_wdb. Note that
827 * to do dynamic geometry a "wdb_dbopen" would normally be called on
828 * an already existing (and possibly prepped) model. Using the
829 * RT_WDB_TYPE_DB_INMEM parameter in this call will result in geometry
830 * changes that only exist in memory and will not be permanently
831 * stored in the original database.
832 *
833 * This routine should be preceded by a call to "rt_unprep" and
834 * followed by a call to "rt_reprep".
835 */
836WDB_EXPORT extern int make_hole(struct rt_wdb *wdbp,
837 point_t hole_start,
838 vect_t hole_depth,
839 fastf_t hole_radius,
840 int num_objs,
841 struct directory **dp);
842
843
844/**
845 * @brief
846 * This routine provides a quick approach to simply adding a hole to existing
847 * prepped geometry.
848 *
849 * The geometry must already be prepped prior to calling this routine. After
850 * calling this routine, the geometry is ready for raytracing (no other routine
851 * need to be called).
852 *
853 * A new RCC primitive is created and written to the database (wdbp). Note that
854 * this will be temporary if the wdbp pointer was created by a call to
855 * wdb_dbopen with the RT_WDB_TYPE_DB_INMEM flag.
856 *
857 * The "regions" parameter is a list of "struct region" pointers (prepped
858 * regions) to get holed. The regions structures are modified, but the on disk
859 * region records are never modified, so the actual holes will never be
860 * permanent regardless of how "wdbp" was opened.
861 *
862 * There is no need to call "rt_unprep" nor "rt_reprep" with this routine.
863 */
864WDB_EXPORT extern int make_hole_in_prepped_regions(struct rt_wdb *wdbp,
865 struct rt_i *rtip,
866 point_t hole_start,
867 vect_t hole_depth,
868 fastf_t radius,
869 struct bu_ptbl *regions);
870
871
872__END_DECLS
873
874#endif /* WDB_H */
875
876/** @} */
877
878/*
879 * Local Variables:
880 * mode: C
881 * tab-width: 8
882 * indent-tabs-mode: t
883 * c-file-style: "stroustrup"
884 * End:
885 * ex: shiftwidth=4 tabstop=8
886 */
Header file for the BRL-CAD Numerical Computation Library, LIBBN.
Header file for the BRL-CAD common definitions.
void float float * y
Definition: tig.h:73
void int char * mode
Definition: tig.h:179
void int char int int double * min
Definition: tig.h:182
void float float float * z
Definition: tig.h:90
void int * c
Definition: tig.h:139
void float * x
Definition: tig.h:72
int mk_arb7(struct rt_wdb *fp, const char *name, const fastf_t *pts7)
int mk_sketch(struct rt_wdb *fp, const char *name, const struct rt_sketch_internal *skt)
int mk_arb6(struct rt_wdb *fp, const char *name, const fastf_t *pts6)
int mk_bot_from_nmg(struct rt_wdb *ofp, const char *name, struct shell *s)
int mk_extrusion(struct rt_wdb *fp, const char *name, const char *sketch_name, const point_t V, const vect_t h, const vect_t u_vec, const vect_t v_vec, int keypoint)
int mk_rpp(struct rt_wdb *fp, const char *name, const point_t min, const point_t max)
int mk_annot(struct rt_wdb *fp, const char *name, const struct rt_annot_internal *ann)
int mk_script(struct rt_wdb *fp, const char *name, const struct rt_script_internal *scr)
int mk_brep(struct rt_wdb *wdbp, const char *name, void *vbrep)
int mk_bot_w_normals_and_uvs(struct rt_wdb *fp, const char *name, unsigned char mode, unsigned char orientation, unsigned char flags, size_t num_vertices, size_t num_faces, const fastf_t *vertices, const int *faces, const fastf_t *thickness, struct bu_bitv *face_mode, size_t num_normals, fastf_t *normals, int *face_normals, size_t num_uvs, fastf_t *uvs, int *face_uvs)
void mk_pipe_free(struct bu_list *headp)
int mk_id_units(struct rt_wdb *fp, const char *title, const char *units)
int mk_ebm(struct rt_wdb *fp, const char *name, const char *file, size_t xdim, size_t ydim, fastf_t tallness, const matp_t mat)
struct wmember * mk_addmember(const char *name, struct bu_list *headp, mat_t mat, int op)
int mk_grip(struct rt_wdb *wdbp, const char *name, const point_t center, const vect_t normal, const fastf_t magnitude)
int mk_hrt(struct rt_wdb *fp, const char *name, const point_t center, const vect_t x, const vect_t y, const vect_t z, const fastf_t dist)
int mk_ell(struct rt_wdb *fp, const char *name, const point_t center, const vect_t a, const vect_t b, const vect_t c)
int mk_trc_top(struct rt_wdb *fp, const char *name, const point_t ibase, const point_t itop, fastf_t radbase, fastf_t radtop)
int mk_tgc(struct rt_wdb *fp, const char *name, const point_t base, const vect_t height, const vect_t a, const vect_t b, const vect_t c, const vect_t d)
int mk_metaball(struct rt_wdb *wdbp, const char *name, const size_t nctlpt, const int method, const fastf_t threshold, const fastf_t *verts[5])
int make_hole_in_prepped_regions(struct rt_wdb *wdbp, struct rt_i *rtip, point_t hole_start, vect_t hole_depth, fastf_t radius, struct bu_ptbl *regions)
This routine provides a quick approach to simply adding a hole to existing prepped geometry.
int mk_comb(struct rt_wdb *wdbp, const char *combname, struct bu_list *headp, int region_kind, const char *shadername, const char *shaderargs, const unsigned char *rgb, int id, int air, int material, int los, int inherit, int append_ok, int gift_semantics)
Combination (region and group) construction: first you build a list of nodes with mk_addmember,...
int mk_arb5(struct rt_wdb *fp, const char *name, const fastf_t *pts5)
int mk_eto(struct rt_wdb *wdbp, const char *name, const point_t vert, const vect_t norm, const vect_t smajor, fastf_t rrot, fastf_t sminor)
double mk_conv2mm
Conversion factor to mm.
wdb_binunif
Definition: wdb.h:365
int mk_arb8(struct rt_wdb *fp, const char *name, const fastf_t *pts8)
int mk_material(struct rt_wdb *wdbp, const char *db_name, const char *name, const char *parent, const char *source, struct bu_attribute_value_set *physicalProperties, struct bu_attribute_value_set *mechanicalProperties, struct bu_attribute_value_set *opticalProperties, struct bu_attribute_value_set *thermalProperties)
int mk_version
Which version database to write.
int make_hole(struct rt_wdb *wdbp, point_t hole_start, vect_t hole_depth, fastf_t hole_radius, int num_objs, struct directory **dp)
This routine is intended to be used to make a hole in some geometry.
int mk_bot_w_normals(struct rt_wdb *fp, const char *name, unsigned char mode, unsigned char orientation, unsigned char flags, size_t num_vertices, size_t num_faces, const fastf_t *vertices, const int *faces, const fastf_t *thickness, struct bu_bitv *face_mode, size_t num_normals, fastf_t *normals, int *face_normals)
int mk_region1(struct rt_wdb *fp, const char *combname, const char *membname, const char *shadername, const char *shaderargs, const unsigned char *rgb)
int mk_comb1(struct rt_wdb *fp, const char *combname, const char *membname, int regflag)
int mk_arbn(struct rt_wdb *fp, const char *name, size_t neqn, const plane_t *eqn)
int mk_submodel(struct rt_wdb *fp, const char *name, const char *file, const char *treetop, int meth)
int mk_set_conversion(double val)
int mk_id_editunits(struct rt_wdb *fp, const char *title, double local2mm)
int mk_rcc(struct rt_wdb *fp, const char *name, const point_t base, const vect_t height, fastf_t radius)
int mk_hyp(struct rt_wdb *wdbp, const char *name, const point_t vert, const vect_t height_vector, const vect_t vectA, fastf_t magB, fastf_t base_neck_ratio)
int mk_ehy(struct rt_wdb *wdbp, const char *name, const point_t vert, const vect_t height, const vect_t breadth, fastf_t r1, fastf_t r2, fastf_t c)
void mk_add_pipe_pnt(struct bu_list *headp, const point_t coord, double od, double id, double bendradius)
int mk_dsp(struct rt_wdb *fp, const char *name, const char *file, size_t xdim, size_t ydim, const matp_t mat)
int mk_arb4(struct rt_wdb *fp, const char *name, const fastf_t *pts4)
int mk_sph(struct rt_wdb *fp, const char *name, const point_t center, fastf_t radius)
int mk_rpc(struct rt_wdb *wdbp, const char *name, const point_t vert, const vect_t height, const vect_t breadth, double half_w)
int mk_cone(struct rt_wdb *fp, const char *name, const point_t base, const vect_t dirv, fastf_t height, fastf_t base_radius, fastf_t nose_radius)
int mk_conversion(char *units_string)
int mk_half(struct rt_wdb *fp, const char *name, const vect_t norm, fastf_t d)
int mk_particle(struct rt_wdb *fp, const char *name, point_t vertex, vect_t height, double vradius, double hradius)
int mk_constraint(struct rt_wdb *wdbp, const char *name, const char *expr)
int mk_bot(struct rt_wdb *fp, const char *name, unsigned char mode, unsigned char orientation, unsigned char error_mode, size_t num_vertices, size_t num_faces, fastf_t *vertices, int *faces, fastf_t *thickness, struct bu_bitv *face_mode)
int mk_write_color_table(struct rt_wdb *ofp)
int mk_bspline(struct rt_wdb *wdbp, const char *name, struct face_g_snurb **surfs)
int mk_trc_h(struct rt_wdb *fp, const char *name, const point_t base, const vect_t height, fastf_t radbase, fastf_t radtop)
int mk_pipe(struct rt_wdb *fp, const char *name, struct bu_list *headp)
int mk_wedge(struct rt_wdb *fp, const char *name, const point_t vert, const vect_t xdirv, const vect_t zdirv, fastf_t xlen, fastf_t ylen, fastf_t zlen, fastf_t x_top_len)
int mk_vol(struct rt_wdb *fp, const char *name, char datasrc, const char *file, size_t xdim, size_t ydim, size_t zdim, size_t lo, size_t hi, const vect_t cellsize, const matp_t mat)
int mk_rhc(struct rt_wdb *wdbp, const char *name, const point_t vert, const vect_t height, const vect_t breadth, fastf_t half_w, fastf_t asymp)
int mk_binunif(struct rt_wdb *fp, const char *name, const void *data, wdb_binunif data_type, long count)
int mk_epa(struct rt_wdb *wdbp, const char *name, const point_t vert, const vect_t height, const vect_t breadth, fastf_t r1, fastf_t r2)
void mk_freemembers(struct bu_list *headp)
int mk_cline(struct rt_wdb *fp, const char *name, const point_t V, const vect_t height, fastf_t radius, fastf_t thickness)
int mk_nmg(struct rt_wdb *filep, const char *name, struct model *m)
void mk_pipe_init(struct bu_list *headp)
int mk_id(struct rt_wdb *fp, const char *title)
int mk_ars(struct rt_wdb *fp, const char *name, size_t ncurves, size_t pts_per_curve, fastf_t *curves[])
int mk_tor(struct rt_wdb *fp, const char *name, const point_t center, const vect_t inorm, double r1, double r2)
@ WDB_BINUNIF_FILE_FLOAT
Definition: wdb.h:386
@ WDB_BINUNIF_INT
Definition: wdb.h:372
@ WDB_BINUNIF_UINT
Definition: wdb.h:373
@ WDB_BINUNIF_FILE_UCHAR
Definition: wdb.h:389
@ WDB_BINUNIF_FILE_INT
Definition: wdb.h:392
@ WDB_BINUNIF_ULONG
Definition: wdb.h:375
@ WDB_BINUNIF_USHORT
Definition: wdb.h:371
@ WDB_BINUNIF_UINT16
Definition: wdb.h:381
@ WDB_BINUNIF_FILE_ULONG
Definition: wdb.h:395
@ WDB_BINUNIF_LONGLONG
Definition: wdb.h:376
@ WDB_BINUNIF_INT8
Definition: wdb.h:378
@ WDB_BINUNIF_FLOAT
Definition: wdb.h:366
@ WDB_BINUNIF_INT64
Definition: wdb.h:384
@ WDB_BINUNIF_FILE_CHAR
Definition: wdb.h:388
@ WDB_BINUNIF_UINT32
Definition: wdb.h:383
@ WDB_BINUNIF_FILE_LONG
Definition: wdb.h:394
@ WDB_BINUNIF_FILE_INT64
Definition: wdb.h:404
@ WDB_BINUNIF_FILE_UINT16
Definition: wdb.h:401
@ WDB_BINUNIF_FILE_UINT
Definition: wdb.h:393
@ WDB_BINUNIF_SHORT
Definition: wdb.h:370
@ WDB_BINUNIF_FILE_UINT8
Definition: wdb.h:399
@ WDB_BINUNIF_FILE_USHORT
Definition: wdb.h:391
@ WDB_BINUNIF_FILE_UINT32
Definition: wdb.h:403
@ WDB_BINUNIF_UCHAR
Definition: wdb.h:369
@ WDB_BINUNIF_FILE_INT32
Definition: wdb.h:402
@ WDB_BINUNIF_ULONGLONG
Definition: wdb.h:377
@ WDB_BINUNIF_FILE_UINT64
Definition: wdb.h:405
@ WDB_BINUNIF_LONG
Definition: wdb.h:374
@ WDB_BINUNIF_FILE_INT16
Definition: wdb.h:400
@ WDB_BINUNIF_DOUBLE
Definition: wdb.h:367
@ WDB_BINUNIF_FILE_INT8
Definition: wdb.h:398
@ WDB_BINUNIF_CHAR
Definition: wdb.h:368
@ WDB_BINUNIF_UINT8
Definition: wdb.h:379
@ WDB_BINUNIF_INT16
Definition: wdb.h:380
@ WDB_BINUNIF_FILE_SHORT
Definition: wdb.h:390
@ WDB_BINUNIF_UINT64
Definition: wdb.h:385
@ WDB_BINUNIF_FILE_DOUBLE
Definition: wdb.h:387
@ WDB_BINUNIF_FILE_ULONGLONG
Definition: wdb.h:397
@ WDB_BINUNIF_FILE_LONGLONG
Definition: wdb.h:396
@ WDB_BINUNIF_INT32
Definition: wdb.h:382
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 plane_t[ELEMENTS_PER_PLANE]
Definition of a plane equation.
Definition: vmath.h:393
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.
Definition: bitv.h:108
Definition: list.h:131
Definition: ptbl.h:53
Face NURBS surface geometry.
Definition: topology.h:392
NMG topological model.
Definition: topology.h:289
Definition: wdb.h:62
NMG topological shell.
Definition: topology.h:261
NMG topological vertex - the simplest element of the topology system.
Definition: topology.h:98
Definition: wdb.h:77
char * wm_name
Definition: wdb.h:81
int wm_op
Boolean operation.
Definition: wdb.h:79
struct bu_list l
Definition: wdb.h:78
mat_t wm_mat
FIXME: Should be a matp_t.
Definition: wdb.h:80