예제 #1
0
        /// <summary>
        /// 始点がfromで終点がtoのエッジを戻す。
        /// </summary>
        private Edge FindEdge(PointInf from, PointInf to, FEOption opt)
        {
            switch (opt)
            {
            case FEOption.SamePointIdx:
                foreach (var e in mEdgeList)
                {
                    if (e.fromPointIdx == from.Idx &&
                        e.toPointIdx == to.Idx)
                    {
                        return(e);
                    }
                }
                break;

            case FEOption.SamePosition: {
                foreach (var e in mEdgeList)
                {
                    var e1 = mPP.FindPointByIdx(e.fromPointIdx, PointProc.FindPointMode.FindAll);
                    if (WWVectorD2.Distance(e1.xy, from.xy) < 1)
                    {
                        var e2 = mPP.FindPointByIdx(e.toPointIdx, PointProc.FindPointMode.FindAll);
                        if (WWVectorD2.Distance(e2.xy, to.xy) < 1)
                        {
                            return(e);
                        }
                    }
                }
            }
            break;
            }

            return(null);
        }
예제 #2
0
        /// <summary>
        /// 始点がidxFromで終点がidxToのエッジを戻す。
        /// </summary>
        public Edge FindEdge(int idxFrom, int idxTo, FEOption opt)
        {
            switch (opt)
            {
            case FEOption.SamePointIdx:
                foreach (var e in mEdgeList)
                {
                    if (e.fromPointIdx == idxFrom &&
                        e.toPointIdx == idxTo)
                    {
                        return(e);
                    }
                }
                break;

            case FEOption.SamePosition: {
                var p1 = mPP.FindPointByIdx(idxFrom, PointProc.FindPointMode.FindAll);
                var p2 = mPP.FindPointByIdx(idxTo, PointProc.FindPointMode.FindAll);
                foreach (var e in mEdgeList)
                {
                    var e1 = mPP.FindPointByIdx(e.fromPointIdx, PointProc.FindPointMode.FindAll);
                    if (WWVectorD2.Distance(e1.xy, p1.xy) < 1)
                    {
                        var e2 = mPP.FindPointByIdx(e.toPointIdx, PointProc.FindPointMode.FindAll);
                        if (WWVectorD2.Distance(e2.xy, p2.xy) < 1)
                        {
                            return(e);
                        }
                    }
                }
            }
            break;
            }

            return(null);
        }