Example #1
0
        private void SharpenRUEdges()
        {
            //this handles cases of horizontal and vertical lines which are recorde 1-away from true positionj because the
            //location point is always in the upper left of a 2x2 cell but the boundary may be at the top, bottom, left, or right.
            for (int i = 0; i < boundaries.Count; i++)
            {
                BoundaryX boundary = boundaries[i];
                //string target = DR.ToString() + R.ToString();

                string s = boundary.motionString;

                s = SharpenCorner(DR, R, UR, s);
                s = SharpenCorner(UR, U, UL, s);
                s = SharpenCorner(UL, L, DL, s);
                boundaries[i].motionString = s;
            }
        }
Example #2
0
        private void FindCorners()
        {
            //TODO add check for boundary ending where it starts
            lines = new List <BoundaryX>();
            for (int i = 0; i < boundaries.Count; i++)
            {
                BoundaryX boundary = boundaries[i];
                int       curX     = (int)Math.Round(boundary.p1.X);
                int       curY     = (int)Math.Round(boundary.p1.Y);
                int       newX     = curX;
                int       newY     = curY;
                corners = new List <Point>();
                corners.Add(new Point(curX, curY));
                BoundaryX theLine;
                string    s = boundary.motionString;
                for (int j = 0; j < s.Length - 2; j++)
                {
                    for (int offset = 1; offset < 4 && j + offset < s.Length; offset++)
                    {
                        if ((IsHoriz(s[j]) && IsVert(s[j + offset])) ||
                            (IsVert(s[j]) && IsHoriz(s[j + offset])) ||
                            (IsAngle(s[j]) && IsAngle(s[j + offset]) && s[j] != s[j + offset])
                            )
                        {
                            string sString = s.Substring(0, j + offset);
                            GetPrincipalSlope(sString);
                            //char last = sString[sString.Length - 1];
                            //char nextToLast = sString[sString.Length - 2];
                            //if (IsAngle(last) && (IsHoriz(nextToLast) || IsVert(nextToLast)))
                            // {
                            //    sString = sString.Substring(0, sString.Length - 1) + nextToLast;
                            // }
                            GetPositionOfLinePoint(curX, curY, s, j + 1, out newX, out newY);
                            //s = s.Substring(j + offset);
                            //j = 0;
                            corners.Add(new Point(newX, newY));
                            j += 1;// offset;

                            /*                            theLine = new Boundary
                             *                          {
                             *                              p1 = new Point(curX, curY),
                             *                              p2 = new Point(newX, newY),
                             *                              debugString = sString,
                             *                              processed = false,
                             *                          };
                             *                          lines.Add(theLine);
                             *                          j = 0;
                             *                          curX = newX;
                             *                          curY = newY;
                             */
                            break;
                        }
                    }
                }
                //GetPositionOfLinePoint(curX, curY, s, s.Length - 1, out newX, out newY);
                //theLine = new Boundary
                //{
                //    p1 = new Point(curX, curY),
                //    p2 = new Point(newX, newY),
                //    debugString = s,
                //    processed = false,
                //};
                //lines.Add(theLine);
            }
        }