本文整理汇总了C++中SurfaceMesh::down方法的典型用法代码示例。如果您正苦于以下问题:C++ SurfaceMesh::down方法的具体用法?C++ SurfaceMesh::down怎么用?C++ SurfaceMesh::down使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SurfaceMesh
的用法示例。
在下文中一共展示了SurfaceMesh::down方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateHistogram
void generateHistogram(const SurfaceMesh &mesh)
{
// compute angle distribution
std::array<double, 18> histogram;
histogram.fill(0);
for (auto face : mesh.get_level_id<3>())
{
auto vertexIDs = mesh.get_name(face);
// Unpack the ID's for convenience
Vertex a = *mesh.get_simplex_up<1>({vertexIDs[0]});
Vertex b = *mesh.get_simplex_up<1>({vertexIDs[1]});
Vertex c = *mesh.get_simplex_up<1>({vertexIDs[2]});
auto binAngle = [&](double angle) -> int{
return std::floor(angle/10);
};
histogram[binAngle(angle(a, b, c))]++;
histogram[binAngle(angle(b, a, c))]++;
histogram[binAngle(angle(c, a, b))]++;
}
int factor = mesh.size<3>()*3;
std::for_each(histogram.begin(), histogram.end(), [&factor](double &n){
n = 100.0*n/factor;
});
std::cout << "Angle Distribution:" << std::endl;
for (int x = 0; x < 18; x++)
std::cout << x*10 << "-" << (x+1)*10 << ": " << std::setprecision(2)
<< std::fixed << histogram[x] << std::endl;
std::cout << std::endl << std::endl;
// compute the edge length distribution
std::cout << "Edge Length Distribution:" << std::endl;
std::vector<double> lengths;
for (auto edge : mesh.get_level_id<2>())
{
auto vertexIDs = mesh.down(edge);
auto t1 = *vertexIDs.cbegin();
auto t2 = *(++vertexIDs.cbegin());
auto v1 = *t1;
auto v2 = *t2;
double len = magnitude(v2-v1);
lengths.push_back(len);
}
std::sort(lengths.begin(), lengths.end());
std::array<double, 20> histogramLength;
histogramLength.fill(0);
double interval = (lengths.back() - lengths.front())/20;
double low = lengths.front();
if (interval <= 0.0000001) // floating point roundoff prevention
{
std::cout << lengths.front() << ": " << 100 << std::endl << std::endl;
}
else
{
for (auto length : lengths)
{
histogramLength[std::floor((length-low)/interval)]++;
}
factor = mesh.size<2>();
std::for_each(histogramLength.begin(), histogramLength.end(), [&factor](double &n){
n = 100.0*n/factor;
});
for (int x = 0; x < 20; x++)
std::cout << x*interval << "-" << (x+1)*interval << ": " << std::setprecision(2)
<< std::fixed << histogramLength[x] << std::endl;
std::cout << std::endl << std::endl;
}
// Compute the valence distribution
std::array<double, 20> histogramValence;
histogramValence.fill(0);
for (auto vertexID : mesh.get_level_id<1>())
{
// TODO bounds checking here...
histogramValence[getValence(mesh, vertexID)]++;
}
factor = mesh.size<1>();
// std::for_each(histogramValence.begin(), histogramValence.end(),
// [&factor](double& n){
// n = 100.0*n/factor;});
std::cout << "Valence distribution:" << std::endl;
for (int x = 0; x < 20; x++)
std::cout << x << ": " << histogramValence[x] << std::endl;
std::cout << std::endl << std::endl;
}