Skip to content

Commit

Permalink
now taking avg of min and max bounding extents. works great for label…
Browse files Browse the repository at this point in the history
… placement.
  • Loading branch information
Brad Eric Hollister committed Aug 11, 2015
1 parent 9efa36c commit 49f6daa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 27 deletions.
8 changes: 5 additions & 3 deletions src/librt/vlist.c
Expand Up @@ -514,18 +514,20 @@ rt_label_vlist_faces(struct bn_vlblock* vbp, struct face** f_list,
struct bu_list *vhead;
char label[256];
int idx;
point_t avg_pt;

vhead = bn_vlblock_find(vbp, 255, 255, 255); /* white */

for ( idx = 0; idx < 12; idx++ ) {
register point_t *pt;
if ( &f_list[idx]->min_pt ) {
pt = &(f_list[idx]->min_pt);
avg_pt[0] = (f_list[idx]->min_pt[0] + f_list[idx]->max_pt[0]) / 2;
avg_pt[1] = (f_list[idx]->min_pt[1] + f_list[idx]->max_pt[1]) / 2;
avg_pt[2] = (f_list[idx]->min_pt[2] + f_list[idx]->max_pt[2]) / 2;
}

if ( f_list[idx] ) {
sprintf(label, " %d", (int)f_list[idx]->index );
bn_vlist_3string(vhead, vbp->free_vlist_hd, label, (*pt), mat, sz);
bn_vlist_3string(vhead, vbp->free_vlist_hd, label, avg_pt, mat, sz);
}
}
}
Expand Down
41 changes: 17 additions & 24 deletions src/mged/overlay.c
Expand Up @@ -184,11 +184,9 @@ f_labelface(ClientData UNUSED(clientData), Tcl_Interp *interp, int argc, const c
struct rt_db_internal internal;
struct directory *dp;
struct display_list *gdlp;
#if 0
struct display_list *next_gdlp;
#endif
int i;
struct bn_vlblock*vbp;
struct bn_vlblock *vbp;
mat_t mat;
fastf_t scale;
struct model* m;
Expand Down Expand Up @@ -237,28 +235,23 @@ f_labelface(ClientData UNUSED(clientData), Tcl_Interp *interp, int argc, const c
scale = view_state->vs_gvp->gv_size / 100; /* divide by # chars/screen */

for (i=1; i<argc; i++) {
struct solid *s;
if ((dp = db_lookup(dbip, argv[i], LOOKUP_NOISY)) == RT_DIR_NULL)
continue;
/* Find uses of this solid in the solid table */
gdlp = BU_LIST_NEXT(display_list, gedp->ged_gdp->gd_headDisplay);
while (BU_LIST_NOT_HEAD(gdlp, gedp->ged_gdp->gd_headDisplay)) {
#if 0
next_gdlp = BU_LIST_PNEXT(display_list, gdlp);
#endif

FOR_ALL_SOLIDS(s, &gdlp->dl_headSolid) {
if (db_full_path_search(&s->s_fullpath, dp)) {
get_face_list(m, &f_list[0]);
rt_label_vlist_faces(vbp, &f_list[0], mat, scale, base2local);
}
}
struct solid *s;
if ((dp = db_lookup(dbip, argv[i], LOOKUP_NOISY)) == RT_DIR_NULL)
continue;

/* Find uses of this solid in the solid table */
gdlp = BU_LIST_NEXT(display_list, gedp->ged_gdp->gd_headDisplay);
while (BU_LIST_NOT_HEAD(gdlp, gedp->ged_gdp->gd_headDisplay)) {
next_gdlp = BU_LIST_PNEXT(display_list, gdlp);
FOR_ALL_SOLIDS(s, &gdlp->dl_headSolid) {
if (db_full_path_search(&s->s_fullpath, dp)) {
get_face_list(m, &f_list[0]);
rt_label_vlist_faces(vbp, &f_list[0], mat, scale, base2local);
}
}

break;
#if 0
gdlp = next_gdlp;
#endif
}
gdlp = next_gdlp;
}
}

cvt_vlblock_to_solids(vbp, "_LABELFACE_", 0);
Expand Down

0 comments on commit 49f6daa

Please sign in to comment.