bool Skin::correct_face(Bface* f, bool& changed) { // // BBBBBBBBBBBBBBB // B /| // B / | // B f / | Change this, where quad face f // B / | is adjacent to 2 boundary edgees... // B / | // B / | // B/- - - - - - o // // BBBBBBBBBBBBBBB // B\ | // B \ | // B \ | ... to this, where neither face of // B \ | the quad is adjacent to more than 1 // B \ | boundary edge. // B \ | // B - - - - - - o // assert(f); // boundary edges have flag == 1, others have flag == 0 uint n = num_edge_flags_set(f); if (n < 2) return true; // not a problem if (n > 2) { // unfixable problem err_adv(debug, " can't fix face with %d boundary edges", n); return false; } // 2 boundary edges; get the non-boundary one: Bedge* e = boundary_connector(f); assert(e); // we want to swap it; only possible if it has 2 faces: if (e->nfaces() != 2) { err_adv(debug, " can't fix edge with %d faces", e->nfaces()); return false; } // swapping won't do any good if its other face has boundary edges too: if (!(num_edge_flags_set(e->f1()) == 0 || num_edge_flags_set(e->f2()) == 0)) { err_adv(debug, " unfixable edge found, giving up"); return false; } // try to swap it: if (e->do_swap()) { err_adv(debug, " swapped edge"); return changed = true; } err_adv(debug, " edge swap failed"); return false; }