Пример #1
0
        private IPathEntity 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.PointCyl.ToDegs(Math.Acos(entity.JetVector.Z / entity.JetVector.Length));
            entity.Position.Cdeg = GeometryLib.PointCyl.ToDegs(Math.Atan2(entity.JetVector.Y, entity.JetVector.X));
            return(entity);
        }
Пример #2
0
        /// <summary>
        /// parse a linear move from NCI file
        /// </summary>
        /// <param name="type"></param>
        /// <param name="ParamArr"></param>
        /// <returns></returns>
        private IPathEntity 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);
        }
Пример #3
0
        /// <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 IPathEntity ParseLine(string ncLine, BlockType blockT, bool jeton, bool invertedF)
        {
            IPathEntity ent = new LinePathEntity(blockT);

            string[] splitLine = ncLine.Split(splitters, StringSplitOptions.None);
            ent.JetOn = jeton;

            ent.InputString = ncLine;

            foreach (string str in splitLine)
            {
                if (str.Contains(n))
                {
                    ent.LineNumber = ParseInt(str, n);
                }
                else if (str.Contains(x))
                {
                    ent.Position.X = ParseDouble(str, x);
                    ent.ContainsX  = true;
                }
                else if (str.Contains(y))
                {
                    ent.Position.Y = ParseDouble(str, y);
                    ent.ContainsY  = true;
                }
                else if (str.Contains(z))
                {
                    ent.Position.Z = ParseDouble(str, z);
                    ent.ContainsZ  = true;
                }
                else if (str.Contains(b))
                {
                    ent.Position.Bdeg = ParseDouble(str, b);
                    ent.Type          = BlockType.LINEAR;
                }
                else if (str.Contains(c))
                {
                    ent.Position.Cdeg = ParseDouble(str, c);
                    ent.Type          = BlockType.LINEAR;
                }
                else if (str.Contains(f))
                {
                    ent.Feedrate  = GetFeedrate(str, invertedF);
                    ent.ContainsF = true;
                }
            }

            if (ent.Type == BlockType.LINEAR)
            {
                Vector3 pt     = new Vector3(0, 0, 1);
                Vector3 origin = new Vector3(0, 0, 0);
                pt.RotateY(origin, PointCyl.ToRadians(ent.Position.Bdeg));
                pt.RotateZ(origin, PointCyl.ToRadians(ent.Position.Cdeg));
                ent.JetVector = pt;
            }
            else
            {
                ent.JetVector = new Vector3(0, 0, 1);
            }
            ent.Type = blockT;

            return(ent);
        }