示例#1
0
 private void start() {
   Path src = TestFile.RIOLERING_TEST.getFile();
   PluginManager pluginManager;
   try {
     pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home"));
     DeserializerPlugin deserializerPlugin =
         pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true);
     Deserializer deserializer = deserializerPlugin.createDeserializer(new PluginConfiguration());
     deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1"));
     try {
       model = deserializer.read(src);
     } catch (Exception e) {
       e.printStackTrace();
     }
     step1();
   } catch (PluginException e1) {
     e1.printStackTrace();
   }
 }
  /*
   * Setup a BIMserver
   */
  @BeforeClass
  public static void initClass() {
    try {
      // Create a BIMserver
      BimServerConfig config = new BimServerConfig();
      config.setHomeDir(Paths.get("home"));
      config.setResourceFetcher(new LocalDevelopmentResourceFetcher(Paths.get("../")));
      bimServer = new BimServer(config);

      // Load plugins
      LocalDevPluginLoader.loadPlugins(bimServer.getPluginManager(), null);

      // Start
      bimServer.start();

      // Convenience, setup the server to make sure it is in RUNNING state
      if (bimServer.getServerInfo().getServerState() == ServerState.NOT_SETUP) {
        bimServer
            .getService(AdminInterface.class)
            .setup(
                "http://localhost",
                "localhost",
                "*****@*****.**",
                "Administrator",
                "*****@*****.**",
                "admin");
      }

      // Change a setting to normal users can create projects
      //			bimServer.getSettingsManager().getSettings().setAllowUsersToCreateTopLevelProjects(true);
    } catch (ServiceException e) {
      e.printStackTrace();
    } catch (PluginException e) {
      e.printStackTrace();
    } catch (DatabaseInitException e) {
      e.printStackTrace();
    } catch (BimserverDatabaseException e) {
      e.printStackTrace();
    } catch (DatabaseRestartRequiredException e) {
      e.printStackTrace();
    }
  }
  private void start() {
    try {
      File testFiles = new File("../TestData/data");
      File output = new File("output");
      PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(new File("home"));

      DeserializerPlugin ifcDeserializerPlugin = pluginManager.getFirstDeserializer("ifc", true);

      SerializerPlugin serializerPlugin =
          pluginManager.getFirstSerializerPlugin("application/collada", true);
      for (File file : testFiles.listFiles()) {
        if (file.isFile()
            && file.getName().endsWith(".ifc")
            && file.getName().equals("Vogel_Gesamt.ifc")) {
          System.out.println(file.getName());
          ProjectInfo projectInfo = new ProjectInfo();
          projectInfo.setAuthorName("test");
          projectInfo.setDescription("");

          EmfDeserializer ifcDeserializer = ifcDeserializerPlugin.createDeserializer();
          ifcDeserializer.init(pluginManager.requireSchemaDefinition());
          IfcModelInterface model = ifcDeserializer.read(file, true);

          EmfSerializer serializer = serializerPlugin.createSerializer();
          serializer.init(
              model,
              projectInfo,
              pluginManager,
              pluginManager.requireIfcEngine().createIfcEngine());
          serializer.writeToFile(new File(output, file.getName() + ".dae"));
        }
      }
    } catch (PluginException e) {
      e.printStackTrace();
    } catch (DeserializeException e) {
      e.printStackTrace();
    } catch (SerializerException e) {
      e.printStackTrace();
    }
  }
示例#4
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();
    }
  }
  private void start() {
    BimServerConfig config = new BimServerConfig();
    Path homeDir = Paths.get("home");
    try {
      if (Files.isDirectory(homeDir)) {
        PathUtils.removeDirectoryWithContent(homeDir);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
    config.setClassPath(System.getProperty("java.class.path"));
    config.setHomeDir(homeDir);
    config.setPort(8080);
    config.setStartEmbeddedWebServer(true);
    config.setResourceFetcher(new LocalDevelopmentResourceFetcher(Paths.get("../")));
    final BimServer bimServer = new BimServer(config);
    try {
      LocalDevPluginLoader.loadPlugins(bimServer.getPluginManager(), null);
      bimServer.start();
      if (bimServer.getServerInfo().getServerState() == ServerState.NOT_SETUP) {
        bimServer
            .getService(AdminInterface.class)
            .setup(
                "http://localhost",
                "localhost",
                "*****@*****.**",
                "Administrator",
                "*****@*****.**",
                "admin");
      }
    } catch (PluginException e2) {
      e2.printStackTrace();
    } catch (ServerException e) {
      e.printStackTrace();
    } catch (DatabaseInitException e) {
      e.printStackTrace();
    } catch (BimserverDatabaseException e) {
      e.printStackTrace();
    } catch (DatabaseRestartRequiredException e) {
      e.printStackTrace();
    } catch (UserException e) {
      e.printStackTrace();
    }

    try {
      final ServiceMap serviceMap = bimServer.getServiceFactory().get(AccessMethod.INTERNAL);
      ServiceInterface serviceInterface = serviceMap.get(ServiceInterface.class);
      SettingsInterface settingsInterface = serviceMap.get(SettingsInterface.class);
      final Bimsie1AuthInterface authInterface = serviceMap.get(Bimsie1AuthInterface.class);
      serviceInterface =
          bimServer
              .getServiceFactory()
              .get(authInterface.login("*****@*****.**", "admin"), AccessMethod.INTERNAL)
              .get(ServiceInterface.class);
      settingsInterface.setCacheOutputFiles(true);
      settingsInterface.setGenerateGeometryOnCheckin(false);
      final SProject project =
          serviceMap.getBimsie1ServiceInterface().addProject("test", "ifc2x3tc1");
      SDeserializerPluginConfiguration deserializerByName =
          serviceMap.getBimsie1ServiceInterface().getDeserializerByName("IfcStepDeserializer");
      Path file = Paths.get("../TestData/data/AC11-Institute-Var-2-IFC.ifc");
      serviceInterface.checkin(
          project.getOid(),
          "test",
          deserializerByName.getOid(),
          file.toFile().length(),
          file.getFileName().toString(),
          new DataHandler(new FileDataSource(file.toFile())),
          false,
          true);
      final SProject projectUpdate =
          serviceMap.getBimsie1ServiceInterface().getProjectByPoid(project.getOid());
      ThreadPoolExecutor executor =
          new ThreadPoolExecutor(20, 20, 1, TimeUnit.HOURS, new ArrayBlockingQueue<Runnable>(1000));
      for (int i = 0; i < 20; i++) {
        executor.execute(
            new Runnable() {
              @Override
              public void run() {
                try {
                  ServiceMap serviceMap2 =
                      bimServer
                          .getServiceFactory()
                          .get(
                              authInterface.login("*****@*****.**", "admin"),
                              AccessMethod.INTERNAL);
                  SSerializerPluginConfiguration serializerPluginConfiguration =
                      serviceMap.getBimsie1ServiceInterface().getSerializerByName("Ifc2x3");
                  Long download =
                      serviceMap2
                          .getBimsie1ServiceInterface()
                          .download(
                              projectUpdate.getLastRevisionId(),
                              serializerPluginConfiguration.getOid(),
                              true,
                              true);
                  SDownloadResult downloadData =
                      serviceMap2.getBimsie1ServiceInterface().getDownloadData(download);
                  if (downloadData.getFile().getDataSource()
                      instanceof CacheStoringEmfSerializerDataSource) {
                    CacheStoringEmfSerializerDataSource c =
                        (CacheStoringEmfSerializerDataSource)
                            downloadData.getFile().getDataSource();
                    try {
                      ByteArrayOutputStream baos = new ByteArrayOutputStream();
                      c.writeToOutputStream(baos, null);
                      System.out.println(baos.size());
                    } catch (SerializerException e) {
                      e.printStackTrace();
                    }
                  } else {
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    IOUtils.copy(downloadData.getFile().getInputStream(), baos);
                    System.out.println(baos.size());
                  }
                  serviceMap2.getServiceInterface().cleanupLongAction(download);
                } catch (ServerException e) {
                  e.printStackTrace();
                } catch (UserException e) {
                  e.printStackTrace();
                } catch (FileNotFoundException e) {
                  e.printStackTrace();
                } catch (IOException e) {
                  e.printStackTrace();
                } catch (PublicInterfaceNotFoundException e1) {
                  e1.printStackTrace();
                }
              }
            });
      }
      executor.shutdown();
      executor.awaitTermination(1, TimeUnit.HOURS);
      bimServer.stop();
    } catch (ServerException e1) {
      e1.printStackTrace();
    } catch (UserException e1) {
      e1.printStackTrace();
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
示例#6
0
  public static void main(String[] args) {
    try {
      PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(new File("home"));
      DeserializerPlugin deserializerPlugin =
          pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true);

      Deserializer deserializer = deserializerPlugin.createDeserializer(null);
      deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1"));

      IfcModelInterface model =
          deserializer.read(new File("../TestData/data/AC9R1-Haus-G-H-Ver2-2x3.ifc"));

      deserializer = deserializerPlugin.createDeserializer(null);
      deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1"));
      IfcModelInterface furnishingModel = deserializer.read(new File("test.ifc"));

      model.fixOids(new IncrementingOidProvider());
      long oid = model.getHighestOid();
      IncrementingOidProvider oidProvider = new IncrementingOidProvider(oid + 1);

      IfcFurnishingElement picknick =
          (IfcFurnishingElement)
              furnishingModel.getByName(
                  Ifc2x3tc1Package.eINSTANCE.getIfcFurnishingElement(), "Picknik Bank");

      ModelHelper modelHelper =
          new ModelHelper(
              pluginManager.getMetaDataManager(),
              new HideAllInversesObjectIDM(
                  CollectionUtils.singleSet(Ifc2x3tc1Package.eINSTANCE),
                  pluginManager.requireSchemaDefinition("ifc2x3tc1")),
              model);

      IfcProductDefinitionShape representation =
          (IfcProductDefinitionShape) picknick.getRepresentation();
      IfcRepresentation surfaceModel = null;
      IfcRepresentation boundingBox = null;
      for (IfcRepresentation ifcRepresentation : representation.getRepresentations()) {
        IfcShapeRepresentation ifcShapeRepresentation = (IfcShapeRepresentation) ifcRepresentation;
        if (ifcShapeRepresentation.getRepresentationType().equals("SurfaceModel")) {
          surfaceModel = (IfcRepresentation) modelHelper.copy(ifcShapeRepresentation, false);
        } else if (ifcShapeRepresentation.getRepresentationType().equals("BoundingBox")) {
          boundingBox = (IfcRepresentation) modelHelper.copy(ifcShapeRepresentation, false);
        }
      }

      IfcOwnerHistory ownerHistory = null;
      List<IfcOwnerHistory> all = model.getAll(IfcOwnerHistory.class);
      if (all.size() > 0) {
        ownerHistory = all.get(0);
      }

      for (IfcBuildingStorey ifcBuildingStorey : model.getAll(IfcBuildingStorey.class)) {
        for (IfcRelDecomposes ifcRelDecomposes : ifcBuildingStorey.getIsDecomposedBy()) {
          for (IfcObjectDefinition ifcObjectDefinition : ifcRelDecomposes.getRelatedObjects()) {
            if (ifcObjectDefinition instanceof IfcSpace) {
              IfcSpace ifcSpace = (IfcSpace) ifcObjectDefinition;
              //							IfcProductDefinitionShape slabRepr = (IfcProductDefinitionShape)
              // ifcSpace.getRepresentation();
              //							IfcBoundingBox box = null;
              //							for (IfcRepresentation representation2 : slabRepr.getRepresentations()) {
              //								IfcShapeRepresentation shapeRepresentation =
              // (IfcShapeRepresentation)representation2;
              //								if (shapeRepresentation.getRepresentationType().equals("BoundingBox")) {
              //									for (IfcRepresentationItem i2 : shapeRepresentation.getItems()) {
              //										box = (IfcBoundingBox)i2;
              //									}
              //								}
              //							}

              IfcFurnishingElement newFurnishing =
                  model.create(IfcFurnishingElement.class, oidProvider);

              IfcRelContainedInSpatialStructure containedInSpatialStructure2 =
                  model.create(IfcRelContainedInSpatialStructure.class, oidProvider);
              containedInSpatialStructure2.setRelatingStructure(ifcBuildingStorey);
              containedInSpatialStructure2.getRelatedElements().add(newFurnishing);

              newFurnishing.setName("Generated");
              newFurnishing.setGlobalId("TEST");
              newFurnishing.setOwnerHistory(ownerHistory);
              IfcProductDefinitionShape definitionShape =
                  model.create(IfcProductDefinitionShape.class, oidProvider);
              newFurnishing.setRepresentation(definitionShape);

              definitionShape.getRepresentations().add(boundingBox);
              definitionShape.getRepresentations().add(surfaceModel);

              IfcLocalPlacement localPlacement = model.create(IfcLocalPlacement.class, oidProvider);
              localPlacement.setPlacementRelTo(ifcSpace.getObjectPlacement());
              IfcAxis2Placement3D axis2Placement3D =
                  model.create(IfcAxis2Placement3D.class, oidProvider);
              localPlacement.setRelativePlacement(axis2Placement3D);

              IfcCartesianPoint pos = model.create(IfcCartesianPoint.class, oidProvider);
              pos.getCoordinates().add(-3d);
              pos.getCoordinates().add(+0.5d);
              pos.getCoordinates().add(0d);
              axis2Placement3D.setLocation(pos);

              newFurnishing.setObjectPlacement(localPlacement);
            }
          }
        }
      }

      model.resetExpressIds();

      SerializerPlugin serializerPlugin =
          pluginManager.getSerializerPlugin(
              "org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin", true);
      Serializer serializer = serializerPlugin.createSerializer(null);
      serializer.init(model, null, pluginManager, null, null, true);
      serializer.writeToFile(new File("withfurn.ifc"), null);
    } catch (PluginException e) {
      e.printStackTrace();
    } catch (DeserializeException e) {
      e.printStackTrace();
    } catch (IfcModelInterfaceException e) {
      e.printStackTrace();
    } catch (SerializerException e) {
      e.printStackTrace();
    }
  }