/// <summary> /// 读取数据,并返回跳出循环的字符串 /// </summary> /// <param name="sr_inp"></param> /// <param name="stringline"> 当前要读取 inp 文件中的那一行数据 </param> /// <remarks>在读取数据时,每一个生成单元的函数中,都会返回最后跳出循环的那个字符串,如果某行字符串没有进行任何的数据提取,或者进行单元类型的判断,则继续读取下一行字符。</remarks> protected override string ReadElements(StreamReader sr_inp, string stringline) { string pattern_ElementType = @"\*ELEMENT,TYPE=(.+),ELSET=(.+)"; //大致结构为: *ELEMENT,TYPE=B31,ELSET=columns-c1 var strLine = stringline; Match match = default(Match); do { //在Hypermesh导出的inp文件中,可以有很多个 *ELEMENT,TYPE=B31,ELSET=columns 这样的语句,它们是按hypermesh中的Component来进行分组的。 match = Regex.Match(strLine, pattern_ElementType); if (match.Success) { // string strEleType = match.Groups[1].Value; string strComponentName = match.Groups[2].Value; // 当前读取到Inp中的那一个 Component(即 Hypermesh 中的 Component) ElementType tp = Hm2Flac3DHandler.GetElementType(strEleType, strComponentName); // 创建 Flac3D 单元 strLine = GenerateElement(tp, sr_inp, strComponentName); } else { //如果某行字符串没有进行任何的数据提取,或者进行单元类型的判断,则继续读取下一行字符。 strLine = sr_inp.ReadLine(); } } while (strLine != null); return(strLine); }
/// <summary> /// 读取数据,并返回跳出循环的字符串 /// </summary> /// <param name="sr_inp"></param> /// <param name="stringline"> 当前要读取 inp 文件中的那一行数据 </param> /// <returns>如果数据提取成功,则返回True,否则返回False</returns> /// <remarks>在读取数据时,每一个生成单元的函数中,都会返回最后跳出循环的那个字符串,如果某行字符串没有进行任何的数据提取,或者进行单元类型的判断,则继续读取下一行字符。</remarks> protected override string ReadElements(StreamReader sr_inp, string stringline) { const string pattern_ElementType = @"\*ELEMENT,TYPE=(.+),ELSET=(.+)"; //大致结构为: *ELEMENT,TYPE=B31,ELSET=columns-c1 const string pattern_ElementSet_LinerGroup = @"\*ELSET, ELSET=(LG.*)"; // 大致结构为:*ELSET, ELSET=LG_C2Wall const string pattern_NodeSet_Merge = @"\*NSET, NSET=(LM.*)"; // 大致结构为:*NSET, NSET=LM_WallBottom //表示 Hypermesh 中的 SetBrowser 里面的 Element 组,用来作为 在Flac3D 中创建 Liner 时的 group 区间。 string strLine = stringline; Match match; do { //在Hypermesh导出的inp文件中,可以有很多个 *ELEMENT,TYPE=B31,ELSET=columns 这样的语句,它们是按hypermesh中的Component来进行分组的。 match = Regex.Match(strLine, pattern_ElementType, RegexOptions.IgnoreCase); if (match.Success) { // string strEleType = match.Groups[1].Value; string strComponentName = match.Groups[2].Value; // 当前读取到Inp中的那一个 Component(即 Hypermesh 中的 Component) ElementType tp = Hm2Flac3DHandler.GetElementType(strEleType, strComponentName); // 创建 Flac3D 单元 strLine = GenerateElement(tp, sr_inp, strComponentName); } else if ((match = Regex.Match(strLine, pattern_ElementSet_LinerGroup, RegexOptions.IgnoreCase)).Success) { string groupName = match.Groups[1].Value; if (groupName.Contains("-")) // set 的名称中不能包含“-” { _message.AppendLine($"Warning : Can not export element set : \" {groupName} \", make sure the set name starts with \"LG\"(case ignored) and excludes \"-\" if you want to bind the set to the creation of Liner elements."); } else { // 创建 Group 用来依附 Liner单元 strLine = Gen_LinerGroup(sr_inp, groupName); } } else if ((match = Regex.Match(strLine, pattern_NodeSet_Merge, RegexOptions.IgnoreCase)).Success) { string groupName = match.Groups[1].Value; if (groupName.Contains("-")) // set 的名称中不能包含“-” { _message.AppendLine($"Warning : Can not export element set : \" {groupName} \", make sure the set name starts with \"LM\"(case ignored)."); } else { // Flac3dCommandWriters fcw = Flac3dCommandWriters.GetUniqueInstance(); Flac3DCommandType fct = Hm2Flac3DHandler.GetCommandType(ElementType.MERGEPOINT); StreamWriter swMergeGp = fcw.GetWriter(fct, groupName, null); // // 节点耦合 strLine = Gen_GpMerge(sr_inp, swMergeGp, groupName); } } else { //如果某行字符串没有进行任何的数据提取,或者进行单元类型的判断,则继续读取下一行字符。 strLine = sr_inp.ReadLine(); } } while (strLine != null); return(strLine); }