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


C++ NodeVector::resize方法代码示例

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


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

示例1: AddFieldNode

 void AddFieldNode(CPLXMLNode* node, int iOrderPos)
 {
     if (iOrderPos >= (int)oFields.size())
         oFields.resize(iOrderPos+1);
     //CPLDebug( "OGR_ILI", "Register field with OrderPos %d to Class %s", iOrderPos, GetName());
     oFields[iOrderPos] = node;
 }
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:7,代码来源:imdreader.cpp

示例2: ConvertFromLonLatToCartesian

void ConvertFromLonLatToCartesian(
    const LonLatNodeVector & vecLonLatNodes,
    NodeVector & vecNodes
) {
    vecNodes.resize(vecLonLatNodes.size());

    // Loop over all nodes
    int i;
    for (i = 0; i < vecLonLatNodes.size(); i++) {
        vecNodes[i].x =
            sin(vecLonLatNodes[i].lon) * cos(vecLonLatNodes[i].lat);
        vecNodes[i].y =
            cos(vecLonLatNodes[i].lon) * cos(vecLonLatNodes[i].lat);
        vecNodes[i].z =
            sin(vecLonLatNodes[i].lat);
    }
}
开发者ID:bssrdf,项目名称:tempestremap,代码行数:17,代码来源:GenerateICOMesh.cpp

示例3: generatePathfindingNodes

void EntityEngine::generatePathfindingNodes(NodeVector & nodes) {
	// lay a grid over the static entities
	Timing tm;

	const int resolutionFactor = 1;
	const float collisionMarginFactor = 2.5f;
	const float gridSize = 1.0f / float(resolutionFactor); // 0.5f;
	//const float neighbourDistance = sqrt(gridSize * gridSize * 2.0f) * 1.1f;

	float floatHighestY = 0;
	float floatLowestY = 100000000000.0f;
	for (Entity const* ent : getStaticEntities()) {
		floatHighestY = std::max(floatHighestY, ent->getPosition().y());
		floatLowestY = std::min(floatLowestY, ent->getPosition().y());
	}

	dropNavigationNodes(nodes);

	// protect against no entities
	if (getStaticEntities().size() == 0)
		return;

	assert(floatHighestY > floatLowestY);
	logging::Info() << "Generating navigation grid for lowY: " << floatLowestY << " highY: " << floatHighestY;

	const int highestY = int(std::ceil(floatHighestY));
	const int lowestY = int(std::floor(floatLowestY));
	const int spanY = highestY - lowestY;

	const float spanX = 15.0f;
	const int nodeCount = (spanX * resolutionFactor) * (spanY * resolutionFactor);

	nodes.resize(nodeCount);

	// with a resolution of 2 times the tile size
	const int sizeX = spanX * resolutionFactor;
	const int sizeY = (spanY * resolutionFactor);

	for (int y = 0; y < sizeY; y++) {
		for (int x = 0; x < sizeX; x++) {
			Vector2 pos(float(x) * gridSize, float(y) * gridSize + float(lowestY));

			// do only add if there is no collision object near by
			if (!checkForCollisionObject(pos, gridSize * collisionMarginFactor)) {
				const int thisNodeLocation = sizeX * y + x;
				NodePtr n = &nodes[thisNodeLocation];
				n->Location = pos;

				// connect to left
				if (x > 0) {
					// left same line
					n->Neighbours.push_back(&nodes[thisNodeLocation - 1]);

					// left lower
					if (y > 0) {
						n->Neighbours.push_back(&nodes[thisNodeLocation - 1 - sizeX]);
					}
					// left upper
					if (y < (sizeY - 1)) {
						n->Neighbours.push_back(&nodes[thisNodeLocation - 1 + sizeX]);
					}
				}
				if (x < (sizeX - 1)) {
					// right same line
					n->Neighbours.push_back(&nodes[thisNodeLocation + 1]);
					// right lower
					if (y > 0) {
						n->Neighbours.push_back(&nodes[thisNodeLocation + 1 - sizeX]);
					}
					// right upper
					if (y < (sizeY - 1)) {
						n->Neighbours.push_back(&nodes[thisNodeLocation + 1 + sizeX]);
					}
				}

				if (y > 0) {
					// lower one
					n->Neighbours.push_back(&nodes[thisNodeLocation - sizeX]);
				}
				if (y < (sizeY - 1)) {
					// upper one
					n->Neighbours.push_back(&nodes[thisNodeLocation + sizeX]);
				}
			}
		}
	}

	float dt = tm.end();
	logging::Info() << "Building the Pathfinding grid took " << dt << " seconds";
}
开发者ID:poseidn,项目名称:KungFoo-legacy,代码行数:90,代码来源:EntityEngine.cpp


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