BRL-CAD
rrt.c
Go to the documentation of this file.
1 /* R R T . 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/rrt.c
21  *
22  * The rrt command.
23  *
24  */
25 
26 #include "common.h"
27 
28 #include <stdlib.h>
29 
30 #include "bu/cmd.h"
31 
32 
33 #include "./ged_private.h"
34 
35 
36 int
37 ged_rrt(struct ged *gedp, int argc, const char *argv[])
38 {
39  char **vp;
40  int i;
41  size_t args;
42 
46  GED_CHECK_ARGC_GT_0(gedp, argc, GED_ERROR);
47 
48  /* initialize result */
49  bu_vls_trunc(gedp->ged_result_str, 0);
50 
51  args = argc + 2 + ged_count_tops(gedp);
52  gedp->ged_gdp->gd_rt_cmd = (char **)bu_calloc(args, sizeof(char *), "alloc gd_rt_cmd");
53 
54  vp = &gedp->ged_gdp->gd_rt_cmd[0];
55  for (i = 1; i < argc; i++)
56  *vp++ = (char *)argv[i];
57  *vp++ = gedp->ged_wdbp->dbip->dbi_filename;
58 
59  _ged_current_gedp = gedp;
61 
62  (void)_ged_run_rt(gedp);
63 
64  bu_free(gedp->ged_gdp->gd_rt_cmd, "free gd_rt_cmd");
65 
66  return GED_OK;
67 }
68 
69 
70 /*
71  * Local Variables:
72  * tab-width: 8
73  * mode: C
74  * indent-tabs-mode: t
75  * c-file-style: "stroustrup"
76  * End:
77  * ex: shiftwidth=4 tabstop=8
78  */
#define GED_OK
Definition: ged.h:55
Definition: ged.h:338
struct db_i * dbip
Definition: raytrace.h:1266
size_t ged_count_tops(struct ged *gedp)
Definition: rt.c:409
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
struct rt_wdb * ged_wdbp
Definition: ged.h:340
Header file for the BRL-CAD common definitions.
#define GED_ERROR
Definition: ged.h:61
#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
int ged_rrt(struct ged *gedp, int argc, const char *argv[])
Definition: rrt.c:37
void * bu_calloc(size_t nelem, size_t elsize, const char *str)
Definition: malloc.c:321
char ** gd_rt_cmd
Definition: ged.h:312
#define GED_CHECK_DRAWABLE(_gedp, _flags)
Definition: ged.h:129
struct bu_vls * ged_result_str
Definition: ged.h:357
struct ged * _ged_current_gedp
Definition: loadview.c:37
struct ged_drawable * ged_gdp
Definition: ged.h:360
int _ged_run_rt(struct ged *gdp)
Definition: rt.c:244
void bu_free(void *ptr, const char *str)
Definition: malloc.c:328
char * dbi_filename
file name
Definition: raytrace.h:805
int ged_build_tops(struct ged *gedp, char **start, char **end)
Definition: rt.c:424