本文整理汇总了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;
}