BRL-CAD
draw.c
Go to the documentation of this file.
1 /* D R A W . C
2  * BRL-CAD
3  *
4  * Copyright (c) 2008-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 /** @file libged/draw.c
21  *
22  * The draw command.
23  *
24  */
25 
26 #include "common.h"
27 
28 #include <stdlib.h>
29 #include <string.h>
30 
31 
32 #include "bu/getopt.h"
33 #include "bu/parallel.h"
34 #include "mater.h"
35 
36 
37 #include "./ged_private.h"
38 
39 /* declare our callbacks used by _ged_drawtrees() */
40 static int drawtrees_depth = 0;
41 
42 
43 static union tree *
44 draw_check_region_end(struct db_tree_state *tsp,
45  const struct db_full_path *pathp,
46  union tree *curtree,
47  void *UNUSED(client_data))
48 {
49  if (tsp) RT_CK_DBTS(tsp);
50  if (pathp) RT_CK_FULL_PATH(pathp);
51  if (curtree) RT_CK_TREE(curtree);
52 
53  return curtree;
54 }
55 
56 static void
57 draw_forced_wireframe(
58  const struct db_full_path *pathp,
59  const struct _ged_client_data *dgcdp)
60 {
61  int ac = 1;
62  const char *av[2];
63 
64  /* draw the path with the given client data, but force wireframe mode */
65  struct _ged_client_data dgcd = *dgcdp;
66  dgcd.gedp->ged_gdp->gd_shaded_mode = 0;
68  dgcd.dmode = _GED_WIREFRAME;
69 
70  av[0] = db_path_to_string(pathp);
71  av[1] = (char *)0;
72 
73  _ged_drawtrees(dgcd.gedp, ac, av, _GED_DRAW_WIREFRAME, &dgcd);
74 
75  bu_free((void *)av[0], "draw_forced_wireframe: av[0]");
76 }
77 
78 static void
79 plot_shaded(
80  struct db_tree_state *tsp,
81  const struct db_full_path *pathp,
82  struct rt_db_internal *ip,
83  struct _ged_client_data *dgcdp)
84 {
85  if (ip->idb_major_type == DB5_MAJORTYPE_BRLCAD &&
86  (ip->idb_minor_type == DB5_MINORTYPE_BRLCAD_BOT ||
87  ip->idb_minor_type == DB5_MINORTYPE_BRLCAD_POLY ||
88  ip->idb_minor_type == DB5_MINORTYPE_BRLCAD_BREP))
89  {
90  struct bu_list vhead;
91  BU_LIST_INIT(&vhead);
92 
93  switch (ip->idb_minor_type) {
94  case DB5_MINORTYPE_BRLCAD_BOT:
95  (void)rt_bot_plot_poly(&vhead, ip, tsp->ts_ttol, tsp->ts_tol);
96  break;
97  case DB5_MINORTYPE_BRLCAD_POLY:
98  (void)rt_pg_plot_poly(&vhead, ip, tsp->ts_ttol, tsp->ts_tol);
99  break;
100  case DB5_MINORTYPE_BRLCAD_BREP:
101  (void)rt_brep_plot_poly(&vhead, pathp, ip, tsp->ts_ttol,
102  tsp->ts_tol, NULL);
103  }
104  _ged_drawH_part2(0, &vhead, pathp, tsp, dgcdp);
105  } else {
106  int ac = 1;
107  const char *av[2];
108 
109  av[0] = db_path_to_string(pathp);
110  av[1] = (char *)0;
111 
112  _ged_drawtrees(dgcdp->gedp, ac, av, _GED_DRAW_NMG_POLY, dgcdp);
113 
114  bu_free((void *)av[0], "plot_shaded: av[0]");
115  }
116 }
117 
118 static union tree *
119 draw_check_leaf(struct db_tree_state *tsp,
120  const struct db_full_path *pathp,
121  struct rt_db_internal *ip,
122  void *client_data)
123 {
124  union tree *curtree;
125  struct _ged_client_data *dgcdp = (struct _ged_client_data *)client_data;
126 
127  /* Indicate success by returning something other than TREE_NULL */
128  RT_GET_TREE(curtree, tsp->ts_resp);
129  curtree->tr_op = OP_NOP;
130 
131  switch (dgcdp->dmode) {
133  if (ip->idb_major_type == DB5_MAJORTYPE_BRLCAD &&
134  (ip->idb_minor_type == DB5_MINORTYPE_BRLCAD_BOT ||
135  ip->idb_minor_type == DB5_MINORTYPE_BRLCAD_POLY ||
136  ip->idb_minor_type == DB5_MINORTYPE_BRLCAD_BREP))
137  {
138  plot_shaded(tsp, pathp, ip, dgcdp);
139  } else {
140  draw_forced_wireframe(pathp, dgcdp);
141  }
142  break;
144  if (ip->idb_major_type == DB5_MAJORTYPE_BRLCAD &&
145  ip->idb_minor_type != DB5_MINORTYPE_BRLCAD_PIPE)
146  {
147  plot_shaded(tsp, pathp, ip, dgcdp);
148  } else {
149  draw_forced_wireframe(pathp, dgcdp);
150  }
151 
152  break;
153  }
154  return curtree;
155 }
156 
157 /**
158  * Once the vlist has been created, perform the common tasks
159  * in handling the drawn solid.
160  *
161  * This routine must be prepared to run in parallel.
162  */
163 void
164 _ged_drawH_part2(int dashflag, struct bu_list *vhead, const struct db_full_path *pathp, struct db_tree_state *tsp, struct _ged_client_data *dgcdp)
165 {
166 
167  if (dgcdp->wireframe_color_override) {
168  dl_add_path(dgcdp->gdlp, dashflag, dgcdp->transparency, dgcdp->dmode, dgcdp->hiddenLine, vhead, pathp, tsp, (unsigned char *)&(dgcdp->wireframe_color), dgcdp->gedp->ged_create_vlist_callback, dgcdp->freesolid);
169  } else {
170  dl_add_path(dgcdp->gdlp, dashflag, dgcdp->transparency, dgcdp->dmode, dgcdp->hiddenLine, vhead, pathp, tsp, NULL, dgcdp->gedp->ged_create_vlist_callback, dgcdp->freesolid);
171  }
172 }
173 
174 static int
175 get_path_and_state(
176  struct db_tree_state *tsp,
177  struct db_full_path *pathp,
178  const char *path_name,
179  struct ged *gedp)
180 {
181  *tsp = gedp->ged_wdbp->wdb_initial_tree_state;
182  tsp->ts_dbip = gedp->ged_wdbp->dbip;
183  tsp->ts_resp = &rt_uniresource;
184 
185  return db_follow_path_for_state(tsp, pathp, path_name, LOOKUP_QUIET);
186 }
187 
188 static int
189 plot_shaded_eval(
190  struct ged *gedp,
191  const char *path_name,
192  struct _ged_client_data *dgcdp)
193 {
194  int ret;
195  const char *av[3];
196  const char *tmp_basename = "tmp_shaded_eval_obj";
197  char *brep_name;
198 
199  /* make a name for the temp brep */
200  av[0] = "make_name";
201  av[1] = tmp_basename;
202 
203  ged_make_name(gedp, 2, (const char **)av);
204 
205  brep_name = bu_vls_strdup(gedp->ged_result_str);
206  bu_vls_trunc(gedp->ged_result_str, 0);
207 
208  /* create temp evaluated brep from named object */
209  av[0] = "brep";
210  av[1] = path_name;
211  av[2] = brep_name;
212  ret = ged_brep(gedp, 3, av);
213 
214  if (ret == GED_OK) {
215  int brep_made = 0;
216  struct db_tree_state ts;
217  struct rt_db_internal brep_intern;
218  struct db_full_path input_path, brep_path;
219 
220  RT_DB_INTERNAL_INIT(&brep_intern);
221  db_full_path_init(&input_path);
222  db_full_path_init(&brep_path);
223 
224  /* get brep internal */
225  ret = get_path_and_state(&ts, &brep_path, brep_name, gedp);
226  if (ret == GED_OK) {
227  struct directory *dp = DB_FULL_PATH_CUR_DIR(&brep_path);
228 
229  if (dp->d_flags & RT_DIR_COMB) {
230  ret = rt_db_get_internal(&brep_intern, dp, ts.ts_dbip, NULL,
231  ts.ts_resp);
232  } else {
233  ret = rt_db_get_internal(&brep_intern, dp, ts.ts_dbip, ts.ts_mat,
234  ts.ts_resp);
235  }
236  if (ret >= 0) {
237  brep_made = 1;
238  }
239  db_free_full_path(&brep_path);
240  }
241 
242  /* plot brep, but use the path and state of the input object */
243  if (brep_made) {
244  ret = get_path_and_state(&ts, &input_path, path_name, gedp);
245  if (ret == GED_OK) {
246  plot_shaded(&ts, &input_path, &brep_intern, dgcdp);
247 
248  rt_db_free_internal(&brep_intern);
249  db_free_full_path(&input_path);
250  }
251  }
252 
253  /* kill temp brep */
254  av[0] = "kill";
255  av[1] = brep_name;
256  ged_kill(gedp, 2, av);
257  }
258  bu_free((char *)brep_name, "vls_strdup");
259 
260  return ret;
261 }
262 
263 static union tree *
264 wireframe_region_end(struct db_tree_state *tsp, const struct db_full_path *pathp, union tree *curtree, void *UNUSED(client_data))
265 {
266  if (tsp) RT_CK_DBTS(tsp);
267  if (pathp) RT_CK_FULL_PATH(pathp);
268  if (curtree) RT_CK_TREE(curtree);
269 
270  return curtree;
271 }
272 
273 
274 /**
275  * When performing "ev" on a region, consider whether to process the
276  * whole subtree recursively.
277  *
278  * Normally, say "yes" to all regions by returning 0.
279  *
280  * Check for special case: a region of one solid, which can be
281  * directly drawn as polygons without going through NMGs. If we draw
282  * it here, then return -1 to signal caller to ignore further
283  * processing of this region. A hack to view polygonal models
284  * (converted from FASTGEN) more rapidly.
285  */
286 static int
287 draw_nmg_region_start(struct db_tree_state *tsp, const struct db_full_path *pathp, const struct rt_comb_internal *combp, void *client_data)
288 {
289  union tree *tp;
290  struct directory *dp;
291  struct rt_db_internal intern;
292  mat_t xform;
293  matp_t matp;
294  struct bu_list vhead;
295  struct _ged_client_data *dgcdp = (struct _ged_client_data *)client_data;
296 
298  char *sofar = db_path_to_string(pathp);
299  bu_vls_printf(dgcdp->gedp->ged_result_str, "nmg_region_start(%s)\n", sofar);
300  bu_free((void *)sofar, "path string");
301  rt_pr_tree(combp->tree, 1);
302  db_pr_tree_state(tsp);
303  }
304 
305  RT_CK_DBI(tsp->ts_dbip);
306  RT_CK_RESOURCE(tsp->ts_resp);
307 
308  BU_LIST_INIT(&vhead);
309 
310  RT_CK_COMB(combp);
311  tp = combp->tree;
312  if (!tp)
313  return -1;
314  RT_CK_TREE(tp);
315  if (tp->tr_l.tl_op != OP_DB_LEAF)
316  return 0; /* proceed as usual */
317 
318  /* The subtree is a single node. It may be a combination, though */
319 
320  /* Fetch by name, check to see if it's an easy type */
321  dp = db_lookup(tsp->ts_dbip, tp->tr_l.tl_name, LOOKUP_NOISY);
322  if (!dp)
323  return 0; /* proceed as usual */
324 
325  if (!bn_mat_is_identity(tsp->ts_mat)) {
326  if (tp->tr_l.tl_mat) {
327  matp = xform;
328  bn_mat_mul(xform, tsp->ts_mat, tp->tr_l.tl_mat);
329  } else {
330  matp = tsp->ts_mat;
331  }
332  } else {
333  if (tp->tr_l.tl_mat) {
334  matp = tp->tr_l.tl_mat;
335  } else {
336  matp = (matp_t)NULL;
337  }
338  }
339 
340  if (rt_db_get_internal(&intern, dp, tsp->ts_dbip, matp, &rt_uniresource) < 0)
341  return 0; /* proceed as usual */
342 
343  switch (intern.idb_type) {
344  case ID_POLY:
345  {
346  if (RT_G_DEBUG&DEBUG_TREEWALK) {
347  bu_log("fastpath draw ID_POLY %s\n", dp->d_namep);
348  }
349  if (dgcdp->draw_wireframes) {
350  (void)rt_pg_plot(&vhead, &intern, tsp->ts_ttol, tsp->ts_tol, NULL);
351  } else {
352  (void)rt_pg_plot_poly(&vhead, &intern, tsp->ts_ttol, tsp->ts_tol);
353  }
354  }
355  goto out;
356  case ID_BOT:
357  {
358  if (RT_G_DEBUG&DEBUG_TREEWALK) {
359  bu_log("fastpath draw ID_BOT %s\n", dp->d_namep);
360  }
361  if (dgcdp->draw_wireframes) {
362  (void)rt_bot_plot(&vhead, &intern, tsp->ts_ttol, tsp->ts_tol, NULL);
363  } else {
364  (void)rt_bot_plot_poly(&vhead, &intern, tsp->ts_ttol, tsp->ts_tol);
365  }
366  }
367  goto out;
368  case ID_BREP:
369  {
370  if (RT_G_DEBUG&DEBUG_TREEWALK) {
371  bu_log("fastpath draw ID_BREP %s\n", dp->d_namep);
372  }
373  if (dgcdp->draw_wireframes) {
374  (void)rt_brep_plot(&vhead, &intern, tsp->ts_ttol, tsp->ts_tol, NULL);
375  } else {
376  (void)rt_brep_plot_poly(&vhead, pathp, &intern, tsp->ts_ttol, tsp->ts_tol, NULL);
377  }
378  }
379  goto out;
380  case ID_COMBINATION:
381  default:
382  break;
383  }
384  rt_db_free_internal(&intern);
385  return 0;
386 
387 out:
388  {
389  struct db_full_path pp;
390  db_full_path_init(&pp);
391  db_dup_full_path(&pp, pathp);
392 
393  /* Successful fastpath drawing of this solid */
394  db_add_node_to_full_path(&pp, dp);
395  _ged_drawH_part2(0, &vhead, &pp, tsp, dgcdp);
396 
397  db_free_full_path(&pp);
398  }
399 
400  rt_db_free_internal(&intern);
401  dgcdp->fastpath_count++;
402  return -1; /* SKIP THIS REGION */
403 }
404 
405 
406 static int
407 process_boolean(union tree *curtree, struct db_tree_state *tsp, const struct db_full_path *pathp, struct _ged_client_data *dgcdp)
408 {
409  int result = 1;
410 
411  if (!BU_SETJUMP) {
412  /* try */
413 
414  result = nmg_boolean(curtree, *tsp->ts_m, tsp->ts_tol, tsp->ts_resp);
415 
416  } else {
417  /* catch */
418  char *sofar = db_path_to_string(pathp);
419 
420  bu_vls_printf(dgcdp->gedp->ged_result_str, "WARNING: Boolean evaluation of %s failed!\n", sofar);
421  bu_free((void *)sofar, "path string");
422  } BU_UNSETJUMP;
423 
424  return result;
425 }
426 
427 
428 static int
429 process_triangulation(struct db_tree_state *tsp, const struct db_full_path *pathp, struct _ged_client_data *dgcdp)
430 {
431  int result = 1;
432 
433  if (!BU_SETJUMP) {
434  /* try */
435 
436  nmg_triangulate_model(*tsp->ts_m, tsp->ts_tol);
437  result = 0;
438 
439  } else {
440  /* catch */
441 
442  char *sofar = db_path_to_string(pathp);
443 
444  bu_vls_printf(dgcdp->gedp->ged_result_str, "WARNING: Triangulation of %s failed!\n", sofar);
445  bu_free((void *)sofar, "path string");
446 
447  } BU_UNSETJUMP;
448 
449  return result;
450 }
451 
452 
453 /**
454  * This routine must be prepared to run in parallel.
455  */
456 static union tree *
457 draw_nmg_region_end(struct db_tree_state *tsp, const struct db_full_path *pathp, union tree *curtree, void *client_data)
458 {
459  struct nmgregion *r;
460  struct bu_list vhead;
461  int failed;
462  struct _ged_client_data *dgcdp = (struct _ged_client_data *)client_data;
463 
464  RT_CK_TESS_TOL(tsp->ts_ttol);
465  BN_CK_TOL(tsp->ts_tol);
466  NMG_CK_MODEL(*tsp->ts_m);
467  RT_CK_RESOURCE(tsp->ts_resp);
468 
469  BU_LIST_INIT(&vhead);
470 
471  if (RT_G_DEBUG&DEBUG_TREEWALK) {
472  char *sofar = db_path_to_string(pathp);
473 
474  bu_vls_printf(dgcdp->gedp->ged_result_str, "nmg_region_end() path='%s'\n", sofar);
475  bu_free((void *)sofar, "path string");
476  } else {
477  char *sofar = db_path_to_string(pathp);
478 
479  bu_vls_printf(dgcdp->gedp->ged_result_str, "%s:\n", sofar);
480  bu_free((void *)sofar, "path string");
481  }
482 
483  if (curtree->tr_op == OP_NOP) return curtree;
484 
485  failed = 1;
486  if (!dgcdp->draw_nmg_only) {
487 
488  failed = process_boolean(curtree, tsp, pathp, dgcdp);
489  if (failed) {
490  db_free_tree(curtree, tsp->ts_resp);
491  return (union tree *)NULL;
492  }
493 
494  } else if (curtree->tr_op != OP_NMG_TESS) {
495  bu_vls_printf(dgcdp->gedp->ged_result_str, "Cannot use '-d' option when Boolean evaluation is required\n");
496  db_free_tree(curtree, tsp->ts_resp);
497  return (union tree *)NULL;
498  }
499  r = curtree->tr_d.td_r;
500  NMG_CK_REGION(r);
501 
502  if (dgcdp->do_not_draw_nmg_solids_during_debugging && r) {
503  db_free_tree(curtree, tsp->ts_resp);
504  return (union tree *)NULL;
505  }
506 
507  if (dgcdp->nmg_triangulate) {
508  failed = process_triangulation(tsp, pathp, dgcdp);
509  if (failed) {
510  db_free_tree(curtree, tsp->ts_resp);
511  return (union tree *)NULL;
512  }
513  }
514 
515  if (r != 0) {
516  int style;
517  /* Convert NMG to vlist */
518  NMG_CK_REGION(r);
519 
520  if (dgcdp->draw_wireframes) {
521  /* Draw in vector form */
522  style = NMG_VLIST_STYLE_VECTOR;
523  } else {
524  /* Default -- draw polygons */
525  style = NMG_VLIST_STYLE_POLYGON;
526  }
527  if (dgcdp->draw_normals) {
528  style |= NMG_VLIST_STYLE_VISUALIZE_NORMALS;
529  }
530  if (dgcdp->shade_per_vertex_normals) {
531  style |= NMG_VLIST_STYLE_USE_VU_NORMALS;
532  }
533  if (dgcdp->draw_no_surfaces) {
534  style |= NMG_VLIST_STYLE_NO_SURFACES;
535  }
536  nmg_r_to_vlist(&vhead, r, style);
537 
538  _ged_drawH_part2(0, &vhead, pathp, tsp, dgcdp);
539 
540  if (dgcdp->draw_edge_uses) {
541  nmg_vlblock_r(dgcdp->draw_edge_uses_vbp, r, 1);
542  }
543  /* NMG region is no longer necessary, only vlist remains */
544  db_free_tree(curtree, tsp->ts_resp);
545  return (union tree *)NULL;
546  }
547 
548  /* Return tree -- it needs to be freed (by caller) */
549  return curtree;
550 }
551 
552 
553 void
554 _ged_cvt_vlblock_to_solids(struct ged *gedp, struct bn_vlblock *vbp, const char *name, int copy)
555 {
556  size_t i;
557  char shortname[32] = {0};
558  char namebuf[64] = {0};
559 
560  bu_strlcpy(shortname, name, sizeof(shortname));
561 
562  for (i = 0; i < vbp->nused; i++) {
563  if (BU_LIST_IS_EMPTY(&(vbp->head[i])))
564  continue;
565  snprintf(namebuf, 64, "%s%lx", shortname, vbp->rgb[i]);
566  invent_solid(gedp->ged_gdp->gd_headDisplay, gedp->ged_wdbp->dbip, gedp->ged_create_vlist_callback, gedp->ged_free_vlist_callback, namebuf, &vbp->head[i], vbp->rgb[i], copy, 0.0, 0, gedp->freesolid, 0);
567  }
568 }
569 
570 
571 /*
572  * This routine is the drawable geometry object's analog of rt_gettrees().
573  * Add a set of tree hierarchies to the active set.
574  * Note that argv[0] should be ignored, it has the command name in it.
575  *
576  * Returns -
577  * 0 Ordinarily
578  * -1 On major error
579  */
580 int
581 _ged_drawtrees(struct ged *gedp, int argc, const char *argv[], int kind, struct _ged_client_data *_dgcdp)
582 {
583  int ret = 0;
584  int c;
585  int ncpu = 1;
586  int nmg_use_tnurbs = 0;
587  int enable_fastpath = 0;
588  struct model *nmg_model;
589  struct _ged_client_data dgcdp;
590  int i;
591  int ac = 1;
592  char *av[3];
593 
594  RT_CHECK_DBI(gedp->ged_wdbp->dbip);
595 
596  if (argc <= 0)
597  return -1; /* FAIL */
598 
599  ++drawtrees_depth;
600  av[1] = (char *)0;
601 
602  /* options are already parsed into _dgcdp */
603  if (_dgcdp != (struct _ged_client_data *)0) {
604  dgcdp = *_dgcdp; /* struct copy */
605  } else {
606  struct bview *gvp;
607 
608  memset(&dgcdp, 0, sizeof(struct _ged_client_data));
609  dgcdp.gedp = gedp;
610 
611  gvp = gedp->ged_gvp;
612  if (gvp && gvp->gv_adaptive_plot)
613  dgcdp.autoview = 1;
614  else
615  dgcdp.autoview = 0;
616 
617  /* Initial values for options, must be reset each time */
618  dgcdp.draw_nmg_only = 0; /* no booleans */
619  dgcdp.nmg_triangulate = 1;
620  dgcdp.draw_wireframes = 0;
621  dgcdp.draw_normals = 0;
622  dgcdp.draw_solid_lines_only = 0;
623  dgcdp.draw_no_surfaces = 0;
624  dgcdp.shade_per_vertex_normals = 0;
625  dgcdp.draw_edge_uses = 0;
626  dgcdp.wireframe_color_override = 0;
627  dgcdp.fastpath_count = 0;
629 
630  /* default color - red */
631  dgcdp.wireframe_color[0] = 255;
632  dgcdp.wireframe_color[1] = 0;
633  dgcdp.wireframe_color[2] = 0;
634 
635  /* default transparency - opaque */
636  dgcdp.transparency = 1.0;
637 
638  /* freesolid */
639  dgcdp.freesolid = gedp->freesolid;
640 
641  enable_fastpath = 0;
642 
643  /* Parse options. */
644  bu_optind = 0; /* re-init bu_getopt() */
645  while ((c = bu_getopt(argc, (char * const *)argv, "dfhm:nqstuvwx:C:STP:A:oR")) != -1) {
646  switch (c) {
647  case 'u':
648  dgcdp.draw_edge_uses = 1;
649  break;
650  case 's':
651  dgcdp.draw_solid_lines_only = 1;
652  break;
653  case 't':
654  nmg_use_tnurbs = 1;
655  break;
656  case 'v':
657  dgcdp.shade_per_vertex_normals = 1;
658  break;
659  case 'w':
660  dgcdp.draw_wireframes = 1;
661  break;
662  case 'S':
663  dgcdp.draw_no_surfaces = 1;
664  break;
665  case 'T':
666  dgcdp.nmg_triangulate = 0;
667  break;
668  case 'n':
669  dgcdp.draw_normals = 1;
670  break;
671  case 'P':
672  ncpu = atoi(bu_optarg);
673  break;
674  case 'q':
676  break;
677  case 'd':
678  dgcdp.draw_nmg_only = 1;
679  break;
680  case 'f':
681  enable_fastpath = 1;
682  break;
683  case 'C':
684  {
685  int r, g, b;
686  char *cp = bu_optarg;
687 
688  r = atoi(cp);
689  while ((*cp >= '0' && *cp <= '9')) cp++;
690  while (*cp && (*cp < '0' || *cp > '9')) cp++;
691  g = atoi(cp);
692  while ((*cp >= '0' && *cp <= '9')) cp++;
693  while (*cp && (*cp < '0' || *cp > '9')) cp++;
694  b = atoi(cp);
695 
696  if (r < 0 || r > 255) r = 255;
697  if (g < 0 || g > 255) g = 255;
698  if (b < 0 || b > 255) b = 255;
699 
700  dgcdp.wireframe_color_override = 1;
701  dgcdp.wireframe_color[0] = r;
702  dgcdp.wireframe_color[1] = g;
703  dgcdp.wireframe_color[2] = b;
704  }
705  break;
706  case 'h':
707  dgcdp.hiddenLine = 1;
709  break;
710  case 'm':
711  dgcdp.shaded_mode_override = atoi(bu_optarg);
712 
713  switch (dgcdp.shaded_mode_override) {
714  case 0:
716  break;
717  case 1:
719  break;
720  case 2:
722  break;
723  case 3:
725  break;
726  default:
727  if (dgcdp.shaded_mode_override < 0) {
729  } else {
731  }
732  }
733  break;
734  case 'x':
735  dgcdp.transparency = atof(bu_optarg);
736 
737  /* clamp it to [0, 1] */
738  if (dgcdp.transparency < 0.0)
739  dgcdp.transparency = 0.0;
740 
741  if (1.0 < dgcdp.transparency)
742  dgcdp.transparency = 1.0;
743 
744  break;
745  case 'R':
746  dgcdp.autoview = 0;
747  break;
748  case 'A':
749  case 'o':
750  /* nothing to do, handled by edit_com wrapper on the front-end */
751  break;
752  default:
753  {
754  bu_vls_printf(gedp->ged_result_str, "unrecognized option - %c\n", c);
755  --drawtrees_depth;
756  return GED_ERROR;
757  }
758  }
759  }
760  argc -= bu_optind;
761  argv += bu_optind;
762 
763  switch (kind) {
764  case _GED_DRAW_WIREFRAME:
765  dgcdp.dmode = _GED_WIREFRAME;
767  dgcdp.dmode = dgcdp.shaded_mode_override;
768  } else if (gedp->ged_gdp->gd_shaded_mode) {
769  dgcdp.dmode = gedp->ged_gdp->gd_shaded_mode;
770  }
771  break;
772  case _GED_DRAW_NMG_POLY:
773  dgcdp.dmode = _GED_BOOL_EVAL;
774  break;
775  }
776 
777  }
778 
779  if (!argc) {
780  bu_vls_printf(gedp->ged_result_str, "Please specify one or more objects to be drawn.\n");
781  --drawtrees_depth;
782  return -1;
783  }
784 
785  switch (kind) {
786  default:
787  bu_vls_printf(gedp->ged_result_str, "ERROR, bad kind\n");
788  --drawtrees_depth;
789  return -1;
790  case _GED_DRAW_WIREFRAME:
791  /*
792  * If asking for wireframe and in shaded_mode and no shaded mode override,
793  * or asking for wireframe and shaded mode is being overridden with a value
794  * greater than 0, then draw shaded polygons for each object's primitives if possible.
795  *
796  * Note -
797  * If shaded_mode is _GED_SHADED_MODE_BOTS, only BOTS and polysolids
798  * will be shaded. The rest is drawn as wireframe.
799  * If shaded_mode is _GED_SHADED_MODE_ALL, everything except pipe solids
800  * are drawn as shaded polygons.
801  */
802  if (dgcdp.dmode == _GED_SHADED_MODE_BOTS ||
803  dgcdp.dmode == _GED_SHADED_MODE_ALL ||
804  dgcdp.dmode == _GED_SHADED_MODE_EVAL)
805  {
806  struct _ged_client_data dgcdp_save;
807 
808  for (i = 0; i < argc; ++i) {
809  if (drawtrees_depth == 1)
810  dgcdp.gdlp = dl_addToDisplay(gedp->ged_gdp->gd_headDisplay, gedp->ged_wdbp->dbip, argv[i]);
811 
812  if (dgcdp.gdlp == GED_DISPLAY_LIST_NULL)
813  continue;
814 
815  dgcdp_save = dgcdp;
816 
817  if (dgcdp.dmode == _GED_SHADED_MODE_EVAL) {
818  ret = plot_shaded_eval(gedp, argv[i], &dgcdp);
819  if (ret == GED_OK) {
820  continue;
821  }
822  /* if evaluated shading failed, fall back to "all" mode */
823  dgcdp.gedp->ged_gdp->gd_shaded_mode = 0;
825  dgcdp.dmode = _GED_SHADED_MODE_ALL;
826  }
827 
828  av[0] = (char *)argv[i];
829  ret = db_walk_tree(gedp->ged_wdbp->dbip,
830  ac,
831  (const char **)av,
832  ncpu,
834  NULL,
835  draw_check_region_end,
836  draw_check_leaf,
837  (void *)&dgcdp);
838 
839  dgcdp = dgcdp_save;
840  }
841  } else {
842  struct display_list **paths_to_draw;
843  struct display_list *gdlp;
844 
845  paths_to_draw = (struct display_list **)
846  bu_malloc(sizeof(struct display_list *) * argc,
847  "redraw paths");
848 
849  /* create solids */
850  for (i = 0; i < argc; ++i) {
851  struct bview_client_data bview_data;
852  bview_data.draw_solid_lines_only = dgcdp.draw_solid_lines_only;
854  bview_data.wireframe_color[0]= dgcdp.wireframe_color[0];
855  bview_data.wireframe_color[1]= dgcdp.wireframe_color[1];
856  bview_data.wireframe_color[2]= dgcdp.wireframe_color[2];
857  bview_data.transparency= dgcdp.transparency;
858  bview_data.dmode = dgcdp.dmode;
859  bview_data.hiddenLine = dgcdp.hiddenLine;
860  bview_data.freesolid = (void *)gedp->freesolid;
861 
862  dgcdp.gdlp = dl_addToDisplay(gedp->ged_gdp->gd_headDisplay, gedp->ged_wdbp->dbip, argv[i]);
863  bview_data.gdlp = dgcdp.gdlp;
864 
865  /* store draw path */
866  paths_to_draw[i] = dgcdp.gdlp;
867 
868  if (dgcdp.gdlp == GED_DISPLAY_LIST_NULL) {
869  continue;
870  }
871 
872  av[0] = (char *)argv[i];
873  ret = db_walk_tree(gedp->ged_wdbp->dbip,
874  ac,
875  (const char **)av,
876  ncpu,
878  NULL,
879  wireframe_region_end,
881  (void *)&bview_data);
882  }
883 
884  /* We need to know the view size in order to choose
885  * appropriate input values for the adaptive plot
886  * routines. Unless we're keeping the current view,
887  * we need to autoview now so we have the correct
888  * view size for plotting.
889  */
890  if (dgcdp.autoview) {
891  const char *autoview_args[2] = {"autoview", NULL};
892  ged_autoview(gedp, 1, autoview_args);
893  }
894 
895  /* calculate plot vlists for solids of each draw path */
896  for (i = 0; i < argc; ++i) {
897  gdlp = paths_to_draw[i];
898 
899  if (gdlp == GED_DISPLAY_LIST_NULL) {
900  continue;
901  }
902 
903  ret = dl_redraw(gdlp, gedp->ged_wdbp->dbip, &gedp->ged_wdbp->wdb_initial_tree_state, gedp->ged_gvp, gedp->ged_create_vlist_callback);
904  if (ret < 0) {
906  "%s: %s redraw failure\n", argv[0], argv[i]);
907  return GED_ERROR;
908  }
909  }
910 
911  bu_free(paths_to_draw, "draw paths");
912  }
913  break;
914  case _GED_DRAW_NMG_POLY:
915  {
916  nmg_model = nmg_mm();
917  gedp->ged_wdbp->wdb_initial_tree_state.ts_m = &nmg_model;
918  if (dgcdp.draw_edge_uses) {
919  bu_vls_printf(gedp->ged_result_str, "Doing the edgeuse thang (-u)\n");
921  }
922 
923  for (i = 0; i < argc; ++i) {
924  if (drawtrees_depth == 1)
925  dgcdp.gdlp = dl_addToDisplay(gedp->ged_gdp->gd_headDisplay, gedp->ged_wdbp->dbip, argv[i]);
926 
927  if (dgcdp.gdlp == GED_DISPLAY_LIST_NULL)
928  continue;
929 
930  av[0] = (char *)argv[i];
931  ret = db_walk_tree(gedp->ged_wdbp->dbip,
932  ac,
933  (const char **)av,
934  ncpu,
936  enable_fastpath ? draw_nmg_region_start : 0,
937  draw_nmg_region_end,
939  (void *)&dgcdp);
940  }
941 
942  if (dgcdp.draw_edge_uses) {
943  _ged_cvt_vlblock_to_solids(gedp, dgcdp.draw_edge_uses_vbp, "_EDGEUSES_", 0);
945  dgcdp.draw_edge_uses_vbp = (struct bn_vlblock *)NULL;
946  }
947 
948  /* Destroy NMG */
949  nmg_km(nmg_model);
950  break;
951  }
952  }
953 
954  --drawtrees_depth;
955 
956  if (dgcdp.fastpath_count) {
957  bu_log("%d region%s rendered through polygon fastpath\n",
958  dgcdp.fastpath_count, dgcdp.fastpath_count == 1 ? "" : "s");
959  }
960 
961  if (ret < 0)
962  return -1;
963 
964  return 0; /* OK */
965 }
966 
967 
968 int
969 ged_draw_guts(struct ged *gedp, int argc, const char *argv[], int kind)
970 {
971  size_t i;
972  int drawtrees_retval;
973  int flag_A_attr=0;
974  int flag_o_nonunique=1;
975  int last_opt=0;
976  struct bu_vls vls = BU_VLS_INIT_ZERO;
977  static const char *usage = "<[-R -C#/#/# -s] objects> | <-o -A attribute name/value pairs>";
978 
979 /* #define DEBUG_TIMING 1 */
980 
981 #ifdef DEBUG_TIMING
982  int64_t elapsedtime;
983 #endif
984 
987  GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
988 
989  /* initialize result */
990  bu_vls_trunc(gedp->ged_result_str, 0);
991 
992  /* must be wanting help */
993  if (argc == 1) {
994  bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
995  return GED_HELP;
996  }
997 
998 #ifdef DEBUG_TIMING
999  elapsedtime = bu_gettime();
1000 #endif
1001 
1002  /* skip past cmd */
1003  --argc;
1004  ++argv;
1005 
1006  /* check args for "-A" (attributes) and "-o" */
1007  for (i = 0; i < (size_t)argc; i++) {
1008  char *ptr_A=NULL;
1009  char *ptr_o=NULL;
1010  char *c;
1011 
1012  if (*argv[i] != '-') {
1013  /* Done checking options. If our display is non-empty,
1014  * add -R to keep current view.
1015  */
1017  bu_vls_strcat(&vls, " -R");
1018  }
1019  break;
1020  }
1021 
1022  ptr_A=strchr(argv[i], 'A');
1023  if (ptr_A)
1024  flag_A_attr = 1;
1025 
1026  ptr_o=strchr(argv[i], 'o');
1027  if (ptr_o)
1028  flag_o_nonunique = 2;
1029 
1030  last_opt = i;
1031 
1032  if (!ptr_A && !ptr_o) {
1033  bu_vls_putc(&vls, ' ');
1034  bu_vls_strcat(&vls, argv[i]);
1035  continue;
1036  }
1037 
1038  if (strlen(argv[i]) == ((size_t)1 + (ptr_A != NULL) + (ptr_o != NULL))) {
1039  /* argv[i] is just a "-A" or "-o" */
1040  continue;
1041  }
1042 
1043  /* copy args other than "-A" or "-o" */
1044  bu_vls_putc(&vls, ' ');
1045  c = (char *)argv[i];
1046  while (*c != '\0') {
1047  if (*c != 'A' && *c != 'o') {
1048  bu_vls_putc(&vls, *c);
1049  }
1050  c++;
1051  }
1052  }
1053 
1054  if (flag_A_attr) {
1055  /* args are attribute name/value pairs */
1056  struct bu_attribute_value_set avs;
1057  int max_count=0;
1058  int remaining_args=0;
1059  int new_argc=0;
1060  char **new_argv=NULL;
1061  struct bu_ptbl *tbl;
1062 
1063  remaining_args = argc - last_opt - 1;
1064  if (remaining_args < 2 || remaining_args%2) {
1065  bu_vls_printf(gedp->ged_result_str, "Error: must have even number of arguments (name/value pairs)\n");
1066  bu_vls_free(&vls);
1067  return GED_ERROR;
1068  }
1069 
1070  bu_avs_init(&avs, (argc - last_opt)/2, "ged_draw_guts avs");
1071  i = 0;
1072  while (i < (size_t)argc) {
1073  if (*argv[i] == '-') {
1074  i++;
1075  continue;
1076  }
1077 
1078  /* this is a name/value pair */
1079  if (flag_o_nonunique == 2) {
1080  bu_avs_add_nonunique(&avs, argv[i], argv[i+1]);
1081  } else {
1082  bu_avs_add(&avs, argv[i], argv[i+1]);
1083  }
1084  i += 2;
1085  }
1086 
1087  tbl = db_lookup_by_attr(gedp->ged_wdbp->dbip, RT_DIR_REGION | RT_DIR_SOLID | RT_DIR_COMB, &avs, flag_o_nonunique);
1088  bu_avs_free(&avs);
1089  if (!tbl) {
1090  bu_log("Error: db_lookup_by_attr() failed!!\n");
1091  bu_vls_free(&vls);
1092  return TCL_ERROR;
1093  }
1094  if (BU_PTBL_LEN(tbl) < 1) {
1095  /* nothing matched, just return */
1096  bu_vls_free(&vls);
1097  return TCL_OK;
1098  }
1099  for (i = 0; i < BU_PTBL_LEN(tbl); i++) {
1100  struct directory *dp;
1101 
1102  dp = (struct directory *)BU_PTBL_GET(tbl, i);
1103  bu_vls_putc(&vls, ' ');
1104  bu_vls_strcat(&vls, dp->d_namep);
1105  }
1106 
1107  max_count = BU_PTBL_LEN(tbl) + last_opt + 1;
1108  bu_ptbl_free(tbl);
1109  bu_free((char *)tbl, "ged_draw_guts ptbl");
1110  new_argv = (char **)bu_calloc(max_count+1, sizeof(char *), "ged_draw_guts new_argv");
1111  new_argc = bu_argv_from_string(new_argv, max_count, bu_vls_addr(&vls));
1112 
1113  /* First, delete any mention of these objects.
1114  * Silently skip any leading options (which start with minus signs).
1115  */
1116  for (i = 0; i < (size_t)new_argc; ++i) {
1117  /* Skip any options */
1118  if (new_argv[i][0] == '-') {
1119  /* If this option requires an argument which was
1120  * provided separately (e.g. '-C 0/255/0' instead of
1121  * '-C0/255/0'), skip the argument too.
1122  */
1123  if (strlen(argv[i]) == 2 && strchr("mxCP", argv[i][1])) {
1124  i++;
1125  }
1126  continue;
1127  }
1128 
1129  dl_erasePathFromDisplay(gedp->ged_gdp->gd_headDisplay, gedp->ged_wdbp->dbip, gedp->ged_free_vlist_callback, new_argv[i], 0, gedp->freesolid);
1130  }
1131 
1132  drawtrees_retval = _ged_drawtrees(gedp, new_argc, (const char **)new_argv, kind, (struct _ged_client_data *)0);
1133  bu_vls_free(&vls);
1134  bu_free((char *)new_argv, "ged_draw_guts new_argv");
1135  if (drawtrees_retval) {
1136  return GED_ERROR;
1137  }
1138  } else {
1139  int empty_display;
1140  bu_vls_free(&vls);
1141 
1142  empty_display = 1;
1144  empty_display = 0;
1145  }
1146 
1147  /* First, delete any mention of these objects.
1148  * Silently skip any leading options (which start with minus signs).
1149  */
1150  for (i = 0; i < (size_t)argc; ++i) {
1151  /* Skip any options */
1152  if (argv[i][0] == '-') {
1153  /* If this option requires an argument which was
1154  * provided separately (e.g. '-C 0/255/0' instead of
1155  * '-C0/255/0'), skip the argument too.
1156  */
1157  if (strlen(argv[i]) == 2 && strchr("mxCP", argv[i][1])) {
1158  i++;
1159  }
1160  continue;
1161  }
1162 
1164  }
1165 
1166  /* if our display is non-empty add -R to keep current view */
1167  if (!empty_display) {
1168  int new_argc;
1169  char **new_argv;
1170 
1171  new_argc = argc + 1;
1172  new_argv = (char **)bu_malloc(new_argc * sizeof(char *), "ged_draw_guts new_argv");
1173 
1174  new_argv[0] = bu_strdup("-R");
1175  for (i = 0; i < (size_t)argc; ++i) {
1176  new_argv[i + 1] = bu_strdup(argv[i]);
1177  }
1178 
1179  drawtrees_retval = _ged_drawtrees(gedp, new_argc, (const char **)new_argv, kind, (struct _ged_client_data *)0);
1180 
1181  for (i = 0; i < (size_t)new_argc; ++i) {
1182  bu_free(new_argv[i], "ged_draw_guts new_argv[i] - bu_strdup(argv[i])");
1183  }
1184  bu_free(new_argv, "ged_draw_guts new_argv");
1185  } else {
1186  drawtrees_retval = _ged_drawtrees(gedp, argc, argv, kind, (struct _ged_client_data *)0);
1187  }
1188  if (drawtrees_retval) {
1189  return GED_ERROR;
1190  }
1191  }
1192 
1193 #ifdef DEBUG_TIMING
1194  elapsedtime = bu_gettime() - elapsedtime;
1195  {
1196  int seconds = elapsedtime / 1000000;
1197  int minutes = seconds / 60;
1198  int hours = minutes / 60;
1199 
1200  minutes = minutes % 60;
1201  seconds = seconds %60;
1202 
1203  bu_vls_printf(gedp->ged_result_str, "Elapsed time: %02d:%02d:%02d\n", hours, minutes, seconds);
1204  }
1205 #endif
1206 
1207  return GED_OK;
1208 }
1209 
1210 
1211 int
1212 ged_draw(struct ged *gedp, int argc, const char *argv[])
1213 {
1214  return ged_draw_guts(gedp, argc, argv, _GED_DRAW_WIREFRAME);
1215 }
1216 
1217 
1218 int
1219 ged_ev(struct ged *gedp, int argc, const char *argv[])
1220 {
1221  return ged_draw_guts(gedp, argc, argv, _GED_DRAW_NMG_POLY);
1222 }
1223 
1224 int
1225 ged_redraw(struct ged *gedp, int argc, const char *argv[])
1226 {
1227  int ret;
1228  struct display_list *gdlp;
1229 
1232  GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
1233  RT_CHECK_DBI(gedp->ged_wdbp->dbip);
1234 
1235  bu_vls_trunc(gedp->ged_result_str, 0);
1236 
1237  if (argc == 1) {
1238  /* redraw everything */
1239  for (BU_LIST_FOR(gdlp, display_list, gedp->ged_gdp->gd_headDisplay))
1240  {
1241  ret = dl_redraw(gdlp, gedp->ged_wdbp->dbip, &gedp->ged_wdbp->wdb_initial_tree_state, gedp->ged_gvp, gedp->ged_create_vlist_callback);
1242  if (ret < 0) {
1243  bu_vls_printf(gedp->ged_result_str, "%s: redraw failure\n", argv[0]);
1244  return GED_ERROR;
1245  }
1246  }
1247  } else {
1248  int i, found_path;
1249  struct db_full_path obj_path, dl_path;
1250 
1251  /* redraw the specified paths */
1252  for (i = 1; i < argc; ++i) {
1253  ret = db_string_to_path(&obj_path, gedp->ged_wdbp->dbip, argv[i]);
1254  if (ret < 0) {
1256  "%s: %s is not a valid path\n", argv[0], argv[i]);
1257  return GED_ERROR;
1258  }
1259 
1260  found_path = 0;
1261  for (BU_LIST_FOR(gdlp, display_list, gedp->ged_gdp->gd_headDisplay))
1262  {
1263  ret = db_string_to_path(&dl_path, gedp->ged_wdbp->dbip,
1264  bu_vls_addr(&gdlp->dl_path));
1265  if (ret < 0) {
1267  "%s: %s is not a valid path\n", argv[0],
1268  bu_vls_addr(&gdlp->dl_path));
1269  return GED_ERROR;
1270  }
1271 
1272  /* this display list path matches/contains the redraw path */
1273  if (db_full_path_match_top(&dl_path, &obj_path)) {
1274  found_path = 1;
1275  db_free_full_path(&dl_path);
1276 
1277  ret = dl_redraw(gdlp, gedp->ged_wdbp->dbip, &gedp->ged_wdbp->wdb_initial_tree_state, gedp->ged_gvp, gedp->ged_create_vlist_callback);
1278  if (ret < 0) {
1280  "%s: %s redraw failure\n", argv[0], argv[i]);
1281  return GED_ERROR;
1282  }
1283  break;
1284  }
1285  db_free_full_path(&dl_path);
1286  }
1287 
1288  db_free_full_path(&obj_path);
1289 
1290  if (!found_path) {
1292  "%s: %s is not being displayed\n", argv[0], argv[i]);
1293  return GED_ERROR;
1294  }
1295  }
1296  }
1297 
1298  return GED_OK;
1299 }
1300 
1301 /*
1302  * Local Variables:
1303  * tab-width: 8
1304  * mode: C
1305  * indent-tabs-mode: t
1306  * c-file-style: "stroustrup"
1307  * End:
1308  * ex: shiftwidth=4 tabstop=8
1309  */
void usage(struct ged *gedp)
Definition: coil.c:315
#define GED_OK
Definition: ged.h:55
int wireframe_color_override
Definition: ged_private.h:104
char * d_namep
pointer to name string
Definition: raytrace.h:859
#define BU_LIST_FOR(p, structure, hp)
Definition: list.h:365
struct model ** ts_m
ptr to ptr to NMG "model"
Definition: raytrace.h:1072
void db_add_node_to_full_path(struct db_full_path *pp, struct directory *dp)
Definition: db_fullpath.c:54
void bu_log(const char *,...) _BU_ATTR_PRINTF12
Definition: log.c:176
#define RT_CHECK_DBI(_p)
Definition: raytrace.h:828
int rt_db_get_internal(struct rt_db_internal *ip, const struct directory *dp, const struct db_i *dbip, const mat_t mat, struct resource *resp)
Definition: dir.c:76
void rt_vlblock_free(struct bn_vlblock *vbp)
Definition: vlist.c:78
int bn_mat_is_identity(const mat_t m)
Definition: mat.c:980
Definition: list.h:118
struct display_list * gdlp
Definition: bview.h:266
struct nmgregion * td_r
ptr to NMG region
Definition: raytrace.h:1168
void db_pr_tree_state(const struct db_tree_state *tsp)
Definition: db_tree.c:155
#define _GED_SHADED_MODE_BOTS
Definition: ged_private.h:59
void db_dup_full_path(struct db_full_path *newp, const struct db_full_path *oldp)
Definition: db_fullpath.c:87
#define OP_NOP
Leaf with no effect.
Definition: raytrace.h:1132
int rt_brep_plot(struct bu_list *vhead, struct rt_db_internal *ip, const struct rt_tess_tol *ttol, const struct bn_tol *tol, const struct rt_view_info *info)
Definition: brep.cpp:4245
Definition: ged.h:338
int invent_solid(struct bu_list *hdlp, struct db_i *dbip, void(*callback_create)(struct display_list *), void(*callback_free)(unsigned int, int), char *name, struct bu_list *vhead, long int rgb, int copy, fastf_t transparency, int dmode, struct solid *freesolid, int csoltab)
void nmg_vlblock_r(struct bn_vlblock *vbp, const struct nmgregion *r, int fancy)
Definition: nmg_plot.c:1186
struct db_i * dbip
Definition: raytrace.h:1266
Definition: clone.c:90
union tree * nmg_booltree_leaf_tnurb(struct db_tree_state *tsp, const struct db_full_path *pathp, struct rt_db_internal *ip, void *client_data)
Definition: nmg_bool.c:1241
void bu_vls_strcat(struct bu_vls *vp, const char *s)
Definition: vls.c:368
#define OP_NMG_TESS
Leaf: tr_stp -> nmgregion.
Definition: raytrace.h:1137
void * freesolid
Definition: bview.h:273
int bu_avs_add(struct bu_attribute_value_set *avp, const char *attribute, const char *value)
Definition: avs.c:78
void bu_vls_trunc(struct bu_vls *vp, int len)
Definition: vls.c:198
#define ID_BOT
Bag o' triangles.
Definition: raytrace.h:488
#define BU_LIST_IS_EMPTY(hp)
Definition: list.h:295
#define GED_CHECK_ARGC_GT_0(_gedp, _argc, _flags)
Definition: ged.h:202
struct directory * db_lookup(const struct db_i *, const char *name, int noisy)
Definition: db_lookup.c:153
struct solid * freesolid
Definition: ged_private.h:121
#define RT_CK_COMB(_p)
Definition: raytrace.h:955
int draw_solid_lines_only
Definition: bview.h:267
struct display_list * dl_addToDisplay(struct bu_list *hdlp, struct db_i *dbip, const char *name)
Definition: display_list.c:42
int shade_per_vertex_normals
Definition: ged_private.h:112
Definition: bview.h:209
struct rt_wdb * ged_wdbp
Definition: ged.h:340
char * bu_optarg
Definition: globals.c:91
Header file for the BRL-CAD common definitions.
#define _GED_DRAW_NMG_POLY
Definition: ged_private.h:66
int bu_optind
Definition: globals.c:89
#define DB_FULL_PATH_CUR_DIR(_pp)
Definition: db_fullpath.h:51
#define RT_DIR_REGION
region
Definition: raytrace.h:885
void(* ged_free_vlist_callback)(unsigned int, int)
function to call after freeing a vlist
Definition: ged.h:371
int ged_ev(struct ged *gedp, int argc, const char *argv[])
Definition: draw.c:1219
long * rgb
rgb[max] variable size array
Definition: vlist.h:173
#define ID_COMBINATION
Combination Record.
Definition: raytrace.h:499
int ged_redraw(struct ged *gedp, int argc, const char *argv[])
Definition: draw.c:1225
struct bn_vlblock * rt_vlblock_init(void)
Definition: vlist.c:71
int rt_brep_plot_poly(struct bu_list *vhead, const struct db_full_path *pathp, struct rt_db_internal *ip, const struct rt_tess_tol *ttol, const struct bn_tol *tol, const struct rt_view_info *info)
Definition: brep.cpp:4350
#define _GED_WIREFRAME
Definition: ged_private.h:58
#define BU_LIST_NON_EMPTY(hp)
Definition: list.h:296
int bu_getopt(int nargc, char *const nargv[], const char *ostr)
Definition: getopt.c:43
void db_full_path_init(struct db_full_path *pathp)
Definition: db_fullpath.c:40
int wireframe_color[3]
Definition: ged_private.h:105
int wireframe_color_override
Definition: bview.h:268
struct bu_list * gd_headDisplay
head of display list
Definition: ged.h:307
void rt_pr_tree(const union tree *tp, int lvl)
#define GED_ERROR
Definition: ged.h:61
struct bu_list * head
head[max] variable size array
Definition: vlist.h:174
struct bview * ged_gvp
Definition: ged.h:361
void * bu_malloc(size_t siz, const char *str)
Definition: malloc.c:314
Definition: ptbl.h:62
struct solid * freesolid
Definition: ged.h:345
int db_full_path_match_top(const struct db_full_path *a, const struct db_full_path *b)
Definition: db_fullpath.c:559
int ged_brep(struct ged *gedp, int argc, const char *argv[])
Definition: brep.c:176
char * strchr(const char *sp, int c)
int idb_major_type
Definition: raytrace.h:192
void bu_vls_free(struct bu_vls *vp)
Definition: vls.c:248
int ged_autoview(struct ged *gedp, int argc, const char *argv[])
Definition: autoview.c:39
int rt_bot_plot_poly(struct bu_list *vhead, struct rt_db_internal *ip, const struct rt_tess_tol *ttol, const struct bn_tol *tol)
Definition: bot.c:681
void * memset(void *s, int c, size_t n)
struct ged * gedp
Definition: ged_private.h:102
struct resource rt_uniresource
default. Defined in librt/globals.c
Definition: globals.c:41
#define GED_CHECK_DATABASE_OPEN(_gedp, _flags)
Definition: ged.h:114
#define RT_G_DEBUG
Definition: raytrace.h:1718
#define OP_DB_LEAF
Leaf of combination, db fmt.
Definition: raytrace.h:1139
int ged_draw(struct ged *gedp, int argc, const char *argv[])
Definition: draw.c:1212
void * bu_calloc(size_t nelem, size_t elsize, const char *str)
Definition: malloc.c:321
#define _GED_BOOL_EVAL
Definition: ged_private.h:61
void _ged_drawH_part2(int dashflag, struct bu_list *vhead, const struct db_full_path *pathp, struct db_tree_state *tsp, struct _ged_client_data *dgcdp)
Definition: draw.c:164
#define RT_DIR_SOLID
this name is a solid
Definition: raytrace.h:883
int db_string_to_path(struct db_full_path *pp, const struct db_i *dbip, const char *str)
Definition: db_fullpath.c:361
struct db_i * ts_dbip
Definition: raytrace.h:1040
#define BU_PTBL_GET(ptbl, i)
Definition: ptbl.h:108
struct bu_ptbl * db_lookup_by_attr(struct db_i *dbip, int dir_flags, struct bu_attribute_value_set *avs, int op)
Definition: db_lookup.c:386
void bu_avs_add_nonunique(struct bu_attribute_value_set *avsp, const char *attribute, const char *value)
Definition: avs.c:287
int wireframe_color[3]
Definition: bview.h:269
#define RT_DB_INTERNAL_INIT(_p)
Definition: raytrace.h:199
#define LOOKUP_QUIET
Definition: raytrace.h:893
#define bu_strlcpy(dst, src, size)
Definition: str.h:60
struct display_list * gdlp
Definition: ged_private.h:103
void db_free_full_path(struct db_full_path *pp)
Definition: db_fullpath.c:473
#define RT_CK_TESS_TOL(_p)
Definition: raytrace.h:184
mat_t ts_mat
transform matrix
Definition: raytrace.h:1050
void nmg_km(struct model *m)
Definition: nmg_mk.c:1634
void db_free_tree(union tree *tp, struct resource *resp)
Definition: db_tree.c:1296
void(* ged_create_vlist_callback)(struct display_list *)
function to call after creating a vlist
Definition: ged.h:370
union tree * nmg_booltree_leaf_tess(struct db_tree_state *tsp, const struct db_full_path *pathp, struct rt_db_internal *ip, void *client_data)
Definition: nmg_bool.c:1175
int do_not_draw_nmg_solids_during_debugging
Definition: ged_private.h:115
void dl_erasePathFromDisplay(struct bu_list *hdlp, struct db_i *dbip, void(*callback)(unsigned int, int), const char *path, int allow_split, struct solid *freesolid)
Definition: display_list.c:204
int ged_kill(struct ged *gedp, int argc, const char *argv[])
Definition: kill.c:37
matp_t tl_mat
xform matp, NULL ==> identity
Definition: raytrace.h:1173
#define _GED_SHADED_MODE_ALL
Definition: ged_private.h:60
int rt_pg_plot_poly(struct bu_list *vhead, struct rt_db_internal *ip, const struct rt_tess_tol *ttol, const struct bn_tol *tol)
Definition: poly.c:519
void dl_add_path(struct display_list *gdlp, int dashflag, int transparency, int dmode, int hiddenLine, struct bu_list *vhead, const struct db_full_path *pathp, struct db_tree_state *tsp, unsigned char *wireframe_color_override, void(*callback)(struct display_list *), struct solid *freesolid)
Definition: display_list.c:670
char * tl_name
Name of this leaf (bu_strdup'ed)
Definition: raytrace.h:1174
int gv_adaptive_plot
Definition: bview.h:255
#define GED_CHECK_DRAWABLE(_gedp, _flags)
Definition: ged.h:129
#define UNUSED(parameter)
Definition: common.h:239
char * bu_vls_strdup(const struct bu_vls *vp)
Definition: vls.c:274
void nmg_triangulate_model(struct model *m, const struct bn_tol *tol)
Definition: nmg_tri.c:3818
goto out
Definition: nmg_mod.c:3846
struct bu_vls dl_path
Definition: bview.h:48
void bn_mat_mul(mat_t o, const mat_t a, const mat_t b)
void bu_avs_init(struct bu_attribute_value_set *avp, size_t len, const char *str)
Definition: avs.c:47
#define BN_CK_TOL(_p)
Definition: tol.h:82
char * db_path_to_string(const struct db_full_path *pp)
Definition: db_fullpath.c:191
char * bu_vls_addr(const struct bu_vls *vp)
Definition: vls.c:111
struct tree::tree_nmgregion tr_d
struct bu_vls * ged_result_str
Definition: ged.h:357
struct resource * ts_resp
Per-CPU data.
Definition: raytrace.h:1074
#define _GED_DRAW_WIREFRAME
Definition: ged_private.h:65
void nmg_r_to_vlist(struct bu_list *vhead, const struct nmgregion *r, int poly_markers)
Definition: nmg_plot.c:404
#define ID_BREP
B-rep object.
Definition: raytrace.h:509
int rt_pg_plot(struct bu_list *vhead, struct rt_db_internal *ip, const struct rt_tess_tol *ttol, const struct bn_tol *tol, const struct rt_view_info *info)
Definition: poly.c:489
struct ged_drawable * ged_gdp
Definition: ged.h:360
#define BU_PTBL_LEN(ptbl)
Definition: ptbl.h:107
void bu_ptbl_free(struct bu_ptbl *b)
Definition: ptbl.c:226
union tree * append_solid_to_display_list(struct db_tree_state *tsp, const struct db_full_path *pathp, struct rt_db_internal *ip, void *client_data)
Definition: display_list.c:946
void _ged_cvt_vlblock_to_solids(struct ged *gedp, struct bn_vlblock *vbp, const char *name, int copy)
Definition: draw.c:554
#define RT_CK_DBI(_p)
Definition: raytrace.h:829
#define RT_CK_FULL_PATH(_p)
Definition: db_fullpath.h:59
struct model * nmg_mm(void)
Definition: nmg_mk.c:235
fastf_t transparency
Definition: ged_private.h:118
struct tree::tree_db_leaf tr_l
#define BU_LIST_INIT(_hp)
Definition: list.h:148
#define RT_DIR_COMB
combination
Definition: raytrace.h:884
#define RT_CK_RESOURCE(_p)
Definition: raytrace.h:1490
int64_t bu_gettime(void)
Definition: timer.c:42
const struct rt_tess_tol * ts_ttol
Tessellation tolerance.
Definition: raytrace.h:1070
struct db_tree_state wdb_initial_tree_state
Definition: raytrace.h:1267
#define RT_CK_DBTS(_p)
Definition: raytrace.h:1084
#define _GED_SHADED_MODE_EVAL
Definition: ged_private.h:63
#define RT_GET_TREE(_tp, _res)
Definition: raytrace.h:1210
union tree * tree
Leading to tree_db_leaf leaves.
Definition: raytrace.h:938
#define BU_UNSETJUMP
Definition: parallel.h:193
#define ID_POLY
Polygonal faceted object.
Definition: raytrace.h:466
void bu_vls_printf(struct bu_vls *vls, const char *fmt,...) _BU_ATTR_PRINTF23
Definition: vls.c:694
#define LOOKUP_NOISY
Definition: raytrace.h:892
int gd_shaded_mode
1 - draw bots shaded by default
Definition: ged.h:330
#define GED_HELP
Definition: ged.h:62
int idb_minor_type
ID_xxx.
Definition: raytrace.h:193
#define _GED_SHADED_MODE_UNSET
Definition: ged_private.h:57
void bu_free(void *ptr, const char *str)
Definition: malloc.c:328
#define RT_CK_TREE(_p)
Definition: raytrace.h:1182
#define BU_SETJUMP
Definition: parallel.h:192
struct bn_vlblock * draw_edge_uses_vbp
Definition: ged_private.h:116
size_t bu_argv_from_string(char *argv[], size_t lim, char *lp)
Definition: argv.c:32
int transparency
Definition: bview.h:270
#define BU_VLS_INIT_ZERO
Definition: vls.h:84
#define GED_DISPLAY_LIST_NULL
Definition: ged.h:73
int db_walk_tree(struct db_i *dbip, int argc, const char **argv, int ncpu, const struct db_tree_state *init_state, int(*reg_start_func)(struct db_tree_state *, const struct db_full_path *, const struct rt_comb_internal *, void *client_data), union tree *(*reg_end_func)(struct db_tree_state *, const struct db_full_path *, union tree *, void *client_data), union tree *(*leaf_func)(struct db_tree_state *, const struct db_full_path *, struct rt_db_internal *, void *client_data), void *client_data)
int tl_op
leaf, OP_DB_LEAF
Definition: raytrace.h:1172
int dl_redraw(struct display_list *gdlp, struct db_i *dbip, struct db_tree_state *tsp, struct bview *gvp, void(*callback)(struct display_list *))
Definition: display_list.c:933
#define DEBUG_TREEWALK
22 Database tree traversal
Definition: raytrace.h:107
int ged_draw_guts(struct ged *gedp, int argc, const char *argv[], int kind)
Definition: draw.c:969
int ged_make_name(struct ged *gedp, int argc, const char *argv[])
Definition: make_name.c:31
int d_flags
flags
Definition: raytrace.h:869
Definition: vls.h:56
int db_follow_path_for_state(struct db_tree_state *tsp, struct db_full_path *pathp, const char *orig_str, int noisy)
Definition: db_tree.c:839
int nmg_boolean(union tree *tp, struct model *m, const struct bn_tol *tol, struct resource *resp)
Definition: nmg_bool.c:1523
const struct bn_tol * ts_tol
Math tolerance.
Definition: raytrace.h:1071
void bu_vls_putc(struct bu_vls *vp, int c)
Definition: vls.c:666
void bu_avs_free(struct bu_attribute_value_set *avp)
Definition: avs.c:235
void rt_db_free_internal(struct rt_db_internal *ip)
Definition: dir.c:216
int _ged_drawtrees(struct ged *gedp, int argc, const char *argv[], int kind, struct _ged_client_data *_dgcdp)
Definition: draw.c:581
size_t nused
Definition: vlist.h:171
#define bu_strdup(s)
Definition: str.h:71
int rt_bot_plot(struct bu_list *vhead, struct rt_db_internal *ip, const struct rt_tess_tol *ttol, const struct bn_tol *tol, const struct rt_view_info *info)
Definition: bot.c:653