zoukankan      html  css  js  c++  java
  • 使用java解析ifc并获取数据(树形结构)

     import java.io.File;
    import java.util.Collection;
    import java.util.Enumeration;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.TreeMap;

    import javax.swing.tree.DefaultMutableTreeNode;

    import com.vfsd.demo.IfcSpatialStructure;
    import com.vfsd.ifc2x3tc1.IfcBuildingStorey;
    import com.vfsd.ifc2x3tc1.IfcWall;
    import com.vfsd.ifcmodel.IfcModel;

    public class Test {
    public static void main(String[] args) throws Exception{
    IfcModel ifcModel = new IfcModel();
    //File file = new File("C:\Users\new\Desktop\项目1.ifc");
    File file  = new File("C:\Users\new\Desktop\项目2016-0002.ifc");
    ifcModel.readStepFile(file);

    DefaultMutableTreeNode rootTreeNode = new DefaultMutableTreeNode("no model loaded");

    Enumeration<?> enumeration;
    enumeration=rootTreeNode.depthFirstEnumeration();//以深度遍历节点
    //enumeration=rootTreeNode.preorderEnumeration();//按前序遍历根节点
    //enumeration=rootTreeNode.breadthFirstEnumeration();//以广度遍历节点
    //enumeration=rootTreeNode.postorderEnumeration();//按后序遍历节点
    //enumeration=rootTreeNode.children();//遍历该节点的所有子节点.

    //知道了遍历方式,开始遍历.
      while(enumeration.hasMoreElements()){ 
      //遍历枚举对象.
      //先定义一个节点变量.
      DefaultMutableTreeNode node;
      node=(DefaultMutableTreeNode) enumeration.nextElement();//将节点名称给node.
      //根据级别输出占位符.
      for(int l=0;l<node.getLevel();l++){
      System.out.print("---");
      }
      //System.out.println(node.getUserObject()+"       "+node.getUserObject().getClass().getName()+"    "+node.getUserObject().getClass().getSimpleName());//输入节点标签.
      System.out.println(node.getUserObject());
    }

    }

    }
  • 相关阅读:
    Duff and Meat(贪心)
    Duff and Meat(贪心)
    Eugeny and Array(水题,注意题目描述即可)
    Eugeny and Array(水题,注意题目描述即可)
    HDU-2588-GCD (欧拉函数)
    HDU-2588-GCD (欧拉函数)
    再谈欧拉函数
    再谈欧拉函数
    容斥定理及浅略介绍
    Vue
  • 原文地址:https://www.cnblogs.com/herd/p/6509869.html
Copyright © 2011-2022 走看看