当前位置: 首页>>代码示例>>C++>>正文


C++ Face::CountVertices方法代码示例

本文整理汇总了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;
	}
}
开发者ID:harfangeek,项目名称:MeshEditor,代码行数:61,代码来源:MeshTransformation.cpp


注:本文中的Face::CountVertices方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。