Skip to content

Commit

Permalink
Migrate HALF read_params logic to functab
Browse files Browse the repository at this point in the history
  • Loading branch information
starseeker committed Jan 2, 2025
1 parent 20d8e24 commit 4399767
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
28 changes: 28 additions & 0 deletions src/mged/primitives/edhalf.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,34 @@ mged_hlf_write_params(
bu_vls_printf(p, "Plane: %.9f %.9f %.9f %.9f\n", V4BASE2LOCAL(half->eqn));
}

int
mged_hlf_read_params(
struct rt_db_internal *ip,
const char *fc,
const struct bn_tol *UNUSED(tol),
fastf_t local2base
)
{
double a = 0.0;
double b = 0.0;
double c = 0.0;
double d = 0.0;
struct rt_half_internal *haf = (struct rt_half_internal *)ip->idb_ptr;
RT_HALF_CK_MAGIC(haf);

if (!fc)
return BRLCAD_ERROR;

const char *lc = fc;
while (lc && strchr(lc, ':')) lc++;

sscanf(lc, "%lf %lf %lf %lf", &a, &b, &c, &d);
VSET(haf->eqn, a, b, c);
haf->eqn[W] = d * local2base;

// Cleanup
return BRLCAD_OK;
}

/*
* Local Variables:
Expand Down
2 changes: 1 addition & 1 deletion src/mged/primitives/table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const struct mged_functab MGED_OBJ[] = {
MGEDFUNCTAB_FUNC_KEYPOINT_CAST(mged_generic_keypoint), /* keypoint */
NULL, /* e_axes_pos */
MGEDFUNCTAB_FUNC_WRITE_PARAMS_CAST(mged_hlf_write_params), /* write_params */
NULL, /* read_params */
MGEDFUNCTAB_FUNC_READ_PARAMS_CAST(mged_hlf_read_params), /* read_params */
NULL /* menu_item */
},

Expand Down
11 changes: 0 additions & 11 deletions src/mged/tedit.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ readsolid(struct mged_state *s)
}

switch (s->edit_state.es_int.idb_type) {
struct rt_half_internal *haf;
struct rt_grip_internal *grip;
struct rt_rpc_internal *rpc;
struct rt_rhc_internal *rhc;
Expand All @@ -252,16 +251,6 @@ readsolid(struct mged_state *s)
Tcl_AppendResult(s->interp, "Cannot text edit this solid type\n", (char *)NULL);
ret_val = 1;
break;
case ID_HALF:
haf = (struct rt_half_internal *)s->edit_state.es_int.idb_ptr;
if ((str=Get_next_line(fp)) == NULL) {
ret_val = 1;
break;
}
sscanf(str, "%lf %lf %lf %lf", &a, &b, &c, &d);
VSET(haf->eqn, a, b, c);
haf->eqn[W] = d * s->dbip->dbi_local2base;
break;
case ID_GRIP:
grip = (struct rt_grip_internal *)s->edit_state.es_int.idb_ptr;
if ((str=Get_next_line(fp)) == NULL) {
Expand Down

0 comments on commit 4399767

Please sign in to comment.