private void start() {
   try {
     RenderEngine failSafeIfcEngine =
         new JvmIfcEngine(
             new File("../buildingSMARTLibrary/schema/IFC2X3_TC1.exp"),
             new File("lib/64"),
             new File("tmp"),
             System.getProperty("java.class.path"));
     RenderEngineModel model =
         failSafeIfcEngine.openModel(new File("../TestData/data/AC11-Institute-Var-2-IFC.ifc"));
     RenderEngineGeometry geometry = model.finalizeModelling(model.initializeModelling());
     System.out.println(geometry);
     model.close();
     failSafeIfcEngine.close();
   } catch (RenderEngineException e) {
     e.printStackTrace();
   }
 }
Exemple #2
0
  public void createTriangles(
      IfcRoot ifcRootObject, IfcModelInterface ifcModel, TransformGroup buildingTransformGroup)
      throws RenderEngineException {
    RenderEngineInstance instance =
        ifcEngineModel.getInstanceFromExpressId(ifcRootObject.getExpressId());
    RenderEngineInstanceVisualisationProperties instanceInModelling =
        instance.getVisualisationProperties();
    if (instanceInModelling.getPrimitiveCount() != 0) {
      Appearance appearance = appearances.getAppearance(ifcRootObject);
      if (appearance != null) {
        Point3f[] coordinates = new Point3f[instanceInModelling.getPrimitiveCount() * 3];
        Vector3f[] normals = new Vector3f[instanceInModelling.getPrimitiveCount() * 3];
        for (int i = instanceInModelling.getStartIndex();
            i < instanceInModelling.getPrimitiveCount() * 3 + instanceInModelling.getStartIndex();
            i += 3) {
          int offsetIndex = i - instanceInModelling.getStartIndex();
          int i1 = geometry.getIndex(i);
          int i2 = geometry.getIndex(i + 1);
          int i3 = geometry.getIndex(i + 2);

          coordinates[offsetIndex] =
              new Point3f(
                  geometry.getVertex(i1 * 3),
                  geometry.getVertex(i1 * 3 + 1),
                  geometry.getVertex(i1 * 3 + 2));
          coordinates[offsetIndex + 1] =
              new Point3f(
                  geometry.getVertex(i3 * 3),
                  geometry.getVertex(i3 * 3 + 1),
                  geometry.getVertex(i3 * 3 + 2));
          coordinates[offsetIndex + 2] =
              new Point3f(
                  geometry.getVertex(i2 * 3),
                  geometry.getVertex(i2 * 3 + 1),
                  geometry.getVertex(i2 * 3 + 2));

          normals[offsetIndex] =
              new Vector3f(
                  geometry.getNormal(i1 * 3),
                  geometry.getNormal(i1 * 3 + 1),
                  geometry.getNormal(i1 * 3 + 2));
          normals[offsetIndex + 1] =
              new Vector3f(
                  geometry.getNormal(i3 * 3),
                  geometry.getNormal(i3 * 3 + 1),
                  geometry.getNormal(i3 * 3 + 2));
          normals[offsetIndex + 2] =
              new Vector3f(
                  geometry.getNormal(i2 * 3),
                  geometry.getNormal(i2 * 3 + 1),
                  geometry.getNormal(i2 * 3 + 2));
        }
        TriangleArray triangleArray =
            new TriangleArray(
                coordinates.length, GeometryArray.COORDINATES | GeometryArray.NORMALS);
        triangleArray.setCoordinates(0, coordinates);
        triangleArray.setNormals(0, normals);
        Shape3D myShape = new Shape3D(triangleArray, appearance);
        buildingTransformGroup.addChild(myShape);
        myShape.setUserData(ifcRootObject);
      }
    }
  }
Exemple #3
0
  private void start() throws PluginException, IfcModelInterfaceException {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    try {
      setIconImage(ImageIO.read(getClass().getResource("haussmall.png")));
    } catch (IOException e) {
      LOGGER.error("", e);
    }
    setSize(800, 600);
    getContentPane().setBackground(Color.BLACK);
    setTitle("IFC Visualiser");
    setVisible(true);

    VirtualUniverse universe = new VirtualUniverse();
    Locale locale = new Locale(universe);
    canvas = new Canvas3D(SimpleUniverse.getPreferredConfiguration());

    sceneBranchGroup = new BranchGroup();
    sceneBranchGroup.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
    sceneBranchGroup.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
    createLoaderSceneGraph();
    locale.addBranchGraph(sceneBranchGroup);

    showLoader = true;
    new Thread() {
      public void run() {
        float x = 0;
        float y = 0;
        while (showLoader) {
          Matrix3f matrixX = new Matrix3f();
          matrixX.rotX(x);

          Matrix3f matrixY = new Matrix3f();
          matrixY.rotY(y);

          Matrix3f rot = new Matrix3f();
          rot.mul(matrixX, matrixY);

          Transform3D transform3d = new Transform3D();
          transform3d.setRotation(rot);
          transform3d.setTranslation(new Vector3d(10, 0, 0));
          loaderTransformGroup.setTransform(transform3d);
          y -= 0.05;
          x += 0.015;
          try {
            Thread.sleep(25);
          } catch (InterruptedException e) {
            LOGGER.error("", e);
          }
        }
      };
    }.start();

    viewBranchGroup = new BranchGroup();
    createViewBranch();
    viewBranchGroup.compile();
    locale.addBranchGraph(viewBranchGroup);

    add(canvas, BorderLayout.CENTER);

    canvas.setVisible(true);
    validate();

    sharedGroup = new SharedGroup();
    try {
      pluginManager = LocalDevPluginLoader.createPluginManager(new File("home"));
    } catch (PluginException e) {
      LOGGER.error("", e);
    }

    DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", true);
    Deserializer deserializer = deserializerPlugin.createDeserializer(new PluginConfiguration());
    deserializer.init(pluginManager.requireSchemaDefinition());
    File file = new File("../TestData/data/AC11-Institute-Var-2-IFC.ifc");

    try {
      model = deserializer.read(file);
    } catch (DeserializationException e) {
      LOGGER.error("", e);
    } catch (Exception e) {
      LOGGER.error("", e);
    }

    ifcEngine = pluginManager.requireRenderEngine().createRenderEngine(new PluginConfiguration());
    ifcEngine.init();
    try {
      ifcEngineModel = ifcEngine.openModel(file);
      try {
        RenderEngineSurfaceProperties initializeModelling = ifcEngineModel.initializeModelling();
        geometry = ifcEngineModel.finalizeModelling(initializeModelling);
        createSceneGraph();
      } finally {
        ifcEngineModel.close();
      }
    } finally {
      ifcEngine.close();
    }
  }