本文整理汇总了C++中TriangleList::end方法的典型用法代码示例。如果您正苦于以下问题:C++ TriangleList::end方法的具体用法?C++ TriangleList::end怎么用?C++ TriangleList::end使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TriangleList
的用法示例。
在下文中一共展示了TriangleList::end方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: triangle_tree
void triangle_tree(
const Eigen::MatrixXd & V,
const Eigen::MatrixXi & F,
TriTree & tree,
TriangleList & tlist)
{
assert(F.cols() == 3);
tlist.clear();
// Loop over facets
for(int f = 0;f<F.rows();f++)
{
Point3 a(V(F(f,0),0), V(F(f,0),1), V(F(f,0),2));
Point3 b(V(F(f,1),0), V(F(f,1),1), V(F(f,1),2));
Point3 c(V(F(f,2),0), V(F(f,2),1), V(F(f,2),2));
tlist.push_back(Triangle3( a,b,c));
}
// constructs AABB tree
tree.clear();
tree.insert(tlist.begin(),tlist.end());
}
示例2: 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;
//.........这里部分代码省略.........
示例3: DeallocateGeometry
//.........这里部分代码省略.........
DWORD numVertices = (DWORD)xIndicesTable.size();
// This buffer holds all of the triangles in this subset
TriangleList triangles;
// This list keeps track of locations in the strip where the winding order changes. This is necessary
// because this next part will remove degenerate triangles from the list.
std::set<size_t> windingChanges;
// Generate the list of triangles from the strip provided
for (DWORD t = 0; t < numStripIndices - 2; ++t)
{
// Build the triangle that will be added to the buffer
// CHANGED July 25, 2008: the winding order is wrong here
//Triangle tri = { pXIndices[t + 0], pXIndices[t + 1], pXIndices[t + 2] };
Triangle tri = { pXIndices[t + 0], pXIndices[t + 2], pXIndices[t + 1] };
// Convert the triangle into subset-indices by using the lookup table
// we generated before.
tri.index[0] = xIndicesTable.find(tri.index[0])->second;
tri.index[1] = xIndicesTable.find(tri.index[1])->second;
tri.index[2] = xIndicesTable.find(tri.index[2])->second;
// Check to make sure this triangle isn't degenerate. If it is, we can just skip
// this triangle entirely to simplify the geometry.
if (tri.index[0] == tri.index[1] || tri.index[1] == tri.index[2] || tri.index[0] == tri.index[2])
{
// Try to find the winding in the list
std::set<size_t>::iterator currentWinding = windingChanges.find(triangles.size());
// Add this to the winding change list, or remove the change if it's already there
if (currentWinding != windingChanges.end())
windingChanges.erase(currentWinding);
else
windingChanges.insert(triangles.size());
// Don't insert a triangle here
continue;
}
// Add this triangle to the list
triangles.push_back(tri);
}
// Calculate the number of indices we need for the buffer
DWORD numGeometryIndices = (DWORD)(triangles.size() * 3);
// Allocate the destination geometry
Geometry* pGeometry = NULL;
if (APP_ERROR(AllocateGeometry(numVertices, numGeometryIndices, &pGeometry))("Couldn't allocate geometry"))
{
// Erase any geometry we made
DeallocateGeometry(subsetGeometry);
// Get rid of the mesh
pSubsetIB->Unlock();
pSubsetIB->Release();
d3dxMesh->UnlockVertexBuffer();
d3dxMesh->Release();
// Free our device
pd3dDevice->Release();
// Error!