inline Bvert_list reorder(CBedge_list& edges) { Bvert_list ret; Bvert_list verts = edges.get_verts(); for (Bvert_list::size_type i = 0; i < verts.size(); i++) if (Bpoint::find_controller(verts[i]) || Bcurve::find_controller(verts[i])) { ret.push_back(verts[i]); break; } if (ret.empty()) return ret; for (Bvert_list::size_type i = 1; i < verts.size(); i++) { for (Bedge_list::size_type j = 0; j < edges.size(); j++) { Bvert* v = edges[j]->other_vertex(ret.back()); if (v && std::find(ret.begin(), ret.end(), v) == ret.end()) { ret.push_back(v); break; } } } err_adv(debug, " reorder: num of verts: %d", ret.size()); return ret; }
bool Bface::get_quad_verts(Bvert_list& verts) const { verts.clear(); Bvert *v1=nullptr, *v2=nullptr, *v3=nullptr, *v4=nullptr; if (!get_quad_verts(v1,v2,v3,v4)) return 0; verts.push_back(v1); verts.push_back(v2); verts.push_back(v3); verts.push_back(v4); return 1; }
Bvert_list BvertGrid::col(int i) const { Bvert_list ret; for (int j=0; j<nrows(); j++) ret.push_back(vert(i,j)); return ret; }
inline void add_p(Lvert* v, Bvert_list& vp, Bedge_list& ep) { // Helper method used below in get_parents(); // Given an Lvert, add its parent simplex to the // appropriate list depending on whether the parent // is an Lvert or Ledge. assert(v); Bsimplex* p = v->parent(); if (!p) return; if (is_vert(p)) vp.push_back((Bvert*)p); else if (is_edge(p)) ep.push_back((Bedge*)p); else assert(0); }
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; }