void draw_blobs()
{
    estack.clear();                           // holds bottle edges that are inside blobs
    get_starting_tetra();                     // for each blob, find one tetra on its surface
    while (Tetra *t = tstack.pop()) {
        int state = 0;
        for (int i = 0; i < 4; i++) {         // check in|out status of all 4 tetra points
            Point *v = t->vertex[i];
            if (v->stamp < timestamp) {
                v->value = calc(v->p);        // calculate blob influence at this point
                v->stamp = timestamp;
            }
            state >>= 1;
            if (v->value > THRESH)
                state |= 8;                   // tetra point is inside so set its state bit
        }
        int *x = em[state];
        if (*x >= 0) {                        // some of the tetrahedra is inside a blob       
            do {                              // draw it
                output_edge(t->edge[*x++]);
            } while (*x >= 0);
            for (int i = 0; i < 4; i++)	      // then push its neighbors on the stack
                if (Tetra *a = t->tetra[i]) {
                    if (a->stamp < timestamp) {
                        tstack.push(a);
                        a->stamp = timestamp;
                    }
                }
                else                          // a tetra face is on the bottle so draw it
                    triangulate_face(t, i);
        }
    }
    while (Edge *e = estack.pop()) {          // fill in where blobs press against bottle
        for (int j = 0; j < 2; j++) {	      // bottle edge borders on 2 bottle faces
            Tetra *t = e->t[j];
            if (t->stamp < timestamp) {
                t->stamp = timestamp;
                for (int i = 0; i < 4; i++)
                    if (t->tetra[i] == 0) {   // face i of the tetrahedra is on the bottle
                        triangulate_face(t, i, 7);
                        break;
                    }
            }
        }
    }
    timestamp++;
}