BRL-CAD
nirt.c
Go to the documentation of this file.
1 /* N I R T . C
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 libged */
21 /** @{ */
22 /** @file libged/nirt.c
23  *
24  * Routines to interface to nirt.
25  *
26  * This code was imported from the RTUIF and modified to work as part
27  * of the drawable geometry object.
28  *
29  */
30 /** @} */
31 
32 #include "common.h"
33 
34 #include <stdlib.h>
35 #include <string.h>
36 #include <math.h>
37 #include <signal.h>
38 #ifdef HAVE_SYS_TIME_H
39 # include <sys/time.h> /* For struct timeval */
40 #endif
41 #ifdef HAVE_SYS_TYPES_H
42 # include <sys/types.h>
43 #endif
44 #ifdef HAVE_SYS_WAIT_H
45 # include <sys/wait.h>
46 #endif
47 
48 #include "tcl.h"
49 
50 #include "bn.h"
51 #include "bu/cmd.h"
52 #include "vmath.h"
53 
54 
55 #include "./qray.h"
56 #include "./ged_private.h"
57 
58 
59 /**
60  * Invoke nirt with the current view & stuff
61  */
62 int
63 ged_nirt(struct ged *gedp, int argc, const char *argv[])
64 {
65  char **vp = NULL;
66  FILE *fp_in = NULL;
67  FILE *fp_out = NULL;
68  FILE *fp_err = NULL;
69  int ret;
70 #ifndef _WIN32
71  int pid = 0;
72  int rpid = 0;
73  int retcode = 0;
74  int pipe_in[2] = {0, 0};
75  int pipe_out[2] = {0, 0};
76  int pipe_err[2] = {0, 0};
77 #else
78  HANDLE pipe_in[2], pipe_inDup;
79  HANDLE pipe_out[2], pipe_outDup;
80  HANDLE pipe_err[2], pipe_errDup;
81  STARTUPINFO si;
82  PROCESS_INFORMATION pi;
83  SECURITY_ATTRIBUTES sa;
84  struct bu_vls line1 = BU_VLS_INIT_ZERO;
85 #endif
86  int use_input_orig = 0;
87  vect_t center_model;
88  vect_t dir;
89  vect_t cml;
90  double scan[4]; /* holds sscanf values */
91  int i = 9;
92  char line[RT_MAXLINE] = {0};
93  char *val = NULL;
94  struct bu_vls o_vls = BU_VLS_INIT_ZERO;
95  struct bu_vls p_vls = BU_VLS_INIT_ZERO;
96  struct bu_vls t_vls = BU_VLS_INIT_ZERO;
97  struct bn_vlblock *vbp = NULL;
98  struct qray_dataList *ndlp = NULL;
99  struct qray_dataList HeadQRayData;
100 
101  const char *bin = NULL;
102  char nirt[256] = {0};
103  size_t args;
104 
105  /* for bu_fgets space trimming */
106  struct bu_vls v = BU_VLS_INIT_ZERO;
107 
110  GED_CHECK_VIEW(gedp, GED_ERROR);
111  GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
112 
113  /* initialize result */
114  bu_vls_trunc(gedp->ged_result_str, 0);
115 
116  args = argc + 20 + 2 + ged_count_tops(gedp);
117  gedp->ged_gdp->gd_rt_cmd = (char **)bu_calloc(args, sizeof(char *), "alloc gd_rt_cmd");
118 
119  bin = bu_brlcad_root("bin", 1);
120  if (bin) {
121 #ifdef _WIN32
122  /* FIXME: is this really necessary? can we wrap command in
123  * quotes for all platforms?
124  */
125  snprintf(nirt, 256, "\"%s/%s\"", bin, argv[0]);
126 #else
127  snprintf(nirt, 256, "%s/%s", bin, argv[0]);
128 #endif
129  }
130 
131  vp = &gedp->ged_gdp->gd_rt_cmd[0];
132  *vp++ = nirt;
133 
134  /* swipe x, y, z off the end if present */
135  if (argc > 3) {
136  if (sscanf(argv[argc-3], "%lf", &scan[X]) == 1 &&
137  sscanf(argv[argc-2], "%lf", &scan[Y]) == 1 &&
138  sscanf(argv[argc-1], "%lf", &scan[Z]) == 1) {
139  use_input_orig = 1;
140  argc -= 3;
141  VSCALE(center_model, scan, gedp->ged_wdbp->dbip->dbi_local2base);
142  }
143  }
144 
145  /* Calculate point from which to fire ray */
146  if (!use_input_orig) {
147  VSET(center_model, -gedp->ged_gvp->gv_center[MDX],
148  -gedp->ged_gvp->gv_center[MDY], -gedp->ged_gvp->gv_center[MDZ]);
149  }
150 
151  VSCALE(cml, center_model, gedp->ged_wdbp->dbip->dbi_base2local);
152  VMOVEN(dir, gedp->ged_gvp->gv_rotation + 8, 3);
153  VSCALE(dir, dir, -1.0);
154 
155  bu_vls_printf(&p_vls, "xyz %lf %lf %lf;",
156  cml[X], cml[Y], cml[Z]);
157  bu_vls_printf(&p_vls, "dir %lf %lf %lf; s",
158  dir[X], dir[Y], dir[Z]);
159 
160  i = 0;
161  if (DG_QRAY_GRAPHICS(gedp->ged_gdp)) {
162 
163  *vp++ = "-e";
164  *vp++ = DG_QRAY_FORMAT_NULL;
165 
166  /* first ray ---- returns partitions */
167  *vp++ = "-e";
168  *vp++ = DG_QRAY_FORMAT_P;
169 
170  /* ray start, direction, and 's' command */
171  *vp++ = "-e";
172  *vp++ = bu_vls_addr(&p_vls);
173 
174  /* second ray ---- returns overlaps */
175  *vp++ = "-e";
176  *vp++ = DG_QRAY_FORMAT_O;
177 
178  /* ray start, direction, and 's' command */
179  *vp++ = "-e";
180  *vp++ = bu_vls_addr(&p_vls);
181 
182  if (DG_QRAY_TEXT(gedp->ged_gdp)) {
183  char *cp;
184  int count = 0;
185 
186  /* get 'r' format now; prepend its format string with a newline */
187  val = bu_vls_addr(&gedp->ged_gdp->gd_qray_fmts[0].fmt);
188 
189  /* find first '"' */
190  while (*val != '"' && *val != '\0')
191  ++val;
192 
193  if (*val == '\0')
194  goto done;
195  else
196  ++val; /* skip first '"' */
197 
198  /* find last '"' */
199  cp = (char *)strrchr(val, '"');
200 
201  if (cp != (char *)NULL) /* found it */
202  count = cp - val;
203 
204  done:
205  if (*val == '\0')
206  bu_vls_printf(&o_vls, " fmt r \"\\n\" ");
207  else {
208  struct bu_vls tmp = BU_VLS_INIT_ZERO;
209  bu_vls_strncpy(&tmp, val, count);
210  bu_vls_printf(&o_vls, " fmt r \"\\n%V\" ", (&tmp));
211  bu_vls_free(&tmp);
212 
213  if (count)
214  val += count + 1;
215  bu_vls_printf(&o_vls, "%s", val);
216  }
217 
218  i = 1;
219 
220  *vp++ = "-e";
221  *vp++ = bu_vls_addr(&o_vls);
222  }
223  }
224 
225  if (DG_QRAY_TEXT(gedp->ged_gdp)) {
226 
227  /* load vp with formats for printing */
228  for (; gedp->ged_gdp->gd_qray_fmts[i].type != (char)0; ++i)
229  bu_vls_printf(&t_vls, "fmt %c %s; ",
230  gedp->ged_gdp->gd_qray_fmts[i].type,
231  bu_vls_addr(&gedp->ged_gdp->gd_qray_fmts[i].fmt));
232 
233  *vp++ = "-e";
234  *vp++ = bu_vls_addr(&t_vls);
235 
236  /* nirt does not like the trailing ';' */
237  bu_vls_trunc(&t_vls, -2);
238  }
239 
240  /* include nirt script string */
241  if (bu_vls_strlen(&gedp->ged_gdp->gd_qray_script)) {
242  *vp++ = "-e";
243  *vp++ = bu_vls_addr(&gedp->ged_gdp->gd_qray_script);
244  }
245 
246  *vp++ = "-e";
247  *vp++ = bu_vls_addr(&p_vls);
248 
249  for (i = 1; i < argc; i++)
250  *vp++ = (char *)argv[i];
251  *vp++ = gedp->ged_wdbp->dbip->dbi_filename;
252 
253  gedp->ged_gdp->gd_rt_cmd_len = vp - gedp->ged_gdp->gd_rt_cmd;
254 
255  /* Note - ged_build_tops sets the last vp to (char *)0 */
256  gedp->ged_gdp->gd_rt_cmd_len += ged_build_tops(gedp, vp, &gedp->ged_gdp->gd_rt_cmd[args]);
257 
258  if (gedp->ged_gdp->gd_qray_cmd_echo) {
259  /* Print out the command we are about to run */
260  vp = &gedp->ged_gdp->gd_rt_cmd[0];
261 
262  while (*vp)
263  bu_vls_printf(gedp->ged_result_str, "%s ", *vp++);
264 
265  bu_vls_printf(gedp->ged_result_str, "\n");
266  }
267 
268  if (use_input_orig) {
269  bu_vls_printf(gedp->ged_result_str, "\nFiring from (%lf, %lf, %lf)...\n",
270  center_model[X], center_model[Y], center_model[Z]);
271  } else
272  bu_vls_printf(gedp->ged_result_str, "\nFiring from view center...\n");
273 
274 #ifndef _WIN32
275  ret = pipe(pipe_in);
276  if (ret < 0)
277  perror("pipe");
278  ret = pipe(pipe_out);
279  if (ret < 0)
280  perror("pipe");
281  ret = pipe(pipe_err);
282  if (ret < 0)
283  perror("pipe");
284 
285  (void)signal(SIGINT, SIG_IGN);
286  if ((pid = fork()) == 0) {
287  /* Redirect stdin, stdout, stderr */
288  (void)close(0);
289  ret = dup(pipe_in[0]);
290  if (ret < 0)
291  perror("dup");
292  (void)close(1);
293  ret = dup(pipe_out[1]);
294  if (ret < 0)
295  perror("dup");
296  (void)close(2);
297  ret = dup (pipe_err[1]);
298  if (ret < 0)
299  perror("dup");
300 
301  /* close pipes */
302  (void)close(pipe_in[0]);
303  (void)close(pipe_in[1]);
304  (void)close(pipe_out[0]);
305  (void)close(pipe_out[1]);
306  (void)close(pipe_err[0]);
307  (void)close(pipe_err[1]);
308  for (i = 3; i < 20; i++)
309  (void)close(i);
310  (void)signal(SIGINT, SIG_DFL);
311  (void)execvp(gedp->ged_gdp->gd_rt_cmd[0], gedp->ged_gdp->gd_rt_cmd);
312  perror (gedp->ged_gdp->gd_rt_cmd[0]);
313  exit(16);
314  }
315 
316  /* use fp_in to feed view info to nirt */
317  (void)close(pipe_in[0]);
318  fp_in = fdopen(pipe_in[1], "w");
319 
320  /* use fp_out to read back the result */
321  (void)close(pipe_out[1]);
322  fp_out = fdopen(pipe_out[0], "r");
323 
324  /* use fp_err to read any error messages */
325  (void)close(pipe_err[1]);
326  fp_err = fdopen(pipe_err[0], "r");
327 
328  /* send quit command to nirt */
329  ret = fwrite("q\n", 1, 2, fp_in);
330  if (ret != 2)
331  perror("fwrite");
332  (void)fclose(fp_in);
333 
334 #else
335  memset((void *)&si, 0, sizeof(STARTUPINFO));
336  memset((void *)&pi, 0, sizeof(PROCESS_INFORMATION));
337  memset((void *)&sa, 0, sizeof(SECURITY_ATTRIBUTES));
338 
339  sa.nLength = sizeof(sa);
340  sa.bInheritHandle = TRUE;
341  sa.lpSecurityDescriptor = NULL;
342 
343  /* Create a pipe for the child process's STDOUT. */
344  CreatePipe(&pipe_out[0], &pipe_out[1], &sa, 0);
345 
346  /* Create noninheritable read handle and close the inheritable read handle. */
347  DuplicateHandle(GetCurrentProcess(), pipe_out[0],
348  GetCurrentProcess(), &pipe_outDup ,
349  0, FALSE,
350  DUPLICATE_SAME_ACCESS);
351  CloseHandle(pipe_out[0]);
352 
353  /* Create a pipe for the child process's STDERR. */
354  CreatePipe(&pipe_err[0], &pipe_err[1], &sa, 0);
355 
356  /* Create noninheritable read handle and close the inheritable read handle. */
357  DuplicateHandle(GetCurrentProcess(), pipe_err[0],
358  GetCurrentProcess(), &pipe_errDup ,
359  0, FALSE,
360  DUPLICATE_SAME_ACCESS);
361  CloseHandle(pipe_err[0]);
362 
363  /* The steps for redirecting child process's STDIN:
364  * 1. Save current STDIN, to be restored later.
365  * 2. Create anonymous pipe to be STDIN for child process.
366  * 3. Set STDIN of the parent to be the read handle to the
367  * pipe, so it is inherited by the child process.
368  * 4. Create a noninheritable duplicate of the write handle,
369  * and close the inheritable write handle.
370  */
371 
372  /* Create a pipe for the child process's STDIN. */
373  CreatePipe(&pipe_in[0], &pipe_in[1], &sa, 0);
374 
375  /* Duplicate the write handle to the pipe so it is not inherited. */
376  DuplicateHandle(GetCurrentProcess(), pipe_in[1],
377  GetCurrentProcess(), &pipe_inDup,
378  0, FALSE, /* not inherited */
379  DUPLICATE_SAME_ACCESS);
380  CloseHandle(pipe_in[1]);
381 
382  si.cb = sizeof(STARTUPINFO);
383  si.lpReserved = NULL;
384  si.lpReserved2 = NULL;
385  si.cbReserved2 = 0;
386  si.lpDesktop = NULL;
387  si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
388  si.hStdInput = pipe_in[0];
389  si.hStdOutput = pipe_out[1];
390  si.hStdError = pipe_err[1];
391  si.wShowWindow = SW_HIDE;
392 
393  bu_vls_strcat(&line1, gedp->ged_gdp->gd_rt_cmd[0]);
394  bu_vls_strcat(&line1, " ");
395 
396  for (i = 1; i < gedp->ged_gdp->gd_rt_cmd_len; i++) {
397  /* skip commands */
398  if (BU_STR_EQUAL(gedp->ged_gdp->gd_rt_cmd[i], "-e")) {
399  ++i;
400  } else {
401  /* append other arguments (i.e. options, file and obj(s)) */
402  bu_vls_printf(&line1, "\"%s\" ", gedp->ged_gdp->gd_rt_cmd[i]);
403  }
404  }
405 
406  CreateProcess(NULL, bu_vls_addr(&line1), NULL, NULL, TRUE,
407  DETACHED_PROCESS, NULL, NULL,
408  &si, &pi);
409 
410  /* use fp_in to feed view info to nirt */
411  CloseHandle(pipe_in[0]);
412  fp_in = _fdopen(_open_osfhandle((intptr_t)pipe_inDup, _O_TEXT), "w");
413 
414  /* send commands down the pipe */
415  for (i = 1; i < gedp->ged_gdp->gd_rt_cmd_len - 2; i++)
416  if (strstr(gedp->ged_gdp->gd_rt_cmd[i], "-e") != NULL)
417  fprintf(fp_in, "%s\n", gedp->ged_gdp->gd_rt_cmd[++i]);
418 
419  /* use fp_out to read back the result */
420  CloseHandle(pipe_out[1]);
421  fp_out = _fdopen(_open_osfhandle((intptr_t)pipe_outDup, _O_TEXT), "r");
422 
423  /* use fp_err to read any error messages */
424  CloseHandle(pipe_err[1]);
425  fp_err = _fdopen(_open_osfhandle((intptr_t)pipe_errDup, _O_TEXT), "r");
426 
427  /* send quit command to nirt */
428  fwrite("q\n", 1, 2, fp_in);
429  (void)fclose(fp_in);
430 
431 #endif
432 
433  bu_vls_free(&p_vls); /* use to form "partition" part of nirt command above */
434  if (DG_QRAY_GRAPHICS(gedp->ged_gdp)) {
435 
436  if (DG_QRAY_TEXT(gedp->ged_gdp))
437  bu_vls_free(&o_vls); /* used to form "overlap" part of nirt command above */
438 
439  BU_LIST_INIT(&HeadQRayData.l);
440 
441  /* handle partitions */
442  while (bu_fgets(line, RT_MAXLINE, fp_out) != (char *)NULL) {
443  bu_vls_strcpy(&v, line);
444  bu_vls_trimspace(&v);
445 
446  if (line[0] == '\n' || line[0] == '\r') {
447  bu_vls_printf(gedp->ged_result_str, "%s", bu_vls_addr(&v));
448  break;
449  }
450 
451  BU_ALLOC(ndlp, struct qray_dataList);
452  BU_LIST_APPEND(HeadQRayData.l.back, &ndlp->l);
453 
454  ret = sscanf(bu_vls_addr(&v), "%le %le %le %le", &scan[0], &scan[1], &scan[2], &scan[3]);
455  ndlp->x_in = scan[0];
456  ndlp->y_in = scan[1];
457  ndlp->z_in = scan[2];
458  ndlp->los = scan[3];
459  if (ret != 4) {
460  bu_log("WARNING: Unexpected nirt line [%s]\nExpecting four numbers.\n", bu_vls_addr(&v));
461  break;
462  }
463  }
464 
465  vbp = rt_vlblock_init();
466  qray_data_to_vlist(gedp, vbp, &HeadQRayData, dir, 0);
467  bu_list_free(&HeadQRayData.l);
469  rt_vlblock_free(vbp);
470 
471  /* handle overlaps */
472  while (bu_fgets(line, RT_MAXLINE, fp_out) != (char *)NULL) {
473  bu_vls_strcpy(&v, line);
474  bu_vls_trimspace(&v);
475 
476  if (line[0] == '\n' || line[0] == '\r') {
477  bu_vls_printf(gedp->ged_result_str, "%s", bu_vls_addr(&v));
478  break;
479  }
480 
481  BU_ALLOC(ndlp, struct qray_dataList);
482  BU_LIST_APPEND(HeadQRayData.l.back, &ndlp->l);
483 
484  ret = sscanf(bu_vls_addr(&v), "%le %le %le %le", &scan[0], &scan[1], &scan[2], &scan[3]);
485  ndlp->x_in = scan[0];
486  ndlp->y_in = scan[1];
487  ndlp->z_in = scan[2];
488  ndlp->los = scan[3];
489  if (ret != 4) {
490  bu_log("WARNING: Unexpected nirt line [%s]\nExpecting four numbers.\n", bu_vls_addr(&v));
491  break;
492  }
493  }
494 
495  vbp = rt_vlblock_init();
496  qray_data_to_vlist(gedp, vbp, &HeadQRayData, dir, 1);
497  bu_list_free(&HeadQRayData.l);
499  rt_vlblock_free(vbp);
500  }
501 
502  if (DG_QRAY_TEXT(gedp->ged_gdp)) {
503  bu_vls_free(&t_vls);
504 
505  while (bu_fgets(line, RT_MAXLINE, fp_out) != (char *)NULL) {
506  bu_vls_strcpy(&v, line);
507  bu_vls_trimspace(&v);
508  bu_vls_printf(gedp->ged_result_str, "%s\n", bu_vls_addr(&v));
509  }
510  }
511 
512  (void)fclose(fp_out);
513 
514  while (bu_fgets(line, RT_MAXLINE, fp_err) != (char *)NULL) {
515  bu_vls_strcpy(&v, line);
516  bu_vls_trimspace(&v);
517  bu_vls_printf(gedp->ged_result_str, "%s\n", bu_vls_addr(&v));
518  }
519  (void)fclose(fp_err);
520 
521  bu_vls_free(&v);
522 
523 #ifndef _WIN32
524 
525  /* Wait for program to finish */
526  while ((rpid = wait(&retcode)) != pid && rpid != -1)
527  ; /* NULL */
528 
529  if (retcode != 0)
530  _ged_wait_status(gedp->ged_result_str, retcode);
531 #else
532  /* Wait for program to finish */
533  WaitForSingleObject(pi.hProcess, INFINITE);
534 
535  bu_vls_free(&line1);
536 #endif
537 
539 
540  bu_free(gedp->ged_gdp->gd_rt_cmd, "free gd_rt_cmd");
541  gedp->ged_gdp->gd_rt_cmd = NULL;
542 
543  return GED_OK;
544 }
545 
546 
547 int
548 ged_vnirt(struct ged *gedp, int argc, const char *argv[])
549 {
550  int i;
551  int status;
552  fastf_t sf = 1.0 * DG_INV_GED;
553  vect_t view_ray_orig;
554  vect_t center_model;
555  double scan[3];
556  struct bu_vls x_vls = BU_VLS_INIT_ZERO;
557  struct bu_vls y_vls = BU_VLS_INIT_ZERO;
558  struct bu_vls z_vls = BU_VLS_INIT_ZERO;
559  char **av;
560  static const char *usage = "vnirt options vX vY";
561 
564  GED_CHECK_VIEW(gedp, GED_ERROR);
565  GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
566 
567  /* initialize result */
568  bu_vls_trunc(gedp->ged_result_str, 0);
569 
570  /* must be wanting help */
571  if (argc == 1) {
572  bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
573  return GED_HELP;
574  }
575 
576  if (argc < 3) {
577  bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage);
578  return GED_ERROR;
579  }
580 
581  /*
582  * The last two arguments are expected to be x, y in view
583  * coordinates. It is also assumed that view z will be the front
584  * of the viewing cube. These coordinates are converted to x, y,
585  * z in model coordinates and then converted to local units before
586  * being handed to nirt. All other arguments are passed straight
587  * through to nirt.
588  */
589  if (sscanf(argv[argc-2], "%lf", &scan[X]) != 1 ||
590  sscanf(argv[argc-1], "%lf", &scan[Y]) != 1) {
591  return GED_ERROR;
592  }
593  scan[Z] = DG_GED_MAX;
594  argc -= 2;
595 
596  av = (char **)bu_calloc(1, sizeof(char *) * (argc + 4), "gd_vnirt_cmd: av");
597 
598  /* Calculate point from which to fire ray */
599  VSCALE(view_ray_orig, scan, sf);
600  MAT4X3PNT(center_model, gedp->ged_gvp->gv_view2model, view_ray_orig);
601  VSCALE(center_model, center_model, gedp->ged_wdbp->dbip->dbi_base2local);
602 
603  bu_vls_printf(&x_vls, "%lf", center_model[X]);
604  bu_vls_printf(&y_vls, "%lf", center_model[Y]);
605  bu_vls_printf(&z_vls, "%lf", center_model[Z]);
606 
607  /* pass remaining arguments to ged nirt command */
608  av[0] = "nirt";
609  for (i = 1; i < argc; ++i)
610  av[i] = (char *)argv[i];
611 
612  /* pass modified coordinates to nirt */
613  av[i++] = bu_vls_addr(&x_vls);
614  av[i++] = bu_vls_addr(&y_vls);
615  av[i++] = bu_vls_addr(&z_vls);
616  av[i] = (char *)NULL;
617 
618  status = ged_nirt(gedp, argc + 3, (const char **)av);
619 
620  bu_vls_free(&x_vls);
621  bu_vls_free(&y_vls);
622  bu_vls_free(&z_vls);
623  bu_free((void *)av, "ged_vnirt: av");
624  av = NULL;
625 
626  return status;
627 }
628 
629 
630 /*
631  * Local Variables:
632  * mode: C
633  * tab-width: 8
634  * indent-tabs-mode: t
635  * c-file-style: "stroustrup"
636  * End:
637  * ex: shiftwidth=4 tabstop=8
638  */
Definition: db_flip.c:35
void usage(struct ged *gedp)
Definition: coil.c:315
#define GED_OK
Definition: ged.h:55
#define FALSE
struct bu_vls fmt
Definition: ged.h:288
void bu_log(const char *,...) _BU_ATTR_PRINTF12
Definition: log.c:176
mat_t gv_center
Definition: bview.h:221
void rt_vlblock_free(struct bn_vlblock *vbp)
Definition: vlist.c:78
Definition: ged.h:338
struct db_i * dbip
Definition: raytrace.h:1266
size_t ged_count_tops(struct ged *gedp)
Definition: rt.c:409
#define DG_GED_MAX
Definition: ged_private.h:74
#define RT_MAXLINE
Definition: raytrace.h:1255
void bu_vls_strcat(struct bu_vls *vp, const char *s)
Definition: vls.c:368
#define VSET(a, b, c, d)
Definition: color.c:53
#define DG_QRAY_FORMAT_NULL
Definition: qray.h:41
fastf_t x_in
Definition: qray.h:53
#define DG_INV_GED
Definition: qray.h:43
void bu_vls_trunc(struct bu_vls *vp, int len)
Definition: vls.c:198
#define GED_CHECK_ARGC_GT_0(_gedp, _argc, _flags)
Definition: ged.h:202
void bu_vls_strncpy(struct bu_vls *vp, const char *s, size_t n)
Definition: vls.c:339
struct rt_wdb * ged_wdbp
Definition: ged.h:340
Header file for the BRL-CAD common definitions.
int ged_nirt(struct ged *gedp, int argc, const char *argv[])
Definition: nirt.c:63
#define BU_LIST_APPEND(old, new)
Definition: list.h:197
struct bn_vlblock * rt_vlblock_init(void)
Definition: vlist.c:71
struct ged_qray_fmt * gd_qray_fmts
Definition: ged.h:325
struct bu_list * gd_headDisplay
head of display list
Definition: ged.h:307
#define GED_ERROR
Definition: ged.h:61
struct bview * ged_gvp
Definition: ged.h:361
struct bu_vls gd_qray_script
query ray script
Definition: ged.h:322
void qray_data_to_vlist(struct ged *gedp, struct bn_vlblock *vbp, struct qray_dataList *headp, vect_t dir, int do_overlaps)
Definition: qray.c:471
struct bu_list l
Definition: qray.h:52
mat_t gv_view2model
Definition: bview.h:224
void bu_vls_free(struct bu_vls *vp)
Definition: vls.c:248
struct bu_vls gd_qray_basename
basename of query ray vlist
Definition: ged.h:321
#define DG_QRAY_TEXT(_dgop)
Definition: qray.h:34
Definition: color.c:49
void * memset(void *s, int c, size_t n)
#define GED_CHECK_VIEW(_gedp, _flags)
Definition: ged.h:140
#define GED_CHECK_DATABASE_OPEN(_gedp, _flags)
Definition: ged.h:114
int gd_rt_cmd_len
Definition: ged.h:313
char type
Definition: ged.h:287
FILE * fdopen(int, const char *)
#define BU_ALLOC(_ptr, _type)
Definition: malloc.h:223
void * bu_calloc(size_t nelem, size_t elsize, const char *str)
Definition: malloc.c:321
fastf_t z_in
Definition: qray.h:55
struct bu_list * back
"back", "last"
Definition: list.h:121
void dl_set_wflag(struct bu_list *hdlp, int wflag)
char ** gd_rt_cmd
Definition: ged.h:312
#define DG_QRAY_GRAPHICS(_dgop)
Definition: qray.h:35
size_t bu_vls_strlen(const struct bu_vls *vp)
Definition: vls.c:189
#define GED_CHECK_DRAWABLE(_gedp, _flags)
Definition: ged.h:129
void _ged_wait_status(struct bu_vls *logstr, int status)
Definition: rtcheck.c:80
char * bu_vls_addr(const struct bu_vls *vp)
Definition: vls.c:111
struct bu_vls * ged_result_str
Definition: ged.h:357
double dbi_base2local
unit conversion factors
Definition: raytrace.h:808
struct ged_drawable * ged_gdp
Definition: ged.h:360
void _ged_cvt_vlblock_to_solids(struct ged *gedp, struct bn_vlblock *vbp, const char *name, int copy)
Definition: draw.c:554
int gd_qray_cmd_echo
0 - don't echo command, 1 - echo command
Definition: ged.h:324
mat_t gv_rotation
Definition: bview.h:220
int ged_vnirt(struct ged *gedp, int argc, const char *argv[])
Definition: nirt.c:548
#define BU_LIST_INIT(_hp)
Definition: list.h:148
#define DG_QRAY_FORMAT_P
Definition: qray.h:39
HIDDEN fastf_t bin(fastf_t val, fastf_t step)
Definition: nmg_tri_mc.c:461
void bu_vls_printf(struct bu_vls *vls, const char *fmt,...) _BU_ATTR_PRINTF23
Definition: vls.c:694
#define GED_HELP
Definition: ged.h:62
fastf_t y_in
Definition: qray.h:54
void bu_vls_trimspace(struct bu_vls *vp)
Definition: vls.c:678
Definition: color.c:51
void bu_vls_strcpy(struct bu_vls *vp, const char *s)
Definition: vls.c:310
void bu_free(void *ptr, const char *str)
Definition: malloc.c:328
#define DG_QRAY_FORMAT_O
Definition: qray.h:40
double dbi_local2base
local2mm
Definition: raytrace.h:807
char * bu_fgets(char *s, int size, FILE *stream)
Definition: fgets.c:31
#define BU_VLS_INIT_ZERO
Definition: vls.h:84
#define DOWN
Definition: bview.h:42
void bu_list_free(struct bu_list *hd)
Definition: list.c:79
const char * bu_brlcad_root(const char *rhs, int fail_quietly)
Definition: brlcad_path.c:292
Definition: vls.h:56
char * dbi_filename
file name
Definition: raytrace.h:805
double fastf_t
Definition: defines.h:300
int ged_build_tops(struct ged *gedp, char **start, char **end)
Definition: rt.c:424
#define TRUE
Definition: color.c:50
fastf_t los
Definition: qray.h:56
#define BU_STR_EQUAL(s1, s2)
Definition: str.h:126