/* * * Usage: * procname getcursor */ HIDDEN int fbo_getcursor_tcl(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) { struct fb_obj *fbop = (struct fb_obj *)clientData; int status; int mode; int x, y; struct bu_vls vls; if (argc != 2) { bu_vls_init(&vls); bu_vls_printf(&vls, "helplib fb_getcursor"); Tcl_Eval(interp, bu_vls_addr(&vls)); bu_vls_free(&vls); return TCL_ERROR; } status = fb_getcursor(fbop->fbo_fbs.fbs_fbp, &mode, &x, &y); if (status == 0) { bu_vls_init(&vls); bu_vls_printf(&vls, "%d %d %d", mode, x, y); Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL); bu_vls_free(&vls); return TCL_OK; } return TCL_ERROR; }
HIDDEN struct bu_cmdhist_obj * cho_open(ClientData UNUSED(clientData), Tcl_Interp *interp, const char *name) { struct bu_cmdhist_obj *chop; /* check to see if command history object exists */ for (BU_LIST_FOR(chop, bu_cmdhist_obj, &HeadCmdHistObj.l)) { if (BU_STR_EQUAL(name, bu_vls_addr(&chop->cho_name))) { Tcl_AppendResult(interp, "ch_open: ", name, " exists.\n", (char *)NULL); return BU_CMDHIST_OBJ_NULL; } } BU_GET(chop, struct bu_cmdhist_obj); bu_vls_init(&chop->cho_name); bu_vls_strcpy(&chop->cho_name, name); BU_LIST_INIT(&chop->cho_head.l); bu_vls_init(&chop->cho_head.h_command); chop->cho_head.h_start.tv_sec = chop->cho_head.h_start.tv_usec = chop->cho_head.h_finish.tv_sec = chop->cho_head.h_finish.tv_usec = 0L; chop->cho_head.h_status = TCL_OK; chop->cho_curr = &chop->cho_head; BU_LIST_APPEND(&HeadCmdHistObj.l, &chop->l); return chop; }
/* FIXME: not verified in the least bit */ static int create_cyl(point_line_t **plta, int count) { int i; point_line_t *plt = NULL; struct bu_vls vls; struct bu_vls vls2; bu_vls_init(&vls); bu_vls_init(&vls2); for (i = 0; i < count; i++) { plt = &(*plta)[i]; if (plt && plt->type) bu_vls_printf(&vls, "{ %f %f %f } ", plt->val[X], plt->val[Y], plt->val[Z]); } bu_vls_printf(&vls2, "cylinder { %S }", &vls); #if PRINT_SCRIPT fprintf(stderr, "%s\n", bu_vls_addr(&vls2)); #endif #if RUN_SCRIPT Tcl_Eval(twerp, bu_vls_addr(&vls2)); if (twerp->result[0] != '\0') bu_log("create_cyl failure: %s\n", twerp->result); else bu_log("create_cyl created\n"); #endif return 1; }
static int X_dm(int argc, char *argv[]) { if (!strcmp(argv[0], "set")) { struct bu_vls vls; bu_vls_init(&vls); if (argc < 2) { /* Bare set command, print out current settings */ bu_vls_struct_print2(&vls, "dm_X internal variables", X_vparse, (const char *)dmp ); } else if (argc == 2) { bu_vls_struct_item_named(&vls, X_vparse, argv[1], (const char *)dmp, ','); } else { struct bu_vls tmp_vls; bu_vls_init(&tmp_vls); bu_vls_printf(&tmp_vls, "%s=\"", argv[1]); bu_vls_from_argv(&tmp_vls, argc-2, (const char **)argv+2); bu_vls_putc(&tmp_vls, '\"'); bu_struct_parse(&tmp_vls, X_vparse, (char *)dmp); bu_vls_free(&tmp_vls); } Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL); bu_vls_free(&vls); return TCL_OK; } return common_dm(argc, argv); }
static void _bu_add_to_list(const char *fn, int fd) { struct _bu_tf_list *newtf; _bu_temp_files++; if (_bu_temp_files == 1) { /* schedule files for closure on exit */ atexit(_bu_close_files); BU_GETSTRUCT(_bu_tf, _bu_tf_list); BU_LIST_INIT(&(_bu_tf->l)); bu_vls_init(&_bu_tf->fn); bu_vls_strcpy(&_bu_tf->fn, fn); _bu_tf->fd = fd; return; } BU_GETSTRUCT(newtf, _bu_tf_list); bu_vls_init(&_bu_tf->fn); bu_vls_strcpy(&_bu_tf->fn, fn); newtf->fd = fd; BU_LIST_PUSH(&(_bu_tf->l), &(newtf->l)); return; }
int main(int argc, char *argv[]) { FILE *inputFile, *outputFile; void *parser; int tokenID; perplex_t scanner; token_t *tokenData; app_data_t appData; if (argc != 3) { fprintf(stderr, "Usage: %s input output", argv[0]); exit(1); } inputFile = fopen(argv[1], "r"); outputFile = fopen(argv[2], "w"); scanner = perplexFileScanner(inputFile); perplexSetExtra(scanner, &appData); appData.outfile = outputFile; appData.doc_comment = 0; appData.tag_text = 0; appData.example_text = 0; appData.return_text = 0; bu_vls_init(&appData.description); bu_vls_init(&appData.tags); parser = ParseAlloc(parse_alloc); BU_GET(tokenData, token_t); bu_vls_init(&tokenData->value); appData.tokenData = tokenData; while ((tokenID = yylex(scanner)) != YYEOF) { Parse(parser, tokenID, tokenData, &appData); BU_GET(tokenData, token_t); bu_vls_init(&tokenData->value); appData.tokenData = tokenData; } Parse(parser, 0, tokenData, &appData); ParseFree(parser, free); perplexFree(scanner); fclose(inputFile); fclose(outputFile); return 0; }
int X_dm_init(struct dm_list *o_dm_list, int argc, char *argv[]) { struct bu_vls vls; dm_var_init(o_dm_list); /* register application provided routines */ cmd_hook = X_dm; Tk_DeleteGenericHandler(doEvent, (ClientData)NULL); if ((dmp = dm_open(interp, DM_TYPE_X, argc-1, argv)) == DM_NULL) return TCL_ERROR; /* keep display manager in sync */ dmp->dm_perspective = mged_variables->mv_perspective_mode; eventHandler = X_doevent; Tk_CreateGenericHandler(doEvent, (ClientData)NULL); (void)DM_CONFIGURE_WIN(dmp); bu_vls_init(&vls); bu_vls_printf(&vls, "mged_bind_dm %s", bu_vls_addr(&pathName)); Tcl_Eval(interp, bu_vls_addr(&vls)); bu_vls_free(&vls); return TCL_OK; }
int Wgl_dm_init(struct dm_list *o_dm_list, int argc, char *argv[]) { struct bu_vls vls; dm_var_init(o_dm_list); /* register application provided routines */ cmd_hook = Wgl_dm; Tk_DeleteGenericHandler(doEvent, (ClientData)NULL); if ((dmp = dm_open(interp, DM_TYPE_WGL, argc-1, argv)) == DM_NULL) return TCL_ERROR; /*XXXX this eventually needs to move into Wgl's private structure */ dmp->dm_vp = &view_state->vs_vop->vo_scale; dmp->dm_perspective = mged_variables->mv_perspective_mode; eventHandler = Wgl_doevent; Tk_CreateGenericHandler(doEvent, (ClientData)NULL); (void)DM_CONFIGURE_WIN(dmp); bu_vls_init(&vls); bu_vls_printf(&vls, "mged_bind_dm %s", bu_vls_addr(&pathName)); Tcl_Eval(interp, bu_vls_addr(&vls)); bu_vls_free(&vls); return TCL_OK; }
/* * P L O T _ L O A D M A T R I X * * Load a new transformation matrix. This will be followed by * many calls to plot_drawVList(). */ static int plot_loadMatrix(struct dm *dmp, fastf_t *mat, int which_eye) { Tcl_Obj *obj; obj = Tcl_GetObjResult(dmp->dm_interp); if (Tcl_IsShared(obj)) obj = Tcl_DuplicateObj(obj); if (((struct plot_vars *)dmp->dm_vars.priv_vars)->debug) { struct bu_vls tmp_vls; Tcl_AppendStringsToObj(obj, "plot_loadMatrix()\n", (char *)NULL); bu_vls_init(&tmp_vls); bu_vls_printf(&tmp_vls, "which eye = %d\t", which_eye); bu_vls_printf(&tmp_vls, "transformation matrix = \n"); bu_vls_printf(&tmp_vls, "%g %g %g %g\n", mat[0], mat[4], mat[8], mat[12]); bu_vls_printf(&tmp_vls, "%g %g %g %g\n", mat[1], mat[5], mat[9], mat[13]); bu_vls_printf(&tmp_vls, "%g %g %g %g\n", mat[2], mat[6], mat[10], mat[14]); bu_vls_printf(&tmp_vls, "%g %g %g %g\n", mat[3], mat[7], mat[11], mat[15]); Tcl_AppendStringsToObj(obj, bu_vls_addr(&tmp_vls), (char *)NULL); bu_vls_free(&tmp_vls); } MAT_COPY(plotmat, mat); Tcl_SetObjResult(dmp->dm_interp, obj); return TCL_OK; }
/** * initialize the name list used for stashing destination names */ static void init_list(struct nametbl *l, size_t s) { size_t i, j; l->names = (struct name *)bu_calloc(10, sizeof(struct name), "alloc l->names"); for (i = 0; i < 10; i++) { bu_vls_init(&l->names[i].src); l->names[i].dest = (struct bu_vls *)bu_calloc(s, sizeof(struct bu_vls), "alloc l->names.dest"); for (j = 0; j < s; j++) bu_vls_init(&l->names[i].dest[j]); } l->name_size = s; l->names_len = 10; l->names_used = 0; }
/* * Usage: * procname configure width height */ int fbo_configure_tcl(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) { struct fb_obj *fbop = (struct fb_obj *)clientData; int width, height; if (argc != 4) { struct bu_vls vls; bu_vls_init(&vls); bu_vls_printf(&vls, "helplib fb_configure"); Tcl_Eval(interp, bu_vls_addr(&vls)); bu_vls_free(&vls); return TCL_ERROR; } if (sscanf(argv[2], "%d", &width) != 1) { Tcl_AppendResult(interp, "fb_configure: bad width - ", argv[2], (char *)NULL); return TCL_ERROR; } if (sscanf(argv[3], "%d", &height) != 1) { Tcl_AppendResult(interp, "fb_configure: bad height - ", argv[3], (char *)NULL); return TCL_ERROR; } /* configure the framebuffer window */ if (fbop->fbo_fbs.fbs_fbp != FBIO_NULL) fb_configureWindow(fbop->fbo_fbs.fbs_fbp, width, height); return TCL_OK; }
/* * Refresh the entire framebuffer or that part specified by * a rectangle (i.e. x y width height) * Usage: * procname refresh [rect] */ HIDDEN int fbo_refresh_tcl(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) { struct fb_obj *fbop = (struct fb_obj *)clientData; int x, y, w, h; /* rectangle to be refreshed */ if (argc < 2 || 3 < argc) { struct bu_vls vls; bu_vls_init(&vls); bu_vls_printf(&vls, "helplib fb_refresh"); Tcl_Eval(interp, bu_vls_addr(&vls)); bu_vls_free(&vls); return TCL_ERROR; } if (argc == 2) { /* refresh the whole display */ x = y = 0; w = fbop->fbo_fbs.fbs_fbp->if_width; h = fbop->fbo_fbs.fbs_fbp->if_height; } else if (sscanf(argv[2], "%d %d %d %d", &x, &y, &w, &h) != 4) { /* refresh rectanglar area */ Tcl_AppendResult(interp, "fb_refresh: bad rectangle - ", argv[2], (char *)NULL); return TCL_ERROR; } #if 1 return fb_refresh(fbop->fbo_fbs.fbs_fbp, x, y, w, h); #else return fbop->fbo_fbs.fbs_fbp->if_refresh(fbop->fbo_fbs.fbs_fbp, x, y, w, h) #endif }
/** * b u _ v l s _ i n i t _ i f _ u n i n i t * * If a VLS is unitialized, initialize it. If it is already * initialized, leave it alone, caller wants to append to it. */ void bu_vls_init_if_uninit(register struct bu_vls *vp) { if (vp == (struct bu_vls *)NULL) bu_bomb("bu_vls_init_if_uninit() passed NULL pointer"); if ( vp->vls_magic == BU_VLS_MAGIC ) return; bu_vls_init( vp ); }
/** * b u _ v l s _ v l s i n i t * * Allocate storage for a struct bu_vls, call bu_vls_init on it, and * return the result. Allows for creation of dynamically allocated * VLS strings. */ struct bu_vls * bu_vls_vlsinit(void) { register struct bu_vls *vp; vp = (struct bu_vls *)bu_malloc(sizeof(struct bu_vls), "bu_vls_vlsinit struct"); bu_vls_init(vp); return vp; }
/* * * Usage: * procname getwidth */ HIDDEN int fbo_getwidth_tcl(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) { struct fb_obj *fbop = (struct fb_obj *)clientData; struct bu_vls vls; if (argc != 2) { bu_vls_init(&vls); bu_vls_printf(&vls, "helplib fb_getwidth"); Tcl_Eval(interp, bu_vls_addr(&vls)); bu_vls_free(&vls); return TCL_ERROR; } bu_vls_init(&vls); bu_vls_printf(&vls, "%d", fb_getwidth(fbop->fbo_fbs.fbs_fbp)); Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL); bu_vls_free(&vls); return TCL_OK; }
HIDDEN int txt_setup(register struct region *rp, struct bu_vls *matparm, void **dpp, const struct mfuncs *mfp, struct rt_i *rtip) { register struct txt_specific *tp; int pixelbytes = 3; BU_CK_VLS(matparm); BU_GET(tp, struct txt_specific); *dpp = tp; bu_vls_init(&tp->tx_name); /* defaults */ tp->tx_w = tp->tx_n = -1; tp->tx_trans_valid = 0; tp->tx_scale[X] = 1.0; tp->tx_scale[Y] = 1.0; tp->tx_mirror = 0; tp->tx_datasrc = 0; /* source is auto-located by default */ tp->tx_binunifp = NULL; tp->tx_mp = NULL; /* load given values */ if (bu_struct_parse(matparm, txt_parse, (char *)tp) < 0) { BU_PUT(tp, struct txt_specific); return -1; } /* validate values */ if (tp->tx_w < 0) tp->tx_w = 512; if (tp->tx_n < 0) tp->tx_n = tp->tx_w; if (tp->tx_trans_valid) rp->reg_transmit = 1; BU_CK_VLS(&tp->tx_name); if (bu_vls_strlen(&tp->tx_name) <= 0) return -1; /* !?! if (tp->tx_name[0] == '\0') return -1; */ /* FAIL, no file */ if (BU_STR_EQUAL(mfp->mf_name, "bwtexture")) pixelbytes = 1; /* load the texture from its datasource */ if (txt_load_datasource(tp, rtip->rti_dbip, tp->tx_w * tp->tx_n * pixelbytes)<0) { bu_log("\nERROR: txt_setup() %s %s could not be loaded [source was %s]\n", rp->reg_name, bu_vls_addr(&tp->tx_name), tp->tx_datasrc==TXT_SRC_OBJECT?"object":tp->tx_datasrc==TXT_SRC_FILE?"file":"auto"); return -1; } if (rdebug & RDEBUG_SHADE) { bu_log("txt_setup: texture loaded! type=%s name=%s\n", tp->tx_datasrc==TXT_SRC_AUTO?"auto":tp->tx_datasrc==TXT_SRC_OBJECT?"object":tp->tx_datasrc==TXT_SRC_FILE?"file":"unknown", bu_vls_addr(&tp->tx_name)); bu_struct_print("texture", txt_parse, (char *)tp); } return 1; /* OK */ }
/** * add a new name to the name list */ static int add_to_list(struct nametbl *l, char *name) { size_t i, j; /* * add more slots if adding 1 more new name will fill up all the * available slots. */ if (l->names_len == (l->names_used+1)) { l->names_len += 10; l->names = (struct name *)bu_realloc(l->names, sizeof(struct name)*(l->names_len+1), "realloc l->names"); for (i = l->names_used; i < l->names_len; i++) { bu_vls_init(&l->names[i].src); l->names[i].dest = (struct bu_vls *)bu_calloc(l->name_size, sizeof(struct bu_vls), "alloc l->names.dest"); for (j = 0; j < l->name_size; j++) bu_vls_init(&l->names[i].dest[j]); } } bu_vls_strcpy(&l->names[l->names_used++].src, name); return l->names_used-1; /* return number of available slots */ }
/* * Listen for framebuffer clients. * * Usage: * procname listen port * * Returns the port number actually used. * */ HIDDEN int fbo_listen_tcl(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) { struct fb_obj *fbop = (struct fb_obj *)clientData; struct bu_vls vls; bu_vls_init(&vls); if (fbop->fbo_fbs.fbs_fbp == FBIO_NULL) { bu_vls_printf(&vls, "%s listen: framebuffer not open!\n", argv[0]); Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL); bu_vls_free(&vls); return TCL_ERROR; } /* return the port number */ if (argc == 2) { bu_vls_printf(&vls, "%d", fbop->fbo_fbs.fbs_listener.fbsl_port); Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL); bu_vls_free(&vls); return TCL_OK; } if (argc == 3) { int port; if (sscanf(argv[2], "%d", &port) != 1) { Tcl_AppendResult(interp, "listen: bad value - ", argv[2], "\n", (char *)NULL); return TCL_ERROR; } if (port >= 0) fbs_open(interp, &fbop->fbo_fbs, port); else { fbs_close(interp, &fbop->fbo_fbs); } bu_vls_printf(&vls, "%d", fbop->fbo_fbs.fbs_listener.fbsl_port); Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL); bu_vls_free(&vls); return TCL_OK; } bu_vls_printf(&vls, "helplib fb_listen"); Tcl_Eval(interp, bu_vls_addr(&vls)); bu_vls_free(&vls); return TCL_ERROR; }
HIDDEN void historyInit(void) { BU_LIST_INIT(&(histHead.l)); bu_vls_init(&(histHead.h_command)); histHead.h_start.tv_sec = histHead.h_start.tv_usec = histHead.h_finish.tv_sec = histHead.h_finish.tv_usec = 0L; histHead.h_status = TCL_OK; currHist = &histHead; #if 0 journalfp = NULL; #endif historyInitialized=1; }
/** * H I S T O R Y _ R E C O R D * * Stores the given command with start and finish times in the * history vls'es. 'status' is either BRLCAD_OK or BRLCAD_ERROR. */ HIDDEN void cmdhist_record(struct bu_cmdhist_obj *chop, struct bu_vls *cmdp, struct timeval *start, struct timeval *finish, int status) { struct bu_cmdhist *new_hist; const char *eol = "\n"; if (UNLIKELY(BU_STR_EQUAL(bu_vls_addr(cmdp), eol))) return; BU_ALLOC(new_hist, struct bu_cmdhist); bu_vls_init(&new_hist->h_command); bu_vls_vlscat(&new_hist->h_command, cmdp); new_hist->h_start = *start; new_hist->h_finish = *finish; new_hist->h_status = status; BU_LIST_INSERT(&chop->cho_head.l, &new_hist->l); chop->cho_curr = &chop->cho_head; }
/* * Close a framebuffer object. * * Usage: * procname close */ HIDDEN int fbo_close_tcl(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) { struct fb_obj *fbop = (struct fb_obj *)clientData; struct bu_vls vls; if (argc != 2) { bu_vls_init(&vls); bu_vls_printf(&vls, "helplib fb_close"); Tcl_Eval(interp, bu_vls_addr(&vls)); bu_vls_free(&vls); return TCL_ERROR; } /* Among other things, this will call dmo_deleteProc. */ Tcl_DeleteCommand(interp, bu_vls_addr(&fbop->fbo_name)); return TCL_OK; }
/* * * Usage: * procname flush */ HIDDEN int fbo_flush_tcl(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) { struct fb_obj *fbop = (struct fb_obj *)clientData; if (argc != 2) { struct bu_vls vls; bu_vls_init(&vls); bu_vls_printf(&vls, "helplib fb_flush"); Tcl_Eval(interp, bu_vls_addr(&vls)); bu_vls_free(&vls); return TCL_ERROR; } fb_flush(fbop->fbo_fbs.fbs_fbp); return TCL_OK; }
/* * E X T _ S E T U P * * Returns 0 on failure, 1 on success. */ HIDDEN int ext_setup(register struct region *rp, struct bu_vls *matparm, char **dpp, struct mfuncs *mf_p, struct rt_i *rtip, struct mfuncs **headp) /* parameter string */ /* pointer to user data pointer */ { struct bu_mapped_file *parameter_file; struct bu_vls parameter_data; char *filename; int status; RT_CHECK_RTI(rtip); BU_CK_VLS( matparm ); RT_CK_REGION(rp); filename = bu_vls_addr(matparm); parameter_file = bu_open_mapped_file( filename, (char *)NULL ); if (!parameter_file) { bu_log("cannot open external shader file \"%s\"\n", filename); bu_bomb("ext_setup()\n"); } bu_vls_init(¶meter_data); bu_vls_strncpy( ¶meter_data, (char *)parameter_file->buf, parameter_file->buflen ); if (rdebug&RDEBUG_SHADE ) { bu_log("ext_setup(%s): {%s}\n", filename, bu_vls_addr(¶meter_data)); } bu_close_mapped_file( parameter_file ); status = sh_stk_setup(rp, ¶meter_data, dpp, mf_p, rtip, headp); bu_vls_free( ¶meter_data ); return status; }
/* * Clear the framebuffer with the specified color. * Otherwise, clear the framebuffer with black. * * Usage: * procname clear [rgb] */ HIDDEN int fbo_clear_tcl(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) { struct fb_obj *fbop = (struct fb_obj *)clientData; int status; RGBpixel pixel; unsigned char *ms; if (argc < 2 || 3 < argc) { struct bu_vls vls; bu_vls_init(&vls); bu_vls_printf(&vls, "helplib fb_clear"); Tcl_Eval(interp, bu_vls_addr(&vls)); bu_vls_free(&vls); return TCL_ERROR; } if (argc == 3) { /* * Decompose the color list into its constituents. * For now must be in the form of rrr ggg bbb. */ if (fbo_tcllist2color(interp, argv[6], pixel) == TCL_ERROR) { Tcl_AppendResult(interp, "fb_cell: invalid color spec: ", argv[6], ".", (char *)NULL); return TCL_ERROR; } ms = pixel; } else ms = RGBPIXEL_NULL; status = fb_clear(fbop->fbo_fbs.fbs_fbp, ms); if (status < 0) return TCL_ERROR; return TCL_OK; }
int mk_dsp(struct rt_wdb *fp, const char *name, const char *file, size_t xdim, size_t ydim, const matp_t mat) /* name of file containing elevation data */ /* X dimension of file (w cells) */ /* Y dimension of file (n cells) */ /* convert solid coords to model space */ { struct rt_dsp_internal *dsp; BU_ALLOC(dsp, struct rt_dsp_internal); dsp->magic = RT_DSP_INTERNAL_MAGIC; bu_vls_init(&dsp->dsp_name); bu_vls_strcat(&dsp->dsp_name, file); dsp->dsp_xcnt = xdim; dsp->dsp_ycnt = ydim; MAT_COPY(dsp->dsp_stom, mat); return wdb_export(fp, name, (void *)dsp, ID_DSP, mk_conv2mm); }
HIDDEN void plot_obr(int test_num, const point_t *pnt_array, int pnt_cnt) { int i = 0; struct bu_vls name; FILE *plot_file = NULL; bu_vls_init(&name); bu_vls_printf(&name, "obr_test_%.3d.pl", test_num); plot_file = fopen(bu_vls_addr(&name), "w"); pl_color(plot_file, 0, 255, 0); for (i = 0; i < pnt_cnt; i++) { pdv_3move(plot_file, pnt_array[i]); if (i < pnt_cnt - 1) { pdv_3cont(plot_file, pnt_array[i+1]); } else { pdv_3cont(plot_file, pnt_array[0]); } } fclose(plot_file); bu_vls_free(&name); }
/* * H I S T O R Y _ R E C O R D * * Stores the given command with start and finish times in the * history vls'es. */ void history_record(struct bu_vls *cmdp, struct timeval *start, struct timeval *finish, int status) /* Either TCL_OK or TCL_ERROR */ { struct bu_cmdhist *new_hist; if (strcmp(bu_vls_addr(cmdp), "\n") == 0) return; new_hist = (struct bu_cmdhist *)bu_malloc(sizeof(struct bu_cmdhist), "mged history"); bu_vls_init(&(new_hist->h_command)); bu_vls_vlscat(&(new_hist->h_command), cmdp); new_hist->h_start = *start; new_hist->h_finish = *finish; new_hist->h_status = status; /* make sure the list is initialized before attempting to add this entry */ if (!historyInitialized) { historyInit(); } BU_LIST_INSERT(&(histHead.l), &(new_hist->l)); /* As long as this isn't our first command to record after setting up the journal (which would be "journal", which we don't want recorded!)... */ #if 0 if (journalfp != NULL && !firstjournal) history_journalize(new_hist); #endif currHist = &histHead; #if 0 firstjournal = 0; #endif }
/* * * Usage: * procname cursor mode x y */ HIDDEN int fbo_cursor_tcl(ClientData clientData, Tcl_Interp *interp, int argc, char **argv) { struct fb_obj *fbop = (struct fb_obj *)clientData; int mode; int x, y; int status; struct bu_vls vls; if (argc != 5) { bu_vls_init(&vls); bu_vls_printf(&vls, "helplib fb_cursor"); Tcl_Eval(interp, bu_vls_addr(&vls)); bu_vls_free(&vls); } if (sscanf(argv[2], "%d", &mode) != 1) { Tcl_AppendResult(interp, "fb_cursor: bad mode - ", argv[2], (char *)NULL); return TCL_ERROR; } if (sscanf(argv[3], "%d", &x) != 1) { Tcl_AppendResult(interp, "fb_cursor: bad x value - ", argv[3], (char *)NULL); return TCL_ERROR; } if (sscanf(argv[4], "%d", &y) != 1) { Tcl_AppendResult(interp, "fb_cursor: bad y value - ", argv[4], (char *)NULL); return TCL_ERROR; } status = fb_cursor(fbop->fbo_fbs.fbs_fbp, mode, x, y); if (status == 0) return TCL_OK; return TCL_ERROR; }
struct bu_vls * bu_units_strings_vls() { register const struct cvt_tab *tp; struct bu_vls *vlsp; double prev_val = 0.0; BU_ALLOC(vlsp, struct bu_vls); bu_vls_init(vlsp); for (tp=bu_units_length_tab; tp->name[0]; tp++) { if (ZERO(prev_val - tp->val)) continue; bu_vls_printf(vlsp, "%s, ", tp->name); prev_val = tp->val; } /* Remove the last ", " */ bu_vls_trunc(vlsp, -2); return vlsp; }
/** * b n _ p r _ p o l y * * Print out the polynomial. */ void bn_pr_poly(const char *title, register const struct bn_poly *eqn) { register int n; register int exp; struct bu_vls str; char buf[48]; bu_vls_init( &str ); bu_vls_extend( &str, 196 ); bu_vls_strcat( &str, title ); snprintf(buf, 48, " polynomial, degree = %d\n", eqn->dgr); bu_vls_strcat( &str, buf ); exp = eqn->dgr; for ( n=0; n<=eqn->dgr; n++, exp-- ) { register double coeff = eqn->cf[n]; if ( n > 0 ) { if ( coeff < 0 ) { bu_vls_strcat( &str, " - " ); coeff = -coeff; } else { bu_vls_strcat( &str, " + " ); } } bu_vls_printf( &str, "%g", coeff ); if ( exp > 1 ) { bu_vls_printf( &str, " *X^%d", exp ); } else if ( exp == 1 ) { bu_vls_strcat( &str, " *X" ); } else { /* For constant term, add nothing */ } } bu_vls_strcat( &str, "\n" ); bu_log( "%s", bu_vls_addr(&str) ); bu_vls_free( &str ); }