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


C++ Bounds::range方法代码示例

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


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

示例1: computeSlices

Slices PartCorresponder::computeSlices( ParticleMesh * input, const SegmentGraph & seg )
{
	static int MAX_SLICE_COUNT = 20;

	Slices curSlices;
	if(seg.vertices.empty()) return curSlices;

	// Compute range of 'z' grid values
	Bounds<int> zcoords;
	for(auto v : seg.vertices)
	{
		Vector3 pg = (input->particles[v].pos - input->grid.translation.cast<double>()) / input->grid.unitlength;
		zcoords.extend( (int)pg.z() );
	}

	int total_range = 1 + zcoords.range();
	int fixedNumLayers = std::min(total_range, MAX_SLICE_COUNT);
	int perLayer = std::floor((double)total_range / fixedNumLayers);
	int numLayers = std::ceil((double)total_range / perLayer);

	curSlices.resize( numLayers );

	// Divide segment into layers
	for(int i = 0; i < numLayers; i++)
	{
		int bottom = zcoords.minimum + (i * perLayer);
		int top = bottom + perLayer;

		SegmentGraph layerGraph;

		for(auto & edge : seg.GetEdgesSet())
		{
			Vector3 pgi = (input->particles[edge.index].pos - input->grid.translation.cast<double>()) / input->grid.unitlength;
			Vector3 pgj = (input->particles[edge.target].pos - input->grid.translation.cast<double>()) / input->grid.unitlength;

			int zi = (int)pgi.z(), zj = (int)pgj.z();

			if((zi < bottom || zj < bottom) || (zi >= top || zj >= top)) continue;

			if(zi >= bottom && zi < top) layerGraph.AddVertex(edge.index);
			if(zj >= bottom && zj < top) layerGraph.AddVertex(edge.target);

			layerGraph.AddEdge( edge.index, edge.target, 1 );
		}

		if( layerGraph.vertices.empty() ) continue;

		auto & slice = curSlices[i];
		slice.chunksFromGraphs( layerGraph.toConnectedParts() );

		// Compute chunks parameters
		for(size_t c = 0; c < slice.chunks.size(); c++)
		{
			auto & chunk = slice.chunks[c];

			// Compute bounding box enclosing chunk
			for(auto p : input->particlesCorners(chunk.g.vertices)) 
				chunk.box.extend(p);

			// Compute index of relative particle positions inside box
			chunk.tree = QSharedPointer<NanoKdTree>(new NanoKdTree);
			for(auto v : chunk.g.vertices)
			{
				input->particles[v].relativePos = (input->particles[v].pos - chunk.box.min()).array() / chunk.box.sizes().array();
				chunk.tree->addPoint( input->particles[v].relativePos );
				chunk.vmap.push_back( v );
			}
			chunk.tree->build();
		}
	}

	Slices goodSlices;
	for(auto slice : curSlices) 
		if(!slice.chunks.empty()) 
			goodSlices.push_back(slice);
	return goodSlices;
}
开发者ID:ialhashim,项目名称:ddtt-dev,代码行数:77,代码来源:PartCorresponder.cpp


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