本文整理汇总了C++中TriangleList::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ TriangleList::empty方法的具体用法?C++ TriangleList::empty怎么用?C++ TriangleList::empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TriangleList
的用法示例。
在下文中一共展示了TriangleList::empty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindEdgeToCollapse
void ProgressiveTriangleGeometry::FindEdgeToCollapse(VertexList& /*org_vertex_list*/,
TriangleList& /*org_triangle_list*/, VertexList& vertex_list, TriangleList& triangle_list, Edge& edge) {
if (triangle_list.empty())
return;
float current_error = 0.0f;
float current_max_error = 0.0f;
edge.v1_ = 0;
edge.v2_ = 0;
edge.triangle_list_.clear();
// Calculate mean error.
VertexList::iterator v_iter;
for (v_iter = vertex_list.begin();
v_iter != vertex_list.end();
++v_iter) {
if (v_iter == vertex_list.begin()) {
current_max_error = (*v_iter)->error_;
} else if((*v_iter)->error_ > current_max_error) {
current_max_error = (*v_iter)->error_;
}
current_error += (*v_iter)->error_;
}
current_error /= (float)vertex_list.size();
float min_error = 0.0f;
float min_error1 = 0.0f; // Temporary error value storage for _edge->v1_.
float min_error2 = 0.0f; // Temporary error value storage for _edge->v2_.
bool first = true;
// Test vertex collaps on all triangles.
TriangleList::iterator tri_iter;
for (tri_iter = triangle_list.begin();
tri_iter != triangle_list.end();
++tri_iter) {
Triangle* triangle = *tri_iter;
vec3 diff1;
vec3 diff2;
Vertex mid;
// Test V1 and V2.
mid.x() = (triangle->v1_->x() + triangle->v2_->x()) * 0.5f;
mid.y() = (triangle->v1_->y() + triangle->v2_->y()) * 0.5f;
mid.z() = (triangle->v1_->z() + triangle->v2_->z()) * 0.5f;
// Calculate the distance between the new, merged position,
// and the original vertex position.
diff1.Set(mid.x() - triangle->v1_->twin_->x(),
mid.y() - triangle->v1_->twin_->y(),
mid.z() - triangle->v1_->twin_->z());
diff2.Set(mid.x() - triangle->v2_->twin_->x(),
mid.y() - triangle->v2_->twin_->y(),
mid.z() - triangle->v2_->twin_->z());
float error1 = diff1.GetLength() + triangle->v1_->error_;
float error2 = diff2.GetLength() + triangle->v2_->error_;
float error = (error1 + error2 + current_error) / 3.0f;
if (first == true || error < min_error) {
edge.v1_ = triangle->v1_;
edge.v2_ = triangle->v2_;
min_error1 = error1;
min_error2 = error2;
min_error = error;
first = false;
}
// Test V2 and V3.
mid.x() = (triangle->v2_->x() + triangle->v3_->x()) * 0.5f;
mid.y() = (triangle->v2_->y() + triangle->v3_->y()) * 0.5f;
mid.z() = (triangle->v2_->z() + triangle->v3_->z()) * 0.5f;
// Calculate the distance between the new, merged position,
// and the original vertex position.
diff1.Set(mid.x() - triangle->v2_->twin_->x(),
mid.y() - triangle->v2_->twin_->y(),
mid.z() - triangle->v2_->twin_->z());
diff2.Set(mid.x() - triangle->v3_->twin_->x(),
mid.y() - triangle->v3_->twin_->y(),
mid.z() - triangle->v3_->twin_->z());
error1 = diff1.GetLength() + triangle->v1_->error_;
error2 = diff2.GetLength() + triangle->v2_->error_;
error = (error1 + error2 + current_error) / 3.0f;
if (error < min_error) {
edge.v1_ = triangle->v1_;
edge.v2_ = triangle->v2_;
min_error = error;
min_error1 = error1;
min_error2 = error2;
}
// Test V3 and V1.
mid.x() = (triangle->v3_->x() + triangle->v1_->x()) * 0.5f;
mid.y() = (triangle->v3_->y() + triangle->v1_->y()) * 0.5f;
mid.z() = (triangle->v3_->z() + triangle->v1_->z()) * 0.5f;
//.........这里部分代码省略.........