Пример #1
0
/* 
 * Add an edge to a ring of edges. 
 */
static void splice(edge * a, edge * b, point * v)
{
    edge *next;


    /* b must be the unnattached edge and a must be the previous 
       ccw edge to b. */

    if (Org(a) == v) {
        next = Onext(a);
        Onext(a) = b;
    } else {
        next = Dnext(a);
        Dnext(a) = b;
    }
    if (Org(next) == v)
        Oprev(next) = b;
    else
        Dprev(next) = b;
    if (Org(b) == v) {
        Onext(b) = next;
        Oprev(b) = a;
    } else {
        Dnext(b) = next;
        Dprev(b) = a;
    }
}
Пример #2
0
/* 
 * Creates a new edge and adds it to two rings of edges.
 */
static edge *join(edge * a, point * u, edge * b, point * v, side s)
{
    edge *e;

    /* u and v are the two vertices which are being joined.
       a and b are the two edges associated with u and v res. */

    e = make_edge(u, v);

    if (s == side::left) {
        if (Org(a) == u)
            splice(Oprev(a), e, u);
        else
            splice(Dprev(a), e, u);
        splice(b, e, v);
    } else {
        splice(a, e, u);
        if (Org(b) == v)
            splice(Oprev(b), e, v);
        else
            splice(Dprev(b), e, v);
    }

    return e;
}
Пример #3
0
void Edge::Draw(unsigned int stamp)
// This is a recursive drawing routine that uses time stamps to
// determine if the edge has already been drawn. This is given
// here for testing purposes only: it is not efficient, and for
// large triangulations the stack might overflow. A better way
// of doing this (and other traversals of the edges) is to maintain
// a list of edges in the corresponding Subdivision object. This
// list should be updated every time an edge is created or destroyed.
{
	if (Qedge()->TimeStamp(stamp)) {

		// Draw the edge
		Point2d a = Org2d();
		Point2d b = Dest2d();
		bgnline();
		v2d((double*)&a);
		v2d((double*)&b);
		endline();

		// visit neighbors
		Onext()->Draw(stamp);
		Oprev()->Draw(stamp);
		Dnext()->Draw(stamp);
		Dprev()->Draw(stamp);
	}
}