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


C# IGraph.CountSegments方法代码示例

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


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

示例1: DisplayGraph

        /// <summary>
        /// Displays the provided function
        /// </summary>
        /// <param name="graph"></param>
        /// <param name="maxDistance"></param>
        /// <param name="startingPoint"></param>
        private void DisplayGraph(IGraph graph, double maxDistance, SpeedDistancePoint startingPoint)
        {
            if (graph != null && startingPoint != null)
            {
                // This empty data point is added in order to allow displaying several
                // deceleration curves without linking the end of the previous curve
                // with the start of the following curve

                DataPoint dataPoint = new DataPoint(0, 0);
                for (int i = 0; i < graph.CountSegments(); i++)
                {
                    ISegment segment = graph.GetSegment(i);
                    if (segment.D0 <= maxDistance && (segment.D0 >= startingPoint.Distance || (segment.Length == double.MaxValue || segment.D0 + segment.Length > startingPoint.Distance)))
                    {
                        double startLocation = Math.Max(startingPoint.Distance, segment.D0);
                        double endLocation = maxDistance;
                        if (!double.IsNaN(segment.Length))
                        {
                            endLocation = Math.Min(segment.D0 + segment.Length, endLocation);
                        }

                        if (segment.A == 0) // this is a flat segment
                        {
                            AddPoint(new DataPoint(startLocation, segment.V0));
                            AddPoint(new DataPoint(endLocation, segment.V0));
                        }
                        else // this is a curve
                        {
                            double distanceInterval = (endLocation - startLocation) /
                                                      GraphVisualizer.DecelerationCurvePrecision;
                            double distance = startLocation;
                            for (int j = 0; j < GraphVisualizer.DecelerationCurvePrecision; j++)
                            {
                                AddDataPoint(distance, segment);
                                distance += distanceInterval;
                            }
                            AddDataPoint(distance, segment);
                        }
                    }
                }
                dataPoint = new DataPoint(0, 0);
                dataPoint.IsEmpty = true;
                AddPoint(dataPoint);
            }
        }
开发者ID:JamesOakey,项目名称:ERTMSFormalSpecs,代码行数:51,代码来源:ProfileFunctionGraph.cs

示例2: UpdateFunction

 /// <summary>
 ///     Updates the provided function and relocates it according to the value of increment
 /// </summary>
 /// <param name="graph"></param>
 /// <param name="lrbgPosition"></param>
 protected void UpdateFunction(IGraph graph, double lrbgPosition)
 {
     if (graph != null)
     {
         for (int i = 0; i < graph.CountSegments(); i++)
         {
             graph.GetSegment(i).D0 += lrbgPosition;
         }
     }
 }
开发者ID:nikiforovandrey,项目名称:ERTMSFormalSpecs,代码行数:15,代码来源:ProfileFunction.cs


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