Revision: 56435
http://sourceforge.net/p/brlcad/code/56435
Author: starseeker
Date: 2013-08-01 19:24:32 +0000 (Thu, 01 Aug 2013)
Log Message:
-----------
Extract the bit from mvall that does the object reference renaming for a comb
tree and make it available as a function call - will need this for a comb
command feature.
Modified Paths:
--------------
brlcad/trunk/include/raytrace.h
brlcad/trunk/src/libged/move_all.c
Modified: brlcad/trunk/include/raytrace.h
===================================================================
--- brlcad/trunk/include/raytrace.h 2013-08-01 19:11:02 UTC (rev 56434)
+++ brlcad/trunk/include/raytrace.h 2013-08-01 19:24:32 UTC (rev 56435)
@@ -4400,6 +4400,19 @@
fastf_t *B);
+/**
+ * d b _ c o m b _ m v a l l
+ *
+ * change all matching object names in the comb tree from old_name to new_name
+ *
+ * calling function must supply an initialized bu_ptbl, and free it once done.
+ */
+RT_EXPORT extern int db_comb_mvall(struct directory *dp,
+ struct db_i *dbip,
+ const char *old_name,
+ const char *new_name,
+ struct bu_ptbl *stack);
+
/* roots.c */
/** @addtogroup librt */
/** @{ */
Modified: brlcad/trunk/src/libged/move_all.c
===================================================================
--- brlcad/trunk/src/libged/move_all.c 2013-08-01 19:11:02 UTC (rev 56434)
+++ brlcad/trunk/src/libged/move_all.c 2013-08-01 19:24:32 UTC (rev 56435)
@@ -123,58 +123,48 @@
/* Examine all COMB nodes */
for (i = 0; i < RT_DBNHASH; i++) {
for (dp = gedp->ged_wdbp->dbip->dbi_Head[i]; dp != RT_DIR_NULL; dp =
dp->d_forw) {
- union tree *comb_leaf;
- int done=0;
- int changed=0;
+ if (nflag) {
+ union tree *comb_leaf;
+ int done=0;
+ if (!(dp->d_flags & RT_DIR_COMB)) continue;
+ if (rt_db_get_internal(&intern, dp, gedp->ged_wdbp->dbip,
(fastf_t *)NULL, &rt_uniresource) < 0) continue;
+ comb = (struct rt_comb_internal *)intern.idb_ptr;
+ bu_ptbl_reset(&stack);
+ /* visit each leaf in the combination */
+ comb_leaf = comb->tree;
+ if (comb_leaf) {
+ while (!done) {
+ while (comb_leaf->tr_op != OP_DB_LEAF) {
+ bu_ptbl_ins(&stack, (long *)comb_leaf);
+ comb_leaf = comb_leaf->tr_b.tb_left;
+ }
- if (!(dp->d_flags & RT_DIR_COMB))
- continue;
-
- if (rt_db_get_internal(&intern, dp, gedp->ged_wdbp->dbip, (fastf_t
*)NULL, &rt_uniresource) < 0)
- continue;
- comb = (struct rt_comb_internal *)intern.idb_ptr;
-
- bu_ptbl_reset(&stack);
- /* visit each leaf in the combination */
- comb_leaf = comb->tree;
- if (comb_leaf) {
- while (!done) {
- while (comb_leaf->tr_op != OP_DB_LEAF) {
- bu_ptbl_ins(&stack, (long *)comb_leaf);
- comb_leaf = comb_leaf->tr_b.tb_left;
- }
-
- if (BU_STR_EQUAL(comb_leaf->tr_l.tl_name, old)) {
- if (nflag)
+ if (BU_STR_EQUAL(comb_leaf->tr_l.tl_name, old)) {
bu_vls_printf(gedp->ged_result_str, "%s ",
dp->d_namep);
- else {
- bu_free(comb_leaf->tr_l.tl_name,
"comb_leaf->tr_l.tl_name");
- comb_leaf->tr_l.tl_name = bu_strdup(new);
- changed = 1;
}
- }
- if (BU_PTBL_END(&stack) < 1) {
- done = 1;
- break;
+ if (BU_PTBL_END(&stack) < 1) {
+ done = 1;
+ break;
+ }
+ comb_leaf = (union tree *)BU_PTBL_GET(&stack,
BU_PTBL_END(&stack)-1);
+ if (comb_leaf->tr_op != OP_DB_LEAF) {
+ bu_ptbl_rm(&stack, (long *)comb_leaf);
+ comb_leaf = comb_leaf->tr_b.tb_right;
+ }
}
- comb_leaf = (union tree *)BU_PTBL_GET(&stack,
BU_PTBL_END(&stack)-1);
- if (comb_leaf->tr_op != OP_DB_LEAF) {
- bu_ptbl_rm(&stack, (long *)comb_leaf);
- comb_leaf = comb_leaf->tr_b.tb_right;
- }
}
- }
-
- if (changed) {
- if (rt_db_put_internal(dp, gedp->ged_wdbp->dbip, &intern,
&rt_uniresource)) {
+ rt_db_free_internal(&intern);
+ } else {
+ int comb_mvall_status = db_comb_mvall(dp, gedp->ged_wdbp->dbip,
old, new, &stack);
+ if (!comb_mvall_status) continue;
+ if (comb_mvall_status == 2) {
bu_ptbl_free(&stack);
bu_vls_printf(gedp->ged_result_str, "Database write error,
aborting");
return GED_ERROR;
}
- } else
- rt_db_free_internal(&intern);
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent
caught up. So what steps can you take to put your SQL databases under
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits