Exemple #1
0
bool join(PointContour& c1, PointContour& c2) {
    ContourPoint c1_front = c1.front();
    ContourPoint c1_back = c1.back();
    ContourPoint c2_front = c2.front();
    ContourPoint c2_back = c2.back();

    if (c1_back == c2_front) {
        c1.splice(c1.end(), c2);
    }
    else if (c1_front == c2_back) {
        c1.splice(c1.begin(), c2);
    }
    else if (c1_back == c2_back) {
        if (c2.size() < c1.size()) {
            c2.reverse();
            c1.splice(c1.end(), c2);
        }
        else {
            c1.reverse();
            c1.splice(c1.begin(), c2);
        }
    }
    else if (c1_front == c2_front) {
        if (c2.size() < c1.size()) {
            c2.reverse();
            c1.splice(c1.begin(), c2);
        }
        else {
            c1.reverse();
            c1.splice(c1.end(), c2);
        }
    }
    else
        return false;

    return true;
}
Exemple #2
0
inline bool closed(PointContour& c) {
    return c.front() == c.back();
}