本文整理汇总了C++中NvFaceInfoVec::reserve方法的典型用法代码示例。如果您正苦于以下问题:C++ NvFaceInfoVec::reserve方法的具体用法?C++ NvFaceInfoVec::reserve怎么用?C++ NvFaceInfoVec::reserve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NvFaceInfoVec
的用法示例。
在下文中一共展示了NvFaceInfoVec::reserve方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BuildStripifyInfo
///////////////////////////////////////////////////////////////////////////////////////////
// BuildStripifyInfo()
//
// Builds the list of all face and edge infos
//
void NvStripifier::BuildStripifyInfo(NvFaceInfoVec &faceInfos, NvEdgeInfoVec &edgeInfos,
const unsigned short maxIndex)
{
// reserve space for the face infos, but do not resize them.
int numIndices = indices.size();
faceInfos.reserve(numIndices / 3);
// we actually resize the edge infos, so we must initialize to NULL
edgeInfos.resize(maxIndex + 1);
for (unsigned short i = 0; i < maxIndex + 1; i++)
edgeInfos[i] = NULL;
// iterate through the triangles of the triangle list
int numTriangles = numIndices / 3;
int index = 0;
bool bFaceUpdated[3];
for (int i = 0; i < numTriangles; i++)
{
bool bMightAlreadyExist = true;
bFaceUpdated[0] = false;
bFaceUpdated[1] = false;
bFaceUpdated[2] = false;
// grab the indices
int v0 = indices[index++];
int v1 = indices[index++];
int v2 = indices[index++];
//we disregard degenerates
if(IsDegenerate(v0, v1, v2))
continue;
// create the face info and add it to the list of faces, but only if this exact face doesn't already
// exist in the list
NvFaceInfo *faceInfo = new NvFaceInfo(v0, v1, v2);
// grab the edge infos, creating them if they do not already exist
NvEdgeInfo *edgeInfo01 = FindEdgeInfo(edgeInfos, v0, v1);
if (edgeInfo01 == NULL)
{
//since one of it's edges isn't in the edge data structure, it can't already exist in the face structure
bMightAlreadyExist = false;
// create the info
edgeInfo01 = new NvEdgeInfo(v0, v1);
// update the linked list on both
edgeInfo01->m_nextV0 = edgeInfos[v0];
edgeInfo01->m_nextV1 = edgeInfos[v1];
edgeInfos[v0] = edgeInfo01;
edgeInfos[v1] = edgeInfo01;
// set face 0
edgeInfo01->m_face0 = faceInfo;
}
else
{
if (edgeInfo01->m_face1 != NULL)
{
printf("BuildStripifyInfo: > 2 triangles on an edge... uncertain consequences\n");
}
else
{
edgeInfo01->m_face1 = faceInfo;
bFaceUpdated[0] = true;
}
}
// grab the edge infos, creating them if they do not already exist
NvEdgeInfo *edgeInfo12 = FindEdgeInfo(edgeInfos, v1, v2);
if (edgeInfo12 == NULL)
{
bMightAlreadyExist = false;
// create the info
edgeInfo12 = new NvEdgeInfo(v1, v2);
// update the linked list on both
edgeInfo12->m_nextV0 = edgeInfos[v1];
edgeInfo12->m_nextV1 = edgeInfos[v2];
edgeInfos[v1] = edgeInfo12;
edgeInfos[v2] = edgeInfo12;
// set face 0
edgeInfo12->m_face0 = faceInfo;
}
else
{
if (edgeInfo12->m_face1 != NULL)
{
printf("BuildStripifyInfo: > 2 triangles on an edge... uncertain consequences\n");
}
else
{
//.........这里部分代码省略.........
示例2: BuildStripifyInfo
///////////////////////////////////////////////////////////////////////////////////////////
// BuildStripifyInfo()
//
// Builds the list of all face and edge infos
//
void NvStripifier::BuildStripifyInfo(NvFaceInfoVec &faceInfos, NvEdgeInfoVec &edgeInfos){
// reserve space for the face infos, but do not resize them.
int numIndices = indices.size();
faceInfos.reserve(numIndices);
// we actually resize the edge infos, so we must initialize to NULL
edgeInfos.resize (numIndices);
for (int i = 0; i < numIndices; i++)
edgeInfos[i] = NULL;
// iterate through the triangles of the triangle list
int numTriangles = numIndices / 3;
int index = 0;
for (u32 i = 0; i < numTriangles; i++)
{
// grab the indices
int v0 = indices[index++];
int v1 = indices[index++];
int v2 = indices[index++];
// create the face info and add it to the list of faces, but only if this exact face doesn't already
// exist in the list
NvFaceInfo *faceInfo = xr_new<NvFaceInfo>(v0, v1, v2);
if(!AlreadyExists(faceInfo, faceInfos))
{
faceInfos.push_back(faceInfo);
// grab the edge infos, creating them if they do not already exist
NvEdgeInfo *edgeInfo01 = FindEdgeInfo(edgeInfos, v0, v1);
if (edgeInfo01 == NULL){
// create the info
edgeInfo01 = xr_new<NvEdgeInfo>(v0, v1);
// update the linked list on both
edgeInfo01->m_nextV0 = edgeInfos[v0];
edgeInfo01->m_nextV1 = edgeInfos[v1];
edgeInfos[v0] = edgeInfo01;
edgeInfos[v1] = edgeInfo01;
// set face 0
edgeInfo01->m_face0 = faceInfo;
}
else {
if (edgeInfo01->m_face1 != NULL) ;
//Msg("! WARNING: BuildStripifyInfo: > 2 triangles on an edge... uncertain consequences");
else
edgeInfo01->m_face1 = faceInfo;
}
// grab the edge infos, creating them if they do not already exist
NvEdgeInfo *edgeInfo12 = FindEdgeInfo(edgeInfos, v1, v2);
if (edgeInfo12 == NULL){
// create the info
edgeInfo12 = xr_new<NvEdgeInfo> (v1, v2);
// update the linked list on both
edgeInfo12->m_nextV0 = edgeInfos[v1];
edgeInfo12->m_nextV1 = edgeInfos[v2];
edgeInfos[v1] = edgeInfo12;
edgeInfos[v2] = edgeInfo12;
// set face 0
edgeInfo12->m_face0 = faceInfo;
}
else {
if (edgeInfo12->m_face1 != NULL) ;
//Msg("! WARNING: BuildStripifyInfo: > 2 triangles on an edge... uncertain consequences");
else
edgeInfo12->m_face1 = faceInfo;
}
// grab the edge infos, creating them if they do not already exist
NvEdgeInfo *edgeInfo20 = FindEdgeInfo(edgeInfos, v2, v0);
if (edgeInfo20 == NULL){
// create the info
edgeInfo20 = xr_new<NvEdgeInfo>(v2, v0);
// update the linked list on both
edgeInfo20->m_nextV0 = edgeInfos[v2];
edgeInfo20->m_nextV1 = edgeInfos[v0];
edgeInfos[v2] = edgeInfo20;
edgeInfos[v0] = edgeInfo20;
// set face 0
edgeInfo20->m_face0 = faceInfo;
}
else {
if (edgeInfo20->m_face1 != NULL) ;
//Msg("! WARNING: BuildStripifyInfo: > 2 triangles on an edge... uncertain consequences");
else
edgeInfo20->m_face1 = faceInfo;
//.........这里部分代码省略.........