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


C++ Neighborhood::push_back方法代码示例

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


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

示例1: n

void
SoftBody::updateNeighborhoods()
{
    auto kdTree = KdTree(posRest);

    std::vector<uint32_t> indices;
    indices.reserve(Neighborhood::MAX_SIZE + 1);

    auto neighbor_it = neighborhoods.begin();
    auto radius_it = radii.begin();
    uint32_t index = 0;
    for (auto& u : posRest) {
        //
        // A particle's neighborhood should not include itself. However, this
        // kdTree will return an index for the current particle. So increment
        // the neighbor count by 1, and then remove the "self" particle when
        // we're done.
        //

        kdTree.neighbors(posRest, u, Neighborhood::MAX_SIZE + 1, *radius_it, indices);
        auto selfLocation = std::find(indices.begin(), indices.end(), index);
        if (selfLocation != indices.end()) {
            indices.erase(selfLocation);
        }

        // If we find a neighbor we didn't already have, add it with an initial
        // weight of zero.
        //

        Neighborhood newNeighbors;

        for (auto j : indices) {
            if (neighbor_it->hasNeighbor(j)) {
                newNeighbors.push_back(neighbor_it->findNeighbor(j));
            } else {
                Vector3d u_ij = posRest[j] - u;
                Neighbor n(j, u_ij, 0.0);
                newNeighbors.push_back(n);
            }
        }
        *neighbor_it = newNeighbors;

        ++neighbor_it;
        ++radius_it;
        ++index;
    }
}
开发者ID:undernones,项目名称:particles,代码行数:47,代码来源:SoftBody.cpp

示例2: mergeNeighborhoods

void mergeNeighborhoods(Neighborhood &n1, Neighborhood &n2)
{
	Neighborhood::iterator it1, it2;
	bool present;
	for (it2 = n2.begin(); it2 != n2.end(); it2++) {
		present = false;
		for (it1 = n1.begin(); it1 != n1.end(); it1++) {
			if ( *it1 == *it2 ) {
				present = true;
				break;
			}
		}
		if (!present) {
			n1.push_back( *it2 );
		}
	}
}
开发者ID:jaredweiss,项目名称:graspit,代码行数:17,代码来源:contactSetting.cpp


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