本文整理汇总了C++中NvStripInfoVec::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ NvStripInfoVec::clear方法的具体用法?C++ NvStripInfoVec::clear怎么用?C++ NvStripInfoVec::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NvStripInfoVec
的用法示例。
在下文中一共展示了NvStripInfoVec::clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RemoveSmallStrips
////////////////////////////////////////////////////////////////////////////////////////
// RemoveSmallStrips()
//
// allStrips is the whole strip _vector_...all small strips will be deleted from this list, to avoid leaking mem
// allBigStrips is an out parameter which will contain all strips above minStripLength
// faceList is an out parameter which will contain all faces which were removed from the striplist
//
void NvStripifier::RemoveSmallStrips(NvStripInfoVec& allStrips, NvStripInfoVec& allBigStrips, NvFaceInfoVec& faceList)
{
faceList.clear();
allBigStrips.clear(); //make sure these are empty
NvFaceInfoVec tempFaceList;
for(int i = 0; i < allStrips.size(); i++)
{
if(allStrips[i]->m_faces.size() < minStripLength)
{
//strip is too small, add faces to faceList
for(int j = 0; j < allStrips[i]->m_faces.size(); j++)
tempFaceList.push_back(allStrips[i]->m_faces[j]);
//and xr_free memory
xr_delete(allStrips[i]);
}
else
{
allBigStrips.push_back(allStrips[i]);
}
}
bool *bVisitedList = xr_alloc<bool> (tempFaceList.size());
ZeroMemory (bVisitedList, tempFaceList.size()*sizeof(bool));
VertexCache* vcache = xr_new<VertexCache> (cacheSize);
int bestNumHits = -1;
int numHits = 0;
int bestIndex = 0;
while(1)
{
bestNumHits = -1;
//find best face to add next, given the current cache
for(int i = 0; i < tempFaceList.size(); i++)
{
if(bVisitedList[i])
continue;
numHits = CalcNumHitsFace(vcache, tempFaceList[i]);
if(numHits > bestNumHits)
{
bestNumHits = numHits;
bestIndex = i;
}
}
if(bestNumHits == -1.0f)
break;
bVisitedList[bestIndex] = true;
UpdateCacheFace(vcache, tempFaceList[bestIndex]);
faceList.push_back(tempFaceList[bestIndex]);
}
xr_delete (vcache);
xr_free (bVisitedList);
}
示例2: RemoveSmallStrips
////////////////////////////////////////////////////////////////////////////////////////
// RemoveSmallStrips()
//
// allStrips is the whole strip vector...all small strips will be deleted from this list, to avoid leaking mem
// allBigStrips is an out parameter which will contain all strips above minStripLength
// faceList is an out parameter which will contain all faces which were removed from the striplist
//
void NvStripifier::RemoveSmallStrips(NvStripInfoVec& allStrips, NvStripInfoVec& allBigStrips, NvFaceInfoVec& faceList)
{
faceList.clear();
allBigStrips.clear(); //make sure these are empty
NvFaceInfoVec tempFaceList;
for(size_t i = 0; i < allStrips.size(); i++)
{
if(allStrips[i]->m_faces.size() < (size_t)minStripLength)
{
//strip is too small, add faces to faceList
for(size_t j = 0; j < allStrips[i]->m_faces.size(); j++)
tempFaceList.push_back(allStrips[i]->m_faces[j]);
//and free memory
delete allStrips[i];
}
else
{
allBigStrips.push_back(allStrips[i]);
}
}
if(tempFaceList.size())
{
bool *bVisitedList = new bool[tempFaceList.size()];
memset(bVisitedList, 0, tempFaceList.size()*sizeof(bool));
VertexCache* vcache = new VertexCache(cacheSize);
int bestNumHits = -1;
int numHits;
int bestIndex;
while(1)
{
bestNumHits = -1;
//find best face to add next, given the current cache
for(size_t i = 0; i < tempFaceList.size(); i++)
{
if(bVisitedList[i])
continue;
numHits = CalcNumHitsFace(vcache, tempFaceList[i]);
if(numHits > bestNumHits)
{
bestNumHits = numHits;
bestIndex = i;
}
}
if(bestNumHits == -1.0f)
break;
bVisitedList[bestIndex] = true;
UpdateCacheFace(vcache, tempFaceList[bestIndex]);
faceList.push_back(tempFaceList[bestIndex]);
}
delete vcache;
delete[] bVisitedList;
}
}
示例3: SplitUpStripsAndOptimize
//.........这里部分代码省略.........
delete allStrips[i]->m_faces[leftOff], allStrips[i]->m_faces[leftOff] = NULL;
}
leftOff++;
}
}
/*
for(size_t k = 0; k < numLeftover; k++)
{
currentStrip->m_faces.push_back(allStrips[i]->m_faces[leftOff++]);
}
*/
tempStrips.push_back(currentStrip);
}
}
else
{
//we're not just doing a tempStrips.push_back(allBigStrips[i]) because
// this way we can delete allBigStrips later to free the memory
currentStrip = new NvStripInfo(startInfo, 0, -1);
for(size_t j = 0; j < allStrips[i]->m_faces.size(); j++)
currentStrip->m_faces.push_back(allStrips[i]->m_faces[j]);
tempStrips.push_back(currentStrip);
}
}
//add small strips to face list
NvStripInfoVec tempStrips2;
RemoveSmallStrips(tempStrips, tempStrips2, outFaceList);
outStrips.clear();
//screw optimization for now
// for(size_t i = 0; i < tempStrips.size(); ++i)
// outStrips.push_back(tempStrips[i]);
if(tempStrips2.size() != 0)
{
//Optimize for the vertex cache
VertexCache* vcache = new VertexCache(cacheSize);
float bestNumHits = -1.0f;
float numHits;
int bestIndex;
bool done = false;
int firstIndex = 0;
float minCost = 10000.0f;
for(size_t i = 0; i < tempStrips2.size(); i++)
{
int numNeighbors = 0;
//find strip with least number of neighbors per face
for(size_t j = 0; j < tempStrips2[i]->m_faces.size(); j++)
{
numNeighbors += NumNeighbors(tempStrips2[i]->m_faces[j], edgeInfos);
}
float currCost = (float)numNeighbors / (float)tempStrips2[i]->m_faces.size();
if(currCost < minCost)
{
minCost = currCost;
firstIndex = i;
示例4: SplitUpStripsAndOptimize
///////////////////////////////////////////////////////////////////////////////////////////
// SplitUpStripsAndOptimize()
//
// Splits the input _vector_ of strips (allBigStrips) into smaller, cache friendly pieces, then
// reorders these pieces to maximize cache hits
// The final strips are output through outStrips
//
void NvStripifier::SplitUpStripsAndOptimize(NvStripInfoVec &allStrips, NvStripInfoVec &outStrips,
NvEdgeInfoVec& edgeInfos, NvFaceInfoVec& outFaceList)
{
int threshold = cacheSize;
NvStripInfoVec tempStrips;
//split up strips into threshold-sized pieces
int i;
for(i = 0; i < allStrips.size(); i++)
{
NvStripInfo* currentStrip;
NvStripStartInfo startInfo(NULL, NULL, false);
if(allStrips[i]->m_faces.size() > threshold)
{
int numTimes = allStrips[i]->m_faces.size() / threshold;
int numLeftover = allStrips[i]->m_faces.size() % threshold;
int j;
for(j = 0; j < numTimes; j++)
{
currentStrip = xr_new<NvStripInfo> (startInfo, 0, -1);
for(int faceCtr = j*threshold; faceCtr < threshold+(j*threshold); faceCtr++) {
currentStrip->m_faces.push_back(allStrips[i]->m_faces[faceCtr]);
}
tempStrips.push_back(currentStrip);
}
int leftOff = j * threshold;
if(numLeftover != 0)
{
currentStrip = xr_new<NvStripInfo> (startInfo, 0, -1);
for(int k = 0; k < numLeftover; k++)
{
currentStrip->m_faces.push_back(allStrips[i]->m_faces[leftOff++]);
}
tempStrips.push_back(currentStrip);
}
}
else
{
//we're not just doing a tempStrips.push_back(allBigStrips[i]) because
// this way we can _delete allBigStrips later to xr_free the memory
currentStrip = xr_new<NvStripInfo> (startInfo, 0, -1);
for(int j = 0; j < allStrips[i]->m_faces.size(); j++)
currentStrip->m_faces.push_back(allStrips[i]->m_faces[j]);
tempStrips.push_back(currentStrip);
}
}
//add small strips to face list
NvStripInfoVec tempStrips2;
RemoveSmallStrips(tempStrips, tempStrips2, outFaceList);
outStrips.clear();
if(tempStrips2.size() != 0)
{
//Optimize for the vertex cache
VertexCache* vcache = xr_new<VertexCache> (cacheSize);
float bestNumHits = -1.0f;
float numHits = 0;
int bestIndex = 0;
int firstIndex = 0;
float minCost = 10000.0f;
for(i = 0; i < tempStrips2.size(); i++)
{
int numNeighbors = 0;
//find strip with least number of neighbors per face
for(int j = 0; j < tempStrips2[i]->m_faces.size(); j++)
{
numNeighbors += NumNeighbors(tempStrips2[i]->m_faces[j], edgeInfos);
}
float currCost = (float)numNeighbors / (float)tempStrips2[i]->m_faces.size();
if(currCost < minCost)
{
minCost = currCost;
firstIndex = i;
}
}
//.........这里部分代码省略.........