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


C# Surface.Reduce方法代码示例

本文整理汇总了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;
        }
开发者ID:nikiforovandrey,项目名称:ERTMSFormalSpecs,代码行数:90,代码来源:Function.cs


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