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; }
/***************************************************************** * InflateCreaseFilter: *****************************************************************/ bool InflateCreaseFilter::accept(CBsimplex* s) const { // Reject non-edges: if (!is_edge(s)) return false; Bedge* e = (Bedge*)s; if (e->nfaces() < 2) return false; // Accept it if it's labelled a crease, is owned by a // Bcurve, or the adjacent faces make a sharp angle: return ( e->is_crease() || Bcurve::find_controller(e) || rad2deg(norm_angle(e)) > 50 ); }
void ProxySurface::grow_quad_from_edge(BMESH* m, EdgeStrip* boundary, int i) { // i is the position of the edge in the boundary Bedge* e = boundary->edge(i); assert(e); //make sure is still a boundary edge if not, return... if(e->nfaces() > 1){ return; } Bvert* v2 = boundary->vert(i); Bvert* v1 = boundary->next_vert(i); assert(v1); assert(v2); if(!(UVdata::is_continuous(e))) { cerr << "ProxySurface::grow_quad_from_edge: e is discontinous!!!" << endl; return; } UVpt uv_1, uv_2, uv_3, uv_4; if(!(UVdata::get_uv(v2, uv_2))) { cerr << "ProxySurface::grow_quad_from_edge: v2 vertex does not have UVdata!!!" << endl; return; } if(!(UVdata::get_uv(v1, uv_1))) { cerr << "ProxySurface::grow_quad_from_edge: v1 vertex does not have UVdata!!!" << endl; return; } // constant in u dir -> v line if(uv_1[0] == uv_2[0]){ if(uv_1[1] > uv_2[1]) { uv_3 = UVpt(uv_2[0]+1,uv_2[1]); uv_4 = UVpt(uv_1[0]+1,uv_1[1]); } else { uv_3 = UVpt(uv_2[0]-1,uv_2[1]); uv_4 = UVpt(uv_1[0]-1,uv_1[1]); } } else { assert(uv_1[1] == uv_2[1]); //constant in v dir if(uv_1[0] > uv_2[0]) { uv_3 = UVpt(uv_2[0],uv_2[1]-1); uv_4 = UVpt(uv_1[0],uv_1[1]-1); } else { uv_3 = UVpt(uv_2[0],uv_2[1]+1); uv_4 = UVpt(uv_1[0],uv_1[1]+1); } } // double dist = e->length(); //cerr << "grow quad: " << i << " " << uv_1 << " " << uv_2 << " " << uv_3 << " " << uv_4 << endl; Bvert* v_1 = vertFromUV(uv_1); Bvert* v_2 = vertFromUV(uv_2); Bvert* v_3 = vertFromUV(uv_3); Bvert* v_4 = vertFromUV(uv_4); assert(v_1 && v_2 && v_3 && v_4); //cerr << "grow quad: " << i << " " << v_1->wloc() << " " << v_2->wloc() << " " << v_3->wloc() << " " << v_4->wloc() << endl; m->add_quad(v_1, v_2, v_3, v_4, uv_1, uv_2, uv_3, uv_4, m->patch(0)); UVdata::set(v_1, uv_1); UVdata::set(v_2, uv_2); UVdata::set(v_3, uv_3); UVdata::set(v_4, uv_4); //PixelsData::get_pix(v_1, this); //PixelsData::get_pix(v_2, this); //PixelsData::get_pix(v_3, this); //PixelsData::get_pix(v_4, this); PixelsData::set_pix(v_1, this,v_1->pix()); PixelsData::set_pix(v_2, this,v_2->pix()); PixelsData::set_pix(v_3, this,v_3->pix()); PixelsData::set_pix(v_4, this,v_4->pix()); }