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; }