private Ray FindVCollision(Ray ray, out VSegment segment) { segment = null; if (ray.mx < 0) { for (int w = (int)Math.Ceiling(ray.x - 1); w >= 0; --w) { var nextRay = ray.MoveInX(w - ray.x); if (!LessOrEqual(0.0, nextRay.d)) { return(null); } foreach (var candidate in SegmentsFacingRight[w]) { if (LessOrEqual(candidate.top, nextRay.y) && LessOrEqual(nextRay.y, candidate.bottom)) { segment = candidate; return(nextRay); } } } } else if (ray.mx > 0) { for (int w = (int)(ray.x + 1); w < Width - 1; ++w) { var nextRay = ray.MoveInX(w - ray.x); if (!LessOrEqual(0.0, nextRay.d)) { return(null); } foreach (var candidate in SegmentsFacingLeft[w]) { if (LessOrEqual(candidate.top, nextRay.y) && LessOrEqual(nextRay.y, candidate.bottom)) { segment = candidate; return(nextRay); } } } } return(null); }
private static void FillSegments(TCR.Models.TCRContext context, string[] fields, Receptor receptor) { string[] alleles = fields[4].Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries); foreach (string allele in alleles) { VSegment segment = context.VSegments.First(s => s.Alleles == allele); receptor.VSegments.Add(segment); } alleles = fields[6].Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries); foreach (string allele in alleles) { DSegment segment = context.DSegments.First(s => s.Alleles == allele); receptor.DSegments.Add(segment); } alleles = fields[5].Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries); foreach (string allele in alleles) { JSegment segment = context.JSegments.First(s => s.Alleles == allele); receptor.JSegments.Add(segment); } }