Skip to content

Commit

Permalink
fixed problem with adding same face struct to bu_list - which caused …
Browse files Browse the repository at this point in the history
…self-referential node (forw/back pointers pointing to node itself) in list
  • Loading branch information
Brad Eric Hollister committed Aug 12, 2015
1 parent aa0082b commit 2a9d3a7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 24 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 bu_list* f_list,
mat_t mat,
double sz,
double mm2local);
Expand Down
4 changes: 2 additions & 2 deletions src/librt/vlist.c
Expand Up @@ -507,7 +507,7 @@ 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 bu_list* f_list,
fastf_t *mat, double sz, double UNUSED(mm2local) )
{
struct bu_list* vhead;
Expand All @@ -517,7 +517,7 @@ rt_label_vlist_faces(struct bn_vlblock* vbp, struct face* f_list,

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

for( BU_LIST_FOR(curr_f, face, &f_list->l) ) {
for( BU_LIST_FOR(curr_f, face, f_list) ) {
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;
Expand Down
37 changes: 16 additions & 21 deletions src/mged/overlay.c
Expand Up @@ -134,16 +134,14 @@ 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 bu_list* f_list )
{
struct nmgregion *r;
struct shell *s;
struct faceuse *fu;
struct face *f;
#if 0
struct face *tail;
int idx = 0;
#endif
struct face* curr_f;
int found;

NMG_CK_MODEL(m);

Expand All @@ -166,26 +164,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);
found = 0;
/* check for duplicate face struct */
for (BU_LIST_FOR(curr_f, face, f_list)) {
if (curr_f->index == f->index) {
found = 1;
break;
}
}
#endif
BU_LIST_INSERT(&f_list->l, &f->l);

if ( !found )
BU_LIST_INSERT( f_list, &(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 @@ -205,12 +203,9 @@ 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 bu_list f_list;

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

/* attempt to resolve and verify */
name = argv[1];
Expand Down

0 comments on commit 2a9d3a7

Please sign in to comment.