Пример #1
0
 public void Add(ElemTrace trace)
 {
     m_traces.Add(trace);
 }
Пример #2
0
        private void UpdateTracesWorker(Elem elem)
        {
            //elem.m_traces.Clear()
            Node node = elem.GetNode();
            if (node.NumTraces() > 0)
            {
                foreach (Trace trace in node.Traces())
                {
                    if (trace.source == node)
                    {
                        foreach (Elem possibledest in Elements())
                        {
                            if (trace.destination == possibledest.GetNode())
                            {
                                ElemTrace newtrace = new ElemTrace(elem, possibledest, trace);
                                InitElemTrace(newtrace);
                                newtrace.sourcexth = elem.tracecount++;
                                newtrace.destinationxth = possibledest.tracecount++;
                                newtrace.ancestor.Add(newtrace);
                                goto foo;
                            }
                        }
                        throw new TreeException("Unfound destination");

                    }
                foo: ;
                }
            }
        }
Пример #3
0
        private void InitElemTrace(ElemTrace et)
        {
            Elem a = et.source;
            Elem b = et.destination;
            Elem olda = null;
            Elem oldb = null;
            if (a.level < b.level)
            {
                Elem c = b;
                b = a;
                a = c;
            }

            bool leftofaexceeded = false;
            bool rightofaexceeded = false;
            bool leftofbexceeded = false;
            bool rightofbexceeded = false;
            int avertices = 0;
            int bvertices = 0;
            while (a.level > b.level)
                if (a.Parent != null)
                {
                    if (!leftofaexceeded)
                        foreach (Elem x in a.LeftSiblings())
                            if (x.altitude > avertices)
                            {
                                leftofaexceeded = true;
                                break;
                            }
                    if (!rightofaexceeded)
                        foreach (Elem x in a.RightSiblings())
                            if (x.altitude > avertices)
                            {
                                rightofaexceeded = true;
                                break;
                            }

                    avertices++;
                    olda = a;
                    a = a.Parent;
                }
                else
                    throw new TreeException("Apparently looking for common ancestor of unrelated nodes");
            while (a != b)
            {
                if (a.Parent != null && b.Parent != null && a.Parent == b.Parent)
                {
                    foreach (Elem x in a.Parent.Children())
                    {
                        int xn = x.GetNumber();
                        if (xn > a.GetNumber() && xn < b.GetNumber())
                        {
                            if (x.altitude > avertices)
                                rightofaexceeded = true;
                            if (x.altitude > bvertices)
                                leftofbexceeded = true;
                        }
                        if (xn < a.GetNumber() && xn > b.GetNumber())
                        {
                            if (x.altitude > avertices)
                                leftofaexceeded = true;
                            if (x.altitude > bvertices)
                                rightofbexceeded = true;
                        }
                    }
                }
                else
                {
                    if (a.Parent != null)
                    {
                        if (!leftofaexceeded)
                            foreach (Elem x in a.LeftSiblings())
                                if (x.altitude > avertices)
                                {
                                    leftofaexceeded = true;
                                    break;
                                }
                        if (!rightofaexceeded)
                            foreach (Elem x in a.RightSiblings())
                                if (x.altitude > avertices)
                                {
                                    rightofaexceeded = true;
                                    break;
                                }
                    }
                    else
                        throw new TreeException("Funny looking tree A");

                    if (b.Parent != null)
                    {

                        if (!leftofbexceeded)
                            foreach (Elem x in b.LeftSiblings())
                                if (x.altitude > bvertices)
                                {
                                    leftofbexceeded = true;
                                    break;
                                }
                        if (!rightofbexceeded)
                            foreach (Elem x in b.RightSiblings())
                                if (x.altitude > bvertices)
                                {
                                    rightofbexceeded = true;
                                    break;
                                }
                    }
                    else
                        throw new TreeException("Funny looking tree B");
                }
                avertices++;
                olda = a;
                a = a.Parent;
                bvertices++;
                oldb = b;
                b = b.Parent;
            }
            if (olda != null && oldb != null)
            {
                int apos = a.GetNode().FindChild(olda.GetNode());
                int bpos = a.GetNode().FindChild(oldb.GetNode());
                if (apos < bpos)
                    et.longextent = rightofaexceeded || leftofbexceeded;
                else
                    et.longextent = leftofaexceeded || rightofbexceeded;
            }
            else
                et.longextent = false;
            et.ancestor = a;
        }