[brlcad-commits] SF.net SVN: brlcad:[47000] brlcad/trunk/src/libged/bot_split.c
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <bo...@us...> - 2011-09-30 19:11:27
|
Revision: 47000 http://brlcad.svn.sourceforge.net/brlcad/?rev=47000&view=rev Author: bob1961 Date: 2011-09-30 19:11:20 +0000 (Fri, 30 Sep 2011) Log Message: ----------- Update libged/bot_split.c to return a list of sublists where each sublist contains the original bot and a subsublist containing the new bots created by the split. Modified Paths: -------------- brlcad/trunk/src/libged/bot_split.c Modified: brlcad/trunk/src/libged/bot_split.c =================================================================== --- brlcad/trunk/src/libged/bot_split.c 2011-09-30 16:00:21 UTC (rev 46999) +++ brlcad/trunk/src/libged/bot_split.c 2011-09-30 19:11:20 UTC (rev 47000) @@ -41,6 +41,9 @@ struct directory *dp; struct rt_db_internal intern; struct rt_bot_internal *bot; + struct bu_vls bot_result_list; + struct bu_vls new_bots; + struct bu_vls error_str; static const char *usage = "bot [bot2 bot3 ...]"; GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR); @@ -50,6 +53,11 @@ /* initialize result */ bu_vls_trunc(gedp->ged_result_str, 0); + /* initialize bot lists */ + bu_vls_init(&bot_result_list); + bu_vls_init(&new_bots); + bu_vls_init(&error_str); + /* must be wanting help */ if (argc == 1) { bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", argv[0], usage); @@ -60,7 +68,7 @@ struct rt_bot_list *headRblp; if ((dp = db_lookup(gedp->ged_wdbp->dbip, argv[i], LOOKUP_QUIET)) == RT_DIR_NULL) { - bu_vls_printf(gedp->ged_result_str, "%s: db_lookup(%s) error\n", argv[0], argv[i]); + bu_vls_printf(&error_str, "%s: db_lookup(%s) error\n", argv[0], argv[i]); continue; } @@ -68,7 +76,7 @@ if (intern.idb_major_type != DB5_MAJORTYPE_BRLCAD || intern.idb_minor_type != DB5_MINORTYPE_BRLCAD_BOT) { rt_db_free_internal(&intern); - bu_vls_printf(gedp->ged_result_str, "%s: %s is not a BOT solid!\n", argv[0], argv[i]); + bu_vls_printf(&error_str, "%s: %s is not a BOT solid!\n", argv[0], argv[i]); continue; } @@ -84,6 +92,7 @@ av[0] = "make_name"; av[2] = (char *)0; + bu_vls_init(&new_bots); for (BU_LIST_FOR(rblp, rt_bot_list, &headRblp->l)) { /* Get a unique name based on the original name */ av[1] = argv[i]; @@ -96,27 +105,41 @@ bot_intern.idb_meth = &rt_functab[ID_BOT]; bot_intern.idb_ptr = (genptr_t)rblp->bot; + /* Save new bot name for later use */ + bu_vls_printf(&new_bots, "%V ", gedp->ged_result_str); + dp = db_diradd(gedp->ged_wdbp->dbip, bu_vls_addr(gedp->ged_result_str), RT_DIR_PHONY_ADDR, 0, RT_DIR_SOLID, (genptr_t)&bot_intern.idb_type); if (dp == RT_DIR_NULL) { - bu_vls_printf(gedp->ged_result_str, " failed to be added to the database."); + bu_vls_printf(&error_str, " failed to be added to the database.\n"); rt_bot_list_free(headRblp, 0); rt_db_free_internal(&intern); } if (rt_db_put_internal(dp, gedp->ged_wdbp->dbip, &bot_intern, &rt_uniresource) < 0) { - bu_vls_printf(gedp->ged_result_str, " failed to be added to the database."); + bu_vls_printf(&error_str, " failed to be added to the database.\n"); rt_bot_list_free(headRblp, 0); rt_db_free_internal(&intern); } } + /* Save the name of the original bot and the new bots as a sublist */ + bu_vls_printf(&bot_result_list, "{%s {%V}} ", argv[i], &new_bots); + bu_vls_trunc(gedp->ged_result_str, 0); + bu_vls_trunc(&new_bots, 0); } rt_bot_list_free(headRblp, 0); rt_db_free_internal(&intern); } + bu_vls_trunc(gedp->ged_result_str, 0); + bu_vls_printf(gedp->ged_result_str, "%V {%V}", &bot_result_list, &error_str); + + bu_vls_free(&bot_result_list); + bu_vls_free(&new_bots); + bu_vls_free(&error_str); + return GED_OK; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |