Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IFC4X3_ADD2 support #40

Open
wants to merge 1 commit into
base: 1.2-stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Ifc/src/org/bimserver/ifc/IfcModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.bimserver.models.ifc4.Ifc4Package;
import org.bimserver.models.ifc4x3.Ifc4x3Package;
import org.bimserver.models.ifc4x3rc4.Ifc4x3rc4Package;
import org.bimserver.models.ifc4x3add2.Ifc4x3add2Package;
import org.bimserver.models.log.LogPackage;
import org.bimserver.models.store.StorePackage;
import org.bimserver.shared.PublicInterfaceNotFoundException;
Expand Down Expand Up @@ -82,7 +83,7 @@ public class IfcModel implements IfcModelInterface {
private static BiMap<EClass, Class<?>> initEClassClassMap() {
BiMap<EClass, Class<?>> eClassClassMap = HashBiMap.create();
eClassIfcRootMap = new HashMap<EClass, EClass>();
for (EPackage ePackage : new EPackage[] { Ifc2x3tc1Package.eINSTANCE, Ifc4Package.eINSTANCE, Ifc4x3rc4Package.eINSTANCE, Ifc4x3Package.eINSTANCE, StorePackage.eINSTANCE, LogPackage.eINSTANCE }) {
for (EPackage ePackage : new EPackage[] { Ifc2x3tc1Package.eINSTANCE, Ifc4Package.eINSTANCE, Ifc4x3rc4Package.eINSTANCE, Ifc4x3Package.eINSTANCE, Ifc4x3add2Package.eINSTANCE, StorePackage.eINSTANCE, LogPackage.eINSTANCE }) {
for (EClassifier eClassifier : ePackage.getEClassifiers()) {
if (eClassifier instanceof EClass) {
EClass eClass = (EClass) eClassifier;
Expand Down
95 changes: 49 additions & 46 deletions Ifc/src/org/bimserver/ifc/IfcSerializer.java
Original file line number Diff line number Diff line change
@@ -1,54 +1,55 @@
package org.bimserver.ifc;

import java.util.Collection;

/******************************************************************************
* Copyright (C) 2009-2013 BIMserver.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/

import java.util.HashMap;
import java.util.Map;

import org.bimserver.emf.IfcModelInterface;
import org.bimserver.interfaces.objects.SIfcHeader;
import org.bimserver.models.ifc2x3tc1.Ifc2x3tc1Package;
import org.bimserver.models.ifc4.Ifc4Package;
import org.bimserver.models.ifc4x3.Ifc4x3Package;
import org.bimserver.models.ifc4x3rc4.Ifc4x3rc4Package;
import org.bimserver.plugins.PluginConfiguration;
import org.bimserver.plugins.PluginException;
import org.bimserver.plugins.PluginManager;
import org.bimserver.plugins.renderengine.RenderEnginePlugin;
import org.bimserver.plugins.schema.Attribute;
import org.bimserver.plugins.schema.EntityDefinition;
import org.bimserver.plugins.schema.InverseAttribute;
import org.bimserver.plugins.schema.SchemaDefinition;
import org.bimserver.plugins.schema.SchemaPlugin;
import org.bimserver.plugins.serializers.EmfSerializer;
import org.bimserver.plugins.serializers.ProjectInfo;
import org.bimserver.plugins.serializers.SerializerException;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EStructuralFeature;
package org.bimserver.ifc;

import java.util.Collection;

/******************************************************************************
* Copyright (C) 2009-2013 BIMserver.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/

import java.util.HashMap;
import java.util.Map;

import org.bimserver.emf.IfcModelInterface;
import org.bimserver.interfaces.objects.SIfcHeader;
import org.bimserver.models.ifc2x3tc1.Ifc2x3tc1Package;
import org.bimserver.models.ifc4.Ifc4Package;
import org.bimserver.models.ifc4x3.Ifc4x3Package;
import org.bimserver.models.ifc4x3add2.Ifc4x3add2Package;
import org.bimserver.models.ifc4x3rc4.Ifc4x3rc4Package;
import org.bimserver.plugins.PluginConfiguration;
import org.bimserver.plugins.PluginException;
import org.bimserver.plugins.PluginManager;
import org.bimserver.plugins.renderengine.RenderEnginePlugin;
import org.bimserver.plugins.schema.Attribute;
import org.bimserver.plugins.schema.EntityDefinition;
import org.bimserver.plugins.schema.InverseAttribute;
import org.bimserver.plugins.schema.SchemaDefinition;
import org.bimserver.plugins.schema.SchemaPlugin;
import org.bimserver.plugins.serializers.EmfSerializer;
import org.bimserver.plugins.serializers.ProjectInfo;
import org.bimserver.plugins.serializers.SerializerException;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EStructuralFeature;

public abstract class IfcSerializer extends EmfSerializer {

protected SchemaDefinition schema;
protected EPackage ePackage;
protected Map<EClassifier, String> upperCases;
protected Map<EClassifier, String> upperCases;
private Map<EStructuralFeature, Boolean> inverseCache = new HashMap<EStructuralFeature, Boolean>();

@Override
Expand All @@ -66,6 +67,8 @@ private EPackage initPackage() throws SerializerException {
return Ifc4Package.eINSTANCE;
} else if ("IFC4X3".equals(schema.getName().toUpperCase())) {
return Ifc4x3Package.eINSTANCE;
} else if ("IFC4X3_ADD2".equals(schema.getName().toUpperCase())) {
return Ifc4x3add2Package.eINSTANCE;
} else if (schema.getName().toUpperCase().startsWith("IFC4X3_RC")) {
return Ifc4x3rc4Package.eINSTANCE;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.bimserver.models.ifc4.Ifc4Package;
import org.bimserver.models.ifc4x3.Ifc4x3Package;
import org.bimserver.models.ifc4x3rc4.Ifc4x3rc4Package;
import org.bimserver.models.ifc4x3add2.Ifc4x3add2Package;
import org.bimserver.plugins.deserializers.DeserializeException;
import org.bimserver.plugins.deserializers.EmfDeserializer;
import org.bimserver.plugins.schema.Attribute;
Expand Down Expand Up @@ -115,6 +116,8 @@ public void init(SchemaDefinition schema) {
ePackage = Ifc4Package.eINSTANCE;
} else if ("IFC4X3".equals(name.toUpperCase())) {
ePackage = Ifc4x3Package.eINSTANCE;
} else if ("IFC4X3_ADD2".equals(name.toUpperCase())) {
ePackage = Ifc4x3add2Package.eINSTANCE;
} else if (name.toUpperCase().startsWith("IFC4X3_RC")) {
ePackage = Ifc4x3rc4Package.eINSTANCE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.bimserver.models.ifc4.Ifc4Package;
import org.bimserver.models.ifc4x3.Ifc4x3Package;
import org.bimserver.models.ifc4x3rc4.Ifc4x3rc4Package;
import org.bimserver.models.ifc4x3add2.Ifc4x3add2Package;
import org.bimserver.plugins.deserializers.DeserializeException;
import org.bimserver.plugins.deserializers.EmfDeserializer;
import org.bimserver.plugins.schema.Attribute;
Expand Down Expand Up @@ -67,7 +68,9 @@ public class IfcStepDeserializer extends EmfDeserializer {
public void init(SchemaDefinition schema) {
this.schema = schema;
String name = this.schema.getName();
if ("IFC4X3".equals(name.toUpperCase())) {
if ("IFC4X3_ADD2".equals(name.toUpperCase())) {
ePackage = Ifc4x3add2Package.eINSTANCE;
} else if ("IFC4X3".equals(name.toUpperCase())) {
ePackage = Ifc4x3Package.eINSTANCE;
} else if (name.toUpperCase().startsWith("IFC4X3_RC")) {
ePackage = Ifc4x3rc4Package.eINSTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.bimserver.models.ifc2x3tc1.Ifc2x3tc1Package;
import org.bimserver.models.ifc4.Ifc4Package;
import org.bimserver.models.ifc4x3.Ifc4x3Package;
import org.bimserver.models.ifc4x3add2.Ifc4x3add2Package;
import org.bimserver.models.ifc4x3rc4.Ifc4x3rc4Package;
import org.bimserver.models.log.LogPackage;
import org.bimserver.models.store.StorePackage;
Expand Down Expand Up @@ -98,7 +99,9 @@ public StepEStore(StepExchange exchange, SchemaDefinition schema) throws StepPar
this.exchange = exchange;
this.schema = schema;
String name = this.schema.getName();
if ("IFC4X3".equals(name.toUpperCase())) {
if ("IFC4X3_ADD2".equals(name.toUpperCase())) {
ePackage = Ifc4x3add2Package.eINSTANCE;
} else if ("IFC4X3".equals(name.toUpperCase())) {
ePackage = Ifc4x3Package.eINSTANCE;
} else if (name.toUpperCase().startsWith("IFC4X3_RC")) {
ePackage = Ifc4x3rc4Package.eINSTANCE;
Expand Down
4 changes: 4 additions & 0 deletions buildingSMARTLibrary/plugin/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@
<interfaceClass>org.bimserver.plugins.schema.SchemaPlugin</interfaceClass>
<implementationClass>nl.tue.buildingsmart.emf.Ifc4x3SchemaPlugin</implementationClass>
</PluginImplementation>
<PluginImplementation>
<interfaceClass>org.bimserver.plugins.schema.SchemaPlugin</interfaceClass>
<implementationClass>nl.tue.buildingsmart.emf.Ifc4x3add2SchemaPlugin</implementationClass>
</PluginImplementation>
</PluginDescriptor>
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package nl.tue.buildingsmart.emf;

/******************************************************************************
* Copyright (C) 2009-2013 BIMserver.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/

import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;

import org.apache.commons.io.IOUtils;
import org.bimserver.models.store.ObjectDefinition;
import org.bimserver.plugins.PluginConfiguration;
import org.bimserver.plugins.PluginContext;
import org.bimserver.plugins.PluginException;
import org.bimserver.plugins.PluginManager;
import org.bimserver.plugins.schema.SchemaDefinition;
import org.bimserver.plugins.schema.SchemaPlugin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Ifc4x3add2SchemaPlugin implements SchemaPlugin {

private static final Logger LOGGER = LoggerFactory.getLogger(Ifc4x3add2SchemaPlugin.class);
private SchemaDefinition schemaDefinition;
private boolean initialized = false;
private File schemaFile;

@Override
public SchemaDefinition getSchemaDefinition(PluginConfiguration pluginConfiguration) {
return schemaDefinition;
}

@Override
public String getDescription() {
return "Ifc4x3add2SchemaPlugin";
}

@Override
public String getVersion() {
return "1.0";
}

@Override
public void init(PluginManager pluginManager) throws PluginException {
PluginContext pluginContext = pluginManager.getPluginContext(this);
try {
InputStream inputStream = pluginContext.getResourceAsInputStream("schema/IFC4X3_ADD2.exp");
if (!pluginManager.getTempDir().exists()) {
pluginManager.getTempDir().mkdir();
}
schemaFile = new File(pluginManager.getTempDir(), "IFC4X3_ADD2.exp");
FileOutputStream fileOutputStream = new FileOutputStream(schemaFile);
IOUtils.copy(inputStream, fileOutputStream);
fileOutputStream.close();
schemaDefinition = loadIfcSchema(schemaFile);
schemaDefinition.setName("IFC4X3_ADD2");
initialized = true;
} catch (Exception e) {
throw new PluginException(e);
}
}

private SchemaDefinition loadIfcSchema(File schemaFile) {
SchemaDefinition schema = SchemaLoader.loadSchema(schemaFile);
if (schema != null) {
LOGGER.info("IFC-Schema successfully loaded from " + schemaFile.getAbsolutePath());
} else {
LOGGER.error("Error loading IFC-Schema");
}
return schema;
}

@Override
public boolean isInitialized() {
return initialized;
}

@Override
public File getExpressSchemaFile() {
return schemaFile;
}

@Override
public String getDefaultName() {
return "Ifc4x3add2SchemaPlugin";
}

@Override
public ObjectDefinition getSettingsDefinition() {
return null;
}
}