private PathEntity5Axis parseFiveAxis(BlockType type, string[] paramArr) { LinePathEntity entity = new LinePathEntity(type); entity.Type = type; entity.Position.X = double.Parse(paramArr[0]); entity.Position.Y = double.Parse(paramArr[1]); entity.Position.Z = double.Parse(paramArr[2]); double xTop = double.Parse(paramArr[3]); double yTop = double.Parse(paramArr[4]); double zTop = double.Parse(paramArr[5]); entity.Feedrate.Value = getPositiveF(double.Parse(paramArr[6])); if (entity.Feedrate.Value == -2) { entity.Type = BlockType.Rapid; entity.RapidMove = true; } else { entity.RapidMove = false; } entity.SurfNormal = new GeometryLib.Vector3(double.Parse(paramArr[9]), double.Parse(paramArr[10]), double.Parse(paramArr[11])); entity.JetVector = new GeometryLib.Vector3(xTop - entity.Position.X, yTop - entity.Position.Y, zTop - entity.Position.Z); entity.ControlFlag = (CtrlFlag)(int.Parse(paramArr[8])); entity.JetOn = getJetOn(entity.Feedrate.Value, toolpath.NomFeedrate); entity.Position.Bdeg = GeometryLib.GeomUtilities.ToDegs(Math.Acos(entity.JetVector.Z / entity.JetVector.Length)); entity.Position.Cdeg = GeometryLib.GeomUtilities.ToDegs(Math.Atan2(entity.JetVector.Y, entity.JetVector.X)); return(entity); }
/// <summary> /// parse a linear move from NCI file /// </summary> /// <param name="type"></param> /// <param name="ParamArr"></param> /// <returns></returns> private PathEntity5Axis parseLine(BlockType type, string[] ParamArr) { LinePathEntity entity = new LinePathEntity(type); entity.Type = type; entity.Ccomp = (CComp)(int.Parse(ParamArr[0])); entity.Position.X = double.Parse(ParamArr[1]); entity.Position.Y = double.Parse(ParamArr[2]); entity.Position.Z = double.Parse(ParamArr[3]); double xTop = double.Parse(ParamArr[1]); double yTop = double.Parse(ParamArr[2]); double zTop = double.Parse(ParamArr[3]); entity.Feedrate.Value = getPositiveF(double.Parse(ParamArr[4])); if (entity.Feedrate.Value == -2) { entity.Type = BlockType.Rapid; entity.RapidMove = true; } else { entity.RapidMove = false; } entity.SurfNormal = new GeometryLib.Vector3(0, 0, 1); entity.JetVector = new GeometryLib.Vector3(xTop - entity.Position.X, yTop - entity.Position.Y, zTop - entity.Position.Z); entity.ControlFlag = (CtrlFlag)(int.Parse(ParamArr[5])); entity.JetOn = getJetOn(entity.Feedrate.Value, toolpath.NomFeedrate); entity.InputString = "X" + entity.Position.X.ToString() + "Y" + entity.Position.Y.ToString() + "Z" + entity.Position.Z.ToString() + "F" + entity.Feedrate.Value.ToString(); return(entity); }
/// <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); }
/// <summary> /// parse 5 axis move from NCI file /// </summary> /// <param name="type"></param> /// <param name="paramArr"></param> /// <returns></returns> private PathEntity fiveAxisMove(BlockType type, string[] paramArr) { LinePathEntity entity = new LinePathEntity(type); entity.EndPoint.X = double.Parse(paramArr[0]); entity.EndPoint.Y = double.Parse(paramArr[1]); entity.EndPoint.Z = double.Parse(paramArr[2]); entity.JetTopPoint.X = double.Parse(paramArr[3]); entity.JetTopPoint.Y = double.Parse(paramArr[4]); entity.JetTopPoint.Z = double.Parse(paramArr[5]); entity.Feedrate = positiveF(double.Parse(paramArr[6])); entity.SurfNormal = new DrawingIO.Vector3(double.Parse(paramArr[9]), double.Parse(paramArr[10]), double.Parse(paramArr[11])); entity.JetVector = new DrawingIO.Vector3(entity.JetTopPoint.X - entity.EndPoint.X, entity.JetTopPoint.Y - entity.EndPoint.Y, entity.JetTopPoint.Z - entity.EndPoint.Z); entity.ControlFlag = (CtrlFlag)(int.Parse(paramArr[8])); return(entity); }
/// <summary> /// parse a linear move from NCI file /// </summary> /// <param name="type"></param> /// <param name="ParamArr"></param> /// <returns></returns> private PathEntity linearMove(BlockType type, string[] ParamArr) { LinePathEntity entity = new LinePathEntity(type); entity.Ccomp = (CComp)(int.Parse(ParamArr[0])); entity.EndPoint.X = double.Parse(ParamArr[1]); entity.EndPoint.Y = double.Parse(ParamArr[2]); entity.EndPoint.Z = double.Parse(ParamArr[3]); entity.JetTopPoint.X = double.Parse(ParamArr[1]); entity.JetTopPoint.Y = double.Parse(ParamArr[2]); entity.JetTopPoint.Z = double.Parse(ParamArr[3]); entity.Feedrate = positiveF(double.Parse(ParamArr[4])); entity.SurfNormal = new DrawingIO.Vector3(0, 0, 1); entity.JetVector = new DrawingIO.Vector3(0, 0, 1); entity.ControlFlag = (CtrlFlag)(int.Parse(ParamArr[5])); return(entity); }
/// <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> private LinePathEntity parseLine(string ncLine, BlockType blockT, bool jeton, bool invertedF) { LinePathEntity ent = new LinePathEntity(blockT); string[] splitLine = ncLine.Split(splitters, StringSplitOptions.None); ent.JetOn = jeton; ent.Feedrate.Inverted = invertedF; ent.InputString = ncLine; foreach (string str in splitLine) { if (str.Contains(n)) { ent.LineNumber = parseInt(str, n); } if (str.Contains(x)) { ent.Position.X = parseDouble(str, x); ent.ContainsX = true; } if (str.Contains(y)) { ent.Position.Y = parseDouble(str, y); ent.ContainsY = true; } if (str.Contains(z)) { ent.Position.Z = parseDouble(str, z); ent.ContainsZ = true; } if (str.Contains(b)) { ent.Position.Bdeg = parseDouble(str, b); ent.Type = BlockType.FiveAxis; } if (str.Contains(c)) { ent.Position.Cdeg = parseDouble(str, c); ent.Type = BlockType.FiveAxis; } if (str.Contains(f)) { ent.Feedrate.Value = parseDouble(str, f); ent.ContainsF = true; } } if (ent.Type == BlockType.FiveAxis) { Vector3 pt = new Vector3(0, 0, 1); Vector3 origin = new Vector3(0, 0, 0); pt.RotateY(origin, GeomUtilities.ToRadians(ent.Position.Bdeg)); pt.RotateZ(origin, GeomUtilities.ToRadians(ent.Position.Cdeg)); ent.JetVector = pt; } else { ent.JetVector = GeometryLib.Vector3.ZAxis; } ent.Type = blockT; return(ent); }