public ParseTreeNode(string nodeLabel, LBT tree)
 {
     nodeType = nodeLabel;
     children = new List <ParseTreeNode>();
     lbt      = new LBT(tree);        // create a copy.
     strokes  = lbt.strokes;
 }
Exemple #2
0
        public LBT(LBT other)
        {
            if (other != null)
            {
                // clone stroke list
                strokes = new List <Stroke>();
                if (other.strokes != null)
                {
                    foreach (Stroke s in other.strokes)
                    {
                        strokes.Add(s);
                    }
                }
                // clone tree
                root = new LBTNode(other.root);

                // rebuild dictionary
                stroke_to_node = new Dictionary <Stroke, LBTNode>();
                Stack stack = new Stack();
                stack.Push(root);
                while (stack.Count > 0)
                {
                    LBTNode node = (LBTNode)stack.Pop();
                    if (node != root)
                    {
                        stroke_to_node.Add(node.stroke, node);
                    }
                    foreach (LBTNode ln in node.children)
                    {
                        stack.Push(ln);
                    }
                }
                raw_data = null;
            }
        }
 // * Watch management of LBT
 public ParseTreeNode(string nodeLabel)
 {
     // Assign label, create empty list of child nodes. No LBT.
     nodeType = nodeLabel;
     children = new List <ParseTreeNode>();
     lbt      = null;
     strokes  = null;
 }
        // Constructor for root node.
        public ParseState(ParseTreeNode inNode, LBT tree)
        {
            // Create root node for parser.
            rootNode = inNode;

            // Construct previous node.
            // **Note: currently a number of fields will be uninitialized.
            previous                 = new PreviousSymbol();
            previous.symbol          = new LexerResult();
            previous.symbol.lbt      = tree;
            previous.regionsOptional = true;

            // Remaining attribute definitions.
            candidateSymbols = null;            // no symbols considered.
            completesParse   = true;            // root node.
            numberStrokes    = tree.strokes.Count;
        }
Exemple #5
0
        public void GraphFromStrokeList(LBT lbt, List <Stroke> strokes, AdjacentCriterion adjacent)
        {
            strokes.Sort(delegate(Stroke a, Stroke b)
            {
                return(Math.Sign(a.aabb.Left - b.aabb.Left));

                //if(a.aabb.Left < b.aabb.Left) return -1;
                //if(a.aabb.Left > b.aabb.Left) return 1;
                //return 0;
            });

            lbt.root        = new LBTNode();
            lbt.root.stroke = null;
            for (int k = 0; k < strokes.Count; k++)
            {
                LBTNode node = new LBTNode();
                node.stroke = strokes[k];
                lbt.stroke_to_node[strokes[k]] = node;
                if (k == 0)
                {
                    lbt.root.children.Add(node);
                    continue;
                }

                // iterate over boxes to the left of this box
                for (int j = k - 1; j >= 0; j--)
                {
                    // if strokes don't overlap on y
                    if (Math.Abs(strokes[k].aabb.Center.y - strokes[j].aabb.Center.y) > (strokes[k].aabb.Radius.y + strokes[j].aabb.Radius.y))
                    {
                        if (j == 0)
                        {
                            lbt.root.children.Add(node);
                        }
                        continue;
                    }

                    if (adjacent(strokes[j].aabb, strokes[k].aabb))
                    {
                        LBTNode parent = lbt.stroke_to_node[strokes[j]];
                        parent.children.Add(node);
                        break;
                    }
                }
            }
        }
Exemple #6
0
        public override bool Equals(object obj)
        {
            if (!(obj is LBT))
            {
                return(false);
            }
            LBT o = obj as LBT;

            // verify stroke lists are the same
            if (strokes.Count != o.strokes.Count)
            {
                return(false);
            }
            foreach (Stroke s in strokes)
            {
                if (!o.strokes.Contains(s))
                {
                    return(false);
                }
            }
            return(true);
        }
 public RelationTreeNode(string relationLabel, string nodeLabel) : base(nodeLabel)
 {
     relationType = relationLabel;
     strokes      = new List <Stroke>();       // empty stroke list.
     lbt          = new LBT(new List <Stroke>(), LBT.DefaultAdjacentCriterion);
 }
 public PartitionResultWrapper(PartitionResult inResult,
                               LBT inLBT)
 {
     result = inResult;
     lbt    = new LBT(inLBT);
 }