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()}"); }
/// <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); } }
private static void RekursivesDispose(MusterNode node) { if (node is GeneratorNode) { ((GeneratorNode)node).Inst.Dispose(); } else if (node is FilterNode) { ((FilterNode)node).Inst.Dispose(); RekursivesDispose(((FilterNode)node).Quelle); } else if (node is MixerNode) { ((MixerNode)node).Inst.Dispose(); foreach (MusterNode m in ((MixerNode)node).Quelle) { RekursivesDispose(m); } } }
public MusterPipelineException(MusterNode mn, System.Exception inner) : base("Node : " + mn.ToString() + " - " + inner, inner) { this.Node = mn; }
public MusterPipeline(MusterNode root) { this.Root = root; }