本文整理汇总了C#中Stand.GetActiveSites方法的典型用法代码示例。如果您正苦于以下问题:C# Stand.GetActiveSites方法的具体用法?C# Stand.GetActiveSites怎么用?C# Stand.GetActiveSites使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stand
的用法示例。
在下文中一共展示了Stand.GetActiveSites方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckRule
//---------------------------------------------------------------------
// Re-written by R. Scheller to simplify and speed the stand processing.
private bool CheckRule(Stand stand, InclusionRule rule)
{
//bool meets = false;
int numCellsValid = 0;
int numActiveCells = 0;
int[] numCellsOtherSpecies = new int[PlugIn.ModelCore.Species.Count];
foreach(ActiveSite site in stand.GetActiveSites())
{
//if(!site.IsActive)
// continue;
numActiveCells++;
bool goodSite = false;
//bool otherSpecies = false;
//Landis.Library.BaseCohorts.ISiteCohorts siteCohorts = (Landis.Library.BaseCohorts.ISiteCohorts) PlugIn.ModelCore.SuccessionCohorts[site];
foreach(ISpecies species in PlugIn.ModelCore.Species)
{
if(SiteVars.Cohorts[site][species] != null)
{
foreach (ICohort cohort in SiteVars.Cohorts[site][species])
{
if (rule.SpeciesList.Contains(species.Name) && rule.RuleAgeRange.Contains(cohort.Age))
{
goodSite = true;
}
// Some other species, NOT in the list
if (!rule.SpeciesList.Contains(species.Name) && rule.RuleAgeRange.Contains(cohort.Age))
{
//otherSpecies = true;
numCellsOtherSpecies[species.Index]++;
}
}
}
}
if(goodSite)
numCellsValid++;
//if(otherSpecies)
//numCellsOtherSpecies[species.Index]++;
} // done looping through sites
if(numCellsValid == 0) // There are no good cells whatsoever.
return false;
bool highest = true;
//If percent != -1, compare to the Percent of Cells
if (rule.PercentOfCells != -1)
{
double targetNumCells = (double) numActiveCells * rule.PercentOfCells;
if(targetNumCells > numActiveCells)
{
string message = string.Format(" Harvest Inclusion Rule Error: target number of cells {0} exceeds number in stand {1}", targetNumCells, numActiveCells);
throw new ApplicationException(message);
}
if(numCellsValid >= targetNumCells)
{
//PlugIn.ModelCore.Log.WriteLine(" numGoodSites={0}, targetNumCells={1}", numCellsValid, targetNumCells);
return true;
}
}
//If percent == -1, use 'highest' evaluation algorithm
else
{
for(int i = 0; i < PlugIn.ModelCore.Species.Count; i++)
{
if(numCellsValid < numCellsOtherSpecies[i])
highest = false;
//PlugIn.ModelCore.Log.WriteLine(" numGoodSites={0}, otherSppCnt={1}, true? {2}", numCellsValid, otherSpeciesCount[i], highest);
}
}
return highest;
}