Revision: 78060
          http://sourceforge.net/p/brlcad/code/78060
Author:   starseeker
Date:     2021-01-08 19:08:14 +0000 (Fri, 08 Jan 2021)
Log Message:
-----------
checkpoint

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-01-08 18:03:51 UTC (rev 
78059)
+++ brlcad/trunk/src/libged/npush/npush.cpp     2021-01-08 19:08:14 UTC (rev 
78060)
@@ -36,22 +36,25 @@
 static void
 push_walk(struct db_i *dbip,
            struct directory *dp,
-           void (*comb_func) (struct db_i *, struct directory *, int depth, 
void *),
-           void (*leaf_func) (struct db_i *, struct directory *, int depth, 
void *),
+           void (*comb_func) (struct db_i *, struct directory *, int depth, 
mat_t *curr_mat, void *),
+           void (*leaf_func) (struct db_i *, struct directory *, int depth, 
mat_t *curr_mat, void *),
            struct resource *resp,
            int depth,
+           mat_t *curr_mat,
            void *client_data);
 
 static void
 push_walk_subtree(struct db_i *dbip,
                    union tree *tp,
-                   void (*comb_func) (struct db_i *, struct directory *, int 
depth, void *),
-                   void (*leaf_func) (struct db_i *, struct directory *, int 
depth, void *),
+                   void (*comb_func) (struct db_i *, struct directory *, int 
depth, mat_t *curr_mat, void *),
+                   void (*leaf_func) (struct db_i *, struct directory *, int 
depth, mat_t *curr_mat, void *),
                    struct resource *resp,
                    int depth,
+                   mat_t *curr_mat,
                    void *client_data)
 {
     struct directory *dp;
+    mat_t om, nm;
 
     if (!tp)
        return;
@@ -67,7 +70,22 @@
        case OP_DB_LEAF:
            if ((dp=db_lookup(dbip, tp->tr_l.tl_name, LOOKUP_NOISY)) == 
RT_DIR_NULL)
                return;
-           push_walk(dbip, dp, comb_func, leaf_func, resp, depth, client_data);
+
+           /* Update current matrix state to reflect the new branch of
+            * the tree we are about to go down. */
+           MAT_COPY(om, *curr_mat);
+           if (tp->tr_l.tl_mat) {
+               MAT_COPY(nm, tp->tr_l.tl_mat);
+           } else {
+               MAT_IDN(nm);
+           }
+           bn_mat_mul(*curr_mat, om, nm);
+
+           /* Process branch */
+           push_walk(dbip, dp, comb_func, leaf_func, resp, depth, curr_mat, 
client_data);
+
+           /* Done with branch - put back the old matrix state */
+           MAT_COPY(*curr_mat, om);
            break;
 
        case OP_UNION:
@@ -74,8 +92,8 @@
        case OP_INTERSECT:
        case OP_SUBTRACT:
        case OP_XOR:
-           push_walk_subtree(dbip, tp->tr_b.tb_left, comb_func, leaf_func, 
resp, depth, client_data);
-           push_walk_subtree(dbip, tp->tr_b.tb_right, comb_func, leaf_func, 
resp, depth, client_data);
+           push_walk_subtree(dbip, tp->tr_b.tb_left, comb_func, leaf_func, 
resp, depth, curr_mat, client_data);
+           push_walk_subtree(dbip, tp->tr_b.tb_right, comb_func, leaf_func, 
resp, depth, curr_mat, client_data);
            break;
        default:
            bu_log("push_walk_subtree: unrecognized operator %d\n", tp->tr_op);
@@ -86,10 +104,11 @@
 static void
 push_walk(struct db_i *dbip,
            struct directory *dp,
-           void (*comb_func) (struct db_i *, struct directory *, int depth, 
void *),
-           void (*leaf_func) (struct db_i *, struct directory *, int depth, 
void *),
+           void (*comb_func) (struct db_i *, struct directory *, int depth, 
mat_t *curr_mat, void *),
+           void (*leaf_func) (struct db_i *, struct directory *, int depth, 
mat_t *curr_mat, void *),
            struct resource *resp,
            int depth,
+           mat_t *curr_mat,
            void *client_data)
 {
     RT_CK_DBI(dbip);
@@ -102,6 +121,7 @@
     }
 
     if (dp->d_flags & RT_DIR_COMB) {
+
        struct rt_db_internal in;
        struct rt_comb_internal *comb;
 
@@ -109,18 +129,22 @@
            return;
 
        comb = (struct rt_comb_internal *)in.idb_ptr;
-       push_walk_subtree(dbip, comb->tree, comb_func, leaf_func, resp, 
depth+1, client_data);
+       push_walk_subtree(dbip, comb->tree, comb_func, leaf_func, resp, 
depth+1, curr_mat, client_data);
        rt_db_free_internal(&in);
 
        /* Finally, the combination itself */
        if (comb_func)
-           comb_func(dbip, dp, depth, client_data);
+           comb_func(dbip, dp, depth, curr_mat, client_data);
 
     } else if (dp->d_flags & RT_DIR_SOLID || dp->d_major_type & 
DB5_MAJORTYPE_BINARY_MASK) {
+
        if (leaf_func)
-           leaf_func(dbip, dp, depth, client_data);
+           leaf_func(dbip, dp, depth, curr_mat, client_data);
+
     } else {
+
        bu_log("push_walk:  %s is neither COMB nor SOLID?\n", dp->d_namep);
+
     }
 }
 
@@ -160,10 +184,11 @@
     std::set<dp_i> s_i;
     std::map<struct directory *, int> s_c;
     int verbosity = 0;
+    const struct bn_tol *tol;
 };
 
 static void
-visit_comb_memb(struct db_i *dbip, struct rt_comb_internal *UNUSED(comb), 
union tree *comb_leaf, void *data, void *UNUSED(u2), void *UNUSED(u3), void 
*UNUSED(u4))
+visit_comb_memb(struct db_i *dbip, struct rt_comb_internal *UNUSED(comb), 
union tree *comb_leaf, void *data, void *cm, void *UNUSED(u3), void *UNUSED(u4))
 {
     struct push_state *s = (struct push_state *)data;
     struct directory *dp;
@@ -178,19 +203,21 @@
     if (s->verbosity) {
        if (comb_leaf->tr_l.tl_mat) {
            bu_log("Found comb entry: %s[M] (Instance count: %d)\n", 
dp->d_namep, s->s_c[dp]);
-           if (s->verbosity > 1) {
-               struct bu_vls title = BU_VLS_INIT_ZERO;
-               bu_vls_sprintf(&title, "%s matrix:", comb_leaf->tr_l.tl_name);
-               bn_mat_print(bu_vls_cstr(&title), comb_leaf->tr_l.tl_mat);
-               bu_vls_free(&title);
-           }
        } else {
            bu_log("Found comb entry: %s (Instance count: %d)\n", dp->d_namep, 
s->s_c[dp]);
        }
+       if (s->verbosity > 1) {
+           struct bu_vls title = BU_VLS_INIT_ZERO;
+           bu_vls_sprintf(&title, "%s matrix", comb_leaf->tr_l.tl_name);
+           mat_t *curr_mat = (mat_t *)cm;
+           if (!bn_mat_is_equal(*curr_mat, bn_mat_identity, s->tol))
+               bn_mat_print(bu_vls_cstr(&title), *curr_mat);
+           bu_vls_free(&title);
+       }
     }
 }
 
-void comb_cnt(struct db_i *dbip, struct directory *dp, int depth, void *data)
+void comb_cnt(struct db_i *dbip, struct directory *dp, int depth, mat_t 
*curr_mat, void *data)
 {
     struct rt_db_internal intern;
     if (rt_db_get_internal(&intern, dp, dbip, (fastf_t *)NULL, 
&rt_uniresource) < 0) {
@@ -198,7 +225,7 @@
     }
     struct rt_comb_internal *comb = (struct rt_comb_internal *)intern.idb_ptr;
     if (comb->tree)
-       db_tree_funcleaf(dbip, comb, comb->tree, visit_comb_memb, data, (void 
*)&depth, NULL, NULL);
+       db_tree_funcleaf(dbip, comb, comb->tree, visit_comb_memb, data, (void 
*)curr_mat, NULL, NULL);
     rt_db_free_internal(&intern);
     struct push_state *s = (struct push_state *)data;
     if (s->verbosity) {
@@ -267,10 +294,13 @@
 
     struct push_state s;
     s.verbosity = verbosity;
+    s.tol = &gedp->ged_wdbp->wdb_tol;
+    mat_t m;
+    MAT_IDN(m);
     for (int i = 0; i < argc; i++) {
        struct directory *dp = db_lookup(dbip, argv[i], LOOKUP_NOISY);
        if (dp != RT_DIR_NULL) {
-           push_walk(dbip, dp, comb_cnt, NULL, &rt_uniresource, 0, &s);
+           push_walk(dbip, dp, comb_cnt, NULL, &rt_uniresource, 0, &m, &s);
        }
     }
 

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