本文整理汇总了C++中Face::Degree方法的典型用法代码示例。如果您正苦于以下问题:C++ Face::Degree方法的具体用法?C++ Face::Degree怎么用?C++ Face::Degree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Face
的用法示例。
在下文中一共展示了Face::Degree方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DropNeighbors
//=================================================================================================================================
/// Removes all the neighbors from a specified Face, with the exception of a specified neighbor
///
/// \param rFace The face to remove from its neighbors
/// \param pExceptNeighbor A neighbor from which rFace should not be removed
///
/// \return true
//=================================================================================================================================
bool FaceManager::DropNeighbors(Face& rFace, Face* pExceptNeighbor)
{
#ifdef _TIMING
_TIME tStart = GetTime();
#endif
// get all the neighbors
Face** neighbors = rFace.GetNeighbors();
// remove this face from the degree bins
m_degreeBins[ rFace.Degree() ].remove(&rFace);
Face* pNeighbor = NULL;
// re-bin the neighbors
for (unsigned int i = 0; i < 3; i++)
{
pNeighbor = neighbors[i];
if (pNeighbor != NULL)
{
if (pNeighbor != pExceptNeighbor)
{
// Note that now the neighbors are only singly linked
// the striped Face knows it's neighbors, but the neighbors
// don't know the striped face.
m_degreeBins[ pNeighbor->Degree() ].remove(pNeighbor);
// push on the back so that if the algorithm needs to start a new strip
// it is more likely to get a face whose vertex is already in the cache
m_degreeBins[ pNeighbor->RemoveNeighbor(&rFace) ].push_back(pNeighbor);
rFace.RemoveNeighbor(pNeighbor);
}
}
}
#ifdef _TIMING
m_tDropNeighbors += (GetTime() - tStart);
#endif
return true;
}
示例2: Stripify
//=================================================================================================================================
/// Generates an efficient list from the previously created faces
///
/// \return true
//=================================================================================================================================
bool FaceManager::Stripify(void)
{
#ifdef _TIMING
_TIME tStartStripify = GetTime();
#endif
for (FaceRefList::iterator iFace = m_faces.begin(); iFace != m_faces.end(); iFace++)
{
m_degreeBins[(*iFace)->Degree() ].push_front(*iFace);
}
#ifdef _TIMING
m_tSortBins += (GetTime() - tStartStripify);
#endif
UINT uWalkMode = START;
UINT uFirstTurn = START;
UINT nodesLeft = (UINT)m_faces.size();
bool bFirstDirection = true;
bool bRepeatedTurn = false;
int stripIndex = -1;
FaceStrips strips;
Face* pCurFace = NULL;
// variables that need to get declared before the switch statement
Face* pNextFace = NULL;
Face* pGateFace = NULL;
UINT uGateEdge;
UINT uBackEdge = 0;
UINT uFirstEdge = 1;
// make sure that the starting edge is in the 0-2 range
uFirstEdge %= 3;
while (nodesLeft > 0)
{
if (uWalkMode == START)
{
bFirstDirection = true;
stripIndex++;
strips.push_back(FaceStrip());
pCurFace = NULL;
// stop when a face with lowest degree is found
// this means we'll start along edges and the strip will work its way inward
// Provided good improvement (~10%)
for (UINT uDegree = 0; uDegree < 4 && pCurFace == NULL; uDegree++)
{
if (m_degreeBins[uDegree].size() > 0)
{
// pick a face that has not already been processed
for (FaceRefList::iterator iter = m_degreeBins[uDegree].begin();
iter != m_degreeBins[uDegree].end() && pCurFace == NULL;
iter++)
{
if (*iter != NULL && (*iter)->WasProcessed() == false)
{
pCurFace = *(iter);
}
}
}
}
// first face has been chosen
// now choose the direction to travel
uGateEdge = uFirstEdge;
pNextFace = NULL;
UINT uLowestDegree = 4;
for (UINT uEdge = 0; uEdge < 3; uEdge++)
{
// use GateFace as a temporary place holder
pGateFace = pCurFace->GetNeighbors()[(uFirstEdge + uEdge) % 3 ];
if (pGateFace != NULL && pGateFace->WasProcessed() == false)
{
if (pGateFace->Degree() < uLowestDegree)
{
// make the next face the neighbor with the highest degree
uLowestDegree = pGateFace->Degree();
pNextFace = pGateFace;
uGateEdge = (uFirstEdge + uEdge) % 3;
uBackEdge = pNextFace->GetEdge(pCurFace);
}
}
}
// Add first face in this strip
AddFaceToStrip(pCurFace, strips[ stripIndex ], START, uGateEdge);
nodesLeft--;
if (pNextFace != NULL)
{
//.........这里部分代码省略.........
示例3: MakeFace
//=================================================================================================================================
/// Makes a Face from the specified vertex indices and associates it with neighbors that have already been created
///
/// \param uVertexIndex1 the first vertex index of the face
/// \param uVertexIndex2 the second vertex index of the face
/// \param uVertexIndex3 the third vertex index of the face
/// \param nID the ID of the face
///
/// \return false if memory could not be allocated for the face; true otherwise
//=================================================================================================================================
bool FaceManager::MakeFace(UINT uVertexIndex1, UINT uVertexIndex2, UINT uVertexIndex3, UINT nID)
{
#ifdef _TIMING
_TIME tMNStart;
_TIME tAdjStart;
tMNStart = GetTime();
#endif
Face* pFace;
try
{
pFace = new Face(uVertexIndex1, uVertexIndex2, uVertexIndex3);
}
catch (std::bad_alloc&)
{
// ran out of memory
return false;
}
#ifdef _TIMING
m_tMakeNeighbors += GetTime() - tMNStart;
tMNStart = GetTime();
#endif
int nAdjacency = -1;
Face* pIterFace = NULL;
for (FaceRefList::iterator f = m_faces.begin(); f != m_faces.end() && pFace->Degree() < 3; f++)
{
pIterFace = *f;
// finding adjacency is expensize, only do it if the face doesn't already have three neighbors
if (pIterFace->Degree() < 3)
{
#ifdef _TIMING
tAdjStart = GetTime();
#endif
nAdjacency = GetFaceAdjacency(*pFace, *pIterFace);
#ifdef _TIMING
m_tAdjacency += (GetTime() - tAdjStart);
#endif
if (nAdjacency >= 0)
{
pFace->AddNeighbor(pIterFace, (nAdjacency / 10));
pIterFace->AddNeighbor(pFace, (nAdjacency % 10));
}
}
}
#ifdef _TIMING
m_tAdjLoop += (GetTime() - tMNStart);
tMNStart = GetTime();
#endif
// set ID for the face. This is used for computing faceRemap.
pFace->SetID(nID);
// add to the total list of faces
// push front since this face is likely to be used in upcoming faces
// and the loop above will work best if the neighbors are found early
m_faces.push_front(pFace);
#ifdef _TIMING
m_tPush += GetTime() - tMNStart;
#endif
return true;
}