inline void debug_check_verts(Cstr_ptr& msg, CBvert_list& verts, CBvert_list& dirty_verts) { Bvert_list A = verts.filter(BitSetSimplexFilter(Lvert::DIRTY_VERT_LIST_BIT)); if (!dirty_verts.contains_all(A)) { Bvert_list bad = A.minus(dirty_verts); cerr << msg << ": found " << bad.num() << " vertices missing from dirty list" << endl; WORLD::show_pts(bad.pts(), 8, Color::red); } Bvert_list B = verts.filter(BitClearSimplexFilter(Lvert::DIRTY_VERT_LIST_BIT)); if (dirty_verts.contains_any(B)) { Bvert_list bad = dirty_verts.minus(B); cerr << msg << ": found " << bad.num() << " unexpected vertices in dirty list" << endl; WORLD::show_pts(bad.pts(), 8, Color::blue); } }
inline int match_span(Bvert* v, Bedge* e, CPIXEL_list& trail, int k, double thresh) { // Ensure various required conditions are true: if (!(v && e && e->contains(v) && trail.valid_index(k))) { err_adv(debug, "match_span: invalid vert/edge/index"); return -1; } // Get the chain of vertices at the "current" mesh level: Bvert_list verts = get_cur_level_verts(v, e); assert(verts.num() > 1); // Ensure the vertex chain starts near the current // position in the pixel trail: if (trail[k].dist(verts.first()->wloc()) > thresh) { err_adv(debug, "match_span: vert chain too far from pixel trail: %f > %f", trail[k].dist(verts.first()->wloc()), thresh); return -1; } // Test that the length of the refined edge is // close to the length of the chosen span. // // This is a cheap way of seeing that the projected edge // lies reasonably along the given portion of the pixel trail. int ret = next_match(verts.last(), trail, k, thresh); if (ret < 0) { err_adv(debug, "match_span: can't match next vert"); return -1; } double vlen = pix_len(verts.wpts()); if (vlen < 0) return -1; // Measure length of the trail, including distance to // beginning and end of the projected edge: double tlen = length(trail, k, ret); double e1 = verts.first()->pix().dist(trail[ k]); double e2 = verts.last ()->pix().dist(trail[ret]);; err_adv(debug, "adding %3.0f, %3.0f", e1, e2); err_adv(debug, "edge length: %3.0f, span length: %3.0f, ratio: %1.2f: %s", vlen, tlen, tlen/vlen, (tlen > 1.2*vlen) ? "rejected" : "accepted"); if (tlen > 1.2*vlen) return -1; return ret; }
Bvert_list LMESH::get_subdiv_inputs(CBvert_list& verts) { static bool debug = Config::get_var_bool("DEBUG_LMESH_SUBDIV_INPUTS",false); // Given a set of vertices from the same LMESH, return // the vertices of the parent LMESH that affect the // subdivision locations of the given vertices. // Require verts share common LMESH // XXX - could relax this, provided we test each Bvert // to ensure it is really an Lvert. if (!isa(verts.mesh())) return Bvert_list(); // Get direct parent vertices and edges Bvert_list vp; // vertex parents Bedge_list ep; // edge parents get_parents(verts, vp, ep); err_adv(debug, "%d verts: parents: %d verts, %d edges", verts.num(), vp.num(), ep.num()); // Clear flags of all adjacent faces clear_face_flags(vp); ep.clear_flag02(); // Put all adjacent faces into a list Bface_list faces = get_q_faces(vp); err_adv(debug, "parent faces from verts: %d", faces.num()); try_append(faces, ep.get_primary_faces()); err_adv(debug, "parent faces from edges too: %d", faces.num()); // Pull out the vertices: return faces.get_verts(); }
void ProxySurface::trim_proxy_surface() { assert(_proxy_mesh); int n = 0; //number of faces outside the bounding box //get all the quads Bface_list faces = _proxy_mesh->faces(); //clear out all the markings for(int i=0; i < faces.num(); ++i) { if(faces[i]) ProxyData::set_mark(faces[i],this, false); //else // cerr << "FACE is NULL" << endl; } //mark all the faces that do not overap bounding box for(int i=0; i < faces.num(); ++i) { if(faces[i]){ bool t1 = (is_inside_bounding_box(faces[i]->e1())) ? true : false; bool t2 = (is_inside_bounding_box(faces[i]->e2())) ? true : false; bool t3 = (is_inside_bounding_box(faces[i]->e3())) ? true : false; // If all the edges are outside, then mark the face if(!t1 && !t2 && !t3){ //cerr << "we can delete this face" << endl; ProxyData::set_mark(faces[i], this, true); n++; } }else { //cerr << "FACE is NULL" << endl; } } if(n < 1) return; //for all verts check to see if all the faces that it is attached to has a marked Bvert_list verts = _proxy_mesh->verts(); for(int i=0; i < verts.num(); ++i) { ARRAY<Bface*> ret; verts[i]->get_quad_faces(ret); // Make sure that all adjasent faces need to be deleted bool do_it=true; for(int k=0; k < ret.num(); ++k) { if(ret[k]){ assert(ret[k]->is_quad()); if(!ProxyData::get_mark(ret[k], this) || !ProxyData::get_mark(ret[k]->quad_partner(), this)) { // cerr << "vert degree " << verts[i]->p_degree() << endl; do_it = false; break; } } } if(do_it){ UVpt remove_uv; UVdata::get_uv(verts[i], remove_uv); remove_vert_grid(remove_uv); _proxy_mesh->remove_vertex(verts[i]); _proxy_mesh->changed(); } } //clean up faces Bface_list faces2 = _proxy_mesh->faces(); for(int i=0; i < faces2.num(); ++i) { if(!(faces2[i]->is_quad()) || !(faces2[i]->quad_partner())){ _proxy_mesh->remove_face(faces2[i]); _proxy_mesh->changed(); } } //debug_grid(); }