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