本文整理汇总了C++中Manifold::no_vertices方法的典型用法代码示例。如果您正苦于以下问题:C++ Manifold::no_vertices方法的具体用法?C++ Manifold::no_vertices怎么用?C++ Manifold::no_vertices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Manifold
的用法示例。
在下文中一共展示了Manifold::no_vertices方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: obj_save
bool obj_save(const string& filename, Manifold& m)
{
ofstream os(filename.data());
if(os.bad())
return false;
VertexAttributeVector<int> vmap;
int k = 0;
for(VertexIDIterator v = m.vertices_begin(); v != m.vertices_end(); ++v){
Vec3d p = m.pos(*v);
os << "v "<< p[0] << " " << p[1] << " " << p[2] << "\n";
vmap[*v] = k++;
}
for(FaceIDIterator f = m.faces_begin(); f != m.faces_end(); ++f){
vector<int> verts;
for(Walker w = m.walker(*f); !w.full_circle(); w = w.circulate_face_ccw()){
int idx = vmap[w.vertex()];
assert(static_cast<size_t>(idx) < m.no_vertices());
// move subscript range from 0..size-1 to 1..size according to OBJ standards
verts.push_back(idx + 1);
}
os << "f ";
for(size_t i = 0; i < verts.size() ; ++i){
os << verts[i] << " ";
}
os<<endl;
}
return true;
}
示例2: mean_curvature_smooth
void mean_curvature_smooth(Manifold& m, bool implicit, double lambda)
{
using EigMat = SparseMatrix<double>;
using EigVec = VectorXd;
int N = (int)m.no_vertices();
VertexAttributeVector<int> indices(m.allocated_vertices());
VertexAttributeVector<double> areas(m.allocated_vertices());
int i=0;
for(auto v: m.vertices()) {
indices[v] = i++;
areas[v] = mixed_area(m, v);
}
EigMat K(N,N); // Sparse matrix initialized with 0
EigVec X(N),Y(N),Z(N);
EigVec Xp(N), Yp(N), Zp(N);
//-----------------------------------------------------------
// Student implementation
//-----------------------------------------------------------
double epsilon = 1e-5;
for (auto vkey : m.vertices())
{
int i = indices[vkey];
for (auto w = m.walker(vkey); !w.full_circle(); w = w.circulate_vertex_ccw())
{
int j = indices[w.vertex()];
assert(i != j);
if (i > j
or w.face() == HMesh::InvalidFaceID
or w.opp().face() == HMesh::InvalidFaceID)
{
continue; // Avoid recomputation
}
auto pi = m.pos(w.opp().vertex());
auto pj = m.pos(w.vertex());
auto pl = m.pos(w.opp().next().vertex());
auto pk = m.pos(w.next().vertex());
double cot_alpha_ij = dot(pj - pk, pi - pk) /
( cross(pi - pk, pj - pk).length() + epsilon);
double cot_beta_ij = dot(pj - pl, pi - pl) /
( cross(pi - pl, pj - pl).length() + epsilon);
double Ai = areas[w.opp().vertex()];
double Aj = areas[w.vertex()];
double Lij = (cot_alpha_ij + cot_beta_ij)
/ sqrt(Ai*Aj + epsilon);
K.coeffRef(i, j) = Lij;
K.coeffRef(j, i) = Lij;
K.coeffRef(i, i) -= Lij;
K.coeffRef(j, j) -= Lij;
}
}
EigMat I(N,N);
for (int i = 0; i < N; i++)
{
I.coeffRef(i, i) = 1;
}
K = I - K*lambda;
for (auto vkey : m.vertices())
{
auto p = m.pos(vkey);
int i = indices[vkey];
X.coeffRef(i) = p[0];
Y.coeffRef(i) = p[1];
Z.coeffRef(i) = p[2];
}
// Solve
SimplicialLLT<EigMat> solver(K);
Xp = solver.solve(X);
Yp = solver.solve(Y);
Zp = solver.solve(Z);
// End student implementation
//-----------------------------------------------------------
for(auto v: m.vertices())
{
int i = indices[v];
m.pos(v) = Vec3d(Xp[i], Yp[i], Zp[i]);
}
}