Ejemplo n.º 1
0
        /// <summary>
        /// Returns whether or not the strokes that make up a shape were
        /// drawn consecutively
        /// </summary>
        /// <param name="sketch">The sketch that contains the shape</param>
        /// <param name="shape">The shape to be checked</param>
        /// <returns>Whether or not the shape was drawn consecutively</returns>
        public bool isConsecutive(Sketch.Sketch sketch, Sketch.Shape shape)
        {
            Substroke[] strokes    = shape.Substrokes;
            Substroke   sub1       = strokes[0];
            bool        inShape    = false;
            int         shapeIndex = 0;

            for (int i = 0; i < sketch.Substrokes.Length; i++)
            {
                Substroke str = sketch.Substrokes[i];
                if (!inShape && str.Equals(sub1))
                {
                    inShape = true;
                }
                if (shapeIndex == strokes.Length)
                {
                    break;
                }
                if (inShape)
                {
                    sub1 = strokes[shapeIndex];
                    if (!sub1.Equals(str))
                    {
                        return(false);
                    }
                    shapeIndex++;
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
        public void TestSubstrokeEqualsAndClone()
        {
            Substroke s1 = Shapes.newValidSubstroke();

            s1.Classification = Domain.LogicDomain.TEXT_CLASS;

            Substroke s2 = s1.Clone();

            Assert.IsTrue(s1.Equals(s2), "Original substroke reports it is not equal to the clone");
            Assert.IsTrue(s2.Equals(s1), "Cloned substroke reports it is not equal to the original");

            s2.Classification = Domain.LogicDomain.GATE_CLASS;

            Assert.IsTrue(s1.Equals(s2), "Substroke equality depends on classification");
            Assert.IsTrue(s2.Equals(s1), "Substroke equality depends on classification");

            Assert.IsFalse(s1.Id.Equals(s2.Id), "Two substrokes should not have the same ID, even if they are clones");
        }
Ejemplo n.º 3
0
        // This function should return something or write to a file
        public void consecutiveStats(string statistics)
        {
            StreamWriter sw = File.CreateText(statistics);

            // Put the key at the top of the file
            sw.WriteLine("SketchID UserID ShapeName IsConsecutive");
            foreach (Sketch.Sketch s in sketches)
            {
                // For each shape calculate if it is consecutive (i.e., are there any strokes interrupting it)
                foreach (Shape sh in s.Shapes)
                {
                    // get the strokes in the shape
                    // In theory these substrokes are time ordered...
                    Substroke[] strokes = sh.Substrokes;
                    if (strokes.Length == 0)
                    {
                        Console.WriteLine("Something's wrong.  Shape " + sh + " has no substrokes");
                    }

                    Substroke s1 = strokes[0];
                    // find the strokes in the sketch and make sure they are not interrupted by strokes not in the shape
                    bool in_shape = false;
                    int  sh_index = 0;
                    bool okSoFar  = true;
                    for (int i = 0; i < s.Substrokes.Length; i++)
                    {
                        Substroke str = s.Substrokes[i];
                        if (!in_shape && str.Equals(s1))
                        {
                            in_shape = true;
                        }
                        if (sh_index == strokes.Length)
                        {
                            break;
                        }
                        if (in_shape)
                        {
                            s1 = strokes[sh_index];
                            if (!s1.Equals(str))
                            {
                                okSoFar = false;
                                sw.WriteLine("{0} {1} {2} False", s.XmlAttrs.Id, userIds[s.XmlAttrs.Id], sh.XmlAttrs.Name);
                                break;
                            }

                            sh_index++;
                        }
                    }
                    if (okSoFar)
                    {
                        sw.WriteLine("{0} {1} {2} True", s.XmlAttrs.Id, userIds[s.XmlAttrs.Id], sh.XmlAttrs.Name);
                    }
                }
            }

            sw.Close();
        }