本文整理汇总了C#中Cell.IsLeaf方法的典型用法代码示例。如果您正苦于以下问题:C# Cell.IsLeaf方法的具体用法?C# Cell.IsLeaf怎么用?C# Cell.IsLeaf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cell
的用法示例。
在下文中一共展示了Cell.IsLeaf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitScanned
/// <exception cref="System.IO.IOException"></exception>
protected internal override void VisitScanned(Cell cell)
{
Shape cShape;
//if this cell represents a point, use the cell center vs the box
// TODO this behavior is debatable; might want to be configurable
// (points never have isLeaf())
if (cell.Level == _enclosing.grid.MaxLevels && !cell.IsLeaf())
{
cShape = cell.GetCenter();
}
else
{
cShape = cell.GetShape();
}
if (_enclosing.queryShape.Relate(cShape).Intersects())
{
CollectDocs(results);
}
}
示例2: RecursiveGetCells
/// <summary>Returns true if cell was added as a leaf.</summary>
/// <remarks>
/// Returns true if cell was added as a leaf. If it wasn't it recursively
/// descends.
/// </remarks>
private bool RecursiveGetCells(Cell cell, Shape shape, int
detailLevel, bool inclParents, bool simplify, IList<Cell> result)
{
if (cell.Level == detailLevel)
{
cell.SetLeaf();
}
//FYI might already be a leaf
if (cell.IsLeaf())
{
result.Add(cell);
return true;
}
if (inclParents && cell.Level != 0)
{
result.Add(cell);
}
ICollection<Cell> subCells = cell.GetSubCells(shape);
int leaves = 0;
foreach (Cell subCell in subCells)
{
if (RecursiveGetCells(subCell, shape, detailLevel, inclParents, simplify, result))
{
leaves++;
}
}
//can we simplify?
if (simplify && leaves == cell.GetSubCellsSize() && cell.Level != 0)
{
do
{
//Optimization: substitute the parent as a leaf instead of adding all
// children as leaves
//remove the leaves
result.RemoveAt(result.Count - 1);
}
while (--leaves > 0);
//remove last
//add cell as the leaf
cell.SetLeaf();
if (!inclParents)
{
// otherwise it was already added up above
result.Add(cell);
}
return true;
}
return false;
}