BRL-CAD
misc.h
Go to the documentation of this file.
1/* T C L C A D / M I S C . H
2 * BRL-CAD
3 *
4 * Copyright (c) 2004-2023 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 libtclcad */
21/** @{ */
22/** @file tclcad/misc.h
23 *
24 * @brief
25 * Miscellaneous header file for the BRL-CAD TclCAD Library, LIBTCLCAD.
26 *
27 */
28
29#ifndef TCLCAD_MISC_H
30#define TCLCAD_MISC_H
31
32#include "common.h"
33#include "bu/process.h"
34#include "tcl.h"
35#include "dm.h"
36#include "ged.h"
37#include "tclcad/defines.h"
38
39__BEGIN_DECLS
40
42 struct ged *gedp;
45
46 // These are view related, but appear to be intended as global across all
47 // views associated with the gedp - that is why they are here and not in
48 // tclcad_view_data.
52};
53
54struct tclcad_obj {
55 struct bu_list l;
56 struct ged *to_gedp;
57 Tcl_Interp *to_interp;
58};
59
60#define TCLCAD_OBJ_NULL (struct tclcad_obj *)0
61
62TCLCAD_EXPORT extern void tclcad_bn_mat_print(Tcl_Interp *interp, const char *title, const mat_t m);
63
64/**
65 * Allow specification of a ray to trace, in two convenient formats.
66 *
67 * Examples -
68 * {0 0 0} dir {0 0 -1}
69 * {20 -13.5 20} at {10 .5 3}
70 */
71TCLCAD_EXPORT extern int tclcad_rt_parse_ray(Tcl_Interp *interp,
72 struct xray *rp,
73 const char *const*argv);
74
75
76/**
77 * Format a "union cutter" structure in a TCL-friendly format. Useful
78 * for debugging space partitioning
79 *
80 * Examples -
81 * type cutnode
82 * type boxnode
83 */
84TCLCAD_EXPORT extern void tclcad_rt_pr_cutter(Tcl_Interp *interp,
85 const union cutter *cutp);
86TCLCAD_EXPORT extern int tclcad_rt_cutter(ClientData clientData,
87 Tcl_Interp *interp,
88 int argc,
89 const char *const*argv);
90
91
92/**
93 * Format a hit in a TCL-friendly format.
94 *
95 * It is possible that a solid may have been removed from the
96 * directory after this database was prepped, so check pointers
97 * carefully.
98 *
99 * It might be beneficial to use some format other than %g to give the
100 * user more precision.
101 */
102TCLCAD_EXPORT extern void tclcad_rt_pr_hit(Tcl_Interp *interp, struct hit *hitp, const struct seg *segp, int flipflag);
103
104
105/**
106 * Generic interface for the LIBRT_class manipulation routines.
107 *
108 * Usage:
109 * procname dbCmdName ?args?
110 * Returns: result of cmdName LIBRT operation.
111 *
112 * Objects of type 'procname' must have been previously created by the
113 * 'rt_gettrees' operation performed on a database object.
114 *
115 * Example -
116 * .inmem rt_gettrees .rt all.g
117 * .rt shootray {0 0 0} dir {0 0 -1}
118 */
119TCLCAD_EXPORT extern int tclcad_rt(ClientData clientData,
120 Tcl_Interp *interp,
121 int argc,
122 const char **argv);
123
124/************************************************************************************************
125 * *
126 * Tcl interface to the Database *
127 * *
128 ************************************************************************************************/
129
130/**
131 * Given the name of a database object or a full path to a leaf
132 * object, obtain the internal form of that leaf. Packaged separately
133 * mainly to make available nice Tcl error handling.
134 *
135 * Returns -
136 * TCL_OK
137 * TCL_ERROR
138 */
139TCLCAD_EXPORT extern int tclcad_rt_import_from_path(Tcl_Interp *interp,
140 struct rt_db_internal *ip,
141 const char *path,
142 struct rt_wdb *wdb);
143
144/**
145 * Take a db_full_path and append it to the TCL result string.
146 *
147 * NOT moving to db_fullpath.h because it is evil Tcl_Interp api
148 */
149TCLCAD_EXPORT extern void db_full_path_appendresult(Tcl_Interp *interp,
150 const struct db_full_path *pp);
151
152
153/**
154 * Expects the Tcl_obj argument (list) to be a Tcl list and extracts
155 * list elements, converts them to int, and stores them in the passed
156 * in array. If the array_len argument is zero, a new array of
157 * appropriate length is allocated. The return value is the number of
158 * elements converted.
159 */
160TCLCAD_EXPORT extern int tcl_obj_to_int_array(Tcl_Interp *interp,
161 Tcl_Obj *list,
162 int **array,
163 int *array_len);
164
165/**
166 * Expects the Tcl_obj argument (list) to be a Tcl list and extracts
167 * list elements, converts them to fastf_t, and stores them in the
168 * passed in array. If the array_len argument is zero, a new array of
169 * appropriate length is allocated. The return value is the number of
170 * elements converted.
171 */
172TCLCAD_EXPORT extern int tcl_obj_to_fastf_array(Tcl_Interp *interp,
173 Tcl_Obj *list,
174 fastf_t **array,
175 int *array_len);
176
177
178/**
179 * interface to above tcl_obj_to_int_array() routine. This routine
180 * expects a character string instead of a Tcl_Obj.
181 *
182 * Returns the number of elements converted.
183 */
184TCLCAD_EXPORT extern int tcl_list_to_int_array(Tcl_Interp *interp,
185 char *char_list,
186 int **array,
187 int *array_len);
188
189
190/**
191 * interface to above tcl_obj_to_fastf_array() routine. This routine
192 * expects a character string instead of a Tcl_Obj.
193 *
194 * returns the number of elements converted.
195 */
196TCLCAD_EXPORT extern int tcl_list_to_fastf_array(Tcl_Interp *interp,
197 const char *char_list,
198 fastf_t **array,
199 int *array_len);
200
201
202/* defined in tclcad_obj.c */
203TCLCAD_EXPORT extern int to_open_tcl(ClientData UNUSED(clientData),
204 Tcl_Interp *interp,
205 int argc,
206 const char **argv);
207TCLCAD_EXPORT extern struct application *to_rt_gettrees_application(struct ged *gedp,
208 int argc,
209 const char *argv[]);
210
211/**
212 * Tcl specific I/O handlers
213 */
215 Tcl_Interp *interp;
217 void *state;
218};
219TCLCAD_EXPORT struct tclcad_io_data *
221TCLCAD_EXPORT void
223
224TCLCAD_EXPORT void
226TCLCAD_EXPORT void
228
229__END_DECLS
230
231#endif /* TCLCAD_MISC_H */
232
233/** @} */
234/*
235 * Local Variables:
236 * mode: C
237 * tab-width: 8
238 * indent-tabs-mode: t
239 * c-file-style: "stroustrup"
240 * End:
241 * ex: shiftwidth=4 tabstop=8
242 */
Header file for the BRL-CAD common definitions.
bu_process_io_t
Definition: process.h:55
#define UNUSED(parameter)
Definition: common.h:334
void(* ged_io_func_t)(void *, int)
Definition: defines.h:85
int tclcad_rt(ClientData clientData, Tcl_Interp *interp, int argc, const char **argv)
struct application * to_rt_gettrees_application(struct ged *gedp, int argc, const char *argv[])
void tclcad_delete_io_handler(struct ged_subprocess *p, bu_process_io_t d)
int tcl_obj_to_int_array(Tcl_Interp *interp, Tcl_Obj *list, int **array, int *array_len)
int tclcad_rt_parse_ray(Tcl_Interp *interp, struct xray *rp, const char *const *argv)
void tclcad_rt_pr_cutter(Tcl_Interp *interp, const union cutter *cutp)
int tclcad_rt_cutter(ClientData clientData, Tcl_Interp *interp, int argc, const char *const *argv)
int tcl_list_to_int_array(Tcl_Interp *interp, char *char_list, int **array, int *array_len)
void db_full_path_appendresult(Tcl_Interp *interp, const struct db_full_path *pp)
void tclcad_rt_pr_hit(Tcl_Interp *interp, struct hit *hitp, const struct seg *segp, int flipflag)
int tclcad_rt_import_from_path(Tcl_Interp *interp, struct rt_db_internal *ip, const char *path, struct rt_wdb *wdb)
void tclcad_bn_mat_print(Tcl_Interp *interp, const char *title, const mat_t m)
struct tclcad_io_data * tclcad_create_io_data(void)
void tclcad_destroy_io_data(struct tclcad_io_data *d)
void tclcad_create_io_handler(struct ged_subprocess *p, bu_process_io_t d, ged_io_func_t callback, void *data)
int to_open_tcl(ClientData clientData, Tcl_Interp *interp, int argc, const char **argv)
int tcl_list_to_fastf_array(Tcl_Interp *interp, const char *char_list, fastf_t **array, int *array_len)
int tcl_obj_to_fastf_array(Tcl_Interp *interp, Tcl_Obj *list, fastf_t **array, int *array_len)
double fastf_t
fastest 64-bit (or larger) floating point type
Definition: vmath.h:330
fastf_t mat_t[ELEMENTS_PER_MAT]
4x4 matrix
Definition: vmath.h:366
Definition: list.h:131
Definition: vls.h:53
Definition: defines.h:195
Information about where a ray hits the surface.
Definition: hit.h:61
Definition: wdb.h:62
Definition: seg.h:59
struct bu_vls go_rt_end_callback
Definition: misc.h:49
int go_more_args_callback_cnt
Definition: misc.h:44
struct dm_view_data go_dmv
Definition: misc.h:51
struct ged * gedp
Definition: misc.h:42
struct bu_vls go_more_args_callback
Definition: misc.h:43
int go_rt_end_callback_cnt
Definition: misc.h:50
Tcl_Interp * interp
Definition: misc.h:215
void * state
Definition: misc.h:217
int io_mode
Definition: misc.h:216
Tcl_Interp * to_interp
Definition: misc.h:57
struct bu_list l
Definition: misc.h:55
struct ged * to_gedp
Definition: misc.h:56
Primary ray data structure.
Definition: xray.h:41
Definitions header file for the BRL-CAD TclCAD Library, LIBTCLCAD.