Updated tutorial unittest. Fixed tutorial variable names.
This commit is contained in:
@@ -24,31 +24,30 @@ int main(int argc, char** argv)
|
||||
std::cerr << "Error: Cannot read mesh from " << infile << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
// Add a vertex property storing the computed centers of gravity
|
||||
auto cog = OpenMesh::makeTemporaryProperty<OpenMesh::VertexHandle, MyMesh::Point>(mesh);
|
||||
|
||||
// Smooth the mesh several times
|
||||
for (int i = 0; i < iterations; ++i) {
|
||||
// Iterate over all vertices to compute centers of gravity
|
||||
for (const auto& vh : mesh.vertices()) {
|
||||
cog[vv] = {0,0,0};
|
||||
int valence = 0;
|
||||
// Iterate over all 1-ring vertices around vh
|
||||
for (const auto& vvh : mesh.vv_range(vh)) {
|
||||
cog[vv] += mesh.point(vvh);
|
||||
++valence;
|
||||
}
|
||||
cog[vv] /= valence;
|
||||
}
|
||||
// Move all vertices to the previously computed positions
|
||||
for (const auto& vh : mesh.vertices()) {
|
||||
mesh.point(vv) = cog[vv];
|
||||
}
|
||||
}
|
||||
// The cog vertex property is removed from the mesh at the end of this scope
|
||||
}
|
||||
// Add a vertex property storing the computed centers of gravity
|
||||
auto cog = OpenMesh::makeTemporaryProperty<OpenMesh::VertexHandle, MyMesh::Point>(mesh);
|
||||
|
||||
// Smooth the mesh several times
|
||||
for (int i = 0; i < iterations; ++i) {
|
||||
// Iterate over all vertices to compute centers of gravity
|
||||
for (const auto& vh : mesh.vertices()) {
|
||||
cog[vh] = {0,0,0};
|
||||
int valence = 0;
|
||||
// Iterate over all 1-ring vertices around vh
|
||||
for (const auto& vvh : mesh.vv_range(vh)) {
|
||||
cog[vh] += mesh.point(vvh);
|
||||
++valence;
|
||||
}
|
||||
cog[vh] /= valence;
|
||||
}
|
||||
// Move all vertices to the previously computed positions
|
||||
for (const auto& vh : mesh.vertices()) {
|
||||
mesh.point(vh) = cog[vh];
|
||||
}
|
||||
}
|
||||
} // The cog vertex property is removed from the mesh at the end of this scope
|
||||
|
||||
// Write mesh file
|
||||
if (!OpenMesh::IO::read_mesh(mesh, outfile)) {
|
||||
|
||||
Reference in New Issue
Block a user