任何人都可以说如何创建一个程序来导入IGES / Parasolid文件格式 [英] Can anyone say how to create a program to import IGES / Parasolid File Formats

查看:94
本文介绍了任何人都可以说如何创建一个程序来导入IGES / Parasolid文件格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们编写了一个打开* .XML文件格式的程序。任何人都可以帮我编写一个程序来导入我的C#应用​​程序中的Parasolid / IGES文件格式。



我已经让我的程序打开一个xml文件格式。

We Written a program to open a *.XML file format. Can anyone help me how to write a program to import a Parasolid/ IGES File Format in my C# Application.

I have given my program to open a xml file format.

#region Open
      private void openToolStripMenuItem_Click(object sender, EventArgs e)
      {
          string filename;
          try
          {
              filename = getOpenFilename(Program.settings.workingDirectory);
          }
          catch { filename = ""; }
          if (filename != "" && filename != null)
          {
              /* Load the file. */
              XmlDocument doc = new XmlDocument();
              doc.Load(filename);
              /* create prefix<->namespace mappings (if any)  */
              XmlNamespaceManager nsMgr = new XmlNamespaceManager(doc.NameTable);
              /* Query the document */
              if (doc.SelectNodes("/grammarRule", nsMgr).Count > 0)
              {
                  grammarRule rule = grammarRule.openRuleFromXml(filename);
                  grammarDisplays.Add(new grammarRuleDisplay(rule, Path.GetFileName(filename)));
                  grammarDisplays[grammarChildCount].Show();
              }
              else if (doc.SelectNodes("/ruleSet", nsMgr).Count > 0)
              {
                  ruleSet rs = ruleSet.openRuleSetFromXml(filename, Program.settings.defaultGenSteps);
                  ruleSetDisplays.Add(new ruleSetDisplay(rs, Path.GetFileName(filename)));
                  ruleSetDisplays[ruleSetChildCount].Show();
              }
              else if (doc.SelectNodes("/designGraph", nsMgr).Count > 0)
              {
                  designGraph graph = designGraph.openGraphFromXml(filename);
                  addAndShowGraphDisplay(graph, Path.GetFileName(filename));
              }
              else if (doc.SelectNodes("/candidate", nsMgr).Count > 0)
              {
                  string tempString = "";
                  candidate c = candidate.openCandidateFromXml(filename);
                  SearchIO.output("The candidate found in " + filename, 0);
                  if (c.performanceParams.Count > 0)
                  {
                      tempString = "has the following performance parameters";
                      foreach (double a in c.performanceParams)
                          tempString += ": " + a.ToString();
                      SearchIO.output(tempString, 0);
                  }
                  if (c.age > 0)
                      SearchIO.output("The candidate has existed for " + c.age.ToString() + " iterations.", 0);
                  SearchIO.output("It's generation ended in RuleSet #" + c.activeRuleSetIndex.ToString(), 0);
                  tempString = "Generation terminated with";
                  foreach (GenerationStatuses a in c.GenerationStatus)
                      tempString += ": " + a.ToString();
                  SearchIO.output(tempString, 0);

                  addAndShowGraphDisplay(c.graph, "Candidate in " + Path.GetFileName(filename));
              }
              else
              {
                  MessageBox.Show("The XML files that you have attempted to open contains an unknown" +
                      "type (not designGraph, grammarRule, ruleSet, or candidate).", "XML Serialization Error",
                      MessageBoxButtons.OK, MessageBoxIcon.Information);
              }
          }
      }
      public string getOpenFilename(string dir)
      {
          try
          {
              OpenFileDialog fileChooser = new OpenFileDialog();
              fileChooser.Title = "Open a graph, rule, or rule set from ...";
              fileChooser.InitialDirectory = dir;
              fileChooser.Filter = "(xml files)|*.xml";
              DialogResult result = fileChooser.ShowDialog();
              if (result == DialogResult.Cancel) return "";
              return fileChooser.FileName;
          }
          catch (Exception e)
          {
              MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
              return "";
          }
      }


    #endregion

推荐答案

这篇关于任何人都可以说如何创建一个程序来导入IGES / Parasolid文件格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆