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


C# INetwork.CreateForwardStar方法代码示例

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


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

示例1: TraceFeeder

        /// <summary>
        /// 
        /// </summary>
        /// <param name="circBreaker"></param>
        private void TraceFeeder(INetworkFeature circBreaker)
        {
            #region Initialize some variables

            listView1.Items.Clear();
            Int32 phaseABit = (int) Math.Pow(2, 28); // 268435456
            Int32 phaseBBit = (int) Math.Pow(2, 29); // 536870912
            Int32 phaseCBit = (int) Math.Pow(2, 30); // 1073741824

            #endregion

            #region Create a queue of junctions to visit and a hash table for path information

            Queue<int> junctionsToVisit = new Queue<int>();
            Dictionary<int, int> pathHash = new Dictionary<int, int>();
            int startEID = ((ISimpleJunctionFeature) circBreaker).EID;
            junctionsToVisit.Enqueue(startEID);
            pathHash.Add(startEID, -99999999);

            #endregion

            #region Get the MMElectricTraceWeight and create a ForwardStar so that we can stop the trace when we reach an open point

            _network = circBreaker.GeometricNetwork.Network;
            _geomNet = circBreaker.GeometricNetwork;
            INetSchema netSchema = (INetSchema) _network;
            INetWeight mmElectricTraceWeight = netSchema.get_WeightByName("MMElectricTraceWeight");
            IForwardStarGEN fStar =
                (IForwardStarGEN) _network.CreateForwardStar(false, mmElectricTraceWeight, null, null, null);

            #endregion

            while (junctionsToVisit.Count > 0)
            {
                #region Orient the Forward Star at the current junction EID

                int eid = junctionsToVisit.Dequeue();
                int adjEdgeCount = 0;
                fStar.FindAdjacent(0, eid, out adjEdgeCount);

                #endregion

                #region Declare and initialize arrays to hold edges and junctions, weights, and orientations

                int[] adjJuncEIDS = new int[adjEdgeCount];
                object[] adjJuncWeights = new object[adjEdgeCount];
                int[] adjEdgeEIDS = new int[adjEdgeCount];
                object[] adjEdgeWeights = new object[adjEdgeCount];
                    // We don't use this, but we still have to declare the array
                bool[] adjRevOrientations = new bool[adjEdgeCount];
                    // We don't use this, but we still have to declare the array

                #endregion

                #region Query the adjacent junctions and edges (while we are at it, get the weights too)

                fStar.QueryAdjacentJunctions(ref adjJuncEIDS, ref adjJuncWeights);
                fStar.QueryAdjacentEdges(ref adjEdgeEIDS, ref adjRevOrientations, ref adjEdgeWeights);

                #endregion

                #region Loop through all of the connected edges

                for (int i = 0; i < adjEdgeCount; i++)
                {
                    #region Get the connected edge and junction

                    int connectedEdgeEID = -1*adjEdgeEIDS[i];
                    int oppositeJuncEID = adjJuncEIDS[i];

                    #endregion

                    #region Check to see if the adjacent junctions has already been added to the paths hashtable

                    if (pathHash.ContainsKey(oppositeJuncEID) == false)
                    {
                        #region Add the opposite junction and the connected edge to the paths hashtable

                        pathHash.Add(oppositeJuncEID, connectedEdgeEID);
                        pathHash.Add(connectedEdgeEID, eid);

                        #endregion

                        #region If the opposite junction is closed on at least one phase (A or B or C), then enque the opposite junction

                        Int32 juncWeight = System.Convert.ToInt32(adjJuncWeights[i]);
                        if ((juncWeight & phaseABit) == 0 || (juncWeight & phaseBBit) == 0 ||
                            (juncWeight & phaseCBit) == 0 || (juncWeight == 0))
                        {
                            junctionsToVisit.Enqueue(oppositeJuncEID);
                        }

                        #endregion
                    }

                    #endregion
//.........这里部分代码省略.........
开发者ID:RiverTaig,项目名称:FindFeederWeb,代码行数:101,代码来源:DoTrace.cs


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