Esempio n. 1
0
/*
 1.28 Evaporate splits this face in triangles and collapses these to a point
 inside. When the parameter ~close~ is false, then the triangles are expanded,
 making this the function "Condensate".
 
*/
vector<MSegs> Face::Evaporate(bool close) {
    vector<MSegs> ret;
    Face reg = *this; // Crate a copy first
    
    // At first, integrate all holes into the cycle
    reg.IntegrateHoles();

    while (reg.v.size() > 3) {
        // Then, repeatedly clip an ear until only a triangle is left
        Face r = reg.ClipEar();
        // and collapse (or expand) the triangles towards its centroid.
        MSegs s = r.collapse(close, r.GetCentroid());
        s.isevaporating = 1;
        ret.push_back(s);
    }
    // Finally, handle the last triangle left.
    MSegs s = reg.collapse(close, reg.GetCentroid());
    s.isevaporating = 1;
    ret.push_back(s);

    return ret;
}