Skip to content

Commit

Permalink
Add HRT mat application method
Browse files Browse the repository at this point in the history
  • Loading branch information
starseeker committed Jan 31, 2025
1 parent 0e4eeab commit e537e6c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
39 changes: 32 additions & 7 deletions src/librt/primitives/hrt/hrt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1543,6 +1543,30 @@ rt_hrt_export5(struct bu_external *ep, const struct rt_db_internal *ip, double l
return 0;
}

int
rt_hrt_mat(struct rt_db_internal *rop, const mat_t mat, const struct rt_db_internal *ip)
{
if (!rop || !ip || !mat)
return BRLCAD_OK;

struct rt_hrt_internal *tip = (struct rt_hrt_internal *)ip->idb_ptr;
RT_HRT_CK_MAGIC(tip);
struct rt_hrt_internal *top = (struct rt_hrt_internal *)rop->idb_ptr;
RT_HRT_CK_MAGIC(top);

vect_t v, xdir, ydir, zdir;
VMOVE(v, tip->v);
VMOVE(xdir, tip->xdir);
VMOVE(ydir, tip->ydir);
VMOVE(zdir, tip->zdir);

MAT4X3PNT(top->v, mat, v);
MAT4X3PNT(top->xdir, mat, xdir);
MAT4X3PNT(top->ydir, mat, ydir);
MAT4X3PNT(top->zdir, mat, zdir);

return BRLCAD_OK;
}

/**
* Import a heart from the database format to the internal format.
Expand Down Expand Up @@ -1574,15 +1598,16 @@ rt_hrt_import5(struct rt_db_internal *ip, const struct bu_external *ep, const fa
/* Convert from database(network) to internal (host) format */
bu_cv_ntohd((unsigned char *)hec, ep->ext_buf, ELEMENTS_PER_VECT*4 + 1);

/* Apply modelling transformations */
if (mat == NULL) mat = bn_mat_identity;
MAT4X3PNT(hip->v, mat, &hec[0*ELEMENTS_PER_VECT]);
MAT4X3PNT(hip->xdir, mat, &hec[1*ELEMENTS_PER_VECT]);
MAT4X3PNT(hip->ydir, mat, &hec[2*ELEMENTS_PER_VECT]);
MAT4X3PNT(hip->zdir, mat, &hec[3*ELEMENTS_PER_VECT]);
/* Assign values */
VMOVE(hip->v, &hec[0*ELEMENTS_PER_VECT]);
VMOVE(hip->xdir, &hec[1*ELEMENTS_PER_VECT]);
VMOVE(hip->ydir, &hec[2*ELEMENTS_PER_VECT]);
VMOVE(hip->zdir, &hec[3*ELEMENTS_PER_VECT]);
hip->d = hec[4*ELEMENTS_PER_VECT];

return 0; /* OK */
/* Apply transformations */
if (mat == NULL) mat = bn_mat_identity;
return rt_hrt_mat(ip, mat, ip);
}


Expand Down
2 changes: 1 addition & 1 deletion src/librt/primitives/table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2367,7 +2367,7 @@ const struct rt_functab OBJ[] = {
NULL, /* serialize */
NULL, /* label */
NULL, /* keypoint */
NULL, /* mat */
RTFUNCTAB_FUNC_MAT_CAST(rt_hrt_mat),
NULL /* perturb */
},

Expand Down

0 comments on commit e537e6c

Please sign in to comment.