/// <summary> /// Extracts a track map from the data. /// </summary> /// <param name="data">the input data; can be an array of microtracks, a linked zone or a TotalScan volume.</param> /// <param name="side">the side to be used.</param> /// <param name="r">the rectangle that sets the bounds for the track map to be extracted.</param> /// <param name="flt">the track filter; leave <c>null</c> to skip filtering.</param> /// <param name="useoriginal">if <c>true</c>, the original (anti-transformed) tracks are used; ignored if the input data is other than a TotalScan volume.</param> /// <returns>the subset of tracks to be used for mapping.</returns> public static SySal.Tracking.MIPEmulsionTrackInfo[] ExtractMap(object data, MapSide side, SySal.BasicTypes.Rectangle r, dMapFilter flt, bool useoriginal) { if (data is SySal.Scanning.Plate.LinkedZone) { return(lzExtractMap((SySal.Scanning.Plate.LinkedZone)data, side, r, flt)); } else if (data is SySal.TotalScan.Layer) { int s = ((SySal.TotalScan.Layer)data).Side; if (s != (int)side) { throw new Exception("Expected side = " + side + " but found " + s + "."); } return(layExtractMap((SySal.TotalScan.Layer)data, r, flt, useoriginal)); } else if (data is SySal.Tracking.MIPEmulsionTrackInfo[]) { return(tkExtractMap((SySal.Tracking.MIPEmulsionTrackInfo[])data, r, flt)); } throw new Exception("Map extraction from type " + data.GetType() + " is not supported."); }
static SySal.Tracking.MIPEmulsionTrackInfo[] tkExtractMap(SySal.Tracking.MIPEmulsionTrackInfo[] tks, dMapFilter flt) { System.Collections.ArrayList ar = new System.Collections.ArrayList(); foreach (SySal.Tracking.MIPEmulsionTrackInfo info in tks) { if (flt == null || flt(info)) { ar.Add(info); } } return((SySal.Tracking.MIPEmulsionTrackInfo[])ar.ToArray(typeof(SySal.Tracking.MIPEmulsionTrackInfo))); }
static SySal.Tracking.MIPEmulsionTrackInfo[] tkExtractMap(SySal.Tracking.MIPEmulsionTrackInfo[] tks, SySal.BasicTypes.Rectangle r, dMapFilter flt) { System.Collections.ArrayList ar = new System.Collections.ArrayList(); foreach (SySal.Tracking.MIPEmulsionTrackInfo info in tks) { if (info.Intercept.X < r.MinX || info.Intercept.X > r.MaxX || info.Intercept.Y < r.MinY || info.Intercept.Y > r.MaxY) { continue; } if (flt == null || flt(info)) { ar.Add(info); } } return((SySal.Tracking.MIPEmulsionTrackInfo[])ar.ToArray(typeof(SySal.Tracking.MIPEmulsionTrackInfo))); }
static SySal.Tracking.MIPEmulsionTrackInfo[] layExtractMap(SySal.TotalScan.Layer lay, SySal.BasicTypes.Rectangle r, dMapFilter flt, bool useoriginal) { System.Collections.ArrayList ar = new System.Collections.ArrayList(); int n = lay.Length; int i; for (i = 0; i < n; i++) { SySal.Tracking.MIPEmulsionTrackInfo info = useoriginal ? lay[i].OriginalInfo : lay[i].Info; if (info.Intercept.X < r.MinX || info.Intercept.X > r.MaxX || info.Intercept.Y < r.MinY || info.Intercept.Y > r.MaxY) { continue; } if (flt == null || flt(lay[i])) { ar.Add(info); } } return((SySal.Tracking.MIPEmulsionTrackInfo[])ar.ToArray(typeof(SySal.Tracking.MIPEmulsionTrackInfo))); }
static SySal.Tracking.MIPEmulsionTrackInfo[] layExtractMap(SySal.TotalScan.Layer lay, dMapFilter flt, bool useoriginal) { System.Collections.ArrayList ar = new System.Collections.ArrayList(); int n = lay.Length; int i; for (i = 0; i < n; i++) { SySal.Tracking.MIPEmulsionTrackInfo info = useoriginal ? lay[i].OriginalInfo : lay[i].Info; if (flt == null || flt(lay[i])) { ar.Add(info); } } return((SySal.Tracking.MIPEmulsionTrackInfo[])ar.ToArray(typeof(SySal.Tracking.MIPEmulsionTrackInfo))); }
static SySal.Tracking.MIPEmulsionTrackInfo[] lzExtractMap(SySal.Scanning.Plate.LinkedZone lz, MapSide side, SySal.BasicTypes.Rectangle r, dMapFilter flt) { System.Collections.ArrayList ar = new System.Collections.ArrayList(); int n; switch (side) { case MapSide.Base: n = lz.Length; break; case MapSide.Top: n = lz.Top.Length; break; case MapSide.Bottom: n = lz.Bottom.Length; break; default: throw new Exception("Internal inconsistency: side = " + side + " is not supported."); } int i; for (i = 0; i < n; i++) { SySal.Tracking.MIPEmulsionTrackInfo info; switch (side) { case MapSide.Base: info = lz[i].Info; break; case MapSide.Top: info = lz.Top[i].Info; break; case MapSide.Bottom: info = lz.Bottom[i].Info; break; default: throw new Exception("Internal inconsistency: side = " + side + " is not supported."); } if (info.Intercept.X < r.MinX || info.Intercept.X > r.MaxX || info.Intercept.Y < r.MinY || info.Intercept.Y > r.MaxY) { continue; } if (flt == null || flt(info)) { ar.Add(info); } } return((SySal.Tracking.MIPEmulsionTrackInfo[])ar.ToArray(typeof(SySal.Tracking.MIPEmulsionTrackInfo))); }