示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TimeWarping"/> class.
        /// </summary>
        /// <param name="originalSequence">The original sequence.</param>
        /// <param name="otherSequence">The other sequence.</param>
        public TimeWarping(Stroke originalSequence, Stroke otherSequence)
        {
            OriginalSequence = originalSequence.AllPoints;
            OtherSequence = otherSequence.AllPoints;

            InitialiseLists();
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Radical"/> class.
        /// </summary>
        /// <param name="activePoints">The active points.</param>
        public Radical(List<List<Point>> activePoints)
        {
            ActivePoints = activePoints;

            for (int i = 0; i < ActivePoints.Count; i++)
            {
                Stroke s = new Stroke(ActivePoints[i]);
                StrokeList.Add(s);
            }
        }
示例#3
0
        /// <summary>
        /// Gets the almost random stroke.
        /// </summary>
        /// <param name="i">The i. Legal values 0 or 1 for one or the other stroke</param>
        /// <returns></returns>
        private static Stroke GetAlmostRandomStroke(int i)
        {
            Random rand = new Random();
            List<Point> p = new List<Point>();

            DateTime now = DateTime.Now;

            int randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            p.Add(new Point(1, 1, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            p.Add(new Point(2, 2, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            p.Add(new Point(4, 2, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            p.Add(new Point(5, 3, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            p.Add(new Point(6, 2, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            p.Add(new Point(6, 3, new DateTime(now.Ticks - randNext)));

            List<Point> q = new List<Point>();
            randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            q.Add(new Point(2, 4, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            q.Add(new Point(3, 5, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            q.Add(new Point(5, 5, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            q.Add(new Point(6, 6, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            q.Add(new Point(7, 5, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            q.Add(new Point(7, 6, new DateTime(now.Ticks - randNext)));

            Stroke r = null;

            switch (i)
            {
                case 0: r = new Stroke(p);
                    break;
                case 1: r = new Stroke(q);
                    break;
            }

            return r;
        }
示例#4
0
        private static void TestStrokeHashing()
        {
            Random rand = new Random();
            List<Point> p = new List<Point>();

            DateTime now = DateTime.Now;

            int randNext = rand.Next((int)Math.Pow(10,4), (int)Math.Pow(10,5));
            p.Add(new Point(1, 1, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10,4), (int)Math.Pow(10,5));
            p.Add(new Point(2, 2, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10,4), (int)Math.Pow(10,5));
            p.Add(new Point(4, 2, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10,4), (int)Math.Pow(10,5));
            p.Add(new Point(5, 3, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10,4), (int)Math.Pow(10,5));
            p.Add(new Point(6, 2, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10,4), (int)Math.Pow(10,5));
            p.Add(new Point(6, 3, new DateTime(now.Ticks - randNext)));

            List<Point> q = new List<Point>();
            randNext = rand.Next((int)Math.Pow(10,4), (int)Math.Pow(10,5));
            q.Add(new Point(2, 4, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10,4), (int)Math.Pow(10,5));
            q.Add(new Point(3, 5, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10,4), (int)Math.Pow(10,5));
            q.Add(new Point(5, 5, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10,4), (int)Math.Pow(10,5));
            q.Add(new Point(6, 6, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10,4), (int)Math.Pow(10,5));
            q.Add(new Point(7, 5, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10,4), (int)Math.Pow(10,5));
            q.Add(new Point(7, 6, new DateTime(now.Ticks - randNext)));

            Stroke s = new Stroke(p);
            Stroke s2 = new Stroke(p);
            Stroke r = new Stroke(q);

            BinaryWriter bw = new BinaryWriter(new FileStream("test", FileMode.Create, FileAccess.Write, FileShare.None));
            bw.Write(s.Hash(false));
            //bw.Write((byte)255);
            bw.Write(s2.Hash(false));
            //bw.Write((byte)255);
            bw.Write(r.Hash(false));
            bw.Close();
        }
示例#5
0
        private static void TestRadicalHashing()
        {
            Random rand = new Random();
            List<Point> p = new List<Point>();

            DateTime now = DateTime.Now;

            int randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            p.Add(new Point(1, 1, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            p.Add(new Point(2, 2, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            p.Add(new Point(4, 2, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            p.Add(new Point(5, 3, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            p.Add(new Point(6, 2, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            p.Add(new Point(6, 3, new DateTime(now.Ticks - randNext)));

            List<Point> q = new List<Point>();
            randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            q.Add(new Point(2, 4, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            q.Add(new Point(3, 5, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            q.Add(new Point(5, 5, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            q.Add(new Point(6, 6, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            q.Add(new Point(7, 5, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            q.Add(new Point(7, 6, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            q.Add(new Point(8, 7, new DateTime(now.Ticks - randNext)));
            randNext = rand.Next((int)Math.Pow(10, 4), (int)Math.Pow(10, 5));
            q.Add(new Point(9, 8, new DateTime(now.Ticks - randNext)));

            Stroke s = new Stroke(p);
            Stroke s2 = new Stroke(p);
            Stroke r = new Stroke(q);

            List<Stroke> strokelist = new List<Stroke>();
            strokelist.Add(s);
            strokelist.Add(s2);
            strokelist.Add(r);

            Radical rad = new Radical(strokelist);

            BinaryWriter bw = new BinaryWriter(new FileStream("test", FileMode.Create, FileAccess.Write, FileShare.None));
            bw.Write(rad.Hash(true));
            bw.Close();
        }
示例#6
0
        private static Stroke ReadElementContentAsStroke(this XmlTextReader xmlr)
        {
            if (xmlr.NodeType == XmlNodeType.Element)
            {
                if (xmlr.Name == "stroke")
                {
                    Stroke s = new Stroke();

                    xmlr.ReadStartElement("stroke"); //now moving to point
                    while (xmlr.NodeType != XmlNodeType.EndElement)
                        s.AllPoints.Add(xmlr.ReadElementContentAsPoint());

                    xmlr.ReadEndElement();
                    return s;
                }
                else throw new Exception(string.Format("Not the correct element. This was a {0}-tag", xmlr.Name));
            }
            else throw new Exception("Not even an element type");
        }
示例#7
0
        /// <summary>
        /// Reads the upx element content as a character.
        /// </summary>
        /// <param name="xmlr">The XMLR.</param>
        /// <returns>An instance of the Stroke class</returns>
        public static Stroke ReadUPXElementContentAsStroke(XmlTextReader xmlr)
        {
            if (UPXReader.IsUPXhLevelStroke(xmlr) && (xmlr.HasAttributes))
            {
                Stroke s = new Stroke();

                s.ID = XmlTools.ReadIDAttribute(xmlr);

                //now moving to label and reading it
                //then the strokes
                //if we're hitting and end element that is a hLevel stop reading
                //when hLevel end element is hit, stroke is finished
                while (xmlr.Read() && (!IsEndElementTypeWithName(xmlr, "hLevel")))
                {
                    if (xmlr.NodeType == XmlNodeType.Element)
                    {
                        switch (xmlr.Name)
                        {
                            case "label":
                                s.Value = ReadUPXElementContentAsLabel(xmlr, s.ID);
                                break;
                            case "hwTraces":
                                if (IsElementTypeWithName(xmlr, "hwtraces"))
                                    s.AllPoints = ReadUPXElementContentAsPointList(xmlr);
                                break;
                        }
                    }
                }
                return s;
            }
            else throw new Exception(string.Format("Not the correct element. This was a {0}-tag.", xmlr.Name));
        }