Exemple #1
0
struct pixel *
lookup_pixel(struct bu_rb_tree *palette, unsigned char *color)
{
    int rc = 0;	/* Return code from bu_rb_insert() */
    struct pixel *qpp = NULL;	/* The query */
    struct pixel *pp = NULL;	/* Value to return */

    /*
     * Prepare the palette query
     */
    qpp = mk_pixel(color);

    /*
     * Perform the query by attempting an insertion...
     * If the query succeeds (i.e., the insertion fails!),
     * then we have our pixel.
     * Otherwise, we must create a new pixel.
     */
    switch (rc = bu_rb_insert(palette, (void *)qpp)) {
	case -1:
	    pp = (struct pixel *)bu_rb_curr1(palette);
	    free_pixel(qpp);
	    break;
	case 0:
	    pp = qpp;
	    break;
	default:
	    bu_exit(1, "bu_rb_insert() returns %d:  This should not happen\n", rc);
    }

    return pp;
}
Exemple #2
0
/*
 *			 L O O K U P _ V E R T E X ( )
 */
struct vertex *lookup_vertex(bu_rb_tree *dict, long int index, char *label)
{
    int			rc;	/* Return code from bu_rb_insert() */
    struct vertex	*qvp;	/* The query */
    struct vertex	*vp;	/* Value to return */

    /*
     *	Prepare the dictionary query
     */
    qvp = mk_vertex(index, label);

    /*
     *	Perform the query by attempting an insertion...
     *	If the query succeeds (i.e., the insertion fails!),
     *	then we have our vertex.
     *	Otherwise, we must create a new vertex.
     */
    switch (rc = bu_rb_insert(dict, (void *) qvp))
    {
	case -1:
	    vp = (struct vertex *) bu_rb_curr1(dict);
	    free_vertex(qvp);
	    break;
	case 0:
	    vp = qvp;
	    break;
	default:
	    bu_exit (1, "bu_rb_insert() returns %d:  This should not happen\n", rc);
    }

    return (vp);
}
Exemple #3
0
/*
 *			  A D D _ T O _ P R I O Q ( )
 *
 */
void add_to_prioq (void *v, int depth)
{
    struct vertex	*vp = (struct vertex *) v;

    BU_CKMAG(vp, VERTEX_MAGIC, "vertex");
    BU_CKMAG(vp -> v_bridge, BRIDGE_MAGIC, "bridge");

    bu_rb_insert(prioq, (void *) (vp -> v_bridge));
}