[brlcad-commits] SF.net SVN: brlcad: [31629] brlcad/trunk
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <bo...@us...> - 2008-06-26 17:25:13
|
Revision: 31629 http://brlcad.svn.sourceforge.net/brlcad/?rev=31629&view=rev Author: bob1961 Date: 2008-06-26 10:25:09 -0700 (Thu, 26 Jun 2008) Log Message: ----------- Added bu_structparse_get_terse_form() to libbu/parse.c. Added wdb_import_from_path to librt/wdb.c. Modified the adjust, get and form members of struct rt_functab (i.e. signature). Added four new commands to libged: adjust, form, get and put. Modified Paths: -------------- brlcad/trunk/include/bu.h brlcad/trunk/include/ged.h brlcad/trunk/include/raytrace.h brlcad/trunk/misc/win32-msvc8/brlcad/brlcad.sln brlcad/trunk/misc/win32-msvc8/libged/libged.vcproj brlcad/trunk/misc/win32-msvc8/librt/librt.vcproj brlcad/trunk/src/conv/g2asc.c brlcad/trunk/src/libbu/bu_tcl.c brlcad/trunk/src/libbu/parse.c brlcad/trunk/src/libged/Makefile.am brlcad/trunk/src/libged/wdb_obj.c brlcad/trunk/src/librt/db5_bin.c brlcad/trunk/src/librt/primitives/arbn/arbn.c brlcad/trunk/src/librt/primitives/ars/ars.c brlcad/trunk/src/librt/primitives/bot/bot.c brlcad/trunk/src/librt/primitives/bspline/bspline.c brlcad/trunk/src/librt/primitives/cline/cline.c brlcad/trunk/src/librt/primitives/dsp/dsp.c brlcad/trunk/src/librt/primitives/ebm/ebm.c brlcad/trunk/src/librt/primitives/extrude/extrude.c brlcad/trunk/src/librt/primitives/nmg/nmg.c brlcad/trunk/src/librt/primitives/pipe/pipe.c brlcad/trunk/src/librt/primitives/sketch/sketch.c brlcad/trunk/src/librt/table.c brlcad/trunk/src/librt/tcl.c brlcad/trunk/src/librt/wdb.c brlcad/trunk/src/libtclcad/ged_obj.c brlcad/trunk/src/mged/edsol.c Added Paths: ----------- brlcad/trunk/src/libged/adjust.c brlcad/trunk/src/libged/form.c brlcad/trunk/src/libged/get.c brlcad/trunk/src/libged/put.c Modified: brlcad/trunk/include/bu.h =================================================================== --- brlcad/trunk/include/bu.h 2008-06-26 16:24:57 UTC (rev 31628) +++ brlcad/trunk/include/bu.h 2008-06-26 17:25:09 UTC (rev 31629) @@ -173,6 +173,8 @@ #include "tcl.h" /* Included for Tcl_Interp definition */ #include "magic.h" +/*XXX Temporary global interp */ +BU_EXPORT Tcl_Interp *brlcad_interp; /** * B U _ F O R T R A N @@ -2254,6 +2256,9 @@ const struct bu_external *ip)); BU_EXPORT BU_EXTERN(char *bu_next_token, (char *str)); +BU_EXPORT BU_EXTERN(void bu_structparse_get_terse_form, + (struct bu_vls *log, + const struct bu_structparse *sp)); BU_EXPORT BU_EXTERN(int bu_structparse_argv, (struct bu_vls *log, int argc, Modified: brlcad/trunk/include/ged.h =================================================================== --- brlcad/trunk/include/ged.h 2008-06-26 16:24:57 UTC (rev 31628) +++ brlcad/trunk/include/ged.h 2008-06-26 17:25:09 UTC (rev 31629) @@ -900,6 +900,14 @@ GED_EXPORT BU_EXTERN(int ged_editit, (const char *file)); /** + * Adjust object's attribute(s) + * + * Usage: + * adjust object attr value ?attr value? + */ +GED_EXPORT BU_EXTERN(int ged_adjust, (struct ged *gedp, int argc, const char *argv[])); + +/** * Allow editing of the matrix, etc., along an arc. * * Usage: @@ -1006,6 +1014,22 @@ GED_EXPORT BU_EXTERN(int ged_erase_all, (struct ged *gedp, int argc, const char *argv[])); /** + * returns form for objects of type "type" + * + * Usage: + * form type + */ +GED_EXPORT BU_EXTERN(int ged_form, (struct ged *gedp, int argc, const char *argv[])); + +/** + * Get object attributes + * + * Usage: + * get object ?attr? + */ +GED_EXPORT BU_EXTERN(int ged_get, (struct ged *gedp, int argc, const char *argv[])); + +/** * Get view size and center such that all displayed solids would be in view * * Usage: @@ -1160,6 +1184,14 @@ GED_EXPORT BU_EXTERN(int ged_pathsum, (struct ged *gedp, int argc, const char *argv[])); /** + * Create a database object + * + * Usage: + * put object type attrs + */ +GED_EXPORT BU_EXTERN(int ged_put, (struct ged *gedp, int argc, const char *argv[])); + +/** * Get/set query_ray attributes * * Usage: Modified: brlcad/trunk/include/raytrace.h =================================================================== --- brlcad/trunk/include/raytrace.h 2008-06-26 16:24:57 UTC (rev 31628) +++ brlcad/trunk/include/raytrace.h 2008-06-26 17:25:09 UTC (rev 31629) @@ -1939,25 +1939,15 @@ const struct bu_structparse *ft_parsetab; /**< @brief rt_xxx_parse */ size_t ft_internal_size; /**< @brief sizeof(struct rt_xxx_internal) */ unsigned long ft_internal_magic; /**< @brief RT_XXX_INTERNAL_MAGIC */ -#if defined(TCL_OK) - int (*ft_tclget) BU_ARGS((Tcl_Interp *, - const struct rt_db_internal *, const char *item)); - int (*ft_tcladjust) BU_ARGS((Tcl_Interp *, - struct rt_db_internal *, - int /*argc*/, char ** /*argv*/, - struct resource * /*resp*/)); - int (*ft_tclform) BU_ARGS((const struct rt_functab *, - Tcl_Interp *)); -#else - int (*ft_tclget) BU_ARGS((genptr_t /*interp*/, - const struct rt_db_internal *, const char *item)); - int (*ft_tcladjust) BU_ARGS((genptr_t /*interp*/, - struct rt_db_internal *, - int /*argc*/, char ** /*argv*/, - struct resource * /*resp*/)); - int (*ft_tclform) BU_ARGS((const struct rt_functab *, - genptr_t /*interp*/)); -#endif + int (*ft_get) BU_ARGS((struct bu_vls *, + const struct rt_db_internal *, const char *item)); + int (*ft_adjust) BU_ARGS((struct bu_vls *, + struct rt_db_internal *, + int /*argc*/, char ** /*argv*/, + struct resource * /*resp*/)); + int (*ft_form) BU_ARGS((struct bu_vls *, + const struct rt_functab *)); + void (*ft_make) BU_ARGS((const struct rt_functab *, struct rt_db_internal *, double /*diameter*/)); int (*ft_params) BU_ARGS((struct pc_pc_set *,const struct rt_db_internal */*ip*/)); @@ -2547,10 +2537,15 @@ (struct rt_wdb *wdbp, struct db_i *dbip, int mode)); - RT_EXPORT BU_EXTERN(void wdb_close, (struct rt_wdb *wdbp)); +RT_EXPORT BU_EXTERN(int wdb_import_from_path, + (struct bu_vls *log, + struct rt_db_internal *ip, + const char *path, + struct rt_wdb *wdb)); + /* db_anim.c */ RT_EXPORT BU_EXTERN(struct animate *db_parse_1anim, (struct db_i *dbip, Modified: brlcad/trunk/misc/win32-msvc8/brlcad/brlcad.sln =================================================================== --- brlcad/trunk/misc/win32-msvc8/brlcad/brlcad.sln 2008-06-26 16:24:57 UTC (rev 31628) +++ brlcad/trunk/misc/win32-msvc8/brlcad/brlcad.sln 2008-06-26 17:25:09 UTC (rev 31629) @@ -354,7 +354,6 @@ Release.AspNetCompiler.Debug = "False" EndProjectSection ProjectSection(ProjectDependencies) = postProject - {7A073879-92A6-4934-B386-37AF30F27B38} = {7A073879-92A6-4934-B386-37AF30F27B38} {EA0BB405-25E2-4B31-92D7-97316770F32B} = {EA0BB405-25E2-4B31-92D7-97316770F32B} {2794FD11-F9A6-4145-92DE-A05F5A2E6361} = {2794FD11-F9A6-4145-92DE-A05F5A2E6361} {5118991D-8BCF-4FE4-981C-F33C9D500E95} = {5118991D-8BCF-4FE4-981C-F33C9D500E95} @@ -365,6 +364,8 @@ {E0756E58-9FF9-489C-8264-F39BF1A621AC} = {E0756E58-9FF9-489C-8264-F39BF1A621AC} {A0C3B415-61DD-4E5A-B724-D13AA64DA645} = {A0C3B415-61DD-4E5A-B724-D13AA64DA645} {39785814-94C1-4245-AA56-60ED2C0E1F41} = {39785814-94C1-4245-AA56-60ED2C0E1F41} + {E1CBDBEE-887A-4CD8-9D3E-59A52CA2E45E} = {E1CBDBEE-887A-4CD8-9D3E-59A52CA2E45E} + {7A073879-92A6-4934-B386-37AF30F27B38} = {7A073879-92A6-4934-B386-37AF30F27B38} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libtk", "..\libtk\libtk.vcproj", "{9C2287FD-4991-493F-81A4-41CAA48565CE}" @@ -1334,6 +1335,7 @@ Release.AspNetCompiler.Debug = "False" EndProjectSection ProjectSection(ProjectDependencies) = postProject + {EA0BB405-25E2-4B31-92D7-97316770F32B} = {EA0BB405-25E2-4B31-92D7-97316770F32B} {2794FD11-F9A6-4145-92DE-A05F5A2E6361} = {2794FD11-F9A6-4145-92DE-A05F5A2E6361} {5118991D-8BCF-4FE4-981C-F33C9D500E95} = {5118991D-8BCF-4FE4-981C-F33C9D500E95} {39172035-CC5F-4140-9118-E1A9AD311FC7} = {39172035-CC5F-4140-9118-E1A9AD311FC7} Modified: brlcad/trunk/misc/win32-msvc8/libged/libged.vcproj =================================================================== --- brlcad/trunk/misc/win32-msvc8/libged/libged.vcproj 2008-06-26 16:24:57 UTC (rev 31628) +++ brlcad/trunk/misc/win32-msvc8/libged/libged.vcproj 2008-06-26 17:25:09 UTC (rev 31629) @@ -126,6 +126,10 @@ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;f90;for;f;fpp" > <File + RelativePath="..\..\..\src\libged\adjust.c" + > + </File> + <File RelativePath="..\..\..\src\libged\arced.c" > </File> @@ -178,10 +182,18 @@ > </File> <File + RelativePath="..\..\..\src\libged\form.c" + > + </File> + <File RelativePath="..\..\..\src\libged\ged.c" > </File> <File + RelativePath="..\..\..\src\libged\get.c" + > + </File> + <File RelativePath="..\..\..\src\libged\get_autoview.c" > </File> @@ -266,6 +278,10 @@ > </File> <File + RelativePath="..\..\..\src\libged\put.c" + > + </File> + <File RelativePath="..\..\..\src\libged\qray.c" > </File> Modified: brlcad/trunk/misc/win32-msvc8/librt/librt.vcproj =================================================================== --- brlcad/trunk/misc/win32-msvc8/librt/librt.vcproj 2008-06-26 16:24:57 UTC (rev 31628) +++ brlcad/trunk/misc/win32-msvc8/librt/librt.vcproj 2008-06-26 17:25:09 UTC (rev 31629) @@ -680,6 +680,10 @@ > </File> <File + RelativePath="..\..\..\src\librt\primitives\revolve\revolve.c" + > + </File> + <File RelativePath="..\..\..\src\librt\primitives\rhc\rhc.c" > </File> Modified: brlcad/trunk/src/conv/g2asc.c =================================================================== --- brlcad/trunk/src/conv/g2asc.c 2008-06-26 16:24:57 UTC (rev 31628) +++ brlcad/trunk/src/conv/g2asc.c 2008-06-26 17:25:09 UTC (rev 31629) @@ -262,11 +262,18 @@ continue; } if ( dp->d_flags & DIR_COMB ) { - if ( intern.idb_meth->ft_tclget( interp, &intern, "tree" ) != TCL_OK ) { + struct bu_vls log; + + bu_vls_init(&log); + if ( intern.idb_meth->ft_get(&log, &intern, "tree" ) != TCL_OK ) { rt_db_free_internal( &intern, &rt_uniresource ); - bu_log("Unable to export '%s', skipping\n", dp->d_namep ); + bu_log("Unable to export '%s', skipping\n", dp->d_namep); + Tcl_AppendResult(interp, bu_vls_addr(&log), (char *)0); + bu_vls_free(&log); continue; } + Tcl_AppendResult(interp, bu_vls_addr(&log), (char *)0); + bu_vls_free(&log); if ( dp->d_flags & DIR_REGION ) { fprintf( ofp, "put {%s} comb region yes tree {%s}\n", tclify_name( dp->d_namep ), @@ -277,7 +284,7 @@ Tcl_GetStringResult(interp) ); } } else { - if ( dp->d_minor_type!= ID_CONSTRAINT && intern.idb_meth->ft_tclget( interp, &intern, NULL ) != TCL_OK ) { + if ( dp->d_minor_type!= ID_CONSTRAINT && intern.idb_meth->ft_get( interp, &intern, NULL ) != TCL_OK ) { rt_db_free_internal( &intern, &rt_uniresource ); bu_log("Unable to export '%s', skipping\n", dp->d_namep ); continue; Modified: brlcad/trunk/src/libbu/bu_tcl.c =================================================================== --- brlcad/trunk/src/libbu/bu_tcl.c 2008-06-26 16:24:57 UTC (rev 31628) +++ brlcad/trunk/src/libbu/bu_tcl.c 2008-06-26 17:25:09 UTC (rev 31629) @@ -42,6 +42,8 @@ #include "bn.h" #include "bu.h" +/*XXX Temporary global interp */ +Tcl_Interp *brlcad_interp = (Tcl_Interp *)0; #define TINYBUFSIZ 32 #define SMALLBUFSIZ 256 @@ -138,6 +140,14 @@ bu_tcl_structparse_get_terse_form(Tcl_Interp *interp, const struct bu_structparse *sp) { +#if 1 + struct bu_vls log; + + bu_vls_init(&log); + bu_structparse_get_terse_form(&log, sp); + Tcl_AppendResult(interp, bu_vls_addr(&log), (char *)NULL); + bu_vls_free(&log); +#else struct bu_vls str; int i; @@ -167,6 +177,7 @@ ++sp; } bu_vls_free(&str); +#endif } #if 0 @@ -1434,6 +1445,8 @@ void bu_tcl_setup(Tcl_Interp *interp) { + /*XXX Use of brlcad_interp is temporary */ + brlcad_interp = interp; bu_register_cmds(interp, bu_cmds); Tcl_SetVar(interp, "BU_DEBUG_FORMAT", BU_DEBUG_FORMAT, TCL_GLOBAL_ONLY); Modified: brlcad/trunk/src/libbu/parse.c =================================================================== --- brlcad/trunk/src/libbu/parse.c 2008-06-26 16:24:57 UTC (rev 31628) +++ brlcad/trunk/src/libbu/parse.c 2008-06-26 17:25:09 UTC (rev 31629) @@ -2208,6 +2208,43 @@ return( ret ); } +void +bu_structparse_get_terse_form(struct bu_vls *log, const struct bu_structparse *sp) +{ + struct bu_vls str; + int i; + + bu_vls_init(&str); + + while (sp->sp_name != NULL) { + bu_vls_printf(log, "%s ", sp->sp_name); + /* These types are specified by lengths, e.g. %80s */ + if (strcmp(sp->sp_fmt, "%c") == 0 || + strcmp(sp->sp_fmt, "%s") == 0 || + strcmp(sp->sp_fmt, "%S") == 0) { + if (sp->sp_count > 1) { + /* Make them all look like %###s */ + bu_vls_printf(log, "%%%lds", sp->sp_count); + } else { + /* Singletons are specified by their actual character */ + bu_vls_printf(log, "%%c"); + } + } else { + if (sp->sp_count < 2) { + bu_vls_printf(log, "%s ", sp->sp_fmt); + } else { + /* Vectors are specified by repetition, e.g. {%f %f %f} */ + bu_vls_printf(log, "{%s", sp->sp_fmt); + for (i = 1; i < sp->sp_count; i++) + bu_vls_printf(log, " %s", sp->sp_fmt); + bu_vls_printf(log, "} ", sp->sp_fmt); + } + } + ++sp; + } + bu_vls_free(&str); +} + /** * b u _ s p _ s k i p _ s e p * Modified: brlcad/trunk/src/libged/Makefile.am =================================================================== --- brlcad/trunk/src/libged/Makefile.am 2008-06-26 16:24:57 UTC (rev 31628) +++ brlcad/trunk/src/libged/Makefile.am 2008-06-26 17:25:09 UTC (rev 31629) @@ -3,6 +3,7 @@ noinst_LTLIBRARIES = libged_nil.la libged_nil_la_SOURCES = \ + adjust.c \ arced.c \ attr.c \ autoview.c \ @@ -16,7 +17,9 @@ edmater.c \ erase.c \ erase_all.c \ + form.c \ ged.c \ + get.c \ get_autoview.c \ get_eyemodel.c \ get_obj_bounds.c \ @@ -38,6 +41,7 @@ otranslate.c \ overlay.c \ pathsum.c \ + put.c \ qray.c \ rmater.c \ rt.c \ Added: brlcad/trunk/src/libged/adjust.c =================================================================== --- brlcad/trunk/src/libged/adjust.c (rev 0) +++ brlcad/trunk/src/libged/adjust.c 2008-06-26 17:25:09 UTC (rev 31629) @@ -0,0 +1,108 @@ +/* A D J U S T . C + * BRL-CAD + * + * Copyright (c) 2008 United States Government as represented by + * the U.S. Army Research Laboratory. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; see the file named COPYING for more + * information. + */ +/** @file adjust.c + * + * The adjust command. + * + */ + +#include "common.h" + +#include <stdlib.h> +#include <ctype.h> +#include <string.h> + +#include "ged.h" + + +int +ged_adjust(struct ged *gedp, int argc, const char *argv[]) +{ + int status; + register struct directory *dp; + char *name; + struct rt_db_internal intern; + static const char *usage = "object attr value ?attr value?"; + + GED_CHECK_DATABASE_OPEN(gedp, BRLCAD_ERROR); + GED_CHECK_READ_ONLY(gedp, BRLCAD_ERROR); + + /* initialize result */ + bu_vls_trunc(&gedp->ged_result_str, 0); + gedp->ged_result = GED_RESULT_NULL; + gedp->ged_result_flags = 0; + + /* must be wanting help */ + if (argc == 1) { + gedp->ged_result_flags |= GED_RESULT_FLAGS_HELP_BIT; + bu_vls_printf(&gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return BRLCAD_OK; + } + + if (argc < 4) { + bu_vls_printf(&gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return BRLCAD_ERROR; + } + + name = (char *)argv[1]; + + /* Verify that this wdb supports lookup operations (non-null dbip) */ + RT_CK_DBI(gedp->ged_wdbp->dbip); + + dp = db_lookup(gedp->ged_wdbp->dbip, name, LOOKUP_QUIET); + if (dp == DIR_NULL) { + bu_vls_printf(&gedp->ged_result_str, "%s: not found", name); + return BRLCAD_ERROR; + } + + if (rt_db_get_internal(&intern, dp, gedp->ged_wdbp->dbip, (matp_t)NULL, &rt_uniresource) < 0) { + bu_vls_printf(&gedp->ged_result_str, "rt_db_get_internal(%s) failure", name); + return BRLCAD_ERROR; + } + RT_CK_DB_INTERNAL(&intern); + + /* Find out what type of object we are dealing with and tweak it. */ + RT_CK_FUNCTAB(intern.idb_meth); + + status = intern.idb_meth->ft_adjust(&gedp->ged_result_str, &intern, argc-2, (char **)argv+2, &rt_uniresource); + if (status == BRLCAD_OK && wdb_put_internal(gedp->ged_wdbp, name, &intern, 1.0) < 0) { + bu_vls_printf(&gedp->ged_result_str, "wdb_export(%s) failure", name); + rt_db_free_internal(&intern, &rt_uniresource); + return BRLCAD_ERROR; + } + +#if 0 + /* notify observers */ + bu_observer_notify(interp, &wdbp->wdb_observers, bu_vls_addr(&wdbp->wdb_name)); +#endif + + return BRLCAD_OK; +} + + +/* + * Local Variables: + * tab-width: 8 + * mode: C + * indent-tabs-mode: t + * c-file-style: "stroustrup" + * End: + * ex: shiftwidth=4 tabstop=8 + */ Property changes on: brlcad/trunk/src/libged/adjust.c ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native Added: brlcad/trunk/src/libged/form.c =================================================================== --- brlcad/trunk/src/libged/form.c (rev 0) +++ brlcad/trunk/src/libged/form.c 2008-06-26 17:25:09 UTC (rev 31629) @@ -0,0 +1,77 @@ +/* F O R M . C + * BRL-CAD + * + * Copyright (c) 2008 United States Government as represented by + * the U.S. Army Research Laboratory. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; see the file named COPYING for more + * information. + */ +/** @file form.c + * + * The form command. + * + */ + +#include "common.h" + +#include <stdlib.h> +#include <ctype.h> +#include <string.h> + +#include "ged.h" + + +int +ged_form(struct ged *gedp, int argc, const char *argv[]) +{ + const struct rt_functab *ftp; + static const char *usage = "type"; + + GED_CHECK_DATABASE_OPEN(gedp, BRLCAD_ERROR); + + /* initialize result */ + bu_vls_trunc(&gedp->ged_result_str, 0); + gedp->ged_result = GED_RESULT_NULL; + gedp->ged_result_flags = 0; + + /* must be wanting help */ + if (argc == 1) { + gedp->ged_result_flags |= GED_RESULT_FLAGS_HELP_BIT; + bu_vls_printf(&gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return BRLCAD_OK; + } + + if (argc != 2) { + bu_vls_printf(&gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return BRLCAD_ERROR; + } + + if ((ftp = rt_get_functab_by_label(argv[1])) == NULL) { + bu_vls_printf(&gedp->ged_result_str, "There is no geometric object type \"%s\".", argv[1]); + return BRLCAD_ERROR; + } + + return ftp->ft_form(&gedp->ged_result_str, ftp); +} + + +/* + * Local Variables: + * tab-width: 8 + * mode: C + * indent-tabs-mode: t + * c-file-style: "stroustrup" + * End: + * ex: shiftwidth=4 tabstop=8 + */ Property changes on: brlcad/trunk/src/libged/form.c ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native Added: brlcad/trunk/src/libged/get.c =================================================================== --- brlcad/trunk/src/libged/get.c (rev 0) +++ brlcad/trunk/src/libged/get.c 2008-06-26 17:25:09 UTC (rev 31629) @@ -0,0 +1,86 @@ +/* G E T . C + * BRL-CAD + * + * Copyright (c) 2008 United States Government as represented by + * the U.S. Army Research Laboratory. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; see the file named COPYING for more + * information. + */ +/** @file get.c + * + * The get command. + * + */ + +#include "common.h" + +#include <stdlib.h> +#include <ctype.h> +#include <string.h> + +#include "ged.h" + + +int +ged_get(struct ged *gedp, int argc, const char *argv[]) +{ + int status; + struct rt_db_internal intern; + static const char *usage = "object ?attr?"; + + GED_CHECK_DATABASE_OPEN(gedp, BRLCAD_ERROR); + + /* initialize result */ + bu_vls_trunc(&gedp->ged_result_str, 0); + gedp->ged_result = GED_RESULT_NULL; + gedp->ged_result_flags = 0; + + /* must be wanting help */ + if (argc == 1) { + gedp->ged_result_flags |= GED_RESULT_FLAGS_HELP_BIT; + bu_vls_printf(&gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return BRLCAD_OK; + } + + if (argc < 2 || argc > 3) { + bu_vls_printf(&gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return BRLCAD_ERROR; + } + + /* Verify that this wdb supports lookup operations + (non-null dbip) */ + if (gedp->ged_wdbp->dbip == 0) { + bu_vls_printf(&gedp->ged_result_str, "dbip does not support lookup operations"); + return BRLCAD_ERROR; + } + + if (wdb_import_from_path(&gedp->ged_result_str, &intern, argv[1], gedp->ged_wdbp) == BRLCAD_ERROR) + return BRLCAD_ERROR; + + status = intern.idb_meth->ft_get(&gedp->ged_result_str, &intern, argv[2]); + rt_db_free_internal(&intern, &rt_uniresource); + + return status; +} + + +/* + * Local Variables: + * tab-width: 8 + * mode: C + * indent-tabs-mode: t + * c-file-style: "stroustrup" + * End: + * ex: shiftwidth=4 tabstop=8 + */ Property changes on: brlcad/trunk/src/libged/get.c ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native Added: brlcad/trunk/src/libged/put.c =================================================================== --- brlcad/trunk/src/libged/put.c (rev 0) +++ brlcad/trunk/src/libged/put.c 2008-06-26 17:25:09 UTC (rev 31629) @@ -0,0 +1,129 @@ +/* P U T . C + * BRL-CAD + * + * Copyright (c) 2008 United States Government as represented by + * the U.S. Army Research Laboratory. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this file; see the file named COPYING for more + * information. + */ +/** @file put.c + * + * The put command. + * + */ + +#include "common.h" + +#include <stdlib.h> +#include <ctype.h> +#include <string.h> + +#include "ged.h" + + +int +ged_put(struct ged *gedp, int argc, const char *argv[]) +{ + struct rt_db_internal intern; + register const struct rt_functab *ftp; + int i; + char *name; + char type[16]; + static const char *usage = "object type attrs"; + + GED_CHECK_DATABASE_OPEN(gedp, BRLCAD_ERROR); + GED_CHECK_READ_ONLY(gedp, BRLCAD_ERROR); + + /* initialize result */ + bu_vls_trunc(&gedp->ged_result_str, 0); + gedp->ged_result = GED_RESULT_NULL; + gedp->ged_result_flags = 0; + + /* must be wanting help */ + if (argc == 1) { + gedp->ged_result_flags |= GED_RESULT_FLAGS_HELP_BIT; + bu_vls_printf(&gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return BRLCAD_OK; + } + + if (argc < 3) { + bu_vls_printf(&gedp->ged_result_str, "Usage: %s %s", argv[0], usage); + return BRLCAD_ERROR; + } + + name = (char *)argv[1]; + + /* Verify that this wdb supports lookup operations (non-null dbip). + * stdout/file wdb objects don't, but can still be written to. + * If not, just skip the lookup test and write the object + */ + if (gedp->ged_wdbp->dbip && db_lookup(gedp->ged_wdbp->dbip, argv[1], LOOKUP_QUIET) != DIR_NULL) { + bu_vls_printf(&gedp->ged_result_str, "%s already exists", argv[1]); + return BRLCAD_ERROR; + } + + RT_INIT_DB_INTERNAL(&intern); + + for (i = 0; argv[2][i] != 0 && i < 16; i++) { + type[i] = isupper(argv[2][i]) ? tolower(argv[2][i]) : + argv[2][i]; + } + type[i] = 0; + + ftp = rt_get_functab_by_label(type); + if (ftp == NULL) { + bu_vls_printf(&gedp->ged_result_str, "%s is an unknown object type.", type); + return BRLCAD_ERROR; + } + + RT_CK_FUNCTAB(ftp); + + if (ftp->ft_make) { + if (ftp->ft_make == rt_nul_make) { + bu_vls_printf(&gedp->ged_result_str, + "wdb_put_internal(%s) cannot put a %s", + argv[1], type); + return BRLCAD_ERROR; + } + ftp->ft_make(ftp, &intern, 0.0); + } else { + rt_generic_make(ftp, &intern, 0.0); + } + + if (ftp->ft_adjust(&gedp->ged_result_str, &intern, argc-3, (char **)argv+3, &rt_uniresource) == BRLCAD_ERROR) { + rt_db_free_internal(&intern, &rt_uniresource); + return BRLCAD_ERROR; + } + + if (wdb_put_internal(gedp->ged_wdbp, name, &intern, 1.0) < 0) { + bu_vls_printf(&gedp->ged_result_str, "wdb_put_internal(%s)", argv[1]); + rt_db_free_internal(&intern, &rt_uniresource); + return BRLCAD_ERROR; + } + + rt_db_free_internal(&intern, &rt_uniresource); + + return BRLCAD_OK; +} + + +/* + * Local Variables: + * tab-width: 8 + * mode: C + * indent-tabs-mode: t + * c-file-style: "stroustrup" + * End: + * ex: shiftwidth=4 tabstop=8 + */ Property changes on: brlcad/trunk/src/libged/put.c ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native Modified: brlcad/trunk/src/libged/wdb_obj.c =================================================================== --- brlcad/trunk/src/libged/wdb_obj.c 2008-06-26 16:24:57 UTC (rev 31628) +++ brlcad/trunk/src/libged/wdb_obj.c 2008-06-26 17:25:09 UTC (rev 31629) @@ -842,7 +842,15 @@ if (rt_tcl_import_from_path(interp, &intern, argv[1], wdbp) == TCL_ERROR) return TCL_ERROR; - status = intern.idb_meth->ft_tclget(interp, &intern, argv[2]); + { + struct bu_vls log; + + bu_vls_init(&log); + status = intern.idb_meth->ft_get(&log, &intern, argv[2]); + Tcl_AppendResult(interp, bu_vls_addr(&log), (char *)NULL); + bu_vls_free(&log); + } + rt_db_free_internal(&intern, &rt_uniresource); return status; } @@ -1121,19 +1129,30 @@ rt_generic_make(ftp, &intern, 0.0); } - if (ftp->ft_tcladjust(interp, &intern, argc-3, argv+3, &rt_uniresource) == TCL_ERROR) { - rt_db_free_internal(&intern, &rt_uniresource); - return TCL_ERROR; + { + struct bu_vls log; + + bu_vls_init(&log); + + if (ftp->ft_adjust(&log, &intern, argc-3, argv+3, &rt_uniresource) == BRLCAD_ERROR) { + Tcl_AppendResult(interp, bu_vls_addr(&log), (char *)NULL); + bu_vls_free(&log); + rt_db_free_internal(&intern, &rt_uniresource); + return TCL_ERROR; + } + + Tcl_AppendResult(interp, bu_vls_addr(&log), (char *)NULL); + bu_vls_free(&log); } - if (wdb_put_internal(wdbp, name, &intern, 1.0) < 0) { + if (wdb_put_internal(wdbp, name, &intern, 1.0) < 0) { Tcl_AppendResult(interp, "wdb_put_internal(", argv[1], ") failure", (char *)NULL); rt_db_free_internal(&intern, &rt_uniresource); return TCL_ERROR; } - rt_db_free_internal( &intern, &rt_uniresource ); + rt_db_free_internal(&intern, &rt_uniresource); return TCL_OK; } @@ -1203,12 +1222,23 @@ /* Find out what type of object we are dealing with and tweak it. */ RT_CK_FUNCTAB(intern.idb_meth); - status = intern.idb_meth->ft_tcladjust(interp, &intern, argc-2, argv+2, &rt_uniresource); - if ( status == TCL_OK && wdb_put_internal(wdbp, name, &intern, 1.0) < 0) { - Tcl_AppendResult(interp, "wdb_export(", name, - ") failure", (char *)NULL); - rt_db_free_internal(&intern, &rt_uniresource); - return TCL_ERROR; + { + struct bu_vls log; + + bu_vls_init(&log); + status = intern.idb_meth->ft_adjust(&log, &intern, argc-2, argv+2, &rt_uniresource); + + if (status == BRLCAD_OK && wdb_put_internal(wdbp, name, &intern, 1.0) < 0) { + Tcl_AppendResult(interp, bu_vls_addr(&log), (char *)NULL); + bu_vls_free(&log); + Tcl_AppendResult(interp, "wdb_export(", name, + ") failure", (char *)NULL); + rt_db_free_internal(&intern, &rt_uniresource); + return TCL_ERROR; + } + + Tcl_AppendResult(interp, bu_vls_addr(&log), (char *)NULL); + bu_vls_free(&log); } /* notify observers */ @@ -1270,7 +1300,18 @@ argv[1], "\".", (char *)NULL); return TCL_ERROR; } - return ftp->ft_tclform(ftp, interp); + + { + int ret; + struct bu_vls log; + + bu_vls_init(&log); + ret = ftp->ft_form(&log, ftp); + Tcl_AppendResult(interp, bu_vls_addr(&log), (char *)NULL); + bu_vls_free(&log); + + return ret; + } } /** @@ -9054,7 +9095,7 @@ qsort((genptr_t)list_of_names, (unsigned)num_in_list, (unsigned)sizeof(struct directory *), - (int (*)())wdb_cmpdirname); + (int (*)(const void *, const void *))wdb_cmpdirname); /* * For the number of (full and partial) lines that will be needed, @@ -9110,7 +9151,7 @@ qsort((genptr_t)list_of_names, (unsigned)num_in_list, (unsigned)sizeof(struct directory *), - (int (*)())wdb_cmpdirname); + (int (*)(const void *, const void *))wdb_cmpdirname); /* * Traverse the list of names, find the longest name and set the @@ -9205,7 +9246,7 @@ qsort((genptr_t)list_of_names, (unsigned)num_in_list, (unsigned)sizeof(struct directory *), - (int (*)())wdb_cmpdirname); + (int (*)(const void *, const void *))wdb_cmpdirname); for (i=0; i < num_in_list; i++) { int len; @@ -9323,7 +9364,7 @@ qsort( (genptr_t)list_of_names, (unsigned)num_in_list, (unsigned)sizeof(struct directory *), - (int (*)())wdb_cmpdirname); + (int (*)(const void *, const void *))wdb_cmpdirname); /* * i - tracks the list item Modified: brlcad/trunk/src/librt/db5_bin.c =================================================================== --- brlcad/trunk/src/librt/db5_bin.c 2008-06-26 16:24:57 UTC (rev 31628) +++ brlcad/trunk/src/librt/db5_bin.c 2008-06-26 17:25:09 UTC (rev 31629) @@ -624,72 +624,60 @@ } int -rt_binunif_tclget(Tcl_Interp *interp, const struct rt_db_internal *intern, const char *attr ) +rt_binunif_get(struct bu_vls *log, const struct rt_db_internal *intern, const char *attr) { register struct rt_binunif_internal *bip=(struct rt_binunif_internal *)intern->idb_ptr; struct bu_external ext; - Tcl_DString ds; - struct bu_vls vls; - int status=TCL_OK; int i; - unsigned char *c; + unsigned char *c; RT_CHECK_BINUNIF( bip ); - Tcl_DStringInit( &ds ); - bu_vls_init( &vls ); - - if ( attr == (char *)NULL ) - { + if (attr == (char *)NULL) { /* export the object to get machine independent form */ if ( rt_binunif_export5( &ext, intern, 1.0, NULL, NULL, intern->idb_minor_type ) ) { - bu_vls_strcpy( &vls, "Failed to export binary object!!\n" ); - status = TCL_ERROR; + bu_vls_strcpy( log, "Failed to export binary object!!\n" ); + return BRLCAD_ERROR; } else { - bu_vls_strcpy( &vls, "binunif" ); - bu_vls_printf( &vls, " T %d D {", bip->type ); + bu_vls_strcpy( log, "binunif" ); + bu_vls_printf( log, " T %d D {", bip->type ); c = ext.ext_buf; for ( i=0; i<ext.ext_nbytes; i++, c++ ) { - if ( i%40 == 0 ) bu_vls_strcat( &vls, "\n" ); - bu_vls_printf( &vls, "%2.2x", *c ); + if ( i%40 == 0 ) bu_vls_strcat( log, "\n" ); + bu_vls_printf( log, "%2.2x", *c ); } - bu_vls_strcat( &vls, "}" ); + bu_vls_strcat( log, "}" ); bu_free_external( &ext ); } } else { if ( !strcmp( attr, "T" ) ) { - bu_vls_printf( &vls, "%d", bip->type ); + bu_vls_printf( log, "%d", bip->type ); } else if ( !strcmp( attr, "D" ) ) { /* export the object to get machine independent form */ if ( rt_binunif_export5( &ext, intern, 1.0, NULL, NULL, intern->idb_minor_type ) ) { - bu_vls_strcpy( &vls, "Failed to export binary object!!\n" ); - status = TCL_ERROR; + bu_vls_strcpy( log, "Failed to export binary object!!\n" ); + return BRLCAD_ERROR; } else { c = ext.ext_buf; for ( i=0; i<ext.ext_nbytes; i++, c++ ) { - if ( i != 0 && i%40 == 0 ) bu_vls_strcat( &vls, "\n" ); - bu_vls_printf( &vls, "%2.2x", *c ); + if ( i != 0 && i%40 == 0 ) bu_vls_strcat( log, "\n" ); + bu_vls_printf( log, "%2.2x", *c ); } bu_free_external( &ext ); } } else { - bu_vls_printf( &vls, "Binary object has no attribute '%s'", attr ); - status = TCL_ERROR; + bu_vls_printf( log, "Binary object has no attribute '%s'", attr ); + return BRLCAD_ERROR; } } - Tcl_DStringAppend( &ds, bu_vls_addr( &vls ), -1 ); - Tcl_DStringResult( interp, &ds ); - Tcl_DStringFree( &ds ); - bu_vls_free( &vls ); - - return( status ); + return BRLCAD_OK; } int -rt_binunif_tcladjust( Tcl_Interp *interp, struct rt_db_internal *intern, int argc, char **argv ) +rt_binunif_adjust(struct bu_vls *log, struct rt_db_internal *intern, int argc, char **argv ) { struct rt_binunif_internal *bip; int i; @@ -717,11 +705,10 @@ new_type = atoi( argv[1] ); } else { if ( argv[1][1] != '\0' ) { - Tcl_AppendResult( interp, "Illegal type: ", - argv[1], - ", must be 'f', 'd', 'c', 'i', 'l', 'C', 'S', 'I', or 'L'", - (char *)NULL ); - return TCL_ERROR; + bu_vls_printf(log, + "Illegal type: %s, must be 'f', 'd', 'c', 'i', 'l', 'C', 'S', 'I', or 'L'", + argv[1]); + return BRLCAD_ERROR; } switch ( argv[1][0] ) { case 'f': @@ -760,9 +747,8 @@ new_type > DB5_MINORTYPE_BINU_64BITINT || binu_types[new_type] == NULL ) { /* Illegal value for type */ - Tcl_AppendResult( interp, "Illegal value for binary type: ", argv[1], - (char *)NULL ); - return TCL_ERROR; + bu_vls_printf(log, "Illegal value for binary type: %s", argv[1]); + return BRLCAD_ERROR; } else { if ( bip->u.uint8 ) { int new_count; @@ -803,8 +789,8 @@ obj = Tcl_NewStringObj( argv[1], -1 ); list = Tcl_NewListObj( 0, NULL ); - Tcl_ListObjAppendList( interp, list, obj ); - (void)Tcl_ListObjGetElements( interp, list, &list_len, &obj_array ); + Tcl_ListObjAppendList( brlcad_interp, list, obj ); + (void)Tcl_ListObjGetElements( brlcad_interp, list, &list_len, &obj_array ); hexlen = 0; for ( i=0; i<list_len; i++ ) { @@ -812,10 +798,8 @@ } if ( hexlen % 2 ) { - Tcl_AppendResult( interp, - "Hex form of binary data must have an even number of hex digits", - (char *)NULL ); - return TCL_ERROR; + bu_vls_printf(log, "Hex form of binary data must have an even number of hex digits"); + return BRLCAD_ERROR; } buf = (unsigned char *)bu_malloc( hexlen / 2, "tcladjust binary data" ); Modified: brlcad/trunk/src/librt/primitives/arbn/arbn.c =================================================================== --- brlcad/trunk/src/librt/primitives/arbn/arbn.c 2008-06-26 16:24:57 UTC (rev 31628) +++ brlcad/trunk/src/librt/primitives/arbn/arbn.c 2008-06-26 17:25:09 UTC (rev 31629) @@ -1061,7 +1061,7 @@ } /** - * R T _ A R B N _ T C L G E T + * R T _ A R B N _ G E T * * Routine to format the parameters of an ARBN primitive for "db get" * @@ -1073,68 +1073,53 @@ */ int -rt_arbn_tclget(Tcl_Interp *interp, const struct rt_db_internal *intern, const char *attr) +rt_arbn_get(struct bu_vls *log, const struct rt_db_internal *intern, const char *attr) { register struct rt_arbn_internal *arbn=(struct rt_arbn_internal *)intern->idb_ptr; - Tcl_DString ds; - struct bu_vls vls; int i; RT_ARBN_CK_MAGIC( arbn ); - Tcl_DStringInit( &ds ); - bu_vls_init( &vls ); - if ( attr == (char *)NULL ) { - bu_vls_strcpy( &vls, "arbn" ); - bu_vls_printf( &vls, " N %d", arbn->neqn ); + bu_vls_strcpy( log, "arbn" ); + bu_vls_printf( log, " N %d", arbn->neqn ); for ( i=0; i<arbn->neqn; i++ ) { - bu_vls_printf( &vls, " P%d {%.25g %.25g %.25g %.25g}", i, + bu_vls_printf( log, " P%d {%.25g %.25g %.25g %.25g}", i, V4ARGS( arbn->eqn[i] ) ); } } else if ( !strcmp( attr, "N" ) ) - bu_vls_printf( &vls, "%d", arbn->neqn ); + bu_vls_printf( log, "%d", arbn->neqn ); else if ( !strcmp( attr, "P" ) ) { for ( i=0; i<arbn->neqn; i++ ) { - bu_vls_printf( &vls, " P%d {%.25g %.25g %.25g %.25g}", i, + bu_vls_printf( log, " P%d {%.25g %.25g %.25g %.25g}", i, V4ARGS( arbn->eqn[i] ) ); } } else if ( attr[0] == 'P' ) { if ( isdigit( attr[1] ) == 0 ) { - Tcl_SetResult( interp, "ERROR: Illegal plane number\n", - TCL_STATIC ); - bu_vls_free( &vls ); - return( TCL_ERROR ); + bu_vls_printf(log, "ERROR: Illegal plane number\n"); + return BRLCAD_ERROR; } i = atoi( &attr[1] ); if ( i >= arbn->neqn || i < 0 ) { - Tcl_SetResult( interp, "ERROR: Illegal plane number\n", - TCL_STATIC ); - bu_vls_free( &vls ); - return( TCL_ERROR ); + bu_vls_printf(log, "ERROR: Illegal plane number\n"); + return BRLCAD_ERROR; } - bu_vls_printf( &vls, "%.25g %.25g %.25g %.25g", V4ARGS( arbn->eqn[i] ) ); + bu_vls_printf(log, "%.25g %.25g %.25g %.25g", V4ARGS( arbn->eqn[i] ) ); } else { - Tcl_SetResult( interp, "ERROR: Unknown attribute, choices are N, P, or P#\n", - TCL_STATIC ); - bu_vls_free( &vls ); - return( TCL_ERROR ); + bu_vls_printf(log, "ERROR: Unknown attribute, choices are N, P, or P#\n"); + return BRLCAD_ERROR; } - Tcl_DStringAppend( &ds, bu_vls_addr( &vls ), -1 ); - Tcl_DStringResult( interp, &ds ); - Tcl_DStringFree( &ds ); - bu_vls_free( &vls ); - return( TCL_OK ); + return BRLCAD_OK; } /** - * R T _ A R B N _ T C L A D J U S T + * R T _ A R B N _ A D J U S T * * Routine to modify an arbn via the "db adjust" command * @@ -1146,7 +1131,7 @@ */ int -rt_arbn_tcladjust(Tcl_Interp *interp, struct rt_db_internal *intern, int argc, char **argv) +rt_arbn_adjust(struct bu_vls *log, struct rt_db_internal *intern, int argc, char **argv) { struct rt_arbn_internal *arbn; unsigned char *c; @@ -1174,9 +1159,8 @@ } arbn->neqn = i; } else { - Tcl_SetResult( interp, - "ERROR: number of planes must be greater than 0\n", - TCL_STATIC ); + bu_vls_printf(log, + "ERROR: number of planes must be greater than 0\n"); } } else if ( !strcmp( argv[0], "P" ) ) { @@ -1188,15 +1172,14 @@ c++; } len = 0; - (void)tcl_list_to_fastf_array( interp, argv[1], &new_planes, &len ); + (void)tcl_list_to_fastf_array( brlcad_interp, argv[1], &new_planes, &len ); if ( len%4 ) { - Tcl_SetResult( interp, - "ERROR: Incorrect number of plane coefficients\n", - TCL_STATIC ); + bu_vls_printf(log, + "ERROR: Incorrect number of plane coefficients\n"); if ( len ) bu_free( (char *)new_planes, "new_planes" ); - return( TCL_ERROR ); + return BRLCAD_ERROR; } if ( arbn->eqn ) bu_free( (char *)arbn->eqn, "arbn->eqn" ); @@ -1216,39 +1199,35 @@ else if ( isdigit( argv[0][1] ) ) { i = atoi( &argv[0][1] ); } else { - Tcl_SetResult( interp, - "ERROR: illegal argument, choices are P, P#, P+, or N\n", - TCL_STATIC ); + bu_vls_printf(log, + "ERROR: illegal argument, choices are P, P#, P+, or N\n"); return( TCL_ERROR ); } if ( i < 0 || i >= arbn->neqn ) { - Tcl_SetResult( interp, - "ERROR: plane number out of range\n", - TCL_STATIC ); - return( TCL_ERROR ); + bu_vls_printf(log, + "ERROR: plane number out of range\n"); + return BRLCAD_ERROR; } len = 4; array = (fastf_t *)&arbn->eqn[i]; - if ( tcl_list_to_fastf_array( interp, argv[1], + if ( tcl_list_to_fastf_array( brlcad_interp, argv[1], &array, &len ) != 4 ) { - Tcl_SetResult( interp, - "ERROR: incorrect number of coefficients for a plane\n", - TCL_STATIC ); - return( TCL_ERROR ); + bu_vls_printf(log, + "ERROR: incorrect number of coefficients for a plane\n"); + return BRLCAD_ERROR; } VUNITIZE( arbn->eqn[i] ); } else { - Tcl_SetResult( interp, - "ERROR: illegal argument, choices are P, P#, P+, or N\n", - TCL_STATIC ); - return( TCL_ERROR ); + bu_vls_printf(log, + "ERROR: illegal argument, choices are P, P#, P+, or N\n"); + return BRLCAD_ERROR; } cont: argc -= 2; argv += 2; } - return( TCL_OK ); + return BRLCAD_OK; } /** Modified: brlcad/trunk/src/librt/primitives/ars/ars.c =================================================================== --- brlcad/trunk/src/librt/primitives/ars/ars.c 2008-06-26 16:24:57 UTC (rev 31628) +++ brlcad/trunk/src/librt/primitives/ars/ars.c 2008-06-26 17:25:09 UTC (rev 31629) @@ -1164,35 +1164,30 @@ } int -rt_ars_tclget(Tcl_Interp *interp, const struct rt_db_internal *intern, const char *attr) +rt_ars_get(struct bu_vls *log, const struct rt_db_internal *intern, const char *attr) { register struct rt_ars_internal *ars=(struct rt_ars_internal *)intern->idb_ptr; - Tcl_DString ds; - struct bu_vls vls; - int i, j; + int i, j; RT_ARS_CK_MAGIC( ars ); - Tcl_DStringInit( &ds ); - bu_vls_init( &vls ); - if ( attr == (char *)NULL ) { - bu_vls_strcpy( &vls, "ars" ); - bu_vls_printf( &vls, " NC %d PPC %d", ars->ncurves, ars->pts_per_curve ); + bu_vls_strcpy( log, "ars" ); + bu_vls_printf( log, " NC %d PPC %d", ars->ncurves, ars->pts_per_curve ); for ( i=0; i<ars->ncurves; i++ ) { - bu_vls_printf( &vls, " C%d {", i ); + bu_vls_printf( log, " C%d {", i ); for ( j=0; j<ars->pts_per_curve; j++ ) { - bu_vls_printf( &vls, " { %.25g %.25g %.25g }", + bu_vls_printf( log, " { %.25g %.25g %.25g }", V3ARGS( &ars->curves[i][j*3] ) ); } - bu_vls_printf( &vls, " }" ); + bu_vls_printf( log, " }" ); } } else if ( !strcmp( attr, "NC" ) ) { - bu_vls_printf( &vls, "%d", ars->ncurves ); + bu_vls_printf( log, "%d", ars->ncurves ); } else if ( !strcmp( attr, "PPC" ) ) { - bu_vls_printf( &vls, "%d", ars->pts_per_curve ); + bu_vls_printf( log, "%d", ars->pts_per_curve ); } else if ( attr[0] == 'C' ) { char *ptr; @@ -1200,53 +1195,48 @@ if ( attr[1] == '\0' ) { /* all the curves */ for ( i=0; i<ars->ncurves; i++ ) { - bu_vls_printf( &vls, " C%d {", i ); + bu_vls_printf( log, " C%d {", i ); for ( j=0; j<ars->pts_per_curve; j++ ) { - bu_vls_printf( &vls, " { %.25g %.25g %.25g }", + bu_vls_printf( log, " { %.25g %.25g %.25g }", V3ARGS( &ars->curves[i][j*3] ) ); } - bu_vls_printf( &vls, " }" ); + bu_vls_printf( log, " }" ); } } else if ( !isdigit( attr[1] ) ) { - Tcl_SetResult( interp, - "ERROR: illegal argument, must be NC, PPC, C, C#, or C#P#\n", - TCL_STATIC ); - return( TCL_ERROR ); + bu_vls_printf(log, + "ERROR: illegal argument, must be NC, PPC, C, C#, or C#P#\n"); + return BRLCAD_ERROR; } if ( (ptr=strchr( attr, 'P' )) ) { /* a specific point on a specific curve */ if ( !isdigit( *(ptr+1) ) ) { - Tcl_SetResult( interp, - "ERROR: illegal argument, must be NC, PPC, C, C#, or C#P#\n", - TCL_STATIC ); - return( TCL_ERROR ); + bu_vls_printf(log, + "ERROR: illegal argument, must be NC, PPC, C, C#, or C#P#\n"); + return BRLCAD_ERROR; } j = atoi( (ptr+1) ); *ptr = '\0'; i = atoi( &attr[1] ); - bu_vls_printf( &vls, "%.25g %.25g %.25g", + bu_vls_printf( log, "%.25g %.25g %.25g", V3ARGS( &ars->curves[i][j*3] ) ); } else { /* the entire curve */ i = atoi( &attr[1] ); for ( j=0; j<ars->pts_per_curve; j++ ) { - bu_vls_printf( &vls, " { %.25g %.25g %.25g }", + bu_vls_printf( log, " { %.25g %.25g %.25g }", V3ARGS( &ars->curves[i][j*3] ) ); } } } - Tcl_DStringAppend( &ds, bu_vls_addr( &vls ), -1 ); - Tcl_DStringResult( interp, &ds ); - Tcl_DStringFree( &ds ); - bu_vls_free( &vls ); - return( TCL_OK ); + + return BRLCAD_OK; } int -rt_ars_tcladjust(Tcl_Interp *interp, struct rt_db_internal *intern, int argc, char **argv) +rt_ars_adjust(struct bu_vls *log, struct rt_db_internal *intern, int argc, char **argv) { struct rt_ars_internal *ars; int i, j, k; @@ -1301,10 +1291,9 @@ /* change the number of points per curve */ i = atoi( argv[1] ); if ( i < 3 ) { - Tcl_SetResult( interp, - "ERROR: must have at least 3 points per curve\n", - TCL_STATIC ); - return( TCL_ERROR ); + bu_vls_printf(log, + "ERROR: must have at least 3 points per curve\n"); + return BRLCAD_ERROR; } if ( i < ars->pts_per_curve ) { for ( j=0; j<ars->ncurves; j++ ) { @@ -1344,12 +1333,11 @@ j = atoi( ptr+1 ); len = 3; array = &ars->curves[i][j*3]; - if ( tcl_list_to_fastf_array( interp, argv[1], + if ( tcl_list_to_fastf_array( brlcad_interp, argv[1], &array, &len )!= len ) { - Tcl_SetResult( interp, - "WARNING: incorrect number of parameters provided for a point\n", - TCL_STATIC ); + bu_vls_printf(log, + "WARNING: incorrect number of parameters provided for a point\n"); } } else { @@ -1368,33 +1356,30 @@ sizeof( fastf_t ), "ars->curves[i]" ); } - if ( tcl_list_to_fastf_array( interp, argv[1], + if ( tcl_list_to_fastf_array( brlcad_interp, argv[1], &ars->curves[i], &len ) != len ) { - Tcl_SetResult( interp, - "WARNING: incorrect number of parameters provided for a curve\n", - TCL_STATIC ); + bu_vls_printf(log, + "WARNING: incorrect number of parameters provided for a curve\n"); } } } else { - Tcl_SetResult( interp, - "ERROR: Illegal argument, must be NC, PPC, C#, or C#P#\n", - TCL_STATIC ); - return( TCL_ERROR ); + bu_vls_printf(log, + "ERROR: Illegal argument, must be NC, PPC, C#, or C#P#\n"); + return BRLCAD_ERROR; } } else { - Tcl_SetResult( interp, - "ERROR: Illegal argument, must be NC, PPC, C#, or C#P#\n", - TCL_STATIC ); - return( TCL_ERROR ); + bu_vls_printf(log, + "ERROR: Illegal argument, must be NC, PPC, C#, or C#P#\n"); + return BRLCAD_ERROR; } argc -= 2; argv += 2; } - return( TCL_OK ); + return BRLCAD_OK; } /** Modified: brlcad/trunk/src/librt/primitives/bot/bot.c =================================================================== --- brlcad/trunk/src/librt/primitives/bot/bot.c 2008-06-26 16:24:57 UTC (rev 31628) +++ brlcad/trunk/src/librt/primitives/bot/bot.c 2008-06-26 17:25:09 UTC (rev 31629) @@ -1502,7 +1502,7 @@ }; /** - * R T _ B O T _ T C L G E T + * R T _ B O T _ G E T * * Examples - * db get name fm get los facemode bit vector @@ -1528,63 +1528,58 @@ * db get name flags get BOT flags */ int -rt_bot_tclget(Tcl_Interp *interp, const struct rt_db_internal *intern, const char *attr) +rt_bot_get(struct bu_vls *log, const struct rt_db_internal *intern, const char *attr) { register struct rt_bot_internal *bot=(struct rt_bot_internal *)intern->idb_ptr; - Tcl_DString ds; - struct bu_vls vls; int status; int i; RT_BOT_CK_MAGIC( bot ); - Tcl_DStringInit( &ds ); - bu_vls_init( &vls ); - if ( attr == (char *)NULL ) { - bu_vls_strcpy( &vls, "bot" ); - bu_vls_printf( &vls, " mode %s orient %s", + bu_vls_strcpy( log, "bot" ); + bu_vls_printf( log, " mode %s orient %s", modes[bot->mode], orientation[bot->orientation] ); - bu_vls_printf( &vls, " flags {" ); + bu_vls_printf( log, " flags {" ); if ( bot->bot_flags & RT_BOT_HAS_SURFACE_NORMALS ) { - bu_vls_printf( &vls, " has_normals" ); + bu_vls_printf( log, " has_normals" ); } if ( bot->bot_flags & RT_BOT_USE_NORMALS ) { - bu_vls_printf( &vls, " use_normals" ); + bu_vls_printf( log, " use_normals" ); } if ( bot->bot_flags & RT_BOT_USE_FLOATS ) { - bu_vls_printf( &vls, " use_floats" ); + bu_vls_printf( log, " use_floats" ); } - bu_vls_printf( &vls, "} V {" ); + bu_vls_printf( log, "} V {" ); for ( i=0; i<bot->num_vertices; i++ ) - bu_vls_printf( &vls, " { %.25G %.25G %.25G }", + bu_vls_printf( log, " { %.25G %.25G %.25G }", V3ARGS( &bot->vertices[i*3] ) ); - bu_vls_strcat( &vls, "} F {" ); + bu_vls_strcat( log, "} F {" ); for ( i=0; i<bot->num_faces; i++ ) - bu_vls_printf( &vls, " { %d %d %d }", + bu_vls_printf( log, " { %d %d %d }", V3ARGS( &bot->faces[i*3] ) ); - bu_vls_strcat( &vls, "}" ); + bu_vls_strcat( log, "}" ); if ( bot->mode == RT_BOT_PLATE || bot->mode == RT_BOT_PLATE_NOCOS ) { - bu_vls_strcat( &vls, " T {" ); + bu_vls_strcat( log, " T {" ); for ( i=0; i<bot->num_faces; i++ ) - bu_vls_printf( &vls, " %.25G", bot->thickness[i] ); - bu_vls_strcat( &vls, "} fm " ); - bu_bitv_to_hex( &vls, bot->face_mode ); + bu_vls_printf( log, " %.25G", bot->thickness[i] ); + bu_vls_strcat( log, "} fm " ); + bu_bitv_to_hex( log, bot->face_mode ); } if ( bot->bot_flags & RT_BOT_HAS_SURFACE_NORMALS ) { - bu_vls_printf( &vls, " N {" ); + bu_vls_printf( log, " N {" ); for ( i=0; i<bot->num_normals; i++ ) { - bu_vls_printf( &vls, " { %.25G %.25G %.25G }", V3ARGS( &bot->normals[i*3] ) ); + bu_vls_printf( log, " { %.25G %.25G %.25G }", V3ARGS( &bot->normals[i*3] ) ); } - bu_vls_printf( &vls, "} fn {" ); + bu_vls_printf( log, "} fn {" ); for ( i=0; i<bot->num_faces; i++ ) { - bu_vls_printf( &vls, " { %d %d %d }", V3ARGS( &bot->face_normals[i*3] ) ); + bu_vls_printf( log, " { %d %d %d }", V3ARGS( &bot->face_normals[i*3] ) ); } - bu_vls_printf( &vls, "}" ); + bu_vls_printf( log, "}" ); } - status = TCL_OK; + status = BRLCAD_OK; } else { @@ -1592,21 +1587,21 @@ { if ( attr[1] == '\0' ) { if ( !(bot->bot_flags & RT_BOT_HAS_SURFACE_NORMALS) || bot->num_normals < 1 ) { - bu_vls_strcat( &vls, "{}" ); + bu_vls_strcat( log, "{}" ); } else { for ( i=0; i<bot->num_normals; i++ ) { - bu_vls_printf( &vls, " { %.25G %.25G %.25G }", V3ARGS( &bot->normals[i*3] ) ); + bu_vls_printf( log, " { %.25G %.25G %.25G }", V3ARGS( &bot->normals[i*3] ) ); } } - status = TCL_OK; + status = BRLCAD_OK; } else { i = atoi( &attr[1] ); if ( i < 0 || i >= bot->num_normals ) { - bu_vls_strcat( &vls, "Specified normal index is out of range" ); - status = TCL_ERROR; + bu_vls_strcat( log, "Specified normal index is out of range" ); + status = BRLCAD_ERROR; } else { - bu_vls_printf( &vls, "%.25G %.25G %.25G", V3ARGS( &bot->normals[i*3] ) ); - status = TCL_OK; + bu_vls_printf( log, "%.25G %.25G %.25G", V3ARGS( &bot->normals[i*3] ) ); + status = BRLCAD_OK; } } } @@ -1614,65 +1609,65 @@ { if ( attr[2] == '\0' ) { for ( i=0; i<bot->num_faces; i++ ) { - bu_vls_printf( &vls, " { %d %d %d }", V3ARGS( &bot->face_normals[i*3] ) ); + bu_vls_printf( log, " { %d %d %d }", V3ARGS( &bot->face_normals[i*3] ) ); } - status = TCL_OK; + status = BRLCAD_OK; } else { i = atoi( &attr[2] ); if ( i < 0 || i >= bot->num_faces ) { - bu_vls_strcat( &vls, "Specified face index is out of range" ); - status = TCL_ERROR; + bu_vls_strcat( log, "Specified face index is out of range" ); + status = BRLCAD_ERROR; } else { - bu_vls_printf( &vls, "%d %d %d", V3ARGS( &bot->face_normals[i*3] ) ); - status = TCL_OK; + bu_vls_printf( log, "%d %d %d", V3ARGS( &bot->face_normals[i*3] ) ); + status = BRLCAD_OK; } } } else if ( !strcmp( attr, "nn" ) ) { if ( !(bot->bot_flags & RT_BOT_HAS_SURFACE_NORMALS) || bot->num_normals < 1 ) { - bu_vls_strcat( &vls, "0" ); + bu_vls_strcat( log, "0" ); } else { - bu_vls_printf( &vls, "%d", bot->num_normals ); + bu_vls_printf( log, "%d", bot->num_normals ); } - status = TCL_OK; + status = BRLCAD_OK; } else if ( !strcmp( attr, "nfn" ) ) { if ( !(bot->bot_flags & RT_BOT_HAS_SURFACE_NORMALS) || bot->num_face_normals < 1 ) { - bu_vls_strcat( &vls, "0" ); + bu_vls_strcat( log, "0" ); } else { - bu_vls_printf( &vls, "%d", bot->num_face_normals ); + bu_vls_printf( log, "%d", bot->num_face_normals ); } - status = TCL_OK; + status = BRLCAD_OK; } else if ( !strncmp( attr, "fm", 2 ) ) { if ( bot->mode != RT_BOT_PLATE && bot->mode != RT_BOT_PLATE_NOCOS ) { - bu_vls_strcat( &vls, "Only plate mode BOTs have face_modes" ); - status = TCL_ERROR; + bu_vls_strcat( log, "Only plate mode BOTs have face_modes" ); + status = BRLCAD_ERROR; } else { if ( attr[2] == '\0' ) { - bu_bitv_to_hex( &vls, bot->face_mode ); - status = TCL_OK; + bu_bitv_to_hex( log, bot->face_mode ); + status = BRLCAD_OK; } else { i = atoi( &attr[2] ); if ( i < 0 || i >=bot->num_faces ) { - bu_vls_printf( &vls, "face number %d out of range (0..%d)", i, bot->num_faces-1 ); - status = TCL_ERROR; + bu_vls_printf( log, "face number %d out of range (0..%d)", i, bot->num_faces-1 ); + status = BRLCAD_ERROR; } else { - bu_vls_printf( &vls, "%s", + bu_vls_printf( log, "%s", los[BU_BITTEST( bot->face_mode, i )?1:0] ); - status = TCL_OK; + status = BRLCAD_OK; } } } @@ -1684,22 +1679,22 @@ i = atoi( &attr[1] ); if ( i < 0 || i >=bot->num_vertices ) { - bu_vls_printf( &vls, "vertex number %d out of range (0..%d)", i, bot->num_vertices-1 ); - status = TCL_ERROR; + bu_vls_printf( log, "vertex number %d out of range (0..%d)", i, bot->num_vertices-1 ); + status = BRLCAD_ERROR; } else { - bu_vls_printf( &vls, "%.25G %.25G %.25G", + bu_vls_printf( log, "%.25G %.25G %.25G", V3ARGS( &bot->vertices[i*3] ) ); - status = TCL_OK; + status = BRLCAD_OK; } } else { for ( i=0; i<bot->num_vertices; i++ ) - bu_vls_printf( &vls, " { %.25G %.25G %.25G }", + bu_vls_printf( log, " { %.25G %.25G %.25G }", V3ARGS( &bot->vertices[i*3] ) ); - status = TCL_OK; + status = BRLCAD_OK; } } else if ( attr[0] == 'F' ) @@ -1708,40 +1703,40 @@ if ( attr[1] == '\0' ) { for ( i=0; i<bot->num_faces; i++ ) - bu_vls_printf( &vls, " { %d %d %d }", + bu_vls_printf( log, " { %d %d %d }", V3ARGS( &bot->faces[i*3] ) ); - status = TCL_OK; + status = BRLCAD_OK; } else { i = atoi( &attr[1] ); if ( i < 0 || i >=bot->num_faces ) { - bu_vls_printf( &vls, "face number %d out of range (0..%d)", i, bot->num_faces-1 ); - status = TCL_ERROR; + bu_vls_printf( log, "face number %d out of range (0..%d)", i, bot->num_faces-1 ); + status = BRLCAD_ERROR; } else { - bu_vls_printf( &vls, "%d %d %d", + bu_vls_printf( log, "%d %d %d", V3ARGS( &bot->faces[i*3] ) ); - status = TCL_OK; + status = BRLCAD_OK; } } } else if ( !strcmp( attr, "flags" ) ) { - bu_vls_printf( &vls, "{" ); + bu_vls_printf( log, "{" ); if ( bot->bot_flags & RT_BOT_HAS_SURFACE_NORMALS ) { - bu_vls_printf( &vls, " has_normals" ); + bu_vls_printf( log, " has_normals" ); } if ( bot->bot_flags & RT_BOT_USE_NORMALS ) { - bu_vls_printf( &vls, " use_normals" ); + bu_vls_printf( log, " use_normals" ); } if ( bot->bot_flags & RT_BOT_USE_FLOATS ) { - bu_vls_printf( &vls, " use_floats" ); + bu_vls_printf( log, " use_floats" ); } - bu_vls_printf( &vls, "}" ); - status = TCL_OK; + bu_vls_printf( log, "}" ); + status = BRLCAD_OK; } else if ( attr[0] == 'f' ) { @@ -1751,49 +1746,49 @@ { for ( i=0; i<bot->num_faces; i++ ) { indx = bot->faces[i*3]; - bu_vls_printf( &vls, " { %.25G %.25G %.25G }", + bu_vls_printf( log, " { %.25G %.25G %.25G }", bot->vertices[indx*3], bot->vertices[indx*3+1], bot->vertices[indx*3+2] ); indx = bot->faces[i*3+1]; - bu_vls_printf( &vls, " { %.25G %.25G %.25G }", + bu_vls_printf( log, " { %.25G %.25G %.25G }", bot->vertices[indx*3], bot->vertices[indx*3+1], bot->vertices[indx*3+2] ); indx = bot->faces[i*3+2]; - bu_vls_printf( &vls, " { %.25G %.25G %.25G }", + bu_vls_printf( log, " { %.25G %.25G %.25G }", bot->vertices[indx*3], bot->vertices[indx*3+1], bot->vertices[indx*3+2] ); } - status = TCL_OK; + status = BRLCAD_OK; } else { i = atoi( &attr[1] ); if ( i < 0 || i >=bot->num_faces ) { - bu_vls_printf( &vls, "face number %d out of range (0..%d)", i, bot->num_faces-1 ); - status = TCL_ERROR; + bu_vls_printf( log, "face number %d out of range (0..%d)", i, bot->num_faces-1 ); + status = BRLCAD_ERROR; } else { indx = bot->faces[i*3]; - bu_vls_printf( &vls, " { %.25G %.25G %.25G }", + bu_vls_printf( log, " { %.25G %.25G %.25G }", bot->vertices[indx*3], bot->vertices[indx*3+1], bot->vertices[indx*3+2] ); indx = bot->faces[i*3+1]; - bu_vls_printf( &vls, " { %.25G %.25G %.25G }", + bu_vls_printf( log, " { %.25G %.25G %.25G }", bot->vertices[indx*3], bot->vertices[indx*3+1], bot->vertices[indx*3+2] ); indx = bot->faces[i*3+2]; - bu_vls_printf( &vls, " { %.25G %.25G %.25G }", + bu_vls_printf( log, " { %.25G %.25G %.25G }", bot->vertices[indx*3], bot->vertices[indx*3+1], bot->vertices[indx*3+2] ); - status = TCL_OK; + status = BRLCAD_OK; } } } @@ -1801,70 +1796,65 @@ { if ( bot->mode != RT_BOT_PLATE && bot->mode != RT_BOT_PLATE_NOCOS ) { - bu_vls_strcat( &vls, "Only plate mode BOTs have thicknesses" ); - status = TCL_ERROR; + bu_vls_strcat( log, "Only plate mode BOTs have thicknesses" ); + status = BRLCAD_ERROR; } else { if ( attr[1] == '\0' ) { for ( i=0; i<bot->num_faces; i++ ) - bu_vls_printf( &vls, " %.25G", bot->thickness[i] ); - status = TCL_OK; + bu_vls_printf( log, " %.25G", bot->thickness[i] ); + status = BRLCAD_OK; } else { i = atoi( &attr[1] ); if ( i < 0 || i >=bot->num_faces ) { - bu_vls_printf( &vls, "face number %d out of range (0..%d)", i, bot->num_faces-1 ); - status = TCL_ERROR; + bu_vls_printf( log, "face number %d out of range (0... [truncated message content] |