示例#1
0
        public LBT(InkML in_data, AdjacentCriterion adjacent)
        {
            raw_data = in_data;
            // sort boxes by left hand extent
            // starting from left, move right and evaluate which strokes have something to the left
            // use filtering function to evaluate if is valid
            strokes        = new List <Stroke>();
            stroke_to_node = new Dictionary <Stroke, LBTNode>();

            foreach (InkML.Trace tr in raw_data.traces)
            {
                strokes.Add(tr.ToStroke());
            }

            GraphFromStrokeList(this, strokes, adjacent);
        }
示例#2
0
        public LBT(List <Stroke> inStrokes, AdjacentCriterion adjacent)
        {
            // DEBUG: input parameter was getting updated ('inStrokes' was 'strokes'),
            // not actual stroke data structure.
            strokes = new List <Stroke>();

            if (inStrokes != null)
            {
                foreach (Stroke s in inStrokes)
                {
                    strokes.Add(s);
                }
            }

            stroke_to_node = new Dictionary <Stroke, LBTNode>();
            GraphFromStrokeList(this, strokes, adjacent);
        }
示例#3
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;
                    }
                }
            }
        }
示例#4
0
 public void PruneNode(Stroke s, AdjacentCriterion adjacent)
 {
     strokes.Remove(s);
     stroke_to_node.Clear();
     GraphFromStrokeList(this, strokes, adjacent);
 }