Exemplo n.º 1
0
        private static uint AssignHandles(IDxfItemInternal item, uint nextHandle, uint ownerHandle, HashSet <IDxfItemInternal> visitedItems)
        {
            if (item == null || !visitedItems.Add(item))
            {
                return(nextHandle);
            }

            Debug.Assert(item.Handle == 0u);
            item.Handle = nextHandle++;
            if (item.OwnerHandle == 0u && ownerHandle != 0u)
            {
                item.OwnerHandle = ownerHandle;
            }

            foreach (var child in item.GetPointers().Where(c => c.Item != null))
            {
                var childItem    = (IDxfItemInternal)child.Item;
                var parentHandle = GetParentHandle(item, childItem);
                nextHandle            = AssignHandles(childItem, nextHandle, parentHandle, visitedItems);
                child.Handle          = childItem.Handle;
                childItem.OwnerHandle = parentHandle;
            }

            return(nextHandle);
        }
Exemplo n.º 2
0
        private static void BindPointers(IDxfItemInternal item, Dictionary <uint, IDxfItemInternal> handleMap, HashSet <IDxfItemInternal> visitedItems, HashSet <IDxfItemInternal> visitedChildren)
        {
            if (visitedItems.Add(item))
            {
                // set initial owners
                SetChildOwners(item, visitedChildren);

                // set explicit owners
                foreach (var child in item.GetPointers())
                {
                    if (handleMap.ContainsKey(child.Handle))
                    {
                        child.Item = handleMap[child.Handle];
                        BindPointers((IDxfItemInternal)child.Item, handleMap, visitedItems, visitedChildren);
                        SetOwner((IDxfItemInternal)child.Item, item, isWriting: false);
                    }
                }
            }
        }