BRL-CAD
Loading...
Searching...
No Matches
comb.h
Go to the documentation of this file.
1/* C O M B . H
2 * BRL-CAD
3 *
4 * Copyright (c) 1993-2026 United States Government as represented by
5 * the U.S. Army Research Laboratory.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * version 2.1 as published by the Free Software Foundation.
10 *
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this file; see the file named COPYING for more
18 * information.
19 */
20/** @file rt/comb.h
21 *
22 */
23
24#ifndef RT_COMB_H
25#define RT_COMB_H
26
27#include "common.h"
28
29#ifdef __cplusplus
30# include "brep/defines.h"
31#endif
32
33#include "vmath.h"
34#include "bu/vls.h"
35#include "rt/defines.h"
36
38
39/* db_comb.c */
40
41
42/**
43 * Take an old v4 shader specification of the form
44 *
45 * shadername arg1=value1 arg2=value2 color=1/2/3
46 *
47 * and convert it into the v5 {} list form
48 *
49 * shadername {arg1 value1 arg2 value2 color 1/2/3}
50 *
51 * Note -- the input string is smashed with nulls.
52 *
53 * Note -- the v5 version is used everywhere internally, and in v5
54 * databases.
55 *
56 * @return 1 error
57 * @return 0 OK
58 */
59RT_EXPORT extern int rt_shader_to_list(const char *in, struct bu_vls *vls);
60
61RT_EXPORT extern int rt_shader_to_key_eq(const char *in, struct bu_vls *vls);
62
63
64/**
65 * Import a combination record from a V4 database into internal form.
66 */
68 const struct bu_external *ep,
69 const mat_t matrix, /* NULL if identity */
70 const struct db_i *dbip);
71
73 const struct rt_db_internal *ip,
74 double local2mm,
75 const struct db_i *dbip);
76
77
78RT_EXPORT extern void db_comb_describe(struct bu_vls *str,
79 const struct rt_comb_internal *comb,
80 int verbose,
81 double mm2local);
82
83/**
84 * OBJ[ID_COMBINATION].ft_describe() method
85 */
86RT_EXPORT extern int rt_comb_describe(struct bu_vls *str,
87 const struct rt_db_internal *ip,
88 int verbose,
89 double mm2local);
90
91/**
92 * fills in rgb with the color for a given comb combination
93 *
94 * returns truthfully if a color could be got. note that this routine
95 * will not (and cannot) handle the color inherit/override flag as
96 * that is set on some higher-level parent combination.
97 *
98 */
99RT_EXPORT extern int rt_comb_get_color(struct db_i *dbip, unsigned char rgb[3], const struct rt_comb_internal *comb);
100
101
102/**
103 * change all matching object names in the comb tree from old_name to
104 * new_name
105 *
106 * calling function must supply an initialized bu_ptbl, and free it
107 * once done.
108 */
109RT_EXPORT extern int db_comb_mvall(struct directory *dp,
110 struct db_i *dbip,
111 const char *old_name,
112 const char *new_name,
113 struct bu_ptbl *stack);
114
115/* db5_comb.c */
116
117/**
118 * Read a combination object in v5 external (on-disk) format, and
119 * convert it into the internal format described in rtgeom.h
120 *
121 * This is an unusual conversion, because some of the data is taken
122 * from attributes, not just from the object body. By the time this
123 * is called, the attributes will already have been cracked into
124 * ip->idb_avs, we get the attributes from there.
125 *
126 * Returns -
127 * 0 OK
128 * -1 FAIL
129 */
130RT_EXPORT extern int rt_comb_import5(struct rt_db_internal *ip, const struct bu_external *ep, const mat_t mat, const struct db_i *dbip);
131
132/**
133 * Return a RT_DIR_NULL terminated array of directory pointers that
134 * holds the set of immediate children associated with comb. The
135 * caller is responsible for freeing the array, but not the directory
136 * structures pointed to by the array.
137 *
138 * Optionally, pointers may also be supplied to collect arrays holding
139 * the boolean operations and matrices associated with the comb entries.
140 * For boolean operations, the caller is responsible for freeing the
141 * array. For matrices, both the array and the matrices themselves
142 * must be freed by the caller. The boolean operations array is zero
143 * terminated, the matrix array is NULL terminated. For example:
144 *
145 * @code
146 * int i = 0;
147 * struct directory *wdp;
148 * struct directory **children = NULL;
149 * int *bool_ops = NULL;
150 * matp_t *matrices = NULL;
151 * matp_t m;
152 * db_comb_children(dbip, comb, &children, &bool_ops, &matrices);
153 * if (db_comb_children(dbip, comb, &bool_ops, &matrices) > 0) {
154 * i = 0;
155 * wdp = children[0];
156 * while (wdp != RT_DIR_NULL) {
157 * char obuf[1024];
158 * bu_log("%s child %d: %d %s\n", dp->d_namep, i, bool_ops[ind], wdp->d_namep);
159 * if (mats[ind]){
160 * bn_mat_print_guts("", mats[i], obuf, 1024);
161 * bu_log("%s %s\n", wdp->d_namep, obuf);
162 * }
163 * i++;
164 * wdp = children[i];
165 * }
166 * }
167 * i = 0;
168 * while (mats[i]) {
169 * bu_free(mats[i], "free matrix");
170 * i++;
171 * }
172 * bu_free(mats, "free mats array");
173 * bu_free(bool_ops, "free ops");
174 * bu_free(children, "free children struct directory ptr array");
175 * @endcode
176 */
177RT_EXPORT extern int db_comb_children(struct db_i *dbip, struct rt_comb_internal *comb, struct directory ***children, int **bool_ops, matp_t **mats);
178
179#ifdef __cplusplus
180RT_EXPORT extern void
181rt_comb_brep(ON_Brep **b, const struct rt_db_internal *ip, const struct bn_tol *tol, const struct db_i *dbip);
182#endif
183
185
186#endif /* RT_COMB_H */
187
188/*
189 * Local Variables:
190 * tab-width: 8
191 * mode: C
192 * indent-tabs-mode: t
193 * c-file-style: "stroustrup"
194 * End:
195 * ex: shiftwidth=4 tabstop=8
196 */
Definition dvec.h:74
int rt_comb_describe(struct bu_vls *str, const struct rt_db_internal *ip, int verbose, double mm2local)
int rt_shader_to_key_eq(const char *in, struct bu_vls *vls)
int rt_comb_import4(struct rt_db_internal *ip, const struct bu_external *ep, const mat_t matrix, const struct db_i *dbip)
void db_comb_describe(struct bu_vls *str, const struct rt_comb_internal *comb, int verbose, double mm2local)
int db_comb_children(struct db_i *dbip, struct rt_comb_internal *comb, struct directory ***children, int **bool_ops, matp_t **mats)
int db_comb_mvall(struct directory *dp, struct db_i *dbip, const char *old_name, const char *new_name, struct bu_ptbl *stack)
int rt_comb_import5(struct rt_db_internal *ip, const struct bu_external *ep, const mat_t mat, const struct db_i *dbip)
int rt_comb_get_color(struct db_i *dbip, unsigned char rgb[3], const struct rt_comb_internal *comb)
int rt_comb_export4(struct bu_external *ep, const struct rt_db_internal *ip, double local2mm, const struct db_i *dbip)
int rt_shader_to_list(const char *in, struct bu_vls *vls)
void rt_comb_brep(ON_Brep **b, const struct rt_db_internal *ip, const struct bn_tol *tol, const struct db_i *dbip)
Header file for the BRL-CAD common definitions.
fastf_t mat_t[ELEMENTS_PER_MAT]
4x4 matrix
Definition vmath.h:369
fastf_t * matp_t
pointer to a 4x4 matrix
Definition vmath.h:372
Definition tol.h:72
Definition ptbl.h:53
Definition vls.h:53
fundamental vector, matrix, quaternion math macros