Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- **
- * This restores the matrix transformation at a combination by taking leaf matrix tranformations, Innverting
- * and storing the changes at the combinations.
- */
- static void
- comb_mat_restore(struct db_i *dbip, struct rt_comb_internal *UNUSED(comb), union tree *comb_leaf, genptr_t user_ptr1, genptr_t (user_ptr2), genptr_t UNUSED(user_ptr3), genptr_t UNUSED(user_ptr4))
- {
- struct directory *dp;
- struct bu_vls *msg = (struct bu_vls *)user_ptr1;
- mat_t inv_mat;
- matp_t mat = (matp_t)user_ptr2;
- RT_CK_DBI(dbip);
- RT_CK_TREE(comb_leaf);
- if ((dp = db_lookup(dbip, comb_leaf->tr_l.tl_name, LOOKUP_NOISY)) == RT_DIR_NULL)
- return;
- /* invert the matrix transformation of the leaf and store new matrix at comb */
- bn_mat_inverse(inv_mat, &mat);
- /* multiply inverse and store at combination */
- bn_mat_mul2(inv_mat,comb_leaf->tr_l.tl_mat);
- MAT_COPY(&mat,comb_leaf->tr_l.tl_mat);
- comb_restore(dp, dbip, mat);
- }
- /**
- *@brief
- *comb_restore(): This routine enters a comb restoring the matrix transformation at the combination
- * calls and calls do_comb_restore() which updates current matrix transformation and moves up tree.
- */
- void
- comb_restore(struct dbi *dbip,
- struct directory *dp,
- (matp_t mp)
- {
- struct rt_db_internal intern;
- struct rt_comb_internal *comb;
- if (dp->d_flags & RT_DIR_SOLID)
- return;
- if (rt_db_get_internal(&intern, dp, dbip, (fastf_t *)NULL, &rt_uniresource) < 0) {
- bu_vls_printf(msg, "Database read error, aborting\n");
- return;
- }
- comb = (struct rt_comb_internal *)intern.idb_ptr;
- if (comb->tree) {
- db_tree_funcleaf(dbip, comb, comb->tree, comb_mat_restore,
- (genptr_t)mp, (genptr_t)NULL, (genptr_t)NULL);
- if (rt_db_put_internal(dp, dbip, &intern, &rt_uniresource) < 0) {
- bu_vls_printf(msg, "Cannot write modified combination (%s) to database\n", dp->d_namep);
- return;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment