public void CreateIteration(MeshFace startingFace)
    {
        Iterations.Clear();
        CopyLayerManager.GotoNextLayer();
        var iterator = new MeshIteration();

        iterator.Create(startingFace);
        Iterations.Add(iterator);
        AddIteration(iterator);
    }
    IEnumerator WaitForLastIteration(MeshIteration iteration)
    {
        var time = Time.realtimeSinceStartup + (meshContainer.IterationSpeed + meshContainer.IterationTime) * 2;

        while (iteration.InProgress || Time.realtimeSinceStartup > time)
        {
            yield return(null);
        }
        InProgress = false;
        CleanUp();
    }
    void AddIteration(MeshIteration previous)
    {
        CopyLayerManager.GotoNextLayer();
        var iterator = new MeshIteration();

        if (iterator.CreateFromIteration(previous))
        {
            Iterations.Add(iterator);
            AddIteration(iterator);
        }
    }
    public bool CreateFromIteration(MeshIteration iteration)
    {
        index = iteration.index + 1;
        foreach (var iterElement in iteration.IterationElements)
        {
            foreach (var neighbour in iterElement.element.Neighbours)
            {
                if (neighbour.IteratorIndex != -1)
                {
                    continue;
                }
                // Add Option to limit number of neighbours allowed to be added.
                IterationElements.Add(new FaceIterationElement(neighbour, iterElement, index));

                //var longEdge = neighbour.GetLongEdgeNeighbour();
                //if (longEdge.IteratorIndex != -1) continue;
                //IterationElements.Add(new FaceIterationElement(longEdge, iterElement, index));
            }
        }
        return(IterationElements.Count > 0);
    }