本文整理汇总了C#中Surface.Reduce方法的典型用法代码示例。如果您正苦于以下问题:C# Surface.Reduce方法的具体用法?C# Surface.Reduce怎么用?C# Surface.Reduce使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Surface
的用法示例。
在下文中一共展示了Surface.Reduce方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReduceSurface
/// <summary>
/// Reduces the X axis of the surface according to the preconditions of this case
/// </summary>
/// <param name="context">The context used to reduce the surface</param>
/// <param name="cas">The case used to reduce the surface</param>
/// <param name="surface">The surface to reduce</param>
/// <param name="parameter">The parameter for which the reduction has been performed</param>
/// <param name="explain"></param>
/// <returns>The reduced surface</returns>
private Surface ReduceSurface(InterpretationContext context, Case cas, Surface surface, out Parameter parameter,
ExplanationPart explain)
{
Surface retVal;
// Evaluate the axis
parameter = null;
foreach (PreCondition preCondition in cas.PreConditions)
{
List<ISegment> boundaries = EvaluateBoundaries(context, preCondition, surface.XParameter, explain);
if (boundaries.Count != 0 && !FullRange(boundaries))
{
if (parameter != surface.YParameter)
{
parameter = surface.XParameter;
}
else
{
throw new Exception("Cannot reduce a graph on both X axis and Y axis on the same time (1)");
}
}
else
{
boundaries = EvaluateBoundaries(context, preCondition, surface.YParameter, explain);
if (boundaries.Count != 0 && !FullRange(boundaries))
{
if (parameter != surface.XParameter)
{
parameter = surface.YParameter;
}
else
{
throw new Exception("Cannot reduce a graph on both X axis and Y axis on the same time (2)");
}
}
}
}
if (parameter == surface.XParameter)
{
// Reduce the surface on the X axis
retVal = new Surface(surface.XParameter, surface.YParameter);
foreach (ISurfaceSegment segment in surface.Segments)
{
retVal.AddSegment(new Surface.Segment(segment));
}
// Reduces the segments according to this preconditions
foreach (PreCondition preCondition in cas.PreConditions)
{
List<ISegment> boundaries = EvaluateBoundaries(context, preCondition, surface.XParameter,
explain);
retVal.Reduce(boundaries);
}
}
else if (parameter == surface.YParameter)
{
// Reduce the surface, for all segments of the X axis, on the Y axis
retVal = new Surface(surface.XParameter, surface.YParameter);
foreach (Surface.Segment segment in surface.Segments)
{
// Reduces the segments according to this preconditions
foreach (PreCondition preCondition in cas.PreConditions)
{
List<ISegment> boundaries = EvaluateBoundaries(context, preCondition, surface.YParameter,
explain);
segment.Graph.Reduce(boundaries);
}
if (!segment.Empty())
{
retVal.AddSegment(segment);
}
}
}
else
{
retVal = surface;
}
return retVal;
}