Search in sources :

Example 1 with RenderEnginePlugin

use of org.bimserver.plugins.renderengine.RenderEnginePlugin in project BIMserver by opensourceBIM.

the class TestGen method start.

private void start(String[] args) {
    try {
        PluginManagerInterface pluginManager = LocalDevSetup.setupPluginManager(args);
        DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true);
        Deserializer deserializer = deserializerPlugin.createDeserializer(null);
        deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1"));
        RenderEnginePlugin renderEnginePlugin = pluginManager.getRenderEnginePlugin("org.bimserver.ifcengine.JvmRenderEnginePlugin", true);
        RenderEngine renderEngine = renderEnginePlugin.createRenderEngine(null, "ifc2x3tc1");
        renderEngine.init();
        Path path = Paths.get("../TestData/data/AC11-Institute-Var-2-IFC.ifc");
        RenderEngineModel renderEngineModel = renderEngine.openModel(new FileInputStream(path.toFile()), Files.size(path));
        RenderEngineSettings settings = new RenderEngineSettings();
        settings.setPrecision(Precision.SINGLE);
        settings.setIndexFormat(IndexFormat.AUTO_DETECT);
        settings.setGenerateNormals(true);
        settings.setGenerateTriangles(true);
        settings.setGenerateWireFrame(false);
        renderEngineModel.setSettings(settings);
        renderEngineModel.generateGeneralGeometry();
        renderEngineModel.close();
        renderEngine.close();
        long start = System.nanoTime();
        long end = System.nanoTime();
        System.out.println(((end - start) / 1000000) + " ms");
    } catch (PluginException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : Path(java.nio.file.Path) PluginException(org.bimserver.shared.exceptions.PluginException) DeserializerPlugin(org.bimserver.plugins.deserializers.DeserializerPlugin) FileNotFoundException(java.io.FileNotFoundException) RenderEnginePlugin(org.bimserver.plugins.renderengine.RenderEnginePlugin) IOException(java.io.IOException) RenderEngineModel(org.bimserver.plugins.renderengine.RenderEngineModel) FileInputStream(java.io.FileInputStream) PluginManagerInterface(org.bimserver.plugins.PluginManagerInterface) Deserializer(org.bimserver.plugins.deserializers.Deserializer) RenderEngineSettings(org.bimserver.plugins.renderengine.RenderEngineSettings) RenderEngine(org.bimserver.plugins.renderengine.RenderEngine)

Example 2 with RenderEnginePlugin

use of org.bimserver.plugins.renderengine.RenderEnginePlugin in project BIMserver by opensourceBIM.

the class LongDownloadOrCheckoutAction method executeAction.

protected void executeAction(BimDatabaseAction<? extends IfcModelInterface> action, DownloadParameters downloadParameters, DatabaseSession session, boolean commit) throws BimserverDatabaseException, UserException, NoSerializerFoundException, ServerException {
    try {
        if (action == null) {
            checkoutResult = new SCheckoutResult();
            checkoutResult.setFile(new CachingDataHandler(getBimServer().getDiskCacheManager(), downloadParameters));
            checkoutResult.setSerializerOid(downloadParameters.getSerializerOid());
        } else {
            Revision revision = session.get(StorePackage.eINSTANCE.getRevision(), downloadParameters.getRoid(), OldQuery.getDefault());
            if (revision == null) {
                throw new UserException("Revision with roid " + downloadParameters.getRoid() + " not found");
            }
            // Little hack to make
            revision.getProject().getGeoTag().load();
            // sure this is
            // lazily loaded,
            // because after the
            // executeAndCommitAction
            // the session won't
            // be usable
            IfcModelInterface ifcModel = session.executeAndCommitAction(action);
            // Session is closed after this
            DatabaseSession newSession = getBimServer().getDatabase().createSession();
            RenderEnginePlugin renderEnginePlugin = null;
            try {
                PluginConfiguration serializerPluginConfiguration = newSession.get(StorePackage.eINSTANCE.getPluginConfiguration(), downloadParameters.getSerializerOid(), OldQuery.getDefault());
                if (serializerPluginConfiguration != null) {
                    if (serializerPluginConfiguration instanceof MessagingSerializerPluginConfiguration) {
                        try {
                            messagingSerializer = getBimServer().getSerializerFactory().createMessagingSerializer(getUserName(), ifcModel, downloadParameters);
                        } catch (SerializerException e) {
                            e.printStackTrace();
                        }
                    } else if (serializerPluginConfiguration instanceof SerializerPluginConfiguration) {
                        RenderEnginePluginConfiguration renderEngine = ((SerializerPluginConfiguration) serializerPluginConfiguration).getRenderEngine();
                        if (renderEngine != null) {
                            renderEnginePlugin = getBimServer().getPluginManager().getRenderEnginePlugin(renderEngine.getPluginDescriptor().getPluginClassName(), true);
                        }
                        checkoutResult = convertModelToCheckoutResult(revision.getProject(), getUserName(), ifcModel, renderEnginePlugin, downloadParameters);
                    }
                }
            } catch (BimserverDatabaseException e) {
                LOGGER.error("", e);
            } finally {
                newSession.close();
            }
        }
    } finally {
        done();
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) IfcModelInterface(org.bimserver.emf.IfcModelInterface) SCheckoutResult(org.bimserver.interfaces.objects.SCheckoutResult) RenderEnginePlugin(org.bimserver.plugins.renderengine.RenderEnginePlugin) SerializerException(org.bimserver.plugins.serializers.SerializerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) RenderEnginePluginConfiguration(org.bimserver.models.store.RenderEnginePluginConfiguration) Revision(org.bimserver.models.store.Revision) MessagingSerializerPluginConfiguration(org.bimserver.models.store.MessagingSerializerPluginConfiguration) RenderEnginePluginConfiguration(org.bimserver.models.store.RenderEnginePluginConfiguration) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) PluginConfiguration(org.bimserver.models.store.PluginConfiguration) MessagingSerializerPluginConfiguration(org.bimserver.models.store.MessagingSerializerPluginConfiguration) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) MessagingSerializerPluginConfiguration(org.bimserver.models.store.MessagingSerializerPluginConfiguration) UserException(org.bimserver.shared.exceptions.UserException)

Example 3 with RenderEnginePlugin

use of org.bimserver.plugins.renderengine.RenderEnginePlugin in project BIMserver by opensourceBIM.

the class RenderEnginePools method getRenderEnginePool.

public RenderEnginePool getRenderEnginePool(Schema schema, String className, PluginConfiguration pluginConfiguration) throws PluginException {
    if (pools.containsKey(schema)) {
        Map<String, RenderEnginePool> map = pools.get(schema);
        if (map.containsKey(className)) {
            return map.get(className);
        } else {
            // Maybe this plugin has been installed after startup, let's have a look in the PluginManager
            RenderEnginePlugin renderEnginePlugin = bimServer.getPluginManager().getRenderEnginePlugin(className, true);
            if (renderEnginePlugin == null) {
                throw new PluginException("No render engine found for className " + className);
            } else {
                RenderEnginePool renderEnginePool = renderEnginePoolFactory.newRenderEnginePool(new RenderEngineFactory() {

                    @Override
                    public RenderEngine createRenderEngine() throws RenderEngineException {
                        return renderEnginePlugin.createRenderEngine(pluginConfiguration, schema.name());
                    }
                });
                map.put(className, renderEnginePool);
                return renderEnginePool;
            }
        }
    } else {
        throw new PluginException("No render engine found for schema " + schema);
    }
}
Also used : PluginException(org.bimserver.shared.exceptions.PluginException) RenderEnginePlugin(org.bimserver.plugins.renderengine.RenderEnginePlugin) RenderEngine(org.bimserver.plugins.renderengine.RenderEngine) RenderEngineException(org.bimserver.plugins.renderengine.RenderEngineException)

Aggregations

RenderEnginePlugin (org.bimserver.plugins.renderengine.RenderEnginePlugin)3 RenderEngine (org.bimserver.plugins.renderengine.RenderEngine)2 PluginException (org.bimserver.shared.exceptions.PluginException)2 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)1 DatabaseSession (org.bimserver.database.DatabaseSession)1 IfcModelInterface (org.bimserver.emf.IfcModelInterface)1 SCheckoutResult (org.bimserver.interfaces.objects.SCheckoutResult)1 MessagingSerializerPluginConfiguration (org.bimserver.models.store.MessagingSerializerPluginConfiguration)1 PluginConfiguration (org.bimserver.models.store.PluginConfiguration)1 RenderEnginePluginConfiguration (org.bimserver.models.store.RenderEnginePluginConfiguration)1 Revision (org.bimserver.models.store.Revision)1 SerializerPluginConfiguration (org.bimserver.models.store.SerializerPluginConfiguration)1 PluginManagerInterface (org.bimserver.plugins.PluginManagerInterface)1 Deserializer (org.bimserver.plugins.deserializers.Deserializer)1 DeserializerPlugin (org.bimserver.plugins.deserializers.DeserializerPlugin)1 RenderEngineException (org.bimserver.plugins.renderengine.RenderEngineException)1