// // Silently collect data from the input sources. // internal void collectVolatileData_Silent() { try { // Choose input. IGH_Structure orig = new GH_Structure <IGH_Goo>(); if (this.Sources.Count > 0 && !isNullOrEmpty(this.Sources[0].VolatileData)) { orig = this.Sources[0].VolatileData; } else if (m_param.Sources.Count > 0 && !isNullOrEmpty(m_param.Sources[0].VolatileData)) { orig = m_param.Sources[0].VolatileData; } GH_Structure <IGH_Goo> TempCopy = DuplicateStructure(orig); localCopy = TempCopy.Duplicate(); int minh = PathIndex(history, "min"); int maxnew = PathIndex(TempCopy, "max"); history = shiftPaths(history, Math.Max(0, maxnew - minh + 1), true); TempCopy.MergeStructure(history); history = TempCopy; this.m_data = localCopy.Duplicate(); } catch (Exception e) { m_owner.attr.Panel.Message("err", m_owner.NickName, "Error while collecting data: " + e.Message); } }
protected override void SolveInstance(IGH_DataAccess access) { // Maybe Data input could be optional...? // Don't exit if no data, we want to check against the empty structure access.GetDataTree(0, out GH_Structure <IGH_Goo> datum); bool isRecording = true; access.GetData(1, ref isRecording); bool shouldReset = false; access.GetData(2, ref shouldReset); int lim = 0; access.GetData(3, ref lim); dataLimit = lim; if (shouldReset) { data = new List <GH_Structure <IGH_Goo> >(); justReset = true; return; } // If turning off reset, do not record right away (like the vanilla component), // but wait for a new data tick. else if (justReset) { justReset = false; return; } if (isRecording) { if (!recordToggle) { // If just turned on recording, don't record this datum (like original component). recordToggle = true; } else { // Add a deep clone to avoid pointer problems. data.Add(new GH_Structure <IGH_Goo>(datum, false)); } } else { recordToggle = false; } if (dataLimit != 0) { while (data.Count > dataLimit) { data.RemoveAt(0); } } // This is not very optimal, but oh well, at least its O(n)...? var merge = new GH_Structure <IGH_Goo>(); foreach (var tree in data) { merge.MergeStructure(tree); } access.SetDataTree(0, merge); }