Exemplo n.º 1
0
        private List <NomSection> MakeSectionsFromFile(string nomFileName)
        {
            List <NomSection> sections = null;

            using (StreamReader reader = File.OpenText(nomFileName))
            {
                Regex reg    = new Regex(@"\b(-?\d+)(\.\d+)?\b"); // 数值
                Regex numreg = new Regex(@"^(NUM_SECT)(\s\d+)");  // 截面数
                //Regex secreg = new Regex(@"^(SECTION)(\s\S+)(\s\d+)"); // 截面点数

                int linenum = 0;
                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine();
                    linenum++;
                    if (!numreg.IsMatch(line))
                    {
                        continue;
                    }
                    MatchCollection mac       = numreg.Matches(line);
                    int             sectCount = Convert.ToInt32(mac[0].Groups[2].Value); // 获得截面数
                    sections = new List <NomSection>();
                    for (int i = 0; i < sectCount; i++)
                    {
                        // 创建截面并写入blade.txt文件
                        NomSection sect = new NomSection();
                        sect.ReadSection(reader);
                        sections.Add(sect);
                    }
                }
            }
            return(sections);
        }
Exemplo n.º 2
0
        private List <NomSection> MakeSectionsFromFile1(string nomFileName)
        {
            List <NomSection> sections = null;

            using (StreamReader reader = File.OpenText(nomFileName))
            {
                // 读入头部分
                string line;
                int    sectionCount = 0;
                while (!reader.EndOfStream)
                {
                    line = reader.ReadLine();
                    if (line.Contains("NUM_SECT"))
                    {
                        string[] strarr = line.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        sectionCount = int.Parse(strarr[1]);
                        break;
                    }
                }
                sections = new List <NomSection>();
                for (int i = 0; i < sectionCount; i++)
                {
                    NomSection sect = new NomSection();
                    sect.ReadSection1(reader);
                    sections.Add(sect);
                }
            }
            return(sections);
        }