bool OVERSKETCH::apply_offsets(CBvert_list& sil_verts, const vector<double>& sil_offsets) { // XXX - preliminary... assert(sil_verts.size() == sil_offsets.size()); // Expand region around oversketched silhouette verts. // XXX - Should compute the one-ring size, not use "3" Bface_list region = sil_verts.one_ring_faces().n_ring_faces(3); // Find the minimum distance to the silhouette verts from the // outer boundary of the region Wpt_list sil_path = sil_verts.pts(); double R = min_dist(region.get_boundary().verts().pts(), sil_path); Bvert_list region_verts = region.get_verts(); Wpt_list new_locs = region_verts.pts(); vector<double> offsets; for (Bvert_list::size_type i=0; i<region_verts.size(); i++) { Wpt foo; int k = -1; double d = sil_path.closest(region_verts[i]->loc(), foo, k); if (k < 0 || k >= (int)sil_offsets.size()) { err_adv(debug, "OVERSKETCH::apply_offsets: error: can't find closest"); continue; } double s = swell_profile(d/R); double h = sil_offsets[k] * s; // err_adv(debug, " d: %f, d/R: %f, s: %f", d, d/R, s); offsets.push_back(h); new_locs[i] += region_verts[i]->norm()*h; // WORLD::show(region_verts[i]->loc(), new_locs[i], 1); } // now apply new locs // FIT_VERTS_CMDptr cmd = make_shared<FIT_VERTS_CMD>(region_verts, new_locs); SUBDIV_OFFSET_CMDptr cmd = make_shared<SUBDIV_OFFSET_CMD>(region_verts, offsets); cmd->doit(); WORLD::add_command(cmd); return true; }
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 (!dynamic_pointer_cast<LMESH>(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.size(), vp.size(), ep.size()); // 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.size()); try_append(faces, ep.get_primary_faces()); err_adv(debug, "parent faces from edges too: %d", faces.size()); // Pull out the vertices: return faces.get_verts(); }