本文整理汇总了C++中MeshBuilder::getVertexIndicesOfFace方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshBuilder::getVertexIndicesOfFace方法的具体用法?C++ MeshBuilder::getVertexIndicesOfFace怎么用?C++ MeshBuilder::getVertexIndicesOfFace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshBuilder
的用法示例。
在下文中一共展示了MeshBuilder::getVertexIndicesOfFace方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: faceProcessed
// Construct vertex and index buffers from half edge mesh and pointcloud
ConvexHull(const MeshBuilder<T>& mesh, const VertexDataSource<T>& pointCloud, bool CCW, bool useOriginalIndices) {
if (!useOriginalIndices) {
m_optimizedVertexBuffer.reset(new std::vector<Vector3<T>>());
}
std::vector<bool> faceProcessed(mesh.m_faces.size(),false);
std::vector<size_t> faceStack;
std::unordered_map<size_t,size_t> vertexIndexMapping; // Map vertex indices from original point cloud to the new mesh vertex indices
for (size_t i = 0;i<mesh.m_faces.size();i++) {
if (!mesh.m_faces[i].isDisabled()) {
faceStack.push_back(i);
break;
}
}
if (faceStack.size()==0) {
return;
}
const size_t finalMeshFaceCount = mesh.m_faces.size() - mesh.m_disabledFaces.size();
m_indices.reserve(finalMeshFaceCount*3);
while (faceStack.size()) {
auto it = faceStack.end()-1;
size_t top = *it;
assert(!mesh.m_faces[top].isDisabled());
faceStack.erase(it);
if (faceProcessed[top]) {
continue;
}
else {
faceProcessed[top]=true;
auto halfEdges = mesh.getHalfEdgeIndicesOfFace(mesh.m_faces[top]);
size_t adjacent[] = {mesh.m_halfEdges[mesh.m_halfEdges[halfEdges[0]].m_opp].m_face,mesh.m_halfEdges[mesh.m_halfEdges[halfEdges[1]].m_opp].m_face,mesh.m_halfEdges[mesh.m_halfEdges[halfEdges[2]].m_opp].m_face};
for (auto a : adjacent) {
if (!faceProcessed[a] && !mesh.m_faces[a].isDisabled()) {
faceStack.push_back(a);
}
}
auto vertices = mesh.getVertexIndicesOfFace(mesh.m_faces[top]);
if (!useOriginalIndices) {
for (auto& v : vertices) {
auto it = vertexIndexMapping.find(v);
if (it == vertexIndexMapping.end()) {
m_optimizedVertexBuffer->push_back(pointCloud[v]);
vertexIndexMapping[v] = m_optimizedVertexBuffer->size()-1;
v = m_optimizedVertexBuffer->size()-1;
}
else {
v = it->second;
}
}
}
m_indices.push_back(vertices[0]);
if (CCW) {
m_indices.push_back(vertices[2]);
m_indices.push_back(vertices[1]);
}
else {
m_indices.push_back(vertices[1]);
m_indices.push_back(vertices[2]);
}
}
}
if (!useOriginalIndices) {
m_vertices = VertexDataSource<T>(*m_optimizedVertexBuffer);
}
else {
m_vertices = pointCloud;
}
}