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


C++ StateSet::getStates方法代码示例

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


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

示例1:

StateTreeNode::StateTreeNode(
	const StateSet &stateSet,
	int maxDepth,
	double centerShiftMultiplier
) :
	numSpacePartitions(pow(2, stateSet.getStates().at(0)->getCoordinates().size()))
{
	const vector<AbstractState*> &states = stateSet.getStates();
	unsigned int numCoordinates = states.at(0)->getCoordinates().size();

	for(unsigned int n = 1; n < states.size(); n++){
		TBTKAssert(
			numCoordinates == states.at(n)->getCoordinates().size(),
			"StateTreeNode::StateTreeNode()",
			"Unable to handle StateSets containing states with different dimensions.",
			""
		);
	}

	//Find bounding box.
	vector<double> min;
	vector<double> max;
	double maxFiniteExtent = 0.;
	unsigned int n = 0;
	//Find first state with finite extent and initialize min and max such
	//that the state is contained inside the corresponding rectangle.
	for(; n < states.size(); n++){
		if(states.at(n)->hasFiniteExtent()){
			for(unsigned int c = 0; c < numCoordinates; c++){
				min.push_back(states.at(n)->getCoordinates().at(c) - states.at(n)->getExtent());
				max.push_back(states.at(n)->getCoordinates().at(c) + states.at(n)->getExtent());
			}
			maxFiniteExtent = states.at(n)->getExtent();
			break;
		}
	}
	//If all state have infinite extent, create a dummy box of zero extent.
	if(n == states.size()){
		for(unsigned int c = 0; c < states.at(0)->getCoordinates().size(); c++){
			min.push_back(0);
			max.push_back(0);
		}
	}
	//Loop over all remaining states and update min and max so that every
	//state is contained in the corresponding rectangle.
	for(; n < states.size(); n++){
		if(!states.at(n)->hasFiniteExtent())
			continue;

		for(unsigned int c = 0; c < numCoordinates; c++){
			if(min.at(c) > states.at(n)->getCoordinates().at(c) - states.at(n)->getExtent())
				min.at(c) = states.at(n)->getCoordinates().at(c) - states.at(n)->getExtent();
			if(max.at(c) < states.at(n)->getCoordinates().at(c) + states.at(n)->getExtent())
				max.at(c) = states.at(n)->getCoordinates().at(c) + states.at(n)->getExtent();
		}

		if(maxFiniteExtent < states.at(n)->getExtent())
			maxFiniteExtent = states.at(n)->getExtent();
	}

	//Enlarge and shift box to avoid problems with high level partition
	//boundaries cutting through states. This would be particularly
	//problematic if the states for example have three dimensional
	//coordinates, but are contained in a plane. Without shifting the box,
	//the first partition boundary would cut every state and thereby every
	//state would be added to the root node.
	for(unsigned int n = 0; n < max.size(); n++)
		max.at(n) += centerShiftMultiplier*maxFiniteExtent;
	for(unsigned int n = 0; n < min.size(); n++)
		min.at(n) -= 2.*(max.at(n) - min.at(n))*(1 - ROUNDOFF_MARGIN_MULTIPLIER);

	//Calculate center nad halfSize of the bounding box.
	halfSize = 0.;
	for(unsigned int n = 0; n < numCoordinates; n++){
		center.push_back((min.at(n) + max.at(n))/2.);
		if(halfSize < (max.at(n) - min.at(n))/2.)
			halfSize = (max.at(n) - min.at(n))/2.;
	}

	this->maxDepth = maxDepth;

	for(unsigned int n = 0; n < states.size(); n++)
		add(states.at(n));
}
开发者ID:dafer45,项目名称:TBTK,代码行数:84,代码来源:StateTreeNode.cpp


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