static public CylGridData ColorCodeData(Barrel barrel, DataOutputOptions options, CylGridData correctedRingList, COLORCODE colorOption) { try { var resultGrid = new CylGridData(); foreach (var cylstrip in correctedRingList) { var resultStrip = new CylData(correctedRingList[0].FileName); foreach (PointCyl pt in cylstrip) { var c = System.Drawing.Color.LightGray; switch (colorOption) { case COLORCODE.GREEN_RED: c = MapGreenRedColor(barrel, pt); break; case COLORCODE.RAINBOW: c = MapRainbowColor(barrel, pt); break; } pt.Col = c; resultStrip.Add(new PointCyl(pt.R, pt.ThetaRad, pt.Z, c, pt.ID)); } resultGrid.Add(resultStrip); } return(resultGrid); } catch (Exception) { Debug.WriteLine(" exception in colorCodeData"); throw; } }
public void CylG_boundingbox() { var cgd = new CylGridData(); var cd = new CylData(); cd.Add(new GeometryLib.PointCyl(1, 0, 0)); cd.Add(new GeometryLib.PointCyl(1, Math.PI, 1)); cd.Add(new GeometryLib.PointCyl(1, Math.PI / 2, 1)); cd.Add(new GeometryLib.PointCyl(1, 3 * Math.PI / 2, 1)); cgd.Add(cd); var cd2 = new CylData(); cd2.Add(new GeometryLib.PointCyl(2, 0, 0)); cd2.Add(new GeometryLib.PointCyl(2, Math.PI, 1)); cd2.Add(new GeometryLib.PointCyl(2, Math.PI / 2, 1)); cd2.Add(new GeometryLib.PointCyl(2, 3 * Math.PI / 2, 1)); cgd.Add(cd2); var bb = cgd.BoundingBox(); Assert.AreEqual(2.0, bb.Max.X); Assert.AreEqual(-2.0, bb.Min.X); Assert.AreEqual(2.0, bb.Max.Y); Assert.AreEqual(-2.0, bb.Min.Y); Assert.AreEqual(0, bb.Min.Z); Assert.AreEqual(1.0, bb.Max.Z); }
/// <summary> /// build stl files from ring data /// </summary> /// <param name="correctedRingList"></param> /// <param name="flatFileName"></param> /// <param name="rolledFileName"></param> static void SaveRolledSTLFile(Barrel barrel, DataOutputOptions options, CylGridData correctedRingList, double unrollRadius, string fileName, IProgress <int> progress) { try { var v3rolledPtList = correctedRingList.AsCartGridData(); var _flatStlFile = new StlFile(); var trimesh = new TriMesh(); trimesh.BuildFromGrid(v3rolledPtList); StlFile.SaveBinary(trimesh, fileName); } catch (Exception) { throw; } }
static void SaveFlatPlyFile(Barrel barrel, DataOutputOptions options, CylGridData correctedRingList, double unrollRadius, string fileName, IProgress <int> progress) { try { var outputFilename = BuildFileName(fileName, "_flat", ".ply"); var colorCodedData = DataColorCode.ColorCodeData(barrel, options, correctedRingList, options.SurfaceColorCode); var v3FlatStripList = DataUtil.UnrollCylinder(colorCodedData, options.SurfaceFileScaleFactor, unrollRadius); SavePly(v3FlatStripList, outputFilename, progress); } catch (Exception) { throw; } }
/// <summary> /// separate point list into rings from spiral /// </summary> /// <returns></returns> static CylGridData BuildRingList(MultiRingScript script, double[] rawInputData) { try { int revCount = 0; int i = 0; double thetaStart = GeomUtilities.ToRadians(script.StartLocation.Adeg); double thetaEnd = Math.Abs(thetaStart + (Math.Sign(script.AngleIncrement) * Math.PI * 2.0)); var pointList = new CylData(script.InputDataFileName); var uncorrectedGridData = new CylGridData(); double z = script.StartLocation.X;; int ringStartIndex = 0; int ringEndIndex = ringStartIndex + script.PointsPerRevolution; int nextRingStartIndex = ringEndIndex + script.PointsToSkip; while (i < rawInputData.Length) { var p = GetRadiusPoint(i, rawInputData[i], z, script); i++; if (i >= ringStartIndex && i < ringEndIndex) { pointList.Add(p); } if (i == ringEndIndex) { revCount++; uncorrectedGridData.Add(pointList); } if (i == nextRingStartIndex) { z += script.RingSpacing; pointList = new CylData(script.InputDataFileName); ringStartIndex = nextRingStartIndex; ringEndIndex = ringStartIndex + script.PointsPerRevolution; nextRingStartIndex = ringEndIndex + script.PointsToSkip; } } return(uncorrectedGridData); } catch (Exception) { throw; } }
static void SaveRolledPlyFile(Barrel barrel, DataOutputOptions options, CylGridData correctedRingList, string fileName, IProgress <int> progress) { try { var outputFilename = BuildFileName(fileName, "_rolled", ".ply"); var colorCodedData = DataColorCode.ColorCodeData(barrel, options, correctedRingList, options.SurfaceColorCode); var v3StripList = colorCodedData.AsCartGridData(); SavePly(v3StripList, outputFilename, progress); } catch (Exception) { throw; } }
static public void SavePlyFile(Barrel barrel, DataOutputOptions options, CylGridData correctedRingList, double unrollRadius, string fileName, IProgress <int> progress) { try { if (options.SaveSurfaceFlat) { SaveFlatPlyFile(barrel, options, correctedRingList, unrollRadius, fileName, progress); } else { SaveRolledPlyFile(barrel, options, correctedRingList, fileName, progress); } } catch (Exception) { throw; } }
static void SaveFlatSTLFile(Barrel barrel, DataOutputOptions options, CylGridData correctedRingList, double unrollRadius, string fileName, IProgress <int> progress) { try { Debug.WriteLine("writing STL file " + fileName); var _flatStlFile = new StlFile(); var v3flatptList = DataUtil.UnrollCylinder(correctedRingList, options.SurfaceFileScaleFactor, unrollRadius); var trimesh = new TriMesh(); trimesh.BuildFromGrid(v3flatptList); StlFile.SaveBinary(trimesh, fileName); } catch (Exception) { throw; } }
/// <summary> /// separate point list into rings from spiral /// </summary> /// <returns></returns> static CylGridData BuildGridList(SpiralInspScript script, double[] rawInputData) { try { int pointCountPerRev = 0; int revCount = 0; int i = 0; double thetaStart = GeomUtilities.ToRadians(script.StartLocation.Adeg); double thetaEnd = Math.Abs(thetaStart + (Math.Sign(script.AngleIncrement) * Math.PI * 2.0)); var pointList = new CylData(script.InputDataFileName); var uncorrectedGridData = new CylGridData(); double zStart = script.StartLocation.X; double z = zStart; while (i < rawInputData.Length) { var p = GetRadiusPoint(i, rawInputData[i], z, script); var thA = Math.Abs(p.ThetaRad); i++; if (thA >= thetaStart && thA < thetaEnd) { pointList.Add(p); pointCountPerRev++; } if (thA >= thetaEnd) { revCount++; z += script.PitchInch; pointCountPerRev = 0; uncorrectedGridData.Add(pointList); pointList = new CylData(script.InputDataFileName); thetaStart = thetaEnd; thetaEnd = Math.Abs(thetaStart + (Math.Sign(script.AngleIncrement) * Math.PI * 2.0)); } } return(uncorrectedGridData); } catch (Exception) { throw; } }
static public void SaveSurfaceGridasDXF(CylGridData grid, string fileName, IProgress <int> progress) { try { var outputFilename = BuildFileName(fileName, "", ".dxf"); List <GeometryLib.DwgEntity> entityList = new List <GeometryLib.DwgEntity>(); List <string> DwgConverterLibList = new List <string>(); foreach (CylData strip in grid) { for (int i = 0; i < strip.Count - 1; i++) { entityList.Add(new DXFLine(strip[i], strip[i + 1])); } } DxfFileBuilder.Save(entityList, outputFilename, progress); } catch (Exception) { throw; } }
public void CylGD_countOK() { var cgd = new CylGridData(); var cd = new CylData(); cd.Add(new GeometryLib.PointCyl(1, 0, 0)); cd.Add(new GeometryLib.PointCyl(1, Math.PI, 1)); cd.Add(new GeometryLib.PointCyl(1, Math.PI / 2, 1)); cd.Add(new GeometryLib.PointCyl(1, 3 * Math.PI / 2, 1)); cgd.Add(cd); var cd2 = new CylData(); cd2.Add(new GeometryLib.PointCyl(2, 0, 0)); cd2.Add(new GeometryLib.PointCyl(2, Math.PI, 1)); cd2.Add(new GeometryLib.PointCyl(2, Math.PI / 2, 1)); cd2.Add(new GeometryLib.PointCyl(2, 3 * Math.PI / 2, 1)); cgd.Add(cd2); Assert.AreEqual(2, cgd.Count); Assert.AreEqual(4, cgd[0].Count); Assert.AreEqual(4, cgd[0].Count); Assert.AreEqual(4, cgd[1].Count); }
/// <summary> /// output csv file from ring data /// </summary> /// <param name="correctedRingList"></param> /// <param name="csvFileName"></param> static public void SaveCSVFile(Barrel barrel, DataOutputOptions options, CylGridData correctedRingList, string fileName, IProgress <int> progress) { try { var headings = BuildFileHeader(fileName); var filePoints = new List <string>(); filePoints.AddRange(headings); filePoints.Add("ID,Theta(Radians),R(in),Z(in)"); foreach (var ring in correctedRingList) { foreach (var pt in ring) { string line = string.Concat(pt.ID.ToString() + "," + pt.ThetaRad.ToString(), ",", pt.R.ToString(), ",", pt.Z.ToString()); filePoints.Add(line); } } FileIOLib.FileIO.Save(filePoints, fileName); } catch (Exception) { throw; } }
public SpiralDataSet() { SpiralData = new CylGridData(); UncorrectedSpiralData = new CylGridData(); }
public SpiralDataSet(string filename) : base(filename) { SpiralData = new CylGridData(); UncorrectedSpiralData = new CylGridData(); }
public void CylGD_ctor() { var cd = new CylGridData(); Assert.IsNotNull(cd); }