ANN 查找半径为 fRadius 内所有顶点

    //            说明  ///

    It is easy, however, to determine whether any points were missed. The procedure returns a
    count of the total number of points that lie within the radius bound. (This feature is always
    enabled, even if k = 0.) In order to produce a true fi xed-radius search, first set k = 0 and run
    the procedure in order to obtain the number k0 of points that lie within the radius bound.
   Then, allocate index and distance arrays of size k0 each, and repeat the xed-radius search
   by setting k = k0 and passing in these two arrays.

 



    int nVerSize = G_pScene->m_nVertices;

    int nPtDim = 3;
    ///建立邻域///
    int ptDim = 3;
    ANNpointArray  org_mesh_point_array = annAllocPts(nVerSize, nPtDim);      ///<原始网格顶点位置

    /*CAUTION: only search in inner Facets(with no border vertex) of Warpmesh.*/
    for (unsigned i = 0; i < nVerSize; ++i)
    {
        org_mesh_point_array[i][0] = G_pScene->m_pVertices[i].m_vPosition.x;
        org_mesh_point_array[i][1] = G_pScene->m_pVertices[i].m_vPosition.y;
        org_mesh_point_array[i][2] = G_pScene->m_pVertices[i].m_vPosition.z;
    }


    ANNkd_tree *pAnn_SearchTree = new ANNkd_tree(org_mesh_point_array, nVerSize, nPtDim);
    ANNpoint queryPt = annAllocPt(nPtDim);    
    ANNdist    sqRad = fRadius;    
    ANNidxArray   nnIdx;
    ANNdistArray  dists;

    int nVerInSphere = 0;
    for (unsigned i = 0; i < nVerSize; ++i)
    {
        queryPt[0] =  G_pScene->m_pVertices[i].m_vPosition.x;
        queryPt[1] =  G_pScene->m_pVertices[i].m_vPosition.y;
        queryPt[2] =  G_pScene->m_pVertices[i].m_vPosition.z;

        nVerInSphere = pAnn_SearchTree->annkFRSearch(queryPt, sqRad, 0, nnIdx, dists);

        if(nVerInSphere < 1)  {std::cout<<"ANN  Have No Neighbor "<<std::endl;}

        ANNidxArray   tmp_nnIdx =  new  ANNidx[nVerInSphere + 1];     //  near  neighbor  indices
        ANNdistArray  tmp_dists = new  ANNdist[nVerInSphere + 1];;    //  near  neighbor  distances

        std::set<int>  ngbVerSet;
        pAnn_SearchTree->annkFRSearch(queryPt, sqRad, 0, nnIdx, dists);    

        for (unsigned j = 0; j < nVerInSphere; ++j)
        {
            ngbVerSet.insert(nnIdx[j]);
        }

        mVertexNgbSetlist_2.push_back(ngbVerSet);

        delete[](tmp_nnIdx);
        delete[](tmp_dists);
    }



    delete (pAnn_SearchTree);

    annDeallocPt(queryPt);
    annDeallocPts(org_mesh_point_array);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值