예제 #1
0
        private async Task <RGBPixel[, ]> ExecuteIntAsync(MusterNode m, ulong frame)
        {
            GeneratorNode gn = m as GeneratorNode;

            if (gn != null)
            {
                var muster = await gn.Inst.GenPattern(frame);

                return(muster);
            }

            MixerNode mn = m as MixerNode;

            if (mn != null)
            {
                RGBPixel[][,] allesubquellen = await Task.WhenAll(mn.Quelle.Select(q => this.ExecuteIntAsync(q, frame)));

                RGBPixel[,] muster = await mn.Inst.Mix(allesubquellen, frame);

                return(muster);
            }

            FilterNode fn = m as FilterNode;

            if (fn != null)
            {
                RGBPixel[,] gefiltert = await this.ExecuteIntAsync(fn.Quelle, frame);

                RGBPixel[,] muster = await fn.Inst.Filter(gefiltert, frame);

                return(muster);
            }

            throw new NotImplementedException($"Unbekannter Knotentyp {m.GetType()}");
        }
예제 #2
0
        /// <summary>
        /// Aktivator. Einmal den Baum iterieren, um die
        /// Genrator, Mixer und Filter-Objekte zu instantiieren.
        /// </summary>
        private void Aktiviere(MusterNode node, MatrixParams mparams)
        {
            if (node is MixerNode)
            {
                MixerNode mnode = (MixerNode)node;
                // MixerNode evaluieren und somit erzeugen.
                try
                {
                    mnode.Inst.Initialize(mparams);
                }
                catch (System.Exception ex)
                {
                    throw new MusterPipelineException(mnode, ex);
                }
                foreach (var qnode in mnode.Quelle)
                {
                    // Rekursion
                    this.Aktiviere(qnode, mparams);
                }
            }

            if (node is GeneratorNode)
            {
                GeneratorNode gnode = (GeneratorNode)node;
                // Generatorinstanz erzeugen lassen.
                try
                {
                    gnode.Inst.Initialize(mparams);
                }
                catch (System.Exception ex)
                {
                    throw new MusterPipelineException(gnode, ex);
                }
            }

            if (node is FilterNode)
            {
                FilterNode fnode = (FilterNode)node;
                // Filterinstanz erzeugen durch Zugriff
                try
                {
                    fnode.Inst.Initialize(mparams);
                }
                catch (System.Exception ex)
                {
                    throw new MusterPipelineException(fnode, ex);
                }
                // Rekursion
                this.Aktiviere(fnode.Quelle, mparams);
            }
        }