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


C# Graph.addSegment方法代码示例

本文整理汇总了C#中Graph.addSegment方法的典型用法代码示例。如果您正苦于以下问题:C# Graph.addSegment方法的具体用法?C# Graph.addSegment怎么用?C# Graph.addSegment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Graph的用法示例。


在下文中一共展示了Graph.addSegment方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: createSurfaceForValue

        /// <summary>
        /// Creates the surface associated to the value provided
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        protected Surface createSurfaceForValue(Interpreter.InterpretationContext context, Values.IValue value)
        {
            Surface retVal = null;

            Function function = value as Function;
            if (function != null)
            {
                retVal = function.createSurface(context);
            }
            else
            {
                Values.DoubleValue val = value as Values.DoubleValue;
                Graph graph = new Graph();
                graph.addSegment(new Graph.Segment(0, double.MaxValue, new Graph.Segment.Curve(0, val.Val, 0)));
                retVal = new Functions.Surface(null, null);
                retVal.AddSegment(new Surface.Segment(0, double.MaxValue, graph));
            }

            return retVal;
        }
开发者ID:Assmann-Siemens,项目名称:ERTMSFormalSpecs,代码行数:25,代码来源:PredefinedFunction.cs

示例2: createGraph

        /// <summary>
        /// Provides the graph of this function if it has been statically defined
        /// </summary>
        /// <param name="context">the context used to create the graph</param>
        /// <returns></returns>
        public override Graph createGraph(Interpreter.InterpretationContext context, Parameter parameter)
        {
            Graph retVal = null;

            Graph MRSPGraph = null;
            Function speedRestriction = context.findOnStack(SpeedRestrictions).Value as Function;
            if (speedRestriction != null)
            {
                Parameter p = (Parameter)speedRestriction.FormalParameters[0];

                int token = context.LocalScope.PushContext();
                context.LocalScope.setGraphParameter(p);
                MRSPGraph = createGraphForValue(context, context.findOnStack(SpeedRestrictions).Value, p);
                context.LocalScope.PopContext(token);
            }

            if (MRSPGraph != null)
            {
                Function deceleratorFactor = context.findOnStack(DecelerationFactor).Value as Function;
                if (deceleratorFactor != null)
                {
                    Surface DecelerationSurface = deceleratorFactor.createSurface(context);
                    if (DecelerationSurface != null)
                    {
                        FlatSpeedDistanceCurve MRSPCurve = MRSPGraph.FlatSpeedDistanceCurve(MRSPGraph.ExpectedEndX());
                        AccelerationSpeedDistanceSurface accelerationSurface = DecelerationSurface.createAccelerationSpeedDistanceSurface(double.MaxValue, double.MaxValue);
                        QuadraticSpeedDistanceCurve BrakingCurve = null;
                        try
                        {
                            BrakingCurve = EtcsBrakingCurveBuilder.Build_A_Safe_Backward(accelerationSurface, MRSPCurve);
                        }
                        catch (System.Exception e)
                        {
                            retVal = new Graph();
                            retVal.addSegment(new Graph.Segment(0, double.MaxValue, new Graph.Segment.Curve(0, 0, 0)));
                        }

                        if (BrakingCurve != null)
                        {
                            retVal = new Graph();

                            // TODO : Remove the distinction between linear curves and quadratic curves
                            bool isLinear = true;
                            for (int i = 0; i < BrakingCurve.SegmentCount; i++)
                            {
                                QuadraticCurveSegment segment = BrakingCurve[i];
                                if (segment.A.ToUnits() != 0.0 || segment.V0.ToUnits() != 0.0)
                                {
                                    isLinear = false;
                                    break;
                                }
                            }

                            for (int i = 0; i < BrakingCurve.SegmentCount; i++)
                            {
                                QuadraticCurveSegment segment = BrakingCurve[i];

                                Graph.Segment newSegment;
                                if (isLinear)
                                {
                                    newSegment = new Graph.Segment(
                                        segment.X.X0.ToUnits(),
                                        segment.X.X1.ToUnits(),
                                        new Graph.Segment.Curve(0.0, segment.V0.ToSubUnits(SiSpeed_SubUnits.KiloMeter_per_Hour), 0.0));
                                }
                                else
                                {
                                    newSegment = new Graph.Segment(
                                        segment.X.X0.ToUnits(),
                                        segment.X.X1.ToUnits(),
                                        new Graph.Segment.Curve(
                                            segment.A.ToSubUnits(SiAcceleration_SubUnits.Meter_per_SecondSquare),
                                            segment.V0.ToSubUnits(SiSpeed_SubUnits.KiloMeter_per_Hour),
                                            segment.D0.ToSubUnits(SiDistance_SubUnits.Meter)
                                            )
                                        );
                                }
                                retVal.addSegment(newSegment);
                            }
                        }
                    }
                    else
                    {
                        Log.Error("Cannot create surface for " + DecelerationFactor.ToString());
                    }
                }
                else
                {
                    Log.Error("Cannot evaluate " + DecelerationFactor.ToString() + " as a function");
                }
            }
            else
            {
                Log.Error("Cannot create graph for " + SpeedRestrictions.ToString());
            }
//.........这里部分代码省略.........
开发者ID:Assmann-Siemens,项目名称:ERTMSFormalSpecs,代码行数:101,代码来源:DecelerationProfile.cs

示例3: createGraphForValue

        /// <summary>
        /// Creates the graph associated to the parameter provided
        /// </summary>
        /// <param name="value">The value for which the graph must be created</param>
        /// <returns></returns>
        protected Graph createGraphForValue(Interpreter.InterpretationContext context, Values.IValue value, Parameter parameter = null)
        {
            Graph retVal = new Graph();

            Function function = value as Function;
            if (function != null)
            {
                if (parameter == null)
                {
                    parameter = (Parameter)function.FormalParameters[0];
                    int token = context.LocalScope.PushContext();
                    context.LocalScope.setGraphParameter(parameter);
                    retVal = function.createGraph(context, parameter);
                    context.LocalScope.PopContext(token);
                }
                else
                {
                    retVal = function.createGraph(context, parameter);
                }
            }
            else
            {
                Values.DoubleValue val = value as Values.DoubleValue;
                retVal.addSegment(new Graph.Segment(0, double.MaxValue, new Graph.Segment.Curve(0.0, val.Val, 0.0)));
            }

            return retVal;
        }
开发者ID:Assmann-Siemens,项目名称:ERTMSFormalSpecs,代码行数:33,代码来源:PredefinedFunction.cs

示例4: createGraphForValue

        /// <summary>
        /// Creates the graph for a value
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static Graph createGraphForValue(Values.IValue value)
        {
            Graph retVal = new Graph();

            double val = Functions.Function.getDoubleValue(value);
            retVal.addSegment(new Graph.Segment(0, double.MaxValue, new Graph.Segment.Curve(0.0, val, 0.0)));

            return retVal;
        }
开发者ID:Assmann-Siemens,项目名称:ERTMSFormalSpecs,代码行数:14,代码来源:Function.cs


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