Search in sources :

Example 11 with DeserializerPlugin

use of org.bimserver.plugins.deserializers.DeserializerPlugin in project BIMserver by opensourceBIM.

the class PluginManager method getFirstDeserializer.

public DeserializerPlugin getFirstDeserializer(String extension, Schema schema, boolean onlyEnabled) throws PluginException {
    Collection<DeserializerPlugin> allDeserializerPlugins = getAllDeserializerPlugins(extension, onlyEnabled);
    Iterator<DeserializerPlugin> iterator = allDeserializerPlugins.iterator();
    while (iterator.hasNext()) {
        DeserializerPlugin next = iterator.next();
        if (!next.getSupportedSchemas().contains(schema)) {
            iterator.remove();
        }
    }
    if (allDeserializerPlugins.size() == 0) {
        throw new PluginException("No deserializers with extension " + extension + " found");
    }
    return allDeserializerPlugins.iterator().next();
}
Also used : PluginException(org.bimserver.shared.exceptions.PluginException) StreamingDeserializerPlugin(org.bimserver.plugins.deserializers.StreamingDeserializerPlugin) DeserializerPlugin(org.bimserver.plugins.deserializers.DeserializerPlugin)

Example 12 with DeserializerPlugin

use of org.bimserver.plugins.deserializers.DeserializerPlugin in project BIMserver by opensourceBIM.

the class ExtractFurniture method main.

public static void main(String[] args) {
    try {
        Path home = Paths.get("home");
        PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(home);
        DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true);
        Deserializer deserializer = deserializerPlugin.createDeserializer(null);
        MetaDataManager metaDataManager = new MetaDataManager(home.resolve("tmp"));
        PackageMetaData packageMetaData = metaDataManager.getPackageMetaData("ifc2x3tc1");
        deserializer.init(packageMetaData);
        IfcModelInterface model = DeserializerUtils.readFromFile(deserializer, Paths.get("../TestData/data/ADT-FZK-Haus-2005-2006.ifc"));
        model.fixOids(new IncrementingOidProvider());
        IfcFurnishingElement picknick = (IfcFurnishingElement) model.getByName(Ifc2x3tc1Package.eINSTANCE.getIfcFurnishingElement(), "Picknik Bank");
        IfcModelInterface newModel = new BasicIfcModel(packageMetaData, null);
        ModelHelper modelHelper = new ModelHelper(pluginManager.getMetaDataManager(), new HideAllInversesObjectIDM(CollectionUtils.singleSet(Ifc2x3tc1Package.eINSTANCE), pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1")), newModel);
        modelHelper.copy(picknick, false);
        SerializerPlugin serializerPlugin = pluginManager.getSerializerPlugin("org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin", true);
        Serializer serializer = serializerPlugin.createSerializer(null);
        serializer.init(newModel, null, true);
        SerializerUtils.writeToFile(serializer, Paths.get("test.ifc"));
    } catch (PluginException e) {
        e.printStackTrace();
    } catch (DeserializeException e) {
        e.printStackTrace();
    } catch (IfcModelInterfaceException e) {
        e.printStackTrace();
    } catch (SerializerException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : Path(java.nio.file.Path) ModelHelper(org.bimserver.plugins.ModelHelper) IfcFurnishingElement(org.bimserver.models.ifc2x3tc1.IfcFurnishingElement) PackageMetaData(org.bimserver.emf.PackageMetaData) IfcModelInterface(org.bimserver.emf.IfcModelInterface) PluginException(org.bimserver.shared.exceptions.PluginException) DeserializerPlugin(org.bimserver.plugins.deserializers.DeserializerPlugin) FileNotFoundException(java.io.FileNotFoundException) MetaDataManager(org.bimserver.emf.MetaDataManager) SerializerPlugin(org.bimserver.plugins.serializers.SerializerPlugin) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) IOException(java.io.IOException) BasicIfcModel(org.bimserver.ifc.BasicIfcModel) SerializerException(org.bimserver.plugins.serializers.SerializerException) PluginManager(org.bimserver.plugins.PluginManager) IfcModelInterfaceException(org.bimserver.emf.IfcModelInterfaceException) Deserializer(org.bimserver.plugins.deserializers.Deserializer) HideAllInversesObjectIDM(org.bimserver.plugins.objectidms.HideAllInversesObjectIDM) IncrementingOidProvider(org.bimserver.shared.IncrementingOidProvider) Serializer(org.bimserver.plugins.serializers.Serializer)

Aggregations

DeserializerPlugin (org.bimserver.plugins.deserializers.DeserializerPlugin)12 Deserializer (org.bimserver.plugins.deserializers.Deserializer)8 PluginException (org.bimserver.shared.exceptions.PluginException)8 IOException (java.io.IOException)7 IfcModelInterface (org.bimserver.emf.IfcModelInterface)6 FileNotFoundException (java.io.FileNotFoundException)5 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)5 StreamingDeserializerPlugin (org.bimserver.plugins.deserializers.StreamingDeserializerPlugin)5 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)4 PluginConfiguration (org.bimserver.plugins.PluginConfiguration)4 PluginManager (org.bimserver.plugins.PluginManager)4 SerializerPlugin (org.bimserver.plugins.serializers.SerializerPlugin)4 UserException (org.bimserver.shared.exceptions.UserException)4 Path (java.nio.file.Path)3 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)3 DatabaseSession (org.bimserver.database.DatabaseSession)3 IfcModelInterfaceException (org.bimserver.emf.IfcModelInterfaceException)3 DeserializerPluginConfiguration (org.bimserver.models.store.DeserializerPluginConfiguration)3 SerializerException (org.bimserver.plugins.serializers.SerializerException)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2