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


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

本文整理汇总了C++中Face::AddNeighbor方法的典型用法代码示例。如果您正苦于以下问题:C++ Face::AddNeighbor方法的具体用法?C++ Face::AddNeighbor怎么用?C++ Face::AddNeighbor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Face的用法示例。


在下文中一共展示了Face::AddNeighbor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:xoddark,项目名称:amd-tootle,代码行数:81,代码来源:Stripifier.cpp


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