本文整理汇总了C++中Face::CountVertices方法的典型用法代码示例。如果您正苦于以下问题:C++ Face::CountVertices方法的具体用法?C++ Face::CountVertices怎么用?C++ Face::CountVertices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Face
的用法示例。
在下文中一共展示了Face::CountVertices方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Triangulate
void MeshTransformation::Triangulate(Model::Mesh* mesh)
{
Face* face = NULL;
Face* newFace = NULL;
HalfEdge* edge = NULL;
HalfEdge *newEdge1, *newEdge2; // newEdge1 belong to the new face, newEdge2 belong to the remaining face
unsigned int nbFaces = mesh->faces.size();
for (unsigned int i = 0; i < nbFaces; i++)
{
face = mesh->faces[i];
int nbVertices = face->CountVertices();
edge = face->adjacentHalfEdge;
// Instanciate new faces, but we keep the original face as the last triangle
vector<Face*> newFaces;
for (int j = 0; j * 2 < nbVertices - 3; j++)
{
newFace = new Face();
newFaces.push_back(newFace);
mesh->faces.push_back(newFace);
}
newFaces.push_back(face);
// Triangulate the current face, each iteration create a new triangle
for (int j = 0; j * 2 < nbVertices - 3; j++)
{
newFaces[j]->adjacentHalfEdge = edge;
// Create new half edges
newEdge1 = new HalfEdge();
newEdge2 = new HalfEdge();
mesh->halfEdges.push_back(newEdge1);
mesh->halfEdges.push_back(newEdge2);
// Initialize new half edges
newEdge1->next = edge;
newEdge1->prev = edge->next;
newEdge1->twin = newEdge2;
newEdge1->source = edge->next->next->source;
newEdge1->adjacentFace = newFaces[j];
newEdge2->next = edge->next->next;
newEdge2->prev = edge->prev;
newEdge2->twin = newEdge1;
newEdge2->source = edge->source;
newEdge2->adjacentFace = newFaces[j + 1];
// Save first edge of remaining face
edge = edge->next->next;
// Consolidate existant edges
newEdge1->prev->next = newEdge1;
newEdge1->next->prev = newEdge1;
newEdge2->prev->next = newEdge2;
newEdge2->next->prev = newEdge2;
}
// Consolidate original face (now the last triangle)
face->adjacentHalfEdge = edge;
}
}