예제 #1
0
        /// <summary>
        /// Try and find matching lines.
        /// </summary>
        /// <param name="lines"></param>
        /// <param name="points"></param>
        /// <returns></returns>
        private MatchPosition FindMatch(ILocatedObjectIndex <PointF2D, Scene2D.ScenePoints> linesIndex, Dictionary <Scene2D.ScenePoints, Scene2DStylesSet> lines,
                                        double[] x, double[] y, Scene2DStylesSet style, float epsilon, out Scene2D.ScenePoints found)
        {
            // build box.
            var box = new BoxF2D(x, y);

            box = box.ResizeWith(epsilon * 1.1);

            // get all geometries in this box.
            var potentialMatches = linesIndex.GetInside(box);

            // find a match in the potential matches list.
            PointF2D first = new PointF2D(x[0], y[0]);
            PointF2D last  = new PointF2D(x[x.Length - 1], y[y.Length - 1]);

            MatchPosition position = MatchPosition.None;

            found = null;
            foreach (var line in potentialMatches)
            {
                // check first.
                PointF2D potentialFirst = new PointF2D(line.X[0], line.Y[0]);
                PointF2D potentialLast  = new PointF2D(line.X[line.X.Length - 1], line.Y[line.Y.Length - 1]);
                if (first.Distance(potentialFirst) < epsilon)
                {
                    found    = line;
                    position = MatchPosition.FirstFirst;
                }
                else if (last.Distance(potentialFirst) < epsilon)
                {
                    found    = line;
                    position = MatchPosition.LastFirst;
                }
                else if (first.Distance(potentialLast) < epsilon)
                {
                    found    = line;
                    position = MatchPosition.FirstLast;
                }
                else if (last.Distance(potentialLast) < epsilon)
                {
                    found    = line;
                    position = MatchPosition.LastLast;
                }

                Scene2DStylesSet styleValue;
                if (position != MatchPosition.None && lines.TryGetValue(line, out styleValue) && styleValue.Equals(style))
                {
                    break;
                }
                else
                {
                    position = MatchPosition.None;
                    found    = null;
                }
            }
            return(position);
        }
예제 #2
0
        /// <summary>
        /// Try and find matching lines.
        /// </summary>
        /// <param name="lines"></param>
        /// <param name="points"></param>
        /// <returns></returns>
        private MatchPosition FindMatch(ILocatedObjectIndex<PointF2D, Scene2D.ScenePoints> linesIndex, Dictionary<Scene2D.ScenePoints, Scene2DStylesSet> lines, 
            double[] x, double[] y, Scene2DStylesSet style, float epsilon, out Scene2D.ScenePoints found)
        {
            // build box.
            var box = new BoxF2D(x, y);
            box = box.ResizeWith(epsilon * 1.1);

            // get all geometries in this box.
            var potentialMatches = linesIndex.GetInside(box);

            // find a match in the potential matches list.
            PointF2D first = new PointF2D(x[0], y[0]);
            PointF2D last = new PointF2D(x[x.Length - 1], y[y.Length - 1]);

            MatchPosition position = MatchPosition.None;
            found = null;
            foreach (var line in potentialMatches)
            {
                // check first.
                PointF2D potentialFirst = new PointF2D(line.X[0], line.Y[0]);
                PointF2D potentialLast = new PointF2D(line.X[line.X.Length - 1], line.Y[line.Y.Length - 1]);
                if (first.Distance(potentialFirst) < epsilon)
                {
                    found = line;
                    position = MatchPosition.FirstFirst;
                }
                else if (last.Distance(potentialFirst) < epsilon)
                {
                    found = line;
                    position = MatchPosition.LastFirst;
                }
                else if (first.Distance(potentialLast) < epsilon)
                {
                    found = line;
                    position = MatchPosition.FirstLast;
                }
                else if (last.Distance(potentialLast) < epsilon)
                {
                    found = line;
                    position = MatchPosition.LastLast;
                }

                Scene2DStylesSet styleValue;
                if (position != MatchPosition.None && lines.TryGetValue(line, out styleValue) && styleValue.Equals(style))
                {
                    break;
                }
                else
                {
                    position = MatchPosition.None;
                    found = null;
                }
            }
            return position;
        }