private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { int index = (int)treeView1.SelectedNode.Tag; TableItem tmp_node = (TableItem)(MainStorage.TableNode[index]); tableLayoutPanel1.Controls.Clear(); Label label1 = new Label(); label1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; label1.Text = "StepId:"; Label label2 = new Label(); label2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; label2.Text = tmp_node.STEPId.ToString(); Label label3 = new Label(); label3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; label3.Text = "类型:"; Label label4 = new Label(); label4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; label4.Text = tmp_node.GetTypeName(); Label label5 = new Label(); label5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; label5.Text = "属性字段:"; Label label6 = new Label(); label6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; Label label7 = new Label(); label7.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; label7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; Label label8 = new Label(); label8.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; label8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; Label label9 = new Label(); label9.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; label9.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; Label label10 = new Label(); label10.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; label10.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; Label label11 = new Label(); label11.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; label11.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; Label label12 = new Label(); label12.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; label12.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; //针对不同的节点类型进行处理 switch (tmp_node.TypeFlag) { case 1: { CARTESIAN_POINT struct_tmp = (CARTESIAN_POINT)(tmp_node.node); label6.Text = struct_tmp.property; label7.Text = "X坐标:"; label8.Text = struct_tmp.x_coord.ToString(); label9.Text = "Y坐标:"; label10.Text = struct_tmp.y_coord.ToString(); label11.Text = "Z坐标:"; label12.Text = struct_tmp.z_coord.ToString(); } ; break; case 2: { DIRECTION struct_tmp = (DIRECTION)(tmp_node.node); label6.Text = struct_tmp.property; label7.Text = "X投影分量:"; label8.Text = struct_tmp.x_dir.ToString(); label9.Text = "Y投影分量:"; label10.Text = struct_tmp.y_dir.ToString(); label11.Text = "Z投影分量:"; label12.Text = struct_tmp.z_dir.ToString(); } ; break; case 3: { VERTEX_POINT struct_tmp = (VERTEX_POINT)(tmp_node.node); label6.Text = struct_tmp.property; label7.Text = ""; label8.Text = ""; label9.Text = ""; label10.Text = ""; label11.Text = ""; label12.Text = ""; } ; break; case 4: { CIRCLE struct_tmp = (CIRCLE)(tmp_node.node); label6.Text = struct_tmp.property; label7.Text = "半径:"; label8.Text = struct_tmp.radius.ToString(); label9.Text = ""; label10.Text = ""; label11.Text = ""; label12.Text = ""; } ; break; case 5: { EDGE_CURVE struct_tmp = (EDGE_CURVE)(tmp_node.node); label6.Text = struct_tmp.property; label7.Text = "方向:"; label8.Text = struct_tmp.dir.ToString(); label9.Text = ""; label10.Text = ""; label11.Text = ""; label12.Text = ""; } ; break; case 6: { ORIENTED_EDGE struct_tmp = (ORIENTED_EDGE)(tmp_node.node); label6.Text = struct_tmp.property; label7.Text = "属性1:"; label8.Text = struct_tmp.flag_1; label9.Text = "属性2:"; label10.Text = struct_tmp.flag_2; label11.Text = "方向:"; label12.Text = struct_tmp.dir.ToString(); } ; break; case 7: { AXIS2_PLACEMENT_3D struct_tmp = (AXIS2_PLACEMENT_3D)(tmp_node.node); label6.Text = struct_tmp.property; label7.Text = ""; label8.Text = ""; label9.Text = ""; label10.Text = ""; label11.Text = ""; label12.Text = ""; } ; break; case 8: { EDGE_LOOP struct_tmp = (EDGE_LOOP)(tmp_node.node); label6.Text = struct_tmp.property; label7.Text = ""; label8.Text = ""; label9.Text = ""; label10.Text = ""; label11.Text = ""; label12.Text = ""; } ; break; case 9: { CYLINDRICAL_SURFACE struct_tmp = (CYLINDRICAL_SURFACE)(tmp_node.node); label6.Text = struct_tmp.property; label7.Text = "半径:"; label8.Text = struct_tmp.radius.ToString(); label9.Text = ""; label10.Text = ""; label11.Text = ""; label12.Text = ""; } ; break; case 10: { PLANE struct_tmp = (PLANE)(tmp_node.node); label6.Text = struct_tmp.property; label7.Text = ""; label8.Text = ""; label9.Text = ""; label10.Text = ""; label11.Text = ""; label12.Text = ""; } ; break; case 11: { FACE_OUTER_BOUND struct_tmp = (FACE_OUTER_BOUND)(tmp_node.node); label6.Text = struct_tmp.property; label7.Text = "方向:"; label8.Text = struct_tmp.dir.ToString(); label9.Text = ""; label10.Text = ""; label11.Text = ""; label12.Text = ""; } ; break; case 12: { FACE_BOUND struct_tmp = (FACE_BOUND)(tmp_node.node); label6.Text = struct_tmp.property; label7.Text = "方向:"; label8.Text = struct_tmp.dir.ToString(); label9.Text = ""; label10.Text = ""; label11.Text = ""; label12.Text = ""; } ; break; case 13: { ADVANCED_FACE struct_tmp = (ADVANCED_FACE)(tmp_node.node); label6.Text = struct_tmp.property; label7.Text = "方向:"; label8.Text = struct_tmp.dir.ToString(); label9.Text = ""; label10.Text = ""; label11.Text = ""; label12.Text = ""; } ; break; case 14: { CLOSED_SHELL struct_tmp = (CLOSED_SHELL)(tmp_node.node); label6.Text = struct_tmp.property; label7.Text = ""; label8.Text = ""; label9.Text = ""; label10.Text = ""; label11.Text = ""; label12.Text = ""; } ; break; case 15: { MANIFOLD_SOLID_BREP struct_tmp = (MANIFOLD_SOLID_BREP)(tmp_node.node); label6.Text = struct_tmp.property; label7.Text = ""; label8.Text = ""; label9.Text = ""; label10.Text = ""; label11.Text = ""; label12.Text = ""; } ; break; case 16: { ADVANCED_BREP_SHAPE_REPRESENTATION struct_tmp = (ADVANCED_BREP_SHAPE_REPRESENTATION)(tmp_node.node); label6.Text = "缺省"; label7.Text = ""; label8.Text = ""; label9.Text = ""; label10.Text = ""; label11.Text = ""; label12.Text = ""; } ; break; } tableLayoutPanel1.Controls.Add(label1, 0, 0); tableLayoutPanel1.Controls.Add(label2, 1, 0); tableLayoutPanel1.Controls.Add(label3, 2, 0); tableLayoutPanel1.Controls.Add(label4, 3, 0); tableLayoutPanel1.Controls.Add(label5, 4, 0); tableLayoutPanel1.Controls.Add(label6, 5, 0); tableLayoutPanel1.Controls.Add(label7, 0, 1); tableLayoutPanel1.Controls.Add(label8, 1, 1); tableLayoutPanel1.Controls.Add(label9, 2, 1); tableLayoutPanel1.Controls.Add(label10, 3, 1); tableLayoutPanel1.Controls.Add(label11, 4, 1); tableLayoutPanel1.Controls.Add(label12, 5, 1); }
public void DecodeADVANCED_FACE() //解码高级面字符串 { //插入线 TableItem temp = new TableItem(); temp.child = new ArrayList(); StringBuilder reg = new StringBuilder(); //存储所有中间字符串 int i = 0; //循环控制变量 //STEPId解码 while (!Char.IsDigit(this.str_temp[i]))//跳过无用的字符,直接找到数字 { ++i; } while (Char.IsDigit(this.str_temp[i])) { reg.Append(this.str_temp[i]); ++i; } temp.STEPId = int.Parse(reg.ToString()); //TypeFlag解码 temp.TypeFlag = ADVANCED_FACE_; //信息节点解码 ADVANCED_FACE struct_tmp = new ADVANCED_FACE(); //建立结构体,并将指针赋值给共用体 reg.Clear(); //清空字符串 while (this.str_temp[i] != '\'') //跳过前面的字符,直接读取有效信息 { ++i; } ++i; //读取字符串'XX'里的属性 while (this.str_temp[i] != '\'') { reg.Append(this.str_temp[i]); ++i; } struct_tmp.property = reg.ToString(); reg.Clear(); //读取多个子结点信息,长度不定 while (this.str_temp[i] != '(') { ++i; } i++; while (this.str_temp[i] != ')') { if (!Char.IsDigit(this.str_temp[i])) { ++i; } else if (Char.IsDigit(this.str_temp[i]) && (!Char.IsDigit(this.str_temp[i + 1]))) { reg.Append(this.str_temp[i]); temp.child.Add(int.Parse(reg.ToString())); reg.Clear(); ++i; } else { reg.Append(this.str_temp[i]); ++i; } } //读取最后一个孩子结点信息 while (!Char.IsDigit(this.str_temp[i]))//跳过无用的字符,直接找到数字 { ++i; } while (Char.IsDigit(this.str_temp[i])) { reg.Append(this.str_temp[i]); ++i; } temp.child.Add(int.Parse(reg.ToString())); reg.Clear(); //插入方向信息 while (this.str_temp[i] != '.') { ++i; } ++i; if (this.str_temp[i] == 'T') { struct_tmp.dir = true; } else { struct_tmp.dir = false; } temp.node = struct_tmp; //将结构体插入到向量里 TableNode.Add(temp); }