Ejemplo n.º 1
0
        /// <summary>
        /// Gets the current derivation of the l-system
        /// </summary>
        /// <returns></returns>
        public LinkedList <LSystemNode <T> > GetCurrentDerivation()
        {
            var initialState = new LSystemState <T>(default(T));

            UpdateList(_currentDerivation.First, initialState);
            return(_currentDerivation);
        }
Ejemplo n.º 2
0
        private static void UpdateList(LinkedListNode <LSystemNode <T> > linkedListNode, LSystemState <T> state)
        {
            while (linkedListNode != null)
            {
                linkedListNode.Value.NodeModule?.ChangeState(state);

                if (linkedListNode.Value.NodeModule is ILSystemQueryableModule <T> )
                {
                    var queryModule = (ILSystemQueryableModule <T>)linkedListNode.Value.NodeModule;
                    queryModule.QueryState(state);
                }

                if (linkedListNode.Value.SupportingBranch != null)
                {
                    var currentState = new LSystemState <T>(state.CurrentState);
                    UpdateList(linkedListNode.Value.SupportingBranch.First, currentState);
                }

                linkedListNode = linkedListNode.Next;
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Gets the current derivation of the l-system with a starting parameter
 /// </summary>
 /// <param name="initialState"></param>
 /// <returns></returns>
 public LinkedList <LSystemNode <T> > GetCurrentDerivation(LSystemState <T> initialState)
 {
     UpdateList(_currentDerivation.First, initialState);
     return(_currentDerivation);
 }