inline void get_parents(CBvert_list& verts, Bvert_list& vp, Bedge_list& ep) { // Helper method used below in get_parents(); // from the given list of vertices, return the parent // simplices in two lists: one of Lverts, one of Ledges. if (verts.empty()) return; assert(dynamic_pointer_cast<LMESH>(verts.mesh())); for (Bvert_list::size_type i=0; i<verts.size(); i++) add_p((Lvert*)verts[i], vp, ep); }
inline void get_parents(CBvert_list& verts, Bvert_list& vp, Bedge_list& ep) { // Helper method used below in get_parents(); // from the given list of vertices, return the parent // simplices in two lists: one of Lverts, one of Ledges. if (verts.empty()) return; assert(LMESH::isa(verts.mesh())); for (int i=0; i<verts.num(); i++) add_p((Lvert*)verts[i], vp, ep); }
SubdivUpdater::SubdivUpdater(LMESHptr m, CBvert_list& verts) : _parent(nullptr) { // Screened in SubdivUpdater::create(): assert(m && m == verts.mesh()); _mesh = m; _verts = verts; // Get bbases, add to inputs _inputs = Bbase::find_owners(verts).bnodes(); if (debug) { err_msg("SubdivUpdater::SubdivUpdater:"); cerr << " "; print_dependencies(); err_msg(" level %d, %d verts, %d boss memes", m->subdiv_level(), verts.size(), Bbase::find_boss_vmemes(verts).size()); } // If not covered, create parent if (!Bbase::is_covered(verts)) { // Get parent verts list Bvert_list parents = LMESH::get_subdiv_inputs(verts); // If non-empty create parent SubdivUpdater if (!parents.empty()) { // Create parent subdiv updater on parent verts // and add to _inputs _parent = create(parents); _inputs += _parent; } } hookup(); }
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(); }
bool BvertGrid::build( CBvert_list& bottom, // bottom row CBvert_list& top, // top row CBvert_list& left, // left column CBvert_list& right // right column ) { // Vertices of bottom and top run left to right. // On the left and right they run bottom to top. // Check everything is righteous: if (bottom.size() < 2 || bottom.size() != top.size() || left.size() < 2 || left.size() != right.size() || bottom.front() != left.front() || bottom.back() != right.front() || top.front() != left.back() || top.back() != right.back() || !bottom.same_mesh() || !top.same_mesh() || !left.same_mesh() || !right.same_mesh() || bottom.mesh() == nullptr) { err_msg("BvertGrid::build: can't deal with CRAP input"); std::ostream_iterator<Bvert*> err_it (std::cerr, ", "); cerr << "bottom: "; std::copy(bottom.begin(), bottom.end(), err_it); cerr << endl; cerr << "top: "; std::copy(top.begin(), top.end(), err_it); cerr << endl; cerr << "left: "; std::copy(left.begin(), left.end(), err_it); cerr << endl; cerr << "right: "; std::copy(right.begin(), right.end(), err_it); cerr << endl; return false; } // Wipe the old: clear(); // Build the new... // bottom row: _grid.push_back(bottom); BMESHptr m = bottom.mesh(); assert(m); // Internal rows: for (Bvert_list::size_type j=1; j<left.size()-1; j++) { Bvert_list row; // vertices for row j row.push_back(left[j]); // add first vertex for row j for (Bvert_list::size_type i=1; i<bottom.size()-1; i++) row.push_back(m->add_vertex()); // add internal vertices row.push_back(right[j]); // add last vertex for row j _grid.push_back(row); } // top row: _grid.push_back(top); // Now compute cached values: cache(); return true; }