Revision: 78167
          http://sourceforge.net/p/brlcad/code/78167
Author:   starseeker
Date:     2021-02-02 15:27:20 +0000 (Tue, 02 Feb 2021)
Log Message:
-----------
Pass the full path for the tree update walk as well for better reporting.

Modified Paths:
--------------
    brlcad/trunk/src/libged/npush/npush.cpp

Modified: brlcad/trunk/src/libged/npush/npush.cpp
===================================================================
--- brlcad/trunk/src/libged/npush/npush.cpp     2021-02-02 15:11:29 UTC (rev 
78166)
+++ brlcad/trunk/src/libged/npush/npush.cpp     2021-02-02 15:27:20 UTC (rev 
78167)
@@ -357,6 +357,7 @@
 {
     struct directory *dp;
     dp_i dnew;
+    dnew.parent_dp = DB_FULL_PATH_CUR_DIR(dfp);
     struct push_state *s = (struct push_state *)client_data;
     mat_t om, nm;
 
@@ -540,6 +541,7 @@
 static void
 tree_update_walk(
        const dp_i &dpi,
+       struct db_full_path *dfp,
        int depth,
        mat_t *curr_mat,
        void *client_data);
@@ -547,6 +549,7 @@
 static void
 tree_update_walk_subtree(
                    const dp_i &parent_dpi,
+                   struct db_full_path *dfp,
                    union tree *tp,
                    union tree *wtp,
                    int depth,
@@ -594,33 +597,27 @@
            }
            dpii = s->instances.find(ldpi);
            if (dpii == s->instances.end()) {
-               bu_log("Error - no instance found: %s->%s!\n", 
parent_dpi.dp->d_namep, dp->d_namep);
+               char *ps = db_path_to_string(dfp);
+               bu_log("%s: Error - no instance found: %s->%s!\n", ps, 
parent_dpi.dp->d_namep, dp->d_namep);
                dpii = s->instances.find(ldpi);
                bn_mat_print("curr_mat", *curr_mat);
                if (dpii->apply_to_solid)
-                   bu_log("apply_to_solid set\n");
+                   bu_log("%s: apply_to_solid set\n", ps);
                for (i_it = s->instances.begin(); i_it != s->instances.end(); 
i_it++) {
                    const dp_i &ddpi = *i_it;
                    if (ddpi.dp == dp) {
                        bn_mat_print(tp->tr_l.tl_name, ddpi.mat);
                        if (ddpi.iname.length())
-                           bu_log("iname: %s\n", ddpi.iname.c_str());
+                           bu_log("%s: iname: %s\n", ps, ddpi.iname.c_str());
                        if (ddpi.apply_to_solid)
-                           bu_log("apply_to_solid set\n");
+                           bu_log("%s: apply_to_solid set\n", ps);
                    }
                }
+               bu_free(ps, "path string");
                s->walk_error = true;
                return;
            }
 
-           if (s->verbosity > 2) {
-               if (tp->tr_l.tl_mat && !bn_mat_is_equal(*curr_mat, 
bn_mat_identity, s->tol)) {
-                   bu_log("Found %s->[M]%s\n", parent_dpi.dp->d_namep, 
dp->d_namep);
-               } else {
-                   bu_log("Found %s->%s\n", parent_dpi.dp->d_namep, 
dp->d_namep);
-               }
-           }
-
            /* Tree editing operations - form the tree that will be used in the 
final
             * output of this comb object.  These operations should use the 
writable
             * tree (wtp) to ensure we don't cause any inadvertent issues with 
the
@@ -673,7 +670,9 @@
            }
 
            /* Process */
-           tree_update_walk(*dpii, depth, curr_mat, client_data);
+           db_add_node_to_full_path(dfp, dp);
+           tree_update_walk(*dpii, dfp, depth, curr_mat, client_data);
+           DB_FULL_PATH_POP(dfp);
 
            /* Done with branch - put back the old matrix state */
            MAT_COPY(*curr_mat, om);
@@ -683,8 +682,8 @@
        case OP_INTERSECT:
        case OP_SUBTRACT:
        case OP_XOR:
-           tree_update_walk_subtree(parent_dpi, tp->tr_b.tb_left, 
wtp->tr_b.tb_left, depth+1, curr_mat, tree_altered, client_data);
-           tree_update_walk_subtree(parent_dpi, tp->tr_b.tb_right, 
wtp->tr_b.tb_right, depth+1, curr_mat, tree_altered, client_data);
+           tree_update_walk_subtree(parent_dpi, dfp, tp->tr_b.tb_left, 
wtp->tr_b.tb_left, depth+1, curr_mat, tree_altered, client_data);
+           tree_update_walk_subtree(parent_dpi, dfp, tp->tr_b.tb_right, 
wtp->tr_b.tb_right, depth+1, curr_mat, tree_altered, client_data);
            break;
        default:
            bu_log("tree_update_walk_subtree: unrecognized operator %d\n", 
tp->tr_op);
@@ -695,6 +694,7 @@
 static void
 tree_update_walk(
        const dp_i &dpi,
+       struct db_full_path *dfp,
        int depth,
        mat_t *curr_mat,
        void *client_data)
@@ -724,7 +724,7 @@
        wcomb = (struct rt_comb_internal *)in->idb_ptr;
 
        // Walk one tree copy, while recording updates in the other one
-       tree_update_walk_subtree(dpi, comb->tree, wcomb->tree, depth + 1, 
curr_mat, &tree_altered, client_data);
+       tree_update_walk_subtree(dpi, dfp, comb->tree, wcomb->tree, depth + 1, 
curr_mat, &tree_altered, client_data);
 
        // Read-only copy is done
        rt_db_free_internal(&intern);
@@ -1027,6 +1027,11 @@
     // sharing a common directory pointer.  Any dp with multiple associated
     // instances can't be pushed without a copy being made, as the unique dp
     // instances represent multiple distinct volumes in space.
+    //
+    // Note: we assign the index to the instance because it has proven useful
+    // in debugging sorting behaviors for the dp_i class - if the initial
+    // insert had one answer but a subsequent set rebuild produces another,
+    // the index can help diagnose this.
     std::map<struct directory *, std::vector<size_t>> i_cnt;
     for (size_t i = 0; i < uniq_instances.size(); i++) {
        uniq_instances[i].ind = i;
@@ -1220,8 +1225,17 @@
            MAT_IDN(ldpi.mat);
            ldpi.ts_tol = s.tol;
 
+           struct db_full_path *dfp;
+           BU_GET(dfp, struct db_full_path);
+           db_full_path_init(dfp);
+           db_add_node_to_full_path(dfp, dp);
+
            // Start the walk.
-           tree_update_walk(ldpi, 0, &m, &s);
+           tree_update_walk(ldpi, dfp, 0, &m, &s);
+
+           db_free_full_path(dfp);
+           BU_PUT(dfp, struct db_full_path);
+
        }
     }
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to