コード例 #1
0
ファイル: bedge.C プロジェクト: karmakat/jot-lib
int
Bedge::redefine(Bvert *v, Bvert *u)
{
    // redefine this edge, replacing v with u

    // precondition:
    //   edge does not already contain u.
    //   v is a vertex of this edge.
    //   faces have already been detached.
    //   can't duplicate an existing edge.

    assert(contains(v) && nfaces() == 0);

    if (contains(u))
        return 0;

    Bedge* dup = 0;
    if (v == _v1) {
        if ((dup = u->lookup_edge(_v2))) {
            // can't redefine, but if this is a crease edge
            // should ensure the duplicated edge is also
            if (is_crease())
                dup->set_crease(crease_val());
            return 0;
        }
        // can redefine:
        *_v1 -= this;     // say bye to old _v1
        _v1 = u;          // record new _v1
        *_v1 += this;     // say hi to new _v1
    } else if (v == _v2) {
        // see comments above
        if ((dup = u->lookup_edge(_v1))) {
            if (is_crease())
                dup->set_crease(crease_val());
            return 0;
        }
        *_v2 -= this;
        _v2 = u;
        *_v2 += this;
    } else assert(0);

    geometry_changed();

    return 1;
}