private static Item3D[] DrawBrainIOLinks3D(Viewport3D viewport, Tuple<int, int>[] links, Item3D[] items1, Item3D[] items2, Color defaultColor, bool isRainbow) { const double THICKNESS = .025; if (!isRainbow) { var lines = links.Select(o => Tuple.Create(items1[o.Item1].Position.Value, items2[o.Item2].Position.Value)); return new[] { new Item3D(AddLines(viewport, lines, defaultColor, THICKNESS)), }; } List<Item3D> retVal = new List<Item3D>(); foreach (var byItem1 in links.ToLookup(o => o.Item1)) { //Color color = UtilityWPF.GetRandomColor(150, 220); Color color = new ColorHSV(StaticRandom.NextDouble(360), 60, 100).ToRGB(); var lines = byItem1.Select(o => Tuple.Create(items1[byItem1.Key].Position.Value, items2[o.Item2].Position.Value)); retVal.Add(new Item3D(AddLines(viewport, lines, color, THICKNESS))); } return retVal.ToArray(); }
private static void SaveImages(string parentFolder, string childFolder, int width, int height, Tuple<string, double[]>[] images, bool isColor) { if (images == null || images.Length == 0) { return; } foreach (var set in images.ToLookup(o => o.Item1)) { SaveImages(parentFolder, childFolder, width, height, set.Select(o => o.Item2).ToArray(), isColor, set.Key); } }
/// <summary> /// This adds 2s to 1s one at a time (specified by distances2to1_AddOrder) /// </summary> private static Tuple<int, int>[] AddLinks(LinkItem[] items1, LinkItem[] items2, DistributeDistances distances, IEnumerable<int> distances2to1_AddOrder, Tuple<int, int>[] initial = null) { // Store the inital link burdens BrainBurden[] links = Enumerable.Range(0, items1.Length). Select(o => new BrainBurden(o, items1, items2)). ToArray(); if (initial != null) { #region Store initial foreach (var set in initial.ToLookup(o => o.Item1)) { foreach (int item2Index in set.Select(o => o.Item2)) { links[set.Key].AddIOLink(item2Index); } } #endregion } foreach (var distanceIO in distances2to1_AddOrder.Select(o => distances.Distances2to1[o])) { int ioIndex = distanceIO.Index2; int closestBrainIndex = distanceIO.DistancesTo1[0].Item1; AddIOLink(links, ioIndex, items2[ioIndex].Size, closestBrainIndex, distances.ResistancesItem1[closestBrainIndex]); } // Build the return List<Tuple<int, int>> retVal = new List<Tuple<int, int>>(); foreach (BrainBurden burden in links) { retVal.AddRange(burden.IOLinks.Select(o => Tuple.Create(burden.Index, o))); } return retVal.ToArray(); }