static PointCyl GetRadiusPoint(int i, double rRaw, double zLocation, CylInspScript script) { var z = zLocation; var theta = i * script.AngleIncrement + GeomUtilities.ToRadians(script.StartLocation.Adeg); double r = script.ProbeSetup[0].DirectionSign * rRaw + script.CalDataSet.ProbeSpacingInch / 2.0; var pt = new PointCyl(r, theta, z, i); return(pt); }
/// <summary> /// build ring data from raw data and auto find lands /// </summary> /// <param name="script"></param> /// <param name="rawInputData"></param> static InspDataSet BuildRingFromRadialData(CylInspScript script, double[] rawInputData, int grooveCount) { try { var dataSet = new RingDataSet(script.InputDataFileName); dataSet.UncorrectedCylData = GetUncorrectedData(script, rawInputData); dataSet.RawLandPoints = GetLandPoints(dataSet.UncorrectedCylData, script.PointsPerRevolution, grooveCount); dataSet.CylData = CorrectRing(dataSet.UncorrectedCylData, dataSet.RawLandPoints, script.ProbeSetup.Direction, script.CalDataSet.ProbeSpacingInch / 2.0); dataSet.CorrectedLandPoints = GetLandPoints(dataSet.CylData, script.PointsPerRevolution, grooveCount); return(dataSet); } catch (Exception) { throw; } }
//static CylData GetUncorrectedData(CylInspScript script,double zLocation, double[] data) //{ // try // { // var points = new CylData(script.InputDataFileName); // int pointCt = 0; // if (script.ScanFormat == ScanFormat.RING) // { // pointCt = Math.Min(script.PointsPerRevolution, data.Length); // } // else // { // pointCt = data.Length; // } // double minR = double.MaxValue; // for (int i = 0; i < pointCt; i++) // { // if (data[i] < minR) // { // minR = data[i]; // } // var pt = GetPoint(i, data[i], zLocation, script); // points.Add(pt); // } // points.MinRadius = script.ProbeSetup[0].DirectionSign * minR + script.CalDataSet.ProbeSpacingInch / 2.0; // return points; // } // catch (Exception) // { // throw; // } //} static CylData GetUncorrectedData(CylInspScript script, double[] data) { try { var points = new CylData(script.InputDataFileName); int pointCt = 0; if (script.ScanFormat == ScanFormat.RING) { pointCt = Math.Min(script.PointsPerRevolution, data.Length); } else { pointCt = data.Length; } double minR = double.MaxValue; for (int i = 0; i < pointCt; i++) { if (data[i] < minR) { minR = data[i]; } var pt = GetRadiusPoint(i, data[i], script.StartLocation.X, script); points.Add(pt); } points.MinRadius = script.ProbeSetup[0].DirectionSign * minR + script.CalDataSet.ProbeSpacingInch / 2.0; return(points); } catch (Exception) { throw; } }
static SpiralDataSet BuildSpiralFromRadialData(IProgress <int> progress, CylInspScript script, double[] rawInputData, int grooveCount) { try { var dataSet = new SpiralDataSet(script.InputDataFileName); if (script is SpiralInspScript spiratlScript) { dataSet.UncorrectedSpiralData = BuildGridList(spiratlScript, rawInputData); } if (script is MultiRingScript multiRingScript) { dataSet.UncorrectedSpiralData = BuildRingList(multiRingScript, rawInputData); } int totalrings = dataSet.UncorrectedSpiralData.Count; //find all land points int i = 1; foreach (var row in dataSet.UncorrectedSpiralData) { var landPointArr = GetLandPoints(row, script.PointsPerRevolution, grooveCount); //find polynomial fit for lands and correct for eccentricity var correctedRing = CorrectRing(row, landPointArr, script.ProbeSetup.Direction, script.CalDataSet.ProbeSpacingInch / 2.0); dataSet.SpiralData.Add(correctedRing); int p = (int)(100 * i / totalrings); progress.Report(p); i++; } return(dataSet); } catch (Exception) { throw; } }
/// <summary> /// build ring data from raw and auto find lands /// </summary> /// <param name="ct"></param> /// <param name="progress"></param> /// <param name="script"></param> /// <param name="rawDataSet"></param> /// <param name="options"></param> static public InspDataSet BuildDataAsync(CancellationToken ct, IProgress <int> progress, CylInspScript script, double[] rawDataSet, int grooveCount) { try { if (script is SpiralInspScript spiralScript) { return(BuildSpiralFromRadialData(progress, spiralScript, rawDataSet, grooveCount)); } else if (script is MultiRingScript multiringScript) { return(BuildSpiralFromRadialData(progress, multiringScript, rawDataSet, grooveCount)); } else { return(BuildRingFromRadialData(script, rawDataSet, grooveCount)); } } catch (Exception) { throw; } }