コード例 #1
0
        /// <summary>
        ///载入坐标序列
        ///</summary>
        private int LoadCoordArray()
        {
            int    Indexfirst = 0, Indexlast = 0;        //坐标点数据区首尾
            string str;                                  //临时字符串
            bool   found = false;                        //记录是否找到已存在的坐标序列,true为找到

            MathFun.JPOStyp pos = new MathFun.JPOStyp(); //临时数据变量

            for (int i = 0; i < lengthHead; i++)         //记录首末坐标序列行的行索引
            {
                str = headLines[i].ToString();
                string[] subCMD = str.Split(' ');

                if (subCMD[0] == "C0000")  //找到首数据
                {
                    Indexfirst = i;
                    found      = true;
                }

                if (subCMD[0].Substring(0, 1) == "C" && subCMD[0].Length == 5)
                {
                    Indexlast = i;
                }
                else if (found)  //数据区结束,退出
                {
                    break;
                }
            }

            if (!found)
            {
                return(0);         //没有数据区(纯逻辑程序))
            }
            NumPos = Indexlast - Indexfirst + 1;

            poses.Clear();                                //清空数据点
            for (int i = Indexfirst; i <= Indexlast; i++) //载入坐标序列
            {
                str = headLines[i].ToString();
                str = str.Remove(0, 6);
                string[] subCMD = str.Split(',');

                try
                {
                    pos.J1 = double.Parse(subCMD[0]);
                    pos.J2 = double.Parse(subCMD[1]);
                    pos.J3 = double.Parse(subCMD[2]);
                    pos.J4 = double.Parse(subCMD[3]);
                    poses.Add(pos);
                }
                catch
                {
                    //MessageBox.Show("参数格式有误!", "错误!");
                    return(-1);
                }
            }

            return(0);
        }
コード例 #2
0
        /// <summary>
        /// 插入一个数据点 ToString("F6") index + 9?
        /// </summary>
        public void insPos(int index, MathFun.JPOStyp pos)
        {
            if ((index < 0) || (index > NumPos))
            {
                return;
            }
            poses.Insert(index, pos);
            string str = "C" + index.ToString("D4") + " " + pos.J1.ToString("F6") + "," + pos.J2.ToString("F6") + "," + pos.J3.ToString("F6") + "," + pos.J4.ToString("F6");

            headLines.Insert(index + 9, str);
            NumPos++;
            lengthHead++;
        }