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


C++ ObjectType::getCentroid方法代码示例

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


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

示例1: comp

KDTree<ObjectType, FloatType, dimension>::KDTree(vector<ObjectType> objs, unsigned splitDim, size_t minNodeSize) {
	this->splitDim = splitDim;
	lower = NULL;
	upper = NULL;
	size_t numObjs = objs.size();
	if (numObjs < minNodeSize) {
		this->nodeObjects = objs;
	} else {
		CoordinateComperator comp(splitDim);
		sort(objs.begin(), objs.end(), comp);
		ObjectType center = objs[numObjs/2];
		FloatType splitPlanePos = center.getCentroid()[splitDim];
		splitPlaneBoundaryLowerNodeUpperBound = -1E30f;
		splitPlaneBoundaryUpperNodeLowerBound = 1E30f;

		vector<ObjectType> lowerList;
		vector<ObjectType> upperList;
		for (size_t i=0; i<numObjs; i++) {
			FloatType centroidCoord = objs[i].getCentroid(splitDim);
			bool sortIntoUpper = false;
			if (centroidCoord >= splitPlanePos) {
				sortIntoUpper = true;
			}

			if (sortIntoUpper) {
				upperList.push_back(objs[i]); 
				splitPlaneBoundaryUpperNodeLowerBound = min(splitPlaneBoundaryUpperNodeLowerBound, objs[i].getMinBB(splitDim));
			} else {
				lowerList.push_back(objs[i]); 
				splitPlaneBoundaryLowerNodeUpperBound = max(splitPlaneBoundaryLowerNodeUpperBound, objs[i].getMaxBB(splitDim));
			}
		}
		if (lowerList.size() == objs.size() || upperList.size() == objs.size()) {
			this->nodeObjects = objs;
		} else {
			if (!lowerList.empty()) lower = new KDTree(lowerList, (splitDim+1) % dimension, minNodeSize);
			if (!upperList.empty()) upper = new KDTree(upperList, (splitDim+1) % dimension, minNodeSize);
		}
	}
}
开发者ID:Ayutac,项目名称:GeoIks4,代码行数:40,代码来源:KDTree.hpp


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