Esempio n. 1
0
        public ITreeData Create(ITreeData p1, ITreeData p2, string unionId)
        {
            var p1A  = (PersonNode)p1;
            var p2A  = (PersonNode)p2;
            var node = new UnionNode(p1A, p2A, unionId, _vertOrient);

            p1A.IsReal = p1A.DrawVert;  // TODO brother/sister incest: both spouses are children
            p2A.IsReal = p2A.DrawVert;
            return(node);
        }
Esempio n. 2
0
        private static void GrowTree(UnionNode parent)
        {
            if (parent == null)
            {
                return; // person has no spouse/child
            }
            var who = parent.P1.Who ?? parent.P2.Who;

            if (who == null) // both parents empty, shouldn't get here!
            {
                return;
            }

            // This union might have already been added to the
            // tree. If so, provide a link to the previous node,
            // and do NOT add children.
            ITreeData dup;

            if (_unionSet.TryGetValue(parent.UnionId, out dup))
            {
                parent.DupNode = dup;
                return;
            }
            _unionSet.Add(parent.UnionId, parent);

            // About to start the next layer down the tree. punt if we've hit the limit
            if (_genDepth >= _config.MaxDepth)
            {
                return;
            }

            _genDepth = _genDepth + 1;

            // 20200407 - when selecting the 2d spouse of a multi-marriage, need
            // to get the correct union.
            Union marr = who.SpouseIn.Where(x => x.Id == parent.UnionId).FirstOrDefault();

            if (marr == null) // shouldn't happen
            {
                return;
            }

            foreach (var child in marr.Childs)
            {
                switch (child.SpouseIn.Count)
                {
                case 0:
                case 1:
                    ITreeData node = MakeNode(child, _genDepth);
                    _tree.addChild(parent, node);
                    GrowTree(node as UnionNode);
                    break;

                default:
                    MultiMarriage(parent, child, _genDepth);
                    break;
                }
            }

            _genDepth = _genDepth - 1;
        }