public override void SolveInstance(ImpalaAccess DA) { int[] branches = { 1, 2, 3, 4, 5 }; var paths = branches.Select(b => new GH_Path(b - 1)).ToArray(); var result = new ImpalaStructure <GH_Integer>(5, branches, paths); DA.SetDataTree(0, result); }
public override void ComputeData() { if (Locked) { Phase = GH_SolutionPhase.Computed; Params.DoEach(p => p.Phase = GH_SolutionPhase.Computed); return; } switch (Phase) { case GH_SolutionPhase.Blank: case GH_SolutionPhase.Computed: case GH_SolutionPhase.Failed: return; case GH_SolutionPhase.Collecting: base.AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Recursive Data Stream!"); return; } // This gives the standard before/after control. // We can look into NOT doing this, actually. Phase = GH_SolutionPhase.Computing; var timer = new Stopwatch(); timer.Start(); Params.Output.DoEach(p => p.Phase = GH_SolutionPhase.Computed); // Do before. if (!TryWith(BeforeSolveInstance, "Before Solution Exception")) { goto done; } // Check that everything has its shit together. var hasData = Params.All(p => p.Optional || !p.VolatileData.IsEmpty); if (!hasData) // Didn't find anything. So, done { Phase = GH_SolutionPhase.Computed; TryWith(AfterSolveInstance, "After Solution Exception"); goto done; } // Do the actual solve instance. var it = new ImpalaAccess(this); try { SolveInstance(it); Phase = GH_SolutionPhase.Computed; } catch (Exception ex) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Solution Exception: " + ex.Message); goto done; } _bbox = BoundingBox.Empty; if (Phase == GH_SolutionPhase.Computed) { Params.DoEach(p => (p as IGH_ParamWithPostProcess)?.PostProcessData()); } TryWith(AfterSolveInstance, "After Solution Exception"); // Quick exit, whenever it is that we get here. done: timer.Stop(); _time = timer.Elapsed; }
// User this instead! public abstract void SolveInstance(ImpalaAccess DA);