Beispiel #1
0
void splay(node *p)
{
    while (p->p != NULL) {
        reverse(p->p->p);
        reverse(p->p);
        reverse(p);
        if (p->p->p == NULL) {
            if (p == p->p->l) {
                zig(p);
            }
            else {
                zag(p);
            }
        }
        else if (p->p == p->p->p->l) {
            if (p == p->p->l) {
                zigzig(p);
            }
            else {
                zagzig(p);
            }
        }
        else {
            if (p == p->p->l) {
                zigzag(p);
            }
            else {
                zagzag(p);
            }
        }
    }
}
/*
 * Segment needs to bend
 */
void StraightConstraint::satisfy() {
    FILE_LOG(logDEBUG)<<"StraightConstraint::satisfy():";
    Edge* e = segment->edge;
    EdgePoint* start = segment->start,
             * end = segment->end,
             * bend = new EdgePoint(node,ri);
    FILE_LOG(logDEBUG1)<<"  u=("<<start->node->id<<":"<<start->rectIntersect<<"), v=("<<node->id<<":"<<ri<<"), w=("<<end->node->id<<":"<<end->rectIntersect<<")";
    COLA_ASSERT(!zigzag(bend,end->outSegment));
    COLA_ASSERT(!zagzig(bend,start->inSegment));
    // shouldn't have straight constraints between end segments and the
    // nodes to which they are connected.
    COLA_ASSERT(!segment->connectedToNode(node));
    
    Segment* s1 = new Segment(e,start,bend);
    Segment* s2 = new Segment(e,bend,end);
    if(e->firstSegment==segment) {
        e->firstSegment=s1;
    }
    if(e->lastSegment==segment) {
        e->lastSegment=s2;
    }
    // create BendConstraint to replace this StraightConstraint
    bend->createBendConstraint(scanDim);

    // transfer other StraightConstraint constraints 
    // from s to s1 or s2 depending on which side of p they are on.
    transferStraightConstraintChoose transfer(s1,s2,this);
    segment->forEachStraightConstraint(transfer);
    // BendConstraint constraints associated with segment->end and 
    // segment->start need to be updated
    start->createBendConstraint(scanDim);
    end->createBendConstraint(scanDim);
             
    e->nSegments++;
    delete segment;
}