/// <summary> /// parse string line from nc file into path LINE entity /// </summary> /// <param name="ncLine">line from NC file</param> /// <param name="blockT">Block type</param> /// <returns>LinePathEntity</returns> LinePathEntity parseLine(string ncLine, BlockType blockT) { LinePathEntity ent = new LinePathEntity(blockT); string[] splitLine = ncLine.Split(splitters, StringSplitOptions.None); foreach (string str in splitLine) { if (str.Contains(n)) { ent.PathNumber = parseInt(str, n); } if (str.Contains(x)) { ent.EndPoint.X = parseDouble(str, x); } if (str.Contains(y)) { ent.EndPoint.Y = parseDouble(str, y); } if (str.Contains(z)) { ent.EndPoint.Z = parseDouble(str, z); } if (str.Contains(a)) { ent.A = parseDouble(str, a); ent.Type = BlockType.FiveAxis; } if (str.Contains(b)) { ent.B = parseDouble(str, b); ent.Type = BlockType.FiveAxis; } if (str.Contains(c)) { ent.C = parseDouble(str, c); ent.Type = BlockType.FiveAxis; } if (str.Contains(f)) { ent.Feedrate = parseDouble(str, f); } } if (ent.Type == BlockType.FiveAxis) { DrawingIO.Vector3 pt = new DrawingIO.Vector3(0, 0, 1); DrawingIO.Vector3 origin = new DrawingIO.Vector3(0, 0, 0); pt.RotateXY(origin, ent.B); } else { ent.JetVector = DrawingIO.Vector3.ZAxis; } ent.Type = blockT; return(ent); }
public DrawingIO.Vector3 Normal(double xPosition, double yPosition) { int i = getXindex(xPosition); int j = getYindex(yPosition); double zx1 = getValue(i - 1, j); double zx2 = getValue(i + 1, j); double zy1 = getValue(i, j - 1); double zy2 = getValue(i, j + 1); var vx = new DrawingIO.Vector3(2 * meshSize, 0, zx2 - zx1); var vy = new DrawingIO.Vector3(0, 2 * meshSize, zy2 - zy1); return(vx.Cross(vy)); }
static void Main(string[] args) { double meshSize = .002; int index = 3; double jetD = .050; AbMachJet abmachJet = new AbMachJet(jetD, meshSize, index); Console.WriteLine(abmachJet.Diameter.ToString()); Console.WriteLine(abmachJet.JetMeshRadius.ToString()); Console.WriteLine(abmachJet.EquationIndex.ToString()); Console.ReadLine(); double[,] footprint = abmachJet.FootPrint(); List <string> file = new List <string>(); List <DrawingIO.DwgEntity> pointList = new List <DrawingIO.DwgEntity>(); DrawingIO.DXFFile dxffile = new DrawingIO.DXFFile(); for (int i = 0; i < footprint.GetLength(0); i++) { for (int j = 0; j < footprint.GetLength(1); j++) { double x = i * meshSize; double y = j * meshSize; double z = footprint[i, j]; string l = x + "," + y + "," + z; DrawingIO.Vector3 pt = new DrawingIO.Vector3(x, y, z); pointList.Add(pt); file.Add(l); Console.WriteLine(l); using (System.IO.StreamWriter sw = new System.IO.StreamWriter("jetfootprint.txt")) { foreach (string line in file) { sw.WriteLine(line); } } } } dxffile.Save(pointList, "jetfootprint.dxf"); Console.ReadLine(); }