Skip to content

Commit

Permalink
rt_label_vlist_faces caught in infinite loop. face list element had f…
Browse files Browse the repository at this point in the history
…orw / back points to itself. todo: fix.
  • Loading branch information
Brad Eric Hollister committed Aug 12, 2015
1 parent 49f6daa commit aa0082b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 20 deletions.
2 changes: 1 addition & 1 deletion include/rt/vlist.h
Expand Up @@ -97,7 +97,7 @@ RT_EXPORT extern void rt_label_vlist_verts(struct bn_vlblock *vbp,
* Used by MGED's "labelface" command.
*/
RT_EXPORT extern void rt_label_vlist_faces(struct bn_vlblock *vbp,
struct face** f_list,
struct face* f_list,
mat_t mat,
double sz,
double mm2local);
Expand Down
25 changes: 10 additions & 15 deletions src/librt/vlist.c
Expand Up @@ -507,28 +507,23 @@ rt_label_vlist_verts(struct bn_vlblock *vbp, struct bu_list *src, fastf_t *mat,
}

void
rt_label_vlist_faces(struct bn_vlblock* vbp, struct face** f_list,
rt_label_vlist_faces(struct bn_vlblock* vbp, struct face* f_list,
fastf_t *mat, double sz, double UNUSED(mm2local) )
{
/* struct bn_vlist *vp; */
struct bu_list *vhead;
struct bu_list* vhead;
struct face* curr_f;
char label[256];
int idx;
point_t avg_pt;

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

for ( idx = 0; idx < 12; idx++ ) {
if ( &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, avg_pt, mat, sz);
}
for( BU_LIST_FOR(curr_f, face, &f_list->l) ) {
avg_pt[0] = (curr_f->min_pt[0] + curr_f->max_pt[0]) / 2;
avg_pt[1] = (curr_f->min_pt[1] + curr_f->max_pt[1]) / 2;
avg_pt[2] = (curr_f->min_pt[2] + curr_f->max_pt[2]) / 2;

sprintf(label, " %d", (int)curr_f->index );
bn_vlist_3string(vhead, vbp->free_vlist_hd, label, avg_pt, mat, sz);
}
}

Expand Down
26 changes: 22 additions & 4 deletions src/mged/overlay.c
Expand Up @@ -134,13 +134,16 @@ f_labelvert(ClientData UNUSED(clientData), Tcl_Interp *interp, int argc, const c
return TCL_OK;
}

void get_face_list(const struct model* m, struct face** f_list )
void get_face_list(const struct model* m, struct face* f_list )
{
struct nmgregion *r;
struct shell *s;
struct faceuse *fu;
struct face *f;
#if 0
struct face *tail;
int idx = 0;
#endif

NMG_CK_MODEL(m);

Expand All @@ -163,15 +166,26 @@ void get_face_list(const struct model* m, struct face** f_list )
NMG_CK_FACEUSE(fu);
f = fu->f_p;
NMG_CK_FACE(f);

#if 0
f_list[idx++] = f;

if ( BU_LIST_IS_EMPTY(f_list) ) {
BU_LIST_APPEND(f_list, &f->l);
} else {
BU_LIST_APPEND(&tail->l, &f->l);
}
#endif
BU_LIST_INSERT(&f_list->l, &f->l);

if (f->g.magic_p) switch (*f->g.magic_p) {
case NMG_FACE_G_PLANE_MAGIC:
break;
case NMG_FACE_G_SNURB_MAGIC:
break;
}
#if 0
tail = f;
#endif
}
}
}
Expand All @@ -191,8 +205,12 @@ f_labelface(ClientData UNUSED(clientData), Tcl_Interp *interp, int argc, const c
fastf_t scale;
struct model* m;
const char* name;
#if 0
struct face* f_list[50] = {0};
#endif

struct face f_list;
BU_LIST_INIT(&(f_list.l));

/* attempt to resolve and verify */
name = argv[1];
Expand Down Expand Up @@ -245,8 +263,8 @@ f_labelface(ClientData UNUSED(clientData), Tcl_Interp *interp, int argc, const c
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);
get_face_list(m, &f_list);
rt_label_vlist_faces(vbp, &f_list, mat, scale, base2local);
}
}

Expand Down

0 comments on commit aa0082b

Please sign in to comment.