BRL-CAD
Loading...
Searching...
No Matches
view.h
Go to the documentation of this file.
1/* V I E W . H
2 * BRL-CAD
3 *
4 * Copyright (c) 2008-2025 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 ged_view
21 *
22 * Geometry EDiting Library Database View Related Functions.
23 *
24 */
25/** @{ */
26/** @file ged/view.h */
27
28#ifndef GED_VIEW_H
29#define GED_VIEW_H
30
31#include "common.h"
32#include "bn/tol.h"
33#include "bg/polygon.h"
34#include "rt/db_fullpath.h"
35#include "rt/db_instance.h"
36#include "ged/defines.h"
37
39
40
41/** Check if a drawable exists */
42#define GED_CHECK_DRAWABLE(_gedp, _flags) \
43 if (!ged_dl(_gedp)) { \
44 int ged_check_drawable_quiet = (_flags) & GED_QUIET; \
45 if (!ged_check_drawable_quiet) { \
46 bu_vls_trunc((_gedp)->ged_result_str, 0); \
47 bu_vls_printf((_gedp)->ged_result_str, "A drawable does not exist."); \
48 } \
49 return (_flags); \
50 }
51
52/** Check if a view exists */
53#define GED_CHECK_VIEW(_gedp, _flags) \
54 if (_gedp->ged_gvp == GED_VIEW_NULL) { \
55 int ged_check_view_quiet = (_flags) & GED_QUIET; \
56 if (!ged_check_view_quiet) { \
57 bu_vls_trunc((_gedp)->ged_result_str, 0); \
58 bu_vls_printf((_gedp)->ged_result_str, "A view does not exist."); \
59 } \
60 return (_flags); \
61 }
62
65 void *u_data;
66};
67
68/* defined in display_list.c */
71GED_EXPORT extern void dl_erasePathFromDisplay(struct ged *gedp, const char *path, int allow_split);
72GED_EXPORT extern struct display_list *dl_addToDisplay(struct bu_list *hdlp, struct db_i *dbip, const char *name);
73
74/* Check ged_bv data associated with a display list */
75GED_EXPORT extern unsigned long long ged_dl_hash(struct display_list *dl);
76
77
78GED_EXPORT extern int ged_export_polygon(struct ged *gedp, bv_data_polygon_state *gdpsp, size_t polygon_i, const char *sname);
79GED_EXPORT extern struct bg_polygon *ged_import_polygon(struct ged *gedp, const char *sname);
80GED_EXPORT extern int ged_polygons_overlap(struct ged *gedp, struct bg_polygon *polyA, struct bg_polygon *polyB);
82
83
84/**
85 * Rotate angle degrees about the specified axis
86 */
87GED_EXPORT extern int ged_arot_args(struct ged *gedp, int argc, const char *argv[], mat_t rmat);
88
89/**
90 * Rotate the view.
91 */
92GED_EXPORT extern int ged_rot_args(struct ged *gedp, int argc, const char *argv[], char *coord, mat_t rmat);
93
94/**
95 * Scale the view.
96 */
97GED_EXPORT extern int ged_scale_args(struct ged *gedp, int argc, const char *argv[], fastf_t *sf1, fastf_t *sf2, fastf_t *sf3);
98
99/**
100 * Translate the view.
101 */
102GED_EXPORT extern int ged_tra_args(struct ged *gedp, int argc, const char *argv[], char *coord, vect_t tvec);
103
104
105
106/* Geometry EDiting Library Object Selection Functions.
107 *
108 *
109 * TODO - both the drawn state and the selection state need a rethink, particularly
110 * since they need to sync when an interface is visually indicating one or both
111 * sets of information.
112 *
113 * There are three things we may want from either:
114 *
115 * 1. "minimal" list of active entities - the shallowest paths that fully
116 * express the set of active objects
117 *
118 * 2. "input" list - what the user has actually specified to create the
119 * current state
120 *
121 * 3. "solids" list - the full paths to the solids that will be the sources of
122 * the actual geometry shown in the scene. A complication here is drawing
123 * modes that evaluate the geometry, which will not have child solids but will
124 * themselves be holding a temporary set of generated view data.
125 *
126 * 4. "active" list - the set of all paths between specified/minimal and solids
127 * that are implicit active
128 *
129 * Both #1 and #3 can be generated from #2, although how quickly this can be
130 * done is a concern as hierarchies get large. #3 is necessary for graphical
131 * interrogation of scenes to build selection sets, since it is those solid
132 * objects that the user will be interacting with. (In the case of a selection
133 * set built solely from graphical selection #2 and #3 will be the same.
134 * However, since the drawn scene will more likely have been specified with one
135 * or a small number of higher level objects, the #2 draw list needs to be used
136 * to generate a #3 list to support building up the selection list.)
137 *
138 * When a "who" command is run the user is probably looking for #1, but that is
139 * not as clear in the select case - in a tree view, selecting a comb and all
140 * of the children of that comb have different implications for editing. The
141 * former, unless the comb is a top level object, implies editing the instance of
142 * the comb in its own parent. The latter implies editing the comb definition,
143 * altering the position of its children. Unlike the former, the latter will
144 * impact ALL uses of comb, not just a single instance. That would imply select
145 * should default to #2, but that's most likely not what is desired if the user
146 * has selected large numbers of individual solids from #3 - they MAY want that,
147 * but they may also be seeking to specify groups of regions or higher level objects
148 * to manipulate. That implies the need to expose some "collapse" operations to
149 * the user so they may identify wholly selected parent objects and "promote"
150 * to them.
151 *
152 * We also need an efficient way for both drawing and selection codes to look up
153 * and manipulate the state of their corresponding information in the other container.
154 * When drawing, the interface may need to illuminate selected objects (which can
155 * be selected even if not drawn, and so will need to "appear" selected.) This requires
156 * being able to interrogate the #3 select list from the drawing code to identify if
157 * a given full path is selected. Likewise, when a selection occurs, drawn objects
158 * will need to have their illuminate state updated - the #2 select list will need
159 * to generate a #3 select list and then update (illuminate or de-illuminate, as the
160 * case may be) corresponding solids on the #3 drawn list. All this needs to also
161 * happen quickly, to handle large selections and de-selections on very large geometry
162 * hierarchies. The lists may also be invalidated by geometry editing operations,
163 * and so will need to be quickly validated against the .g state or updated in response
164 * to .g changes.
165 *
166 * A complication on the #2 lists is what happens if an erase or deselect
167 * command removes part of a previously specified object. In that case a new
168 * #2 list must be generated which captures as much of the original semantic
169 * intent of the user specification as possible - "expanding" the relevant
170 * entries from the #2 list to their solids, removing the solids from the user
171 * specified removal parents, and then collapsing the remaining solids back to
172 * a minimal set.
173 *
174 * Another #2 alteration case is when a higher level specification "subsumes" previous
175 * #2 paths into it. The existing paths must be recognized as subpaths of the
176 * specified path, and removed in favor of it.
177 *
178 * At the moment, we have explicit logic in the drawing code for handling the above
179 * cases, using db_full_path top matching. Syncing between the selection and drawing
180 * codes is imperfect - draw does not currently check for selected status when
181 * creating scene objects.
182 *
183 * Design thoughts - what if for both the ged drawn and selected lists we
184 * stash unordered sets of path hashes to indicate activity, and then add/remove
185 * those hashes based on specified paths and the related solid tree walks? To
186 * generate the #1 set from the #2 we get the parent of each #2, check if all the
187 * parent's children are in #4, and if so add it to #4 and process its parent and
188 * so on. If we find a parent without all of its children in #4, remove it from #4
189 * if present and report it as a #1. To go the other way, do a full path tree walk
190 * calculating hashes as we go and populating #4. Any solid we reach that way is
191 * part of #3. If the view containers maintain unordered maps of hashes to scene
192 * objects, the selection code can directly identify any active objects. The
193 * highlighting update pass would be one iteration to clear all flags, and then
194 * a second over the #3 hashes from the selection to set illum flags on the
195 * currently selected objects. As long as the same hashes are used for both,
196 * no further processing would be necessary to ID selection changes.
197 *
198 * Draw objects also still need to be synced with the .g state in response to
199 * update notifications from the .g I/O callbacks, which report directory
200 * pointers... we need a way to flag solids based on that info as well, which
201 * probably means we still need to keep the db_full_path associated with the
202 * scene object. May want to re-examine the current two-tier storage system
203 * and just make all solid objs top level entries. If we're willing to re-calculate
204 * the "drawn" #1 list on the fly, and not worry about #2 for the drawn objects
205 * case, that may simplify some things.
206 */
207
208// TODO - once this settles down, give it a magic number so we can type
209// check it after a void cast
211 struct db_i *dbip;
213 const struct bn_tol *tol;
214 const struct bg_tess_tol *ttol;
216 struct resource *res;
219GED_EXPORT extern unsigned long long dl_name_hash(struct ged *gedp);
220
222/**
223 * Return ged selections for specified object. Created if it doesn't
224 * exist.
225 */
227 const char *object_name);
229/**
230 * Return ged selections of specified kind for specified object.
231 * Created if it doesn't exist.
232 */
234 const char *object_name,
235 const char *selection_name);
236
237
238
239/* Accessors for display list based drawing info. Eventually we want to migrate
240 * off of direct usage of these containers completely, but for now the older
241 * drawing path (which MGED and Archer use) needs them.
242 */
243typedef void (*ged_drawable_notify_func_t)(int);
244
246ged_dl(struct ged *gedp);
247GED_EXPORT void
251
253
254
255/* NMG specific visualizations that (currently) need libged routines.
256 *
257 * This will almost certainly move elsewhere - its presence here should be
258 * considered temporary and not relied on from an API design perspective.
259 */
260GED_EXPORT extern void nmg_plot_eu(struct ged *gedp, struct edgeuse *es_eu, const struct bn_tol *tol, struct bu_list *vlfree);
261
264
265#endif /* GED_VIEW_H */
266
267/** @} */
268
269/*
270 * Local Variables:
271 * tab-width: 8
272 * mode: C
273 * indent-tabs-mode: t
274 * c-file-style: "stroustrup"
275 * End:
276 * ex: shiftwidth=4 tabstop=8
277 */
Definition dvec.h:74
Header file for the BRL-CAD common definitions.
struct display_list * ged_dl(struct ged *gedp)
void ged_polygon_fill_segments(struct ged *gedp, struct bg_polygon *poly, vect2d_t vfilldir, fastf_t vfilldelta)
int ged_polygons_overlap(struct ged *gedp, struct bg_polygon *polyA, struct bg_polygon *polyB)
void dl_set_iflag(struct bu_list *hdlp, int iflag)
int ged_export_polygon(struct ged *gedp, bv_data_polygon_state *gdpsp, size_t polygon_i, const char *sname)
unsigned long long ged_dl_hash(struct display_list *dl)
unsigned long long dl_name_hash(struct ged *gedp)
void ged_dl_notify_func_set(struct ged *gedp, ged_drawable_notify_func_t f)
todo once this settles down
Definition view.h:210
void nmg_plot_eu(struct ged *gedp, struct edgeuse *es_eu, const struct bn_tol *tol, struct bu_list *vlfree)
int ged_arot_args(struct ged *gedp, int argc, const char *argv[], mat_t rmat)
void dl_color_soltab(struct bu_list *hdlp)
struct display_list * dl_addToDisplay(struct bu_list *hdlp, struct db_i *dbip, const char *name)
struct rt_object_selections * ged_get_object_selections(struct ged *gedp, const char *object_name)
struct bg_polygon * ged_import_polygon(struct ged *gedp, const char *sname)
void dl_erasePathFromDisplay(struct ged *gedp, const char *path, int allow_split)
void(* ged_drawable_notify_func_t)(int)
Definition view.h:245
ged_drawable_notify_func_t ged_dl_notify_func_get(struct ged *gedp)
struct rt_selection_set * ged_get_selection_set(struct ged *gedp, const char *object_name, const char *selection_name)
int ged_tra_args(struct ged *gedp, int argc, const char *argv[], char *coord, vect_t tvec)
int ged_scale_args(struct ged *gedp, int argc, const char *argv[], fastf_t *sf1, fastf_t *sf2, fastf_t *sf3)
int ged_rot_args(struct ged *gedp, int argc, const char *argv[], char *coord, mat_t rmat)
fastf_t vect_t[ELEMENTS_PER_VECT]
3-tuple vector
Definition vmath.h:349
double fastf_t
fastest 64-bit (or larger) floating point type
Definition vmath.h:334
fastf_t mat_t[ELEMENTS_PER_MAT]
4x4 matrix
Definition vmath.h:370
fastf_t vect2d_t[ELEMENTS_PER_VECT2D]
2-tuple vector
Definition vmath.h:337
Definition tol.h:72
const struct bg_tess_tol * ttol
Definition view.h:216
struct resource * res
Definition view.h:218
struct bv_mesh_lod_context * mesh_c
Definition view.h:217
const struct bn_tol * tol
Definition view.h:215
struct db_i * dbip
Definition view.h:213
struct db_full_path * fp
Definition view.h:214
NMG topological edge usage.
Definition topology.h:155
struct db_full_path s_fullpath
Definition view.h:64
void * u_data
Definition view.h:65
Definition defines.h:167