本文整理汇总了C++中SurfaceMesh::up方法的典型用法代码示例。如果您正苦于以下问题:C++ SurfaceMesh::up方法的具体用法?C++ SurfaceMesh::up怎么用?C++ SurfaceMesh::up使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SurfaceMesh
的用法示例。
在下文中一共展示了SurfaceMesh::up方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getNormal
Vector getNormal(const SurfaceMesh &mesh, SurfaceMesh::SimplexID<1> vertexID)
{
Vector norm;
auto faces = mesh.up(mesh.up(vertexID));
for (auto faceID : faces)
{
norm += getNormal(mesh, faceID);
}
// norm /= faces.size();
return norm;
}
示例2: coarse
void coarse(SurfaceMesh &mesh, double coarseRate, double flatRate, double denseWeight){
// TODO: Check if all polygons are closed (0)
std::cout << "Before coarsening: " << mesh.size<1>() << " " << mesh.size<2>() << " " << mesh.size<3>() << std::endl;
// Compute the average edge length
double avgLen = 0;
if (denseWeight > 0){
avgLen = surfacemesh_detail::getMeanEdgeLength(mesh);
}
double sparsenessRatio = 1;
double flatnessRatio = 1;
// Construct list of vertices to decimate
std::vector<SurfaceMesh::SimplexID<1> > toRemove;
for(auto vertexID : mesh.get_level_id<1>()){
// Sparseness as coarsening criteria
if(denseWeight > 0){
// Get max length of edges.
auto edges = mesh.up(vertexID);
double maxLen = 0;
for(auto edgeID : edges){
auto name = mesh.get_name(edgeID);
auto v = *mesh.get_simplex_down(edgeID, name[0])
- *mesh.get_simplex_down(edgeID, name[1]);
double tmpLen = std::sqrt(v|v);
if(tmpLen > maxLen) maxLen = tmpLen;
}
sparsenessRatio = std::pow(maxLen/avgLen, denseWeight);
}
// Curvature as coarsening criteria
if(flatRate > 0){
auto lst = surfacemesh_detail::computeLocalStructureTensor(mesh, vertexID, RINGS);
auto eigenvalues = surfacemesh_detail::getEigenvalues(lst).eigenvalues();
// The closer this ratio is to 0 the flatter the local region.
flatnessRatio = std::pow(eigenvalues[1]/eigenvalues[2], flatRate);
}
// Add vertex to delete list
if(sparsenessRatio * flatnessRatio < coarseRate){
toRemove.push_back(vertexID);
}
}
std::cout << toRemove.size() << " vertices are marked to be removed." << std::endl;
for(auto vertexID : toRemove){
surfacemesh_detail::decimateVertex(mesh, vertexID);
}
std::cout << "After coarsening: " << mesh.size<1>() << " " << mesh.size<2>() << " " << mesh.size<3>() << std::endl;
}
示例3: coarseIT
void coarseIT(SurfaceMesh &mesh, double coarseRate, double flatRate, double denseWeight){
std::cout << "Before coarsening: " << mesh.size<1>() << " " << mesh.size<2>() << " " << mesh.size<3>() << std::endl;
// Compute the average edge length
double avgLen = 0;
if (denseWeight > 0){
avgLen = surfacemesh_detail::getMeanEdgeLength(mesh);
}
double sparsenessRatio = 1;
double flatnessRatio = 1;
// Backup vertices so we can modify in place
auto range = mesh.get_level_id<1>();
const std::vector<SurfaceMesh::SimplexID<1> > Vertices(range.begin(), range.end());
for(auto vertexID : Vertices) {
// Sparseness as coarsening criteria
if(denseWeight > 0){
// Get max length of edges.
auto edges = mesh.up(vertexID);
double maxLen = 0;
for(auto edgeID : edges){
auto name = mesh.get_name(edgeID);
auto v = *mesh.get_simplex_down(edgeID, name[0])
- *mesh.get_simplex_down(edgeID, name[1]);
double tmpLen = std::sqrt(v|v);
if(tmpLen > maxLen) maxLen = tmpLen;
}
sparsenessRatio = std::pow(maxLen/avgLen, denseWeight);
}
// Curvature as coarsening criteria
if(flatRate > 0){
auto lst = surfacemesh_detail::computeLocalStructureTensor(mesh, vertexID, RINGS);
auto eigenvalues = surfacemesh_detail::getEigenvalues(lst).eigenvalues();
// The closer this ratio is to 0 the flatter the local region.
flatnessRatio = std::pow(eigenvalues[1]/eigenvalues[2], flatRate);
}
// Check if we should delete
if(sparsenessRatio * flatnessRatio < coarseRate){
surfacemesh_detail::decimateVertex(mesh, vertexID);
}
}
std::cout << "After coarsening: " << mesh.size<1>() << " " << mesh.size<2>() << " " << mesh.size<3>() << std::endl;
}