Пример #1
0
        private IEnumerable <InteractiveLayeredQuiverGeneratorOutput> DoWork(
            InteractiveLayeredQuiverGenerator interactiveQuiverGenerator,
            CompositionParameters nextCompositionParameters,
            ICompositionGenerator compositionGenerator)
        {
            if (nextCompositionParameters is null)
            {
                yield return(interactiveQuiverGenerator.EndGeneration());

                yield break;
            }

            foreach (var composition in compositionGenerator.GenerateCompositions(nextCompositionParameters))
            {
                if (!interactiveQuiverGenerator.TrySupplyComposition(composition, out nextCompositionParameters))
                {
                    continue;
                }

                foreach (var output in DoWork(interactiveQuiverGenerator, nextCompositionParameters, compositionGenerator))
                {
                    yield return(output);
                }

                interactiveQuiverGenerator.UnsupplyLastComposition();
            }
        }
Пример #2
0
        public void EndGeneration_ThrowsInvalidOperationException_IfGenerationIsNotCompleted()
        {
            var layerType = CreateLayerType(5, 5, 10);

            generator.StartGeneration(layerType);

            Assert.That(() => generator.EndGeneration(), Throws.InstanceOf <InvalidOperationException>());

            generator = CreateGenerator();
            layerType = CreateLayerType(5, 5, 10);
            generator.StartGeneration(layerType);
            generator.SupplyComposition(CreateComposition(2, 2, 2, 2, 2));

            Assert.That(() => generator.EndGeneration(), Throws.InstanceOf <InvalidOperationException>());
        }
Пример #3
0
        /// <summary>
        /// Generates all layered quivers of the specified layer type using the specified composition
        /// generator.
        /// </summary>
        /// <param name="layerType">The layer type of the layered quivers to generate.</param>
        /// <param name="firstVertex">The first vertex of the quivers to generate.</param>
        /// <param name="compositionGenerator">The composition generator whose compositions to use.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"><paramref name="layerType"/> is
        /// <see langword="null"/>, or <paramref name="compositionGenerator"/> is
        /// <see langword="null"/>.</exception>
        public IEnumerable <InteractiveLayeredQuiverGeneratorOutput> GenerateForFixedLayerType(
            LayerType layerType,
            ICompositionGenerator compositionGenerator)
        {
            if (layerType is null)
            {
                throw new ArgumentNullException(nameof(layerType));
            }
            if (compositionGenerator is null)
            {
                throw new ArgumentNullException(nameof(compositionGenerator));
            }

            var interactiveGenerator      = new InteractiveLayeredQuiverGenerator();
            var nextCompositionParameters = interactiveGenerator.StartGeneration(layerType, firstVertex);

            return(DoWork(interactiveGenerator, nextCompositionParameters, compositionGenerator));
        }
Пример #4
0
        public IEnumerable <InteractiveLayeredQuiverGeneratorOutput> GenerateFromBaseForFixedLayerType(
            QuiverInPlane <int> quiverInPlane,
            Potential <int> potential,
            IEnumerable <int> boundaryLayer,
            LayerType layerType,
            ICompositionGenerator compositionGenerator,
            int nextVertex)
        {
            if (quiverInPlane is null)
            {
                throw new ArgumentNullException(nameof(quiverInPlane));
            }
            if (potential is null)
            {
                throw new ArgumentNullException(nameof(potential));
            }
            if (boundaryLayer is null)
            {
                throw new ArgumentNullException(nameof(boundaryLayer));
            }
            if (layerType is null)
            {
                throw new ArgumentNullException(nameof(layerType));
            }
            if (compositionGenerator is null)
            {
                throw new ArgumentNullException(nameof(compositionGenerator));
            }

            var interactiveGenerator = new InteractiveLayeredQuiverGenerator();

            if (!interactiveGenerator.TryStartGenerationFromBase(quiverInPlane, potential, boundaryLayer, layerType, nextVertex, out var nextCompositionParameters))
            {
                return(new InteractiveLayeredQuiverGeneratorOutput[0]);
            }

            return(DoWork(interactiveGenerator, nextCompositionParameters, compositionGenerator));
        }
Пример #5
0
 public void SetUp()
 {
     generator = CreateGenerator();
 }