├── IfcPlugins ├── .classpath ├── .gitignore ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ ├── org.eclipse.jdt.core.prefs │ ├── org.eclipse.m2e.core.prefs │ ├── org.eclipse.wst.common.component │ └── org.eclipse.wst.common.project.facet.core.xml ├── license.txt ├── plugin │ ├── icon.png │ ├── plugin.xml │ └── version.properties ├── pom.xml ├── src │ └── org │ │ └── bimserver │ │ ├── deserializers │ │ ├── JsonDeserializer.java │ │ ├── JsonDeserializerPlugin.java │ │ ├── JsonStreamingDeserializer.java │ │ └── JsonStreamingDeserializerPlugin.java │ │ ├── ifc │ │ ├── compare │ │ │ ├── AbstractModelCompare.java │ │ │ ├── CompareService.java │ │ │ ├── GuidBasedModelCompare.java │ │ │ ├── GuidBasedModelComparePlugin.java │ │ │ ├── NameBasedModelCompare.java │ │ │ └── NameBasedModelComparePlugin.java │ │ ├── step │ │ │ ├── deserializer │ │ │ │ ├── DetectIfcVersion.java │ │ │ │ ├── Ifc2x3tc1StepDeserializer.java │ │ │ │ ├── Ifc2x3tc1StepDeserializerPlugin.java │ │ │ │ ├── Ifc2x3tc1StepStreamingDeserializer.java │ │ │ │ ├── Ifc2x3tc1StepStreamingDeserializerPlugin.java │ │ │ │ ├── Ifc4StepDeserializer.java │ │ │ │ ├── Ifc4StepDeserializerPlugin.java │ │ │ │ ├── Ifc4StepStreamingDeserializer.java │ │ │ │ ├── Ifc4StepStreamingDeserializerPlugin.java │ │ │ │ ├── IfcHeaderParser.java │ │ │ │ ├── IfcParserWriterUtils.java │ │ │ │ ├── IfcStepDeserializer.java │ │ │ │ ├── IfcStepDeserializerPlugin.java │ │ │ │ ├── IfcStepStreamingDeserializer.java │ │ │ │ ├── IfcStepStreamingDeserializerPlugin.java │ │ │ │ ├── StepParser.java │ │ │ │ └── StringDecoder.java │ │ │ └── serializer │ │ │ │ ├── Ifc2x3tc1StepSerializer.java │ │ │ │ ├── Ifc2x3tc1StepSerializerPlugin.java │ │ │ │ ├── Ifc2x3tc1StepStreamingSerializer.java │ │ │ │ ├── Ifc2x3tc1StepStreamingSerializerPlugin.java │ │ │ │ ├── Ifc4StepSerializer.java │ │ │ │ ├── Ifc4StepSerializerPlugin.java │ │ │ │ ├── Ifc4StepStreamingSerializer.java │ │ │ │ ├── Ifc4StepStreamingSerializerPlugin.java │ │ │ │ ├── IfcStepSerializer.java │ │ │ │ ├── IfcStepSerializerPlugin.java │ │ │ │ ├── IfcStepStreamingSerializer.java │ │ │ │ ├── IfcStepStreamingSerializerPlugin.java │ │ │ │ └── IfcWriterException.java │ │ └── xml │ │ │ ├── deserializer │ │ │ ├── Ifc2x3tc1XmlDeserializer.java │ │ │ ├── Ifc2x3tc1XmlDeserializerPlugin.java │ │ │ ├── Ifc4XmlDeserializer.java │ │ │ ├── Ifc4XmlDeserializerPlugin.java │ │ │ ├── IfcXmlDeserializer.java │ │ │ └── IfcXmlDeserializerPlugin.java │ │ │ └── serializer │ │ │ ├── IfcXml2x3tc1Serializer.java │ │ │ ├── IfcXml2x3tc1SerializerPlugin.java │ │ │ ├── IfcXml4Serializer.java │ │ │ ├── IfcXml4SerializerPlugin.java │ │ │ ├── IfcXmlSerializer.java │ │ │ └── IfcXmlSerializerPlugin.java │ │ ├── noprenderengine │ │ ├── DefaultNopRenderEngine.java │ │ ├── NopRenderEngine.java │ │ ├── NopRenderEngineGeometry.java │ │ ├── NopRenderEngineInstance.java │ │ └── NopRenderEngineModel.java │ │ └── serializers │ │ ├── JsonSerializer.java │ │ ├── JsonSerializerPlugin.java │ │ ├── JsonSerializerPluginWithGeometry.java │ │ ├── JsonSerializerWithGeometry.java │ │ ├── JsonStreamingSerializerPlugin.java │ │ ├── MinimalJsonStreamingSerializerPlugin.java │ │ ├── MinimalStreamingJsonSerializer.java │ │ └── StreamingJsonSerializer.java └── test │ ├── main │ └── resources │ │ └── logback.xml │ └── org │ └── bimserver │ └── test │ ├── TestHeaderParser.java │ ├── TestReadAddWrite.java │ ├── TestReadModifyWrite.java │ ├── TestReadWrite.java │ └── TestStringDecode.java ├── LICENSE └── README.md /IfcPlugins/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /IfcPlugins/.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /target/ 3 | -------------------------------------------------------------------------------- /IfcPlugins/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | IfcPlugins 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.common.project.facet.core.builder 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.validation.validationbuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.m2e.core.maven2Builder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.jem.workbench.JavaEMFNature 31 | org.eclipse.wst.common.modulecore.ModuleCoreNature 32 | org.eclipse.m2e.core.maven2Nature 33 | org.eclipse.jdt.core.javanature 34 | org.eclipse.wst.common.project.facet.core.nature 35 | 36 | 37 | -------------------------------------------------------------------------------- /IfcPlugins/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | encoding/plugin=UTF-8 4 | encoding/src=UTF-8 5 | encoding/test=UTF-8 6 | -------------------------------------------------------------------------------- /IfcPlugins/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 7 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 8 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 9 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 10 | org.eclipse.jdt.core.compiler.release=disabled 11 | org.eclipse.jdt.core.compiler.source=1.8 12 | -------------------------------------------------------------------------------- /IfcPlugins/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /IfcPlugins/.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /IfcPlugins/.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /IfcPlugins/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) 2009-2019 BIMserver.org 2 | 3 | This program is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU Affero General Public License as 5 | published by the Free Software Foundation, either version 3 of the 6 | License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Affero General Public License for more details. 12 | 13 | You should have received a copy of the GNU Affero General Public License 14 | along with this program. If not, see {@literal}. -------------------------------------------------------------------------------- /IfcPlugins/plugin/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensourceBIM/IfcPlugins/04f1e65fdc439e3232673292f1623c1d77b087c5/IfcPlugins/plugin/icon.png -------------------------------------------------------------------------------- /IfcPlugins/plugin/plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | org.bimserver.plugins.serializers.StreamingSerializerPlugin 5 | org.bimserver.serializers.JsonStreamingSerializerPlugin 6 | JsonStreamingSerializer 7 | Json (Streaming) 8 | 9 | 10 | org.bimserver.plugins.deserializers.DeserializerPlugin 11 | org.bimserver.deserializers.JsonDeserializerPlugin 12 | JsonDeserializerPlugin 13 | Json 14 | 15 | 16 | org.bimserver.plugins.deserializers.StreamingDeserializerPlugin 17 | org.bimserver.deserializers.JsonStreamingDeserializerPlugin 18 | JsonStreamingDeserializerPlugin 19 | Json (Streaming) 20 | 21 | 22 | org.bimserver.plugins.serializers.SerializerPlugin 23 | org.bimserver.ifc.step.serializer.Ifc2x3tc1StepSerializerPlugin 24 | Ifc2x3tc1 Serializer 25 | Ifc2x3tc1 26 | 27 | 28 | org.bimserver.plugins.serializers.SerializerPlugin 29 | org.bimserver.ifc.step.serializer.Ifc4StepSerializerPlugin 30 | Ifc4 Serializer 31 | Ifc4 32 | 33 | 34 | org.bimserver.plugins.serializers.StreamingSerializerPlugin 35 | org.bimserver.ifc.step.serializer.Ifc2x3tc1StepStreamingSerializerPlugin 36 | Ifc2x3tc1 Streaming Serializer 37 | Ifc2x3tc1 (Streaming) 38 | 39 | 40 | org.bimserver.plugins.serializers.StreamingSerializerPlugin 41 | org.bimserver.ifc.step.serializer.Ifc4StepStreamingSerializerPlugin 42 | Ifc4 Streaming Serializer 43 | Ifc4 (Streaming) 44 | 45 | 46 | org.bimserver.plugins.deserializers.StreamingDeserializerPlugin 47 | org.bimserver.ifc.step.deserializer.Ifc4StepStreamingDeserializerPlugin 48 | Ifc4 Step Streaming Deserializer 49 | Ifc4 (Streaming) 50 | 51 | 52 | org.bimserver.plugins.deserializers.StreamingDeserializerPlugin 53 | org.bimserver.ifc.step.deserializer.Ifc2x3tc1StepStreamingDeserializerPlugin 54 | Ifc2x3tc1 Step Streaming Deserializer 55 | Ifc2x3tc1 (Streaming) 56 | 57 | 58 | org.bimserver.plugins.modelcompare.ModelComparePlugin 59 | org.bimserver.ifc.compare.NameBasedModelComparePlugin 60 | Name based compare 61 | Name based 62 | 63 | 64 | org.bimserver.plugins.modelcompare.ModelComparePlugin 65 | org.bimserver.ifc.compare.GuidBasedModelComparePlugin 66 | GUID based compare 67 | GUID based 68 | 69 | 70 | org.bimserver.plugins.services.ServicePlugin 71 | org.bimserver.ifc.compare.CompareService 72 | Calls compare and stores results as IFC model 73 | Compare Service 74 | 75 | 76 | org.bimserver.plugins.renderengine.RenderEnginePlugin 77 | org.bimserver.noprenderengine.DefaultNopRenderEngine 78 | No operation render engine (this engine does nothing, for debugging/testing purposes) 79 | NOP Render Engine 80 | 81 | -------------------------------------------------------------------------------- /IfcPlugins/plugin/version.properties: -------------------------------------------------------------------------------- 1 | build.date=${timestamp} -------------------------------------------------------------------------------- /IfcPlugins/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | org.opensourcebim 5 | ifcplugins 6 | 0.0.105-SNAPSHOT 7 | IfcPlugins 8 | BIMserver plugin that provides IFC serializers/deserializers 9 | https://github.com/opensourceBIM/IfcPlugins/BIMserver 10 | 11 | OpenSource BIM 12 | opensourcebim.org 13 | 14 | 15 | 16 | GNU Affero General Public License 17 | http://www.gnu.org/licenses/agpl-3.0.en.html 18 | repo 19 | 20 | 21 | 22 | 23 | Ruben de Laat 24 | ruben@logic-labs.nl 25 | 26 | 27 | 28 | scm:git:https://github.com/opensourceBIM/IfcPlugins.git 29 | scm:git:https://github.com/opensourceBIM/IfcPlugins.git 30 | https://github.com/opensourceBIM/IfcPlugins.git 31 | HEAD 32 | 33 | 34 | GitHub 35 | https://github.com/opensourceBIM/IfcPlugins/issues 36 | 37 | 38 | 39 | ossrh 40 | https://oss.sonatype.org/service/local/staging/deploy/maven2/ 41 | 42 | 43 | ossrh 44 | https://oss.sonatype.org/content/repositories/snapshots 45 | 46 | 47 | 48 | yyyy-MM-dd'T'HH:mm:ssZ 49 | UTF-8 50 | ${maven.build.timestamp} 51 | 52 | 53 | 54 | org.opensourcebim 55 | shared 56 | 1.5.188-SNAPSHOT 57 | 58 | 59 | ch.qos.logback 60 | logback-classic 61 | 1.3.15 62 | test 63 | 64 | 65 | it.unimi.dsi 66 | fastutil 67 | 8.5.15 68 | 69 | 70 | 71 | 72 | central 73 | https://repo1.maven.org/maven2 74 | 75 | 76 | 77 | src 78 | test 79 | 80 | 81 | plugin 82 | true 83 | plugin 84 | 85 | 86 | 87 | 88 | org.codehaus.mojo 89 | build-helper-maven-plugin 90 | 3.6.0 91 | 92 | 93 | attach-plugin 94 | package 95 | 96 | attach-artifact 97 | 98 | 99 | 100 | 101 | plugin/plugin.xml 102 | xml 103 | plugin 104 | 105 | 106 | plugin/icon.png 107 | png 108 | icon 109 | 110 | 111 | ${project.build.outputDirectory}/plugin/version.properties 112 | properties 113 | version 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | maven-compiler-plugin 122 | 3.10.1 123 | 124 | 8 125 | 126 | 127 | 128 | org.sonatype.plugins 129 | nexus-staging-maven-plugin 130 | 1.6.3 131 | true 132 | 133 | ossrh 134 | https://oss.sonatype.org/ 135 | false 136 | 60 137 | 138 | 139 | 140 | maven-release-plugin 141 | 2.5.3 142 | 143 | false 144 | release 145 | deploy 146 | 147 | 148 | 149 | 150 | 151 | 152 | release 153 | 154 | 155 | 156 | maven-gpg-plugin 157 | 1.5 158 | 159 | 160 | sign-artifacts 161 | verify 162 | 163 | sign 164 | 165 | 166 | 167 | --pinentry-mode 168 | loopback 169 | 170 | ${gpg.keyname} 171 | 172 | 173 | 174 | 175 | 176 | maven-javadoc-plugin 177 | 3.11.2 178 | 179 | 180 | attach-javadocs 181 | 182 | jar 183 | 184 | 185 | 186 | 187 | 188 | maven-source-plugin 189 | 2.4 190 | 191 | 192 | attach-javadocs 193 | 194 | jar 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/deserializers/JsonDeserializer.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.deserializers; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.io.InputStream; 21 | 22 | import org.bimserver.emf.IfcModelInterface; 23 | import org.bimserver.emf.SharedJsonDeserializer; 24 | import org.bimserver.ifc.BasicIfcModel; 25 | import org.bimserver.plugins.deserializers.ByteProgressReporter; 26 | import org.bimserver.plugins.deserializers.DeserializeException; 27 | import org.bimserver.plugins.deserializers.EmfDeserializer; 28 | 29 | public class JsonDeserializer extends EmfDeserializer { 30 | 31 | @Override 32 | public IfcModelInterface read(InputStream in, String filename, long fileSize, ByteProgressReporter progressReporter) throws DeserializeException { 33 | IfcModelInterface model = new SharedJsonDeserializer(true).read(in, new BasicIfcModel(getPackageMetaData(), null), false); 34 | model.resetOids(); 35 | return model; 36 | } 37 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/deserializers/JsonDeserializerPlugin.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.deserializers; 2 | 3 | import java.util.HashSet; 4 | 5 | /****************************************************************************** 6 | * Copyright (C) 2009-2019 BIMserver.org 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Affero General Public License as 10 | * published by the Free Software Foundation, either version 3 of the 11 | * License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Affero General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Affero General Public License 19 | * along with this program. If not, see {@literal}. 20 | *****************************************************************************/ 21 | 22 | import java.util.Set; 23 | 24 | import org.bimserver.emf.Schema; 25 | import org.bimserver.models.store.ObjectDefinition; 26 | import org.bimserver.plugins.PluginConfiguration; 27 | import org.bimserver.plugins.PluginContext; 28 | import org.bimserver.plugins.deserializers.Deserializer; 29 | import org.bimserver.plugins.deserializers.DeserializerPlugin; 30 | import org.bimserver.shared.exceptions.PluginException; 31 | 32 | public class JsonDeserializerPlugin implements DeserializerPlugin { 33 | 34 | @Override 35 | public void init(PluginContext pluginContext, PluginConfiguration systemSettings) throws PluginException { 36 | } 37 | 38 | @Override 39 | public ObjectDefinition getUserSettingsDefinition() { 40 | return null; 41 | } 42 | 43 | @Override 44 | public ObjectDefinition getSystemSettingsDefinition() { 45 | return null; 46 | } 47 | 48 | @Override 49 | public Deserializer createDeserializer(PluginConfiguration pluginConfiguration) { 50 | return new JsonDeserializer(); 51 | } 52 | 53 | @Override 54 | public boolean canHandleExtension(String extension) { 55 | return extension.equals("json"); 56 | } 57 | 58 | @Override 59 | public Set getSupportedSchemas() { 60 | Set set = new HashSet<>(); 61 | set.add(Schema.IFC2X3TC1); 62 | set.add(Schema.IFC4); 63 | return set; 64 | } 65 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/deserializers/JsonStreamingDeserializer.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.deserializers; 2 | 3 | import java.io.InputStream; 4 | import java.util.Map; 5 | 6 | import org.bimserver.emf.PackageMetaData; 7 | import org.bimserver.emf.SharedJsonStreamingDeserializer; 8 | import org.bimserver.models.store.IfcHeader; 9 | import org.bimserver.plugins.deserializers.ByteProgressReporter; 10 | import org.bimserver.plugins.deserializers.DeserializeException; 11 | import org.bimserver.plugins.deserializers.StreamingDeserializer; 12 | import org.bimserver.shared.QueryContext; 13 | import org.eclipse.emf.ecore.EClass; 14 | 15 | public class JsonStreamingDeserializer implements StreamingDeserializer { 16 | 17 | private PackageMetaData packageMetaData; 18 | 19 | @Override 20 | public void init(PackageMetaData packageMetaData) { 21 | this.packageMetaData = packageMetaData; 22 | } 23 | 24 | @Override 25 | public void setProgressReporter(ByteProgressReporter byteProgressReporter) { 26 | } 27 | 28 | @Override 29 | public long read(InputStream inputStream, String fileName, long fileSize, QueryContext reusable) 30 | throws DeserializeException { 31 | return new SharedJsonStreamingDeserializer(packageMetaData).read(inputStream); 32 | } 33 | 34 | @Override 35 | public IfcHeader getIfcHeader() { 36 | return null; 37 | } 38 | 39 | @Override 40 | public Map getSummaryMap() { 41 | return null; 42 | } 43 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/deserializers/JsonStreamingDeserializerPlugin.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.deserializers; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import org.bimserver.emf.Schema; 7 | import org.bimserver.models.store.ObjectDefinition; 8 | import org.bimserver.plugins.PluginConfiguration; 9 | import org.bimserver.plugins.PluginContext; 10 | import org.bimserver.plugins.deserializers.StreamingDeserializer; 11 | import org.bimserver.plugins.deserializers.StreamingDeserializerPlugin; 12 | import org.bimserver.shared.exceptions.PluginException; 13 | 14 | public class JsonStreamingDeserializerPlugin implements StreamingDeserializerPlugin { 15 | 16 | @Override 17 | public void init(PluginContext pluginContext, PluginConfiguration systemSettings) throws PluginException { 18 | } 19 | 20 | @Override 21 | public ObjectDefinition getUserSettingsDefinition() { 22 | return null; 23 | } 24 | 25 | @Override 26 | public ObjectDefinition getSystemSettingsDefinition() { 27 | return null; 28 | } 29 | 30 | @Override 31 | public StreamingDeserializer createDeserializer(PluginConfiguration pluginConfiguration) { 32 | return new JsonStreamingDeserializer(); 33 | } 34 | 35 | @Override 36 | public boolean canHandleExtension(String extension) { 37 | return extension.contentEquals("json"); 38 | } 39 | 40 | @Override 41 | public Set getSupportedSchemas() { 42 | Set set = new HashSet<>(); 43 | set.add(Schema.IFC2X3TC1); 44 | set.add(Schema.IFC4); 45 | return set; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/compare/AbstractModelCompare.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.compare; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.util.HashMap; 21 | import java.util.List; 22 | import java.util.Map; 23 | 24 | import org.bimserver.emf.IdEObject; 25 | import org.bimserver.emf.IdEObjectImpl; 26 | import org.bimserver.models.ifc2x3tc1.IfcRoot; 27 | import org.bimserver.models.store.CompareContainer; 28 | import org.bimserver.models.store.CompareResult; 29 | import org.bimserver.models.store.CompareType; 30 | import org.bimserver.models.store.DataObject; 31 | import org.bimserver.models.store.DataValue; 32 | import org.bimserver.models.store.ListDataValue; 33 | import org.bimserver.models.store.ObjectModified; 34 | import org.bimserver.models.store.ReferenceDataValue; 35 | import org.bimserver.models.store.SimpleDataValue; 36 | import org.bimserver.models.store.StoreFactory; 37 | import org.bimserver.plugins.modelcompare.ModelCompare; 38 | import org.eclipse.emf.common.util.EList; 39 | import org.eclipse.emf.ecore.EAttribute; 40 | import org.eclipse.emf.ecore.EClass; 41 | import org.eclipse.emf.ecore.EDataType; 42 | import org.eclipse.emf.ecore.EObject; 43 | import org.eclipse.emf.ecore.EReference; 44 | import org.eclipse.emf.ecore.EStructuralFeature; 45 | 46 | public abstract class AbstractModelCompare implements ModelCompare { 47 | private final Map map = new HashMap(); 48 | 49 | public AbstractModelCompare() { 50 | } 51 | 52 | protected DataObject makeDataObject(IdEObject eObject) { 53 | DataObject dataObject = StoreFactory.eINSTANCE.createDataObject(); 54 | ((IdEObjectImpl)dataObject).setOid(eObject.getOid()); 55 | if (eObject instanceof IfcRoot) { 56 | IfcRoot ifcRoot = (IfcRoot)eObject; 57 | dataObject.setName(ifcRoot.getName()); 58 | if (ifcRoot.getGlobalId() != null) { 59 | dataObject.setGuid(ifcRoot.getGlobalId()); 60 | } 61 | } 62 | for (EStructuralFeature eStructuralFeature : eObject.eClass().getEAllStructuralFeatures()) { 63 | Object val = eObject.eGet(eStructuralFeature); 64 | if (eStructuralFeature instanceof EReference) { 65 | EReference eReference = (EReference)eStructuralFeature; 66 | if (eReference.isMany()) { 67 | ListDataValue listDataValue = StoreFactory.eINSTANCE.createListDataValue(); 68 | listDataValue.setFieldName(eReference.getName()); 69 | EList values = listDataValue.getValues(); 70 | for (Object v : (List)val) { 71 | IdEObject ref = (IdEObject)v; 72 | ReferenceDataValue referenceDataValue = StoreFactory.eINSTANCE.createReferenceDataValue(); 73 | referenceDataValue.setTypeName(eReference.getEType().getName()); 74 | ((IdEObjectImpl)referenceDataValue).setOid(ref.getOid()); 75 | values.add(referenceDataValue); 76 | } 77 | dataObject.getValues().add(listDataValue); 78 | } else { 79 | IdEObject ref = (IdEObject)val; 80 | if (ref == null) { 81 | 82 | } else { 83 | ReferenceDataValue referenceDataValue = StoreFactory.eINSTANCE.createReferenceDataValue(); 84 | referenceDataValue.setFieldName(eReference.getName()); 85 | referenceDataValue.setTypeName(eReference.getEType().getName()); 86 | ((IdEObjectImpl)referenceDataValue).setOid(ref.getOid()); 87 | dataObject.getValues().add(referenceDataValue); 88 | } 89 | } 90 | } else if (eStructuralFeature instanceof EAttribute) { 91 | EAttribute eAttribute = (EAttribute)eStructuralFeature; 92 | if (eAttribute.isMany()) { 93 | ListDataValue listDataValue = StoreFactory.eINSTANCE.createListDataValue(); 94 | listDataValue.setFieldName(eAttribute.getName()); 95 | EList values = listDataValue.getValues(); 96 | for (Object v : (List)val) { 97 | SimpleDataValue simpleDataValue = StoreFactory.eINSTANCE.createSimpleDataValue(); 98 | simpleDataValue.setFieldName(eAttribute.getName()); 99 | simpleDataValue.setStringValue(v.toString()); 100 | values.add(simpleDataValue); 101 | } 102 | dataObject.getValues().add(listDataValue); 103 | } else { 104 | SimpleDataValue simpleDataValue = StoreFactory.eINSTANCE.createSimpleDataValue(); 105 | simpleDataValue.setFieldName(eAttribute.getName()); 106 | simpleDataValue.setStringValue(val == null ? "null" : val.toString()); 107 | } 108 | } 109 | } 110 | return dataObject; 111 | } 112 | 113 | protected Map getMap() { 114 | return map; 115 | } 116 | 117 | protected CompareContainer getCompareContainer(EClass eClass) { 118 | if (!map.containsKey(eClass)) { 119 | CompareContainer compareContainer = StoreFactory.eINSTANCE.createCompareContainer(); 120 | compareContainer.setType(eClass.getName()); 121 | map.put(eClass, compareContainer); 122 | return compareContainer; 123 | } 124 | return map.get(eClass); 125 | } 126 | 127 | protected void compareEObjects(EClass originalQueryClass, IdEObject eObject1, IdEObject eObject2, CompareResult result, CompareType sCompareType) { 128 | if (eObject1.eClass() != eObject2.eClass()) { 129 | return; 130 | } 131 | EClass eClass = eObject1.eClass(); 132 | if (sCompareType == CompareType.ALL || sCompareType == CompareType.MODIFY) { 133 | for (EStructuralFeature eStructuralFeature : eClass.getEAllStructuralFeatures()) { 134 | if (true) { 135 | if (eStructuralFeature.getEAnnotation("hidden") != null) { 136 | continue; 137 | } 138 | Object value1 = eObject1.eGet(eStructuralFeature); 139 | Object value2 = eObject2.eGet(eStructuralFeature); 140 | if (eStructuralFeature.isMany()) { 141 | } else { 142 | if (eStructuralFeature.getEType() instanceof EClass) { 143 | if (value1 == null && value2 == null) { 144 | } else if (value1 == null && value2 != null) { 145 | EClass value2Class = ((EObject) value2).eClass(); 146 | if (value2Class.getEAnnotation("wrapped") != null) { 147 | Object realVal2 = ((EObject) value2).eGet(value2Class.getEStructuralFeature("wrappedValue")); 148 | ObjectModified objectModified = StoreFactory.eINSTANCE.createObjectModified(); 149 | objectModified.setDataObject(makeDataObject(eObject1)); 150 | objectModified.setFieldName(eStructuralFeature.getName()); 151 | objectModified.setOldValue(null); 152 | objectModified.setNewValue(realVal2.toString()); 153 | getCompareContainer(eObject1.eClass()).getItems().add(objectModified); 154 | } 155 | } else if (value1 != null && value2 == null) { 156 | EClass value1Class = ((EObject) value1).eClass(); 157 | if (value1Class.getEAnnotation("wrapped") != null) { 158 | Object realVal1 = ((EObject) value1).eGet(value1Class.getEStructuralFeature("wrappedValue")); 159 | ObjectModified objectModified = StoreFactory.eINSTANCE.createObjectModified(); 160 | objectModified.setDataObject(makeDataObject(eObject1)); 161 | objectModified.setFieldName(eStructuralFeature.getName()); 162 | objectModified.setOldValue(realVal1.toString()); 163 | objectModified.setNewValue(null); 164 | getCompareContainer(eObject1.eClass()).getItems().add(objectModified); 165 | } 166 | } else { 167 | EClass value1Class = ((EObject) value1).eClass(); 168 | if (((EObject) value1).eClass().getEAnnotation("wrapped") != null) { 169 | Object realVal1 = ((EObject) value1).eGet(value1Class.getEStructuralFeature("wrappedValue")); 170 | Object realVal2 = ((EObject) value2).eGet(value1Class.getEStructuralFeature("wrappedValue")); 171 | if (!realVal1.equals(realVal2)) { 172 | ObjectModified objectModified = StoreFactory.eINSTANCE.createObjectModified(); 173 | objectModified.setDataObject(makeDataObject(eObject1)); 174 | objectModified.setFieldName(eStructuralFeature.getName()); 175 | objectModified.setOldValue(realVal1.toString()); 176 | objectModified.setNewValue(realVal2.toString()); 177 | getCompareContainer(eObject1.eClass()).getItems().add(objectModified); 178 | } 179 | } 180 | } 181 | } else if (eStructuralFeature.getEType() instanceof EDataType) { 182 | if (value1 == null && value2 == null) { 183 | } else if (value1 == null && value2 != null) { 184 | ObjectModified objectModified = StoreFactory.eINSTANCE.createObjectModified(); 185 | objectModified.setDataObject(makeDataObject(eObject1)); 186 | objectModified.setFieldName(eStructuralFeature.getName()); 187 | objectModified.setOldValue(null); 188 | objectModified.setNewValue(value2.toString()); 189 | getCompareContainer(eObject1.eClass()).getItems().add(objectModified); 190 | } else if (value1 != null && value2 == null) { 191 | ObjectModified objectModified = StoreFactory.eINSTANCE.createObjectModified(); 192 | objectModified.setDataObject(makeDataObject(eObject1)); 193 | objectModified.setFieldName(eStructuralFeature.getName()); 194 | objectModified.setOldValue(value1.toString()); 195 | objectModified.setNewValue(null); 196 | getCompareContainer(eObject1.eClass()).getItems().add(objectModified); 197 | } else if (!value1.equals(value2)) { 198 | ObjectModified objectModified = StoreFactory.eINSTANCE.createObjectModified(); 199 | objectModified.setDataObject(makeDataObject(eObject1)); 200 | objectModified.setFieldName(eStructuralFeature.getName()); 201 | objectModified.setOldValue(value1.toString()); 202 | objectModified.setNewValue(value2.toString()); 203 | getCompareContainer(eObject1.eClass()).getItems().add(objectModified); 204 | } 205 | } 206 | } 207 | } 208 | } 209 | } 210 | } 211 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/compare/CompareService.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.compare; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.util.List; 21 | 22 | import javax.activation.DataHandler; 23 | 24 | import org.bimserver.interfaces.objects.SCompareType; 25 | import org.bimserver.interfaces.objects.SDeserializerPluginConfiguration; 26 | import org.bimserver.interfaces.objects.SDownloadResult; 27 | import org.bimserver.interfaces.objects.SModelComparePluginConfiguration; 28 | import org.bimserver.interfaces.objects.SObjectType; 29 | import org.bimserver.interfaces.objects.SProject; 30 | import org.bimserver.interfaces.objects.SRevision; 31 | import org.bimserver.interfaces.objects.SSerializerPluginConfiguration; 32 | import org.bimserver.interfaces.objects.SService; 33 | import org.bimserver.models.store.ServiceDescriptor; 34 | import org.bimserver.plugins.services.AbstractService; 35 | import org.bimserver.plugins.services.BimServerClientInterface; 36 | import org.bimserver.shared.exceptions.UserException; 37 | import org.slf4j.Logger; 38 | import org.slf4j.LoggerFactory; 39 | 40 | public class CompareService extends AbstractService { 41 | 42 | private static final Logger LOGGER = LoggerFactory.getLogger(CompareService.class); 43 | 44 | @Override 45 | public void newRevision(RunningService runningService, BimServerClientInterface bimServerClientInterface, long poid, long roid, String userToken, long soid, SObjectType settings) throws Exception { 46 | SRevision revision = bimServerClientInterface.getServiceInterface().getRevision(roid); 47 | if (revision.getServicesLinked().contains(soid)) { 48 | throw new UserException("Not running service on this revision because it was generated by the same service"); 49 | } 50 | if (revision.getServiceId() == soid) { 51 | throw new UserException("Not running service on this revision because it was generated by the same service"); 52 | } 53 | List allModelCompares = bimServerClientInterface.getPluginInterface().getAllModelCompares(true); 54 | SModelComparePluginConfiguration modelComparePlugin = null; 55 | for (SModelComparePluginConfiguration modelComparePluginConfiguration : allModelCompares) { 56 | if (modelComparePluginConfiguration.getName().equals("GUID based")) { 57 | modelComparePlugin = modelComparePluginConfiguration; 58 | } 59 | } 60 | if (modelComparePlugin == null) { 61 | throw new UserException("No GUID based model compare plugin found"); 62 | } 63 | SProject project = bimServerClientInterface.getServiceInterface().getProjectByPoid(poid); 64 | if (project.getRevisions().size() < 2) { 65 | throw new UserException("At least 2 revision required to be able to run compare"); 66 | } 67 | Long secondLastRoid = project.getRevisions().get(project.getRevisions().size() - 2); 68 | 69 | SSerializerPluginConfiguration serializerByContentType = bimServerClientInterface.getServiceInterface().getSerializerByContentType("application/ifc"); 70 | 71 | Long topicId = bimServerClientInterface.getServiceInterface().downloadCompareResults(serializerByContentType.getOid(), secondLastRoid, roid, modelComparePlugin.getOid(), SCompareType.ALL, true); 72 | SDownloadResult downloadData = bimServerClientInterface.getServiceInterface().getDownloadData(topicId); 73 | DataHandler file = downloadData.getFile(); 74 | 75 | SDeserializerPluginConfiguration suggestedDeserializerForExtension = bimServerClientInterface.getServiceInterface().getSuggestedDeserializerForExtension("ifc", poid); 76 | 77 | LOGGER.info("Using " + suggestedDeserializerForExtension.getName() + " as serializer"); 78 | 79 | SService service = bimServerClientInterface.getServiceInterface().getService(soid); 80 | 81 | bimServerClientInterface.checkinSync(service.getWriteRevisionId(), "test", suggestedDeserializerForExtension.getOid(), false, -1, "", file.getInputStream()); 82 | } 83 | 84 | @Override 85 | public void addRequiredRights(ServiceDescriptor serviceDescriptor) { 86 | serviceDescriptor.setWriteRevision(true); 87 | } 88 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/compare/GuidBasedModelCompare.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.compare; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import org.bimserver.emf.IdEObject; 21 | import org.bimserver.emf.IfcModelInterface; 22 | import org.bimserver.emf.PackageMetaData; 23 | import org.bimserver.models.store.CompareContainer; 24 | import org.bimserver.models.store.CompareResult; 25 | import org.bimserver.models.store.CompareType; 26 | import org.bimserver.models.store.ObjectAdded; 27 | import org.bimserver.models.store.ObjectRemoved; 28 | import org.bimserver.models.store.StoreFactory; 29 | import org.bimserver.plugins.modelcompare.ModelCompareException; 30 | import org.eclipse.emf.ecore.EClass; 31 | 32 | public class GuidBasedModelCompare extends AbstractModelCompare{ 33 | 34 | public GuidBasedModelCompare() { 35 | super(); 36 | } 37 | 38 | public CompareResult compare(IfcModelInterface model1, IfcModelInterface model2, CompareType compareType) throws ModelCompareException { 39 | CompareResult result = StoreFactory.eINSTANCE.createCompareResult(); 40 | try { 41 | PackageMetaData packageMetaData = model1.getPackageMetaData(); 42 | for (EClass eClass : packageMetaData.getAllSubClasses(packageMetaData.getEClass("IfcRoot"))) { 43 | for (String guid : model1.getGuids(eClass)) { 44 | IdEObject eObject1 = model1.getByGuid(guid); 45 | IdEObject eObject2 = model2.getByGuid(guid); 46 | if (eObject2 == null) { 47 | if (compareType == CompareType.ALL || compareType == CompareType.DELETE) { 48 | ObjectRemoved objectRemoved = StoreFactory.eINSTANCE.createObjectRemoved(); 49 | objectRemoved.setDataObject(makeDataObject(eObject1)); 50 | getCompareContainer(eObject1.eClass()).getItems().add(objectRemoved); 51 | } 52 | } 53 | } 54 | for (String guid : model2.getGuids(eClass)) { 55 | IdEObject eObject1 = model1.getByGuid(guid); 56 | IdEObject eObject2 = model2.getByGuid(guid); 57 | if (eObject1 == null) { 58 | if (compareType == CompareType.ALL || compareType == CompareType.ADD) { 59 | ObjectAdded objectAdded = StoreFactory.eINSTANCE.createObjectAdded(); 60 | objectAdded.setDataObject(makeDataObject(eObject2)); 61 | getCompareContainer(eObject2.eClass()).getItems().add(objectAdded); 62 | } 63 | } else { 64 | compareEObjects(eClass, eObject1, eObject2, result, compareType); 65 | } 66 | } 67 | } 68 | } catch (Exception e) { 69 | throw new ModelCompareException(e); 70 | } 71 | for (CompareContainer compareContainer : getMap().values()) { 72 | result.getItems().add(compareContainer); 73 | } 74 | return result; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/compare/GuidBasedModelComparePlugin.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.compare; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.util.HashSet; 21 | import java.util.Set; 22 | 23 | import org.bimserver.emf.PackageMetaData; 24 | import org.bimserver.models.store.ObjectDefinition; 25 | import org.bimserver.plugins.PluginConfiguration; 26 | import org.bimserver.plugins.PluginContext; 27 | import org.bimserver.plugins.modelcompare.ModelCompare; 28 | import org.bimserver.plugins.modelcompare.ModelCompareException; 29 | import org.bimserver.plugins.modelcompare.ModelComparePlugin; 30 | import org.bimserver.shared.exceptions.PluginException; 31 | import org.eclipse.emf.ecore.EPackage; 32 | 33 | public class GuidBasedModelComparePlugin implements ModelComparePlugin { 34 | 35 | private PluginContext pluginContext; 36 | 37 | @Override 38 | public void init(PluginContext pluginContext, PluginConfiguration systemSettings) throws PluginException { 39 | this.pluginContext = pluginContext; 40 | } 41 | 42 | @Override 43 | public ModelCompare createModelCompare(PluginConfiguration pluginConfiguration, PackageMetaData packageMetaData) throws ModelCompareException { 44 | Set packages = new HashSet<>(); 45 | packages.add(packageMetaData.getEPackage()); 46 | return new GuidBasedModelCompare(); 47 | } 48 | 49 | @Override 50 | public ObjectDefinition getUserSettingsDefinition() { 51 | return null; 52 | } 53 | 54 | @Override 55 | public ObjectDefinition getSystemSettingsDefinition() { 56 | return null; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/compare/NameBasedModelCompare.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.compare; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import org.bimserver.emf.IdEObject; 21 | import org.bimserver.emf.IfcModelInterface; 22 | import org.bimserver.emf.PackageMetaData; 23 | import org.bimserver.models.store.CompareContainer; 24 | import org.bimserver.models.store.CompareResult; 25 | import org.bimserver.models.store.CompareType; 26 | import org.bimserver.models.store.ObjectAdded; 27 | import org.bimserver.models.store.ObjectRemoved; 28 | import org.bimserver.models.store.StoreFactory; 29 | import org.bimserver.plugins.modelcompare.ModelCompareException; 30 | import org.eclipse.emf.ecore.EClass; 31 | 32 | public class NameBasedModelCompare extends AbstractModelCompare { 33 | 34 | public NameBasedModelCompare() { 35 | super(); 36 | } 37 | 38 | public CompareResult compare(IfcModelInterface model1, IfcModelInterface model2, CompareType compareType) 39 | throws ModelCompareException { 40 | CompareResult result = StoreFactory.eINSTANCE.createCompareResult(); 41 | try { 42 | PackageMetaData packageMetaData = model1.getPackageMetaData(); 43 | for (EClass eClass : packageMetaData.getAllSubClasses(packageMetaData.getEClass("IfcRoot"))) { 44 | for (String name : model1.getNames(eClass)) { 45 | IdEObject eObject1 = model1.getByName(eClass, name); 46 | IdEObject eObject2 = model2.getByName(eClass, name); 47 | if (eObject2 == null) { 48 | if (compareType == CompareType.ALL || compareType == CompareType.DELETE) { 49 | ObjectRemoved objectRemoved = StoreFactory.eINSTANCE.createObjectRemoved(); 50 | objectRemoved.setDataObject(makeDataObject(eObject1)); 51 | getCompareContainer(eObject1.eClass()).getItems().add(objectRemoved); 52 | } 53 | } 54 | } 55 | for (String name : model2.getNames(eClass)) { 56 | IdEObject eObject1 = model1.getByName(eClass, name); 57 | IdEObject eObject2 = model2.getByName(eClass, name); 58 | if (eObject1 == null) { 59 | if (compareType == CompareType.ALL || compareType == CompareType.ADD) { 60 | ObjectAdded objectAdded = StoreFactory.eINSTANCE.createObjectAdded(); 61 | objectAdded.setDataObject(makeDataObject(eObject2)); 62 | getCompareContainer(eObject2.eClass()).getItems().add(objectAdded); 63 | } 64 | } else { 65 | compareEObjects(eClass, eObject1, eObject2, result, compareType); 66 | } 67 | } 68 | } 69 | } catch (Exception e) { 70 | throw new ModelCompareException(e); 71 | } 72 | for (CompareContainer compareContainer : getMap().values()) { 73 | result.getItems().add(compareContainer); 74 | } 75 | return result; 76 | } 77 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/compare/NameBasedModelComparePlugin.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.compare; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.util.HashSet; 21 | import java.util.Set; 22 | 23 | import org.bimserver.emf.PackageMetaData; 24 | import org.bimserver.models.store.ObjectDefinition; 25 | import org.bimserver.plugins.PluginConfiguration; 26 | import org.bimserver.plugins.PluginContext; 27 | import org.bimserver.plugins.modelcompare.ModelCompare; 28 | import org.bimserver.plugins.modelcompare.ModelCompareException; 29 | import org.bimserver.plugins.modelcompare.ModelComparePlugin; 30 | import org.bimserver.shared.exceptions.PluginException; 31 | import org.eclipse.emf.ecore.EPackage; 32 | 33 | public class NameBasedModelComparePlugin implements ModelComparePlugin { 34 | 35 | private PluginContext pluginContext; 36 | 37 | @Override 38 | public void init(PluginContext pluginContext, PluginConfiguration systemSettings) throws PluginException { 39 | this.pluginContext = pluginContext; 40 | } 41 | 42 | @Override 43 | public ModelCompare createModelCompare(PluginConfiguration pluginConfiguration, PackageMetaData packageMetaData) throws ModelCompareException { 44 | Set packages = new HashSet<>(); 45 | packages.add(packageMetaData.getEPackage()); 46 | return new NameBasedModelCompare(); 47 | } 48 | 49 | @Override 50 | public ObjectDefinition getUserSettingsDefinition() { 51 | return null; 52 | } 53 | 54 | @Override 55 | public ObjectDefinition getSystemSettingsDefinition() { 56 | return null; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/deserializer/DetectIfcVersion.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.deserializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.io.BufferedReader; 21 | import java.io.ByteArrayInputStream; 22 | import java.io.IOException; 23 | import java.io.InputStream; 24 | import java.io.InputStreamReader; 25 | import java.nio.file.Files; 26 | import java.nio.file.Path; 27 | import java.nio.file.Paths; 28 | import java.util.zip.ZipEntry; 29 | import java.util.zip.ZipInputStream; 30 | 31 | import org.apache.commons.io.IOUtils; 32 | import org.bimserver.BimserverDatabaseException; 33 | import org.bimserver.emf.MetaDataException; 34 | import org.bimserver.models.store.IfcHeader; 35 | import org.bimserver.models.store.StoreFactory; 36 | import org.bimserver.plugins.deserializers.DeserializeException; 37 | import org.bimserver.plugins.deserializers.DeserializerErrorCode; 38 | import org.bimserver.utils.FakeClosingInputStream; 39 | 40 | import com.google.common.base.Charsets; 41 | 42 | public class DetectIfcVersion { 43 | private int lineNumber; 44 | private IfcHeader ifcHeader = StoreFactory.eINSTANCE.createIfcHeader(); 45 | 46 | public static void main(String[] args) { 47 | Path path = Paths.get("C:\\Bulk\\Single\\beam-standard-case.ifc"); 48 | byte[] head = new byte[4096]; 49 | try { 50 | IOUtils.readFully(Files.newInputStream(path), head); 51 | System.out.println(new DetectIfcVersion().detectVersion(head, false)); 52 | } catch (IOException e) { 53 | e.printStackTrace(); 54 | } catch (DeserializeException e) { 55 | e.printStackTrace(); 56 | } 57 | } 58 | 59 | public String detectVersion(byte[] head, boolean usesZip) throws DeserializeException, IOException { 60 | if (usesZip) { 61 | ZipInputStream zipInputStream = new ZipInputStream(new ByteArrayInputStream(head)); 62 | ZipEntry nextEntry = zipInputStream.getNextEntry(); 63 | if (nextEntry == null) { 64 | throw new DeserializeException(DeserializerErrorCode.IFCZIP_CONTAINS_NO_IFC_FILES, "Zip files must contain exactly one IFC-file, this zip-file looks empty"); 65 | } 66 | if (nextEntry.getName().toUpperCase().endsWith(".IFC")) { 67 | FakeClosingInputStream fakeClosingInputStream = new FakeClosingInputStream(zipInputStream); 68 | read(fakeClosingInputStream); 69 | } 70 | } else { 71 | read(new ByteArrayInputStream(head)); 72 | } 73 | if (ifcHeader.getIfcSchemaVersion() == null) { 74 | throw new DeserializeException(DeserializerErrorCode.NO_IFC_SCHEMA_VERSION_FOUND, "No IFC schema found"); 75 | } 76 | return ifcHeader.getIfcSchemaVersion(); 77 | } 78 | 79 | private long read(InputStream inputStream) throws DeserializeException { 80 | BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, Charsets.UTF_8)); 81 | lineNumber = 0; 82 | try { 83 | String line = reader.readLine(); 84 | if (line == null) { 85 | throw new DeserializeException(DeserializerErrorCode.UNEXPECTED_END_OF_STREAM_WHILE_READING_FIRST_LINE, 0, "Unexpected end of stream reading first line"); 86 | } 87 | while (line != null) { 88 | try { 89 | while (!processLine(line.trim())) { 90 | String readLine = reader.readLine(); 91 | if (readLine == null) { 92 | break; 93 | } 94 | line += readLine; 95 | lineNumber++; 96 | } 97 | } catch (Exception e) { 98 | if (e instanceof DeserializeException) { 99 | throw (DeserializeException)e; 100 | } else { 101 | throw new DeserializeException(DeserializerErrorCode.UNKNOWN_DESERIALIZER_ERROR, lineNumber, " (" + e.getMessage() + ") " + line, e); 102 | } 103 | } 104 | 105 | if (ifcHeader.getIfcSchemaVersion() != null) { 106 | return lineNumber; 107 | } 108 | line = reader.readLine(); 109 | lineNumber++; 110 | } 111 | return lineNumber; 112 | } catch (IOException e) { 113 | throw new DeserializeException(DeserializerErrorCode.IO_EXCEPTION, lineNumber, e); 114 | } 115 | } 116 | 117 | public enum Mode { 118 | HEADER, DATA, FOOTER, DONE 119 | } 120 | 121 | private boolean processLine(String line) throws DeserializeException, MetaDataException, BimserverDatabaseException { 122 | if (line.length() > 0) { 123 | if (line.endsWith(";")) { 124 | processHeader(line); 125 | return true; 126 | } else { 127 | return false; 128 | } 129 | } 130 | if (line.equals("DATA;")) { 131 | return true; 132 | } 133 | return true; 134 | } 135 | 136 | private boolean processHeader(String line) throws DeserializeException { 137 | if (line.startsWith("/*")) { 138 | if (line.contains("*/")) { 139 | line = line.substring(line.indexOf("*/") + 2); 140 | } 141 | } 142 | if (line.startsWith("FILE_SCHEMA")) { 143 | String fileschema = line.substring("FILE_SCHEMA".length()).trim(); 144 | new IfcHeaderParser().parseFileSchema(fileschema.substring(1, fileschema.length() - 2), ifcHeader, lineNumber); 145 | return true; 146 | } else if (line.startsWith("ENDSEC;")) { 147 | return true; 148 | } 149 | return false; 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/deserializer/Ifc2x3tc1StepDeserializer.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.deserializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import org.bimserver.emf.Schema; 21 | 22 | /** 23 | * @author Ruben de Laat 24 | * Replaced by the streaming deserializers 25 | */ 26 | @Deprecated 27 | public class Ifc2x3tc1StepDeserializer extends IfcStepDeserializer { 28 | 29 | public Ifc2x3tc1StepDeserializer() { 30 | super(Schema.IFC2X3TC1); 31 | } 32 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/deserializer/Ifc2x3tc1StepDeserializerPlugin.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.deserializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.util.Collections; 21 | import java.util.Set; 22 | 23 | import org.bimserver.emf.Schema; 24 | import org.bimserver.plugins.PluginConfiguration; 25 | import org.bimserver.plugins.deserializers.Deserializer; 26 | 27 | /** 28 | * @author Ruben de Laat 29 | * Replaced by the streaming deserializers 30 | */ 31 | @Deprecated 32 | public class Ifc2x3tc1StepDeserializerPlugin extends IfcStepDeserializerPlugin { 33 | @Override 34 | public Deserializer createDeserializer(PluginConfiguration pluginConfiguration) { 35 | return new Ifc2x3tc1StepDeserializer(); 36 | } 37 | 38 | @Override 39 | public Set getSupportedSchemas() { 40 | return Collections.singleton(Schema.IFC2X3TC1); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/deserializer/Ifc2x3tc1StepStreamingDeserializer.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.deserializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | public class Ifc2x3tc1StepStreamingDeserializer extends IfcStepStreamingDeserializer { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/deserializer/Ifc2x3tc1StepStreamingDeserializerPlugin.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.deserializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.util.Collections; 21 | import java.util.Set; 22 | 23 | import org.bimserver.emf.Schema; 24 | import org.bimserver.plugins.PluginConfiguration; 25 | import org.bimserver.plugins.deserializers.StreamingDeserializer; 26 | 27 | public class Ifc2x3tc1StepStreamingDeserializerPlugin extends IfcStepStreamingDeserializerPlugin { 28 | 29 | @Override 30 | public StreamingDeserializer createDeserializer(PluginConfiguration pluginConfiguration) { 31 | return new Ifc2x3tc1StepStreamingDeserializer(); 32 | } 33 | 34 | @Override 35 | public Set getSupportedSchemas() { 36 | return Collections.singleton(Schema.IFC2X3TC1); 37 | } 38 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/deserializer/Ifc4StepDeserializer.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.deserializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import org.bimserver.emf.Schema; 21 | 22 | /** 23 | * @author Ruben de Laat 24 | * Replaced by the streaming deserializers 25 | */ 26 | @Deprecated 27 | public class Ifc4StepDeserializer extends IfcStepDeserializer { 28 | 29 | public Ifc4StepDeserializer(Schema schema) { 30 | super(schema); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/deserializer/Ifc4StepDeserializerPlugin.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.deserializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.util.HashSet; 21 | import java.util.Set; 22 | 23 | import org.bimserver.emf.Schema; 24 | import org.bimserver.plugins.PluginConfiguration; 25 | import org.bimserver.plugins.deserializers.Deserializer; 26 | 27 | /** 28 | * @author Ruben de Laat 29 | * Replaced by the streaming deserializers 30 | */ 31 | @Deprecated 32 | public class Ifc4StepDeserializerPlugin extends IfcStepDeserializerPlugin { 33 | @Override 34 | public Deserializer createDeserializer(PluginConfiguration pluginConfiguration) { 35 | return new Ifc4StepDeserializer(Schema.IFC4); 36 | } 37 | 38 | @Override 39 | public Set getSupportedSchemas() { 40 | Set set = new HashSet<>(); 41 | set.add(Schema.IFC4); 42 | return set; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/deserializer/Ifc4StepStreamingDeserializer.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.deserializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | public class Ifc4StepStreamingDeserializer extends IfcStepStreamingDeserializer { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/deserializer/Ifc4StepStreamingDeserializerPlugin.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.deserializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.util.Collections; 21 | import java.util.Set; 22 | 23 | import org.bimserver.emf.Schema; 24 | import org.bimserver.plugins.PluginConfiguration; 25 | import org.bimserver.plugins.deserializers.StreamingDeserializer; 26 | 27 | public class Ifc4StepStreamingDeserializerPlugin extends IfcStepStreamingDeserializerPlugin { 28 | 29 | @Override 30 | public StreamingDeserializer createDeserializer(PluginConfiguration pluginConfiguration) { 31 | return new Ifc4StepStreamingDeserializer(); 32 | } 33 | 34 | @Override 35 | public Set getSupportedSchemas() { 36 | return Collections.singleton(Schema.IFC4); 37 | } 38 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/deserializer/IfcHeaderParser.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.deserializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.text.ParseException; 21 | import java.text.SimpleDateFormat; 22 | 23 | import org.bimserver.models.store.IfcHeader; 24 | import org.bimserver.models.store.StoreFactory; 25 | import org.bimserver.plugins.deserializers.DeserializeException; 26 | import org.bimserver.plugins.deserializers.DeserializerErrorCode; 27 | 28 | public class IfcHeaderParser { 29 | 30 | public IfcHeader parseFileName(String line, long lineNumber) throws DeserializeException, ParseException { 31 | IfcHeader ifcHeader = StoreFactory.eINSTANCE.createIfcHeader(); 32 | parseFileName(line, ifcHeader, lineNumber); 33 | return ifcHeader; 34 | } 35 | 36 | public IfcHeader parseDescription(String line, long lineNumber) throws DeserializeException, ParseException { 37 | IfcHeader ifcHeader = StoreFactory.eINSTANCE.createIfcHeader(); 38 | parseDescription(line, ifcHeader, lineNumber); 39 | return ifcHeader; 40 | } 41 | 42 | public void parseDescription(String line, IfcHeader ifcHeader, long lineNumber) throws DeserializeException { 43 | line = line.replace("\r\n", ""); 44 | 45 | StepParser stepParser = new StepParser(line); 46 | StepParser startList = stepParser.startList(); 47 | while (startList.hasMoreListItems()) { 48 | ifcHeader.getDescription().add(startList.readNextString(lineNumber)); 49 | } 50 | ifcHeader.setImplementationLevel(stepParser.readNextString(lineNumber)); 51 | } 52 | 53 | public void parseFileName(String line, IfcHeader ifcHeader, long lineNumber) throws DeserializeException { 54 | line = line.replace("\r\n", ""); 55 | SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'kk:mm:ss"); 56 | 57 | StepParser stepParser = new StepParser(line); 58 | ifcHeader.setFilename(stepParser.readNextString(lineNumber)); 59 | try { 60 | ifcHeader.setTimeStamp(dateFormatter.parse(stepParser.readNextString(lineNumber))); 61 | } catch (ParseException e) { 62 | throw new DeserializeException(DeserializerErrorCode.INVALID_DATETIME_LITERAL, "Datetime parse error", e); 63 | } 64 | StepParser startList = stepParser.startList(); 65 | while (startList.hasMoreListItems()) { 66 | ifcHeader.getAuthor().add(startList.readNextString(lineNumber)); 67 | } 68 | startList = stepParser.startList(); 69 | while (startList.hasMoreListItems()) { 70 | ifcHeader.getOrganization().add(startList.readNextString(lineNumber)); 71 | } 72 | ifcHeader.setPreProcessorVersion(stepParser.readNextString(lineNumber)); 73 | ifcHeader.setOriginatingSystem(stepParser.readNextString(lineNumber)); 74 | ifcHeader.setAuthorization(stepParser.readNextString(lineNumber)); 75 | } 76 | 77 | public void parseFileSchema(String line, IfcHeader ifcHeader, long lineNumber) throws DeserializeException { 78 | line = line.replace("\r\n", ""); 79 | StepParser stepParser = new StepParser(line); 80 | ifcHeader.setIfcSchemaVersion(stepParser.readNextString(lineNumber)); 81 | } 82 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/deserializer/IfcParserWriterUtils.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.deserializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.io.IOException; 21 | import java.io.OutputStream; 22 | import java.io.PrintWriter; 23 | import java.math.BigInteger; 24 | import java.nio.ByteBuffer; 25 | import java.nio.CharBuffer; 26 | import java.nio.charset.Charset; 27 | import java.nio.charset.UnsupportedCharsetException; 28 | 29 | import org.apache.commons.codec.DecoderException; 30 | import org.apache.commons.codec.binary.Hex; 31 | import org.bimserver.emf.IdEObject; 32 | import org.bimserver.emf.PackageMetaData; 33 | import org.bimserver.models.ifc4.Ifc4Package; 34 | import org.bimserver.plugins.deserializers.DeserializeException; 35 | import org.bimserver.plugins.deserializers.DeserializerErrorCode; 36 | import org.bimserver.plugins.serializers.SerializerException; 37 | import org.eclipse.emf.common.util.Enumerator; 38 | import org.eclipse.emf.ecore.EEnum; 39 | import org.eclipse.emf.ecore.EStructuralFeature; 40 | import org.slf4j.Logger; 41 | import org.slf4j.LoggerFactory; 42 | 43 | import com.google.common.base.Charsets; 44 | 45 | public class IfcParserWriterUtils { 46 | private static final Logger LOGGER = LoggerFactory.getLogger(IfcParserWriterUtils.class); 47 | private static final boolean USE_ISO_8859_1 = false; 48 | 49 | public static Object convertSimpleValue(PackageMetaData packageMetaData, EStructuralFeature eStructuralFeature, Class instanceClass, String value, long lineNumber) throws DeserializeException { 50 | if (!value.equals("")) { 51 | if (instanceClass == Integer.class || instanceClass == int.class) { 52 | try { 53 | return Integer.parseInt(value); 54 | } catch (NumberFormatException e) { 55 | try { 56 | new BigInteger(value); 57 | } catch (Exception e1) { 58 | throw e; // re-throw, this was a formatting problem 59 | } 60 | throw new NumberFormatException("Input is outside of Integer range (" + value + ")"); 61 | } 62 | } else if (instanceClass == Long.class || instanceClass == long.class) { 63 | if (eStructuralFeature == Ifc4Package.eINSTANCE.getIfcRelConnectsPathElements_RelatingPriorities() || eStructuralFeature == Ifc4Package.eINSTANCE.getIfcRelConnectsPathElements_RelatedPriorities() || eStructuralFeature == Ifc4Package.eINSTANCE.getIfcMaterialProfile_Priority()) { 64 | // HACK to read IFC4 (no add1/add2) files 65 | if (value.contains(".")) { // Reals require a decimal point, so we can use that to determine double/int 66 | return (long)(100 * Double.parseDouble(value)); 67 | } else { 68 | // No conversion 69 | return (long)(Long.parseLong(value)); 70 | } 71 | } 72 | return Long.parseLong(value); 73 | } else if (instanceClass == Boolean.class || instanceClass == boolean.class) { 74 | return Boolean.parseBoolean(value); 75 | } else if (instanceClass.getSimpleName().equals("Tristate")) { 76 | EEnum eEnum = packageMetaData.getEEnum("Tristate"); 77 | if (value.toString().equals("TRUE")) { 78 | return eEnum.getEEnumLiteral("TRUE"); 79 | } else if (value.toString().equals("FALSE")) { 80 | return eEnum.getEEnumLiteral("FALSE"); 81 | } else if (value.toString().equals("UNDEFINED")) { 82 | return eEnum.getEEnumLiteral("UNDEFINED"); 83 | } 84 | throw new DeserializeException(DeserializerErrorCode.NON_EXISTING_ENUM_LITERAL_USED, lineNumber, "Unknown value: " + value); 85 | } else if (instanceClass == Double.class || instanceClass == double.class) { 86 | try { 87 | return Double.parseDouble(value); 88 | } catch (NumberFormatException e) { 89 | throw new DeserializeException(DeserializerErrorCode.INVALID_DOUBLE_LITERAL, lineNumber, "Incorrect double floating point value: " + value, e); 90 | } 91 | } else if (instanceClass == String.class) { 92 | if (value.startsWith("'") && value.endsWith("'")) { 93 | return readString(value, lineNumber); 94 | } else { 95 | return value; 96 | } 97 | } else if (instanceClass == byte[].class) { 98 | if (value.startsWith("\"") && value.endsWith("\"")) { 99 | try { 100 | // TODO Skipping the first one here to make even... 101 | String substring = value.substring(2, value.length() - 1); 102 | byte[] decoded = Hex.decodeHex(substring.toCharArray()); 103 | return decoded; 104 | } catch (DecoderException e) { 105 | throw new DeserializeException(e); 106 | } 107 | } else { 108 | throw new DeserializeException(DeserializerErrorCode.BYTE_ARRAY_NOT_QUOTED, lineNumber, "Byte[] not starting/ending with \""); 109 | } 110 | } else if (IdEObject.class.isAssignableFrom(instanceClass)) { 111 | throw new DeserializeException(DeserializerErrorCode.UNEXPECTED_TYPE, lineNumber, instanceClass.getSimpleName() + " expected, but got \"" + value + "\""); 112 | } else { 113 | throw new DeserializeException(DeserializerErrorCode.UNIMPLEMENTED_BIMSERVER_FEATURE, lineNumber, "Unimplemented " + instanceClass); 114 | } 115 | } 116 | return null; 117 | } 118 | 119 | /** 120 | * Decode a piece of text according to ISO-10303-21 121 | * 122 | * Known possible problems: 123 | * - The order of parsing (X, X2, X4, S) at the time of writing is arbitrary (and has been changed, the S was in front before, causing problems with IFC files outputted by other software). The ISO docs don't say anything about it. 124 | * - Example: \X2\3010\X0\S\X2\301194DD540891D1\X0\, results will be different depending on whether the 'X2' is parsed first or the 'S' 125 | * - This code will process the output of one encoding phase, and possibly use it in the next phase, this is most definitely not according to the standard. Somehow it should be marked which parts are still up for parsing and which parst aren't 126 | * - Overall structure of the code is quite error prone, using a well known parser library/strategy might be better 127 | * - One more note of frustration: It is completely insane to encode text within text 128 | * 129 | * 130 | * @param value The original value 131 | * @param lineNumber, used for throwing exceptions with line numbers 132 | * @return The decoded string 133 | * @throws DeserializeException 134 | */ 135 | public static String readString(String value, long lineNumber) throws DeserializeException { 136 | String result = value.substring(1, value.length() - 1); 137 | // Replace all '' with ' 138 | while (result.contains("''")) { 139 | int index = result.indexOf("''"); 140 | result = result.substring(0, index) + "'" + result.substring(index + 2); 141 | } 142 | return new StringDecoder(result, lineNumber).decode(); 143 | } 144 | 145 | public static void writePrimitive(Object val, OutputStream outputStream) throws SerializerException, IOException { 146 | if (val.getClass().getSimpleName().equals("Tristate")) { 147 | if (val.toString().equals("TRUE")) { 148 | outputStream.write(".T.".getBytes(Charsets.UTF_8)); 149 | } else if (val.toString().equals("FALSE")) { 150 | outputStream.write(".F.".getBytes(Charsets.UTF_8)); 151 | } else if (val.toString().equals("UNDEFINED")) { 152 | outputStream.write(".U.".getBytes(Charsets.UTF_8)); 153 | } 154 | } else if (val instanceof Double) { 155 | if (((Double)val).isInfinite() || (((Double)val).isNaN())) { 156 | LOGGER.info("Serializing infinite or NaN double as 0.0"); 157 | outputStream.write("0.0".getBytes(Charsets.UTF_8)); 158 | } else { 159 | String string = val.toString(); 160 | if (string.endsWith(".0")) { 161 | outputStream.write((string.substring(0, string.length() - 1)).getBytes(Charsets.UTF_8)); 162 | } else { 163 | outputStream.write(string.getBytes(Charsets.UTF_8)); 164 | } 165 | } 166 | } else if (val instanceof Boolean) { 167 | Boolean bool = (Boolean)val; 168 | if (bool) { 169 | outputStream.write(".T.".getBytes(Charsets.UTF_8)); 170 | } else { 171 | outputStream.write(".F.".getBytes(Charsets.UTF_8)); 172 | } 173 | } else if (val instanceof String) { 174 | outputStream.write("'".getBytes(Charsets.UTF_8)); 175 | String stringVal = (String)val; 176 | for (int i=0; i= 32 && c <= 126) { 183 | // ISO 8859-1 184 | outputStream.write(("" + c).getBytes(Charsets.UTF_8)); 185 | } else if (c < 255) { 186 | // ISO 10646 and ISO 8859-1 are the same < 255 , using ISO_8859_1 187 | outputStream.write(("\\X\\" + new String(Hex.encodeHex(Charsets.ISO_8859_1.encode(CharBuffer.wrap(new char[]{(char) c})).array())).toUpperCase()).getBytes(Charsets.UTF_8)); 188 | } else { 189 | if (USE_ISO_8859_1) { 190 | // ISO 8859-1 with -128 offset 191 | ByteBuffer encode = Charsets.ISO_8859_1.encode(new String(new char[]{(char) (c - 128)})); 192 | outputStream.write(("\\S\\" + (char)encode.get()).getBytes(Charsets.UTF_8)); 193 | } else { 194 | // The following code has not been tested (2012-04-25) 195 | // Use UCS-2 or UCS-4 196 | 197 | // TODO when multiple sequential characters should be encoded in UCS-2 or UCS-4, we don't really need to add all those \X0\ \X2\ and \X4\ chars 198 | if (Character.isLowSurrogate(c)) { 199 | throw new SerializerException("Unexpected low surrogate range char"); 200 | } else if (Character.isHighSurrogate(c)) { 201 | // We need UCS-4, this is probably never happening 202 | if (i + 1 < stringVal.length()) { 203 | char low = stringVal.charAt(i + 1); 204 | if (!Character.isLowSurrogate(low)) { 205 | throw new SerializerException("High surrogate char should be followed by char in low surrogate range"); 206 | } 207 | try { 208 | outputStream.write(("\\X4\\" + new String(Hex.encodeHex(Charset.forName("UTF-32").encode(new String(new char[]{c, low})).array())).toUpperCase() + "\\X0\\").getBytes(Charsets.UTF_8)); 209 | } catch (UnsupportedCharsetException e) { 210 | throw new SerializerException(e); 211 | } 212 | i++; 213 | } else { 214 | throw new SerializerException("High surrogate char should be followed by char in low surrogate range, but end of string reached"); 215 | } 216 | } else { 217 | // UCS-2 will do 218 | outputStream.write(("\\X2\\" + new String(Hex.encodeHex(Charsets.UTF_16BE.encode(CharBuffer.wrap(new char[]{c})).array())).toUpperCase() + "\\X0\\").getBytes(Charsets.UTF_8)); 219 | } 220 | } 221 | } 222 | } 223 | outputStream.write("'".getBytes(Charsets.UTF_8)); 224 | } else if (val instanceof Enumerator) { 225 | outputStream.write(("." + val + ".").getBytes(Charsets.UTF_8)); 226 | } else if (val instanceof byte[]) { 227 | // TODO printing default leading 0, must be wrong 228 | outputStream.write(("\"0" + Hex.encodeHexString((byte[])val) + "\"").getBytes(Charsets.UTF_8)); 229 | } else { 230 | outputStream.write((val == null ? "$" : val.toString()).getBytes(Charsets.UTF_8)); 231 | } 232 | } 233 | 234 | public static void writePrimitive(Object val, PrintWriter printWriter) throws SerializerException, IOException { 235 | if (val.getClass().getSimpleName().equals("Tristate")) { 236 | if (val.toString().equals("TRUE")) { 237 | printWriter.write(".T."); 238 | } else if (val.toString().equals("FALSE")) { 239 | printWriter.write(".F."); 240 | } else if (val.toString().equals("UNDEFINED")) { 241 | printWriter.write(".U."); 242 | } 243 | } else if (val instanceof Double) { 244 | if (((Double)val).isInfinite() || (((Double)val).isNaN())) { 245 | LOGGER.info("Serializing infinite or NaN double as 0.0"); 246 | printWriter.write("0.0"); 247 | } else { 248 | String string = val.toString(); 249 | if (string.endsWith(".0")) { 250 | printWriter.write((string.substring(0, string.length() - 1))); 251 | } else { 252 | printWriter.write(string); 253 | } 254 | } 255 | } else if (val instanceof Boolean) { 256 | Boolean bool = (Boolean)val; 257 | if (bool) { 258 | printWriter.write(".T."); 259 | } else { 260 | printWriter.write(".F."); 261 | } 262 | } else if (val instanceof String) { 263 | printWriter.write('\''); 264 | String stringVal = (String)val; 265 | for (int i=0; i= 32 && c <= 126) { 272 | // ISO 8859-1 273 | printWriter.write(new char[]{c}); 274 | } else if (c < 255) { 275 | // ISO 10646 and ISO 8859-1 are the same < 255 , using ISO_8859_1 276 | printWriter.write("\\X\\"); 277 | printWriter.write(Hex.encodeHex(Charsets.ISO_8859_1.encode(CharBuffer.wrap(new char[]{(char) c})).array(), false)); 278 | } else { 279 | if (USE_ISO_8859_1) { 280 | // ISO 8859-1 with -128 offset 281 | printWriter.write("\\S\\"); 282 | printWriter.write((char)Charsets.ISO_8859_1.encode(new String(new char[]{(char) (c - 128)})).get()); 283 | } else { 284 | // The following code has not been tested (2012-04-25) 285 | // Use UCS-2 or UCS-4 286 | 287 | // TODO when multiple sequential characters should be encoded in UCS-2 or UCS-4, we don't really need to add all those \X0\ \X2\ and \X4\ chars 288 | if (Character.isLowSurrogate(c)) { 289 | throw new SerializerException("Unexpected low surrogate range char"); 290 | } else if (Character.isHighSurrogate(c)) { 291 | // We need UCS-4, this is probably never happening 292 | if (i + 1 < stringVal.length()) { 293 | char low = stringVal.charAt(i + 1); 294 | if (!Character.isLowSurrogate(low)) { 295 | throw new SerializerException("High surrogate char should be followed by char in low surrogate range"); 296 | } 297 | try { 298 | printWriter.write("\\X4\\"); 299 | printWriter.write(Hex.encodeHex(Charset.forName("UTF-32").encode(new String(new char[]{c, low})).array(), false)); 300 | printWriter.write("\\X0\\"); 301 | } catch (UnsupportedCharsetException e) { 302 | throw new SerializerException(e); 303 | } 304 | i++; 305 | } else { 306 | throw new SerializerException("High surrogate char should be followed by char in low surrogate range, but end of string reached"); 307 | } 308 | } else { 309 | // UCS-2 will do 310 | printWriter.write(("\\X2\\")); 311 | printWriter.write(Hex.encodeHex(Charsets.UTF_16BE.encode(CharBuffer.wrap(new char[]{c})).array(), false)); 312 | printWriter.write("\\X0\\"); 313 | } 314 | } 315 | } 316 | } 317 | printWriter.write('\''); 318 | } else if (val instanceof Enumerator) { 319 | printWriter.write("."); 320 | printWriter.write(val.toString()); 321 | printWriter.write("."); 322 | } else if (val instanceof byte[]) { 323 | // TODO printing default leading 0, must be wrong 324 | printWriter.write("\"0"); 325 | printWriter.write(Hex.encodeHexString((byte[])val)); 326 | printWriter.write("\""); 327 | } else { 328 | printWriter.write((val == null ? "$" : val.toString())); 329 | } 330 | } 331 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/deserializer/IfcStepDeserializerPlugin.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.deserializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.io.IOException; 21 | 22 | import org.bimserver.emf.Schema; 23 | 24 | /****************************************************************************** 25 | * Copyright (C) 2009-2018 BIMserver.org 26 | * 27 | * This program is free software: you can redistribute it and/or modify 28 | * it under the terms of the GNU Affero General Public License as 29 | * published by the Free Software Foundation, either version 3 of the 30 | * License, or (at your option) any later version. 31 | * 32 | * This program is distributed in the hope that it will be useful, 33 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 34 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 35 | * GNU Affero General Public License for more details. 36 | * 37 | * You should have received a copy of the GNU Affero General Public License 38 | * along with this program. If not, see {@literal}. 39 | *****************************************************************************/ 40 | 41 | import org.bimserver.models.store.ObjectDefinition; 42 | import org.bimserver.plugins.PluginConfiguration; 43 | import org.bimserver.plugins.PluginContext; 44 | import org.bimserver.plugins.deserializers.DeserializeException; 45 | import org.bimserver.plugins.deserializers.DeserializerErrorCode; 46 | import org.bimserver.plugins.deserializers.DeserializerPlugin; 47 | import org.bimserver.plugins.deserializers.IfcSchemaDeterminer; 48 | import org.bimserver.shared.exceptions.PluginException; 49 | 50 | /** 51 | * @author Ruben de Laat 52 | * Replaced by the streaming deserializers 53 | */ 54 | @Deprecated 55 | public abstract class IfcStepDeserializerPlugin implements DeserializerPlugin, IfcSchemaDeterminer { 56 | 57 | @Override 58 | public void init(PluginContext pluginContext, PluginConfiguration systemSettings) throws PluginException { 59 | } 60 | 61 | @Override 62 | public boolean canHandleExtension(String extension) { 63 | return extension.equalsIgnoreCase("ifc") || extension.equalsIgnoreCase("ifczip"); 64 | } 65 | 66 | @Override 67 | public ObjectDefinition getUserSettingsDefinition() { 68 | return null; 69 | } 70 | 71 | @Override 72 | public ObjectDefinition getSystemSettingsDefinition() { 73 | return null; 74 | } 75 | 76 | @Override 77 | public Schema determineSchema(byte[] head, boolean usesZip) throws DeserializeException { 78 | DetectIfcVersion detectIfcVersion = new DetectIfcVersion(); 79 | try { 80 | String schemaString = detectIfcVersion.detectVersion(head, usesZip); 81 | Schema schema = Schema.fromIfcHeader(schemaString); 82 | if (schema == null) { 83 | throw new DeserializeException(DeserializerErrorCode.UNSUPPORTED_IFC_SCHEMA_VERSION, "Unsupported IFC schema: " + schemaString); 84 | } 85 | return schema; 86 | } catch (IOException e) { 87 | e.printStackTrace(); 88 | } 89 | return null; 90 | } 91 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/deserializer/IfcStepStreamingDeserializerPlugin.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.deserializer; 2 | 3 | import java.io.IOException; 4 | 5 | import org.bimserver.emf.Schema; 6 | 7 | /****************************************************************************** 8 | * Copyright (C) 2009-2019 BIMserver.org 9 | * 10 | * This program is free software: you can redistribute it and/or modify 11 | * it under the terms of the GNU Affero General Public License as 12 | * published by the Free Software Foundation, either version 3 of the 13 | * License, or (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Affero General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Affero General Public License 21 | * along with this program. If not, see {@literal}. 22 | *****************************************************************************/ 23 | 24 | import org.bimserver.models.store.ObjectDefinition; 25 | import org.bimserver.plugins.PluginConfiguration; 26 | import org.bimserver.plugins.PluginContext; 27 | import org.bimserver.plugins.deserializers.DeserializeException; 28 | import org.bimserver.plugins.deserializers.DeserializerErrorCode; 29 | import org.bimserver.plugins.deserializers.IfcSchemaDeterminer; 30 | import org.bimserver.plugins.deserializers.StreamingDeserializerPlugin; 31 | import org.bimserver.shared.exceptions.PluginException; 32 | 33 | public abstract class IfcStepStreamingDeserializerPlugin implements StreamingDeserializerPlugin, IfcSchemaDeterminer { 34 | 35 | @Override 36 | public void init(PluginContext pluginContext, PluginConfiguration systemSettings) throws PluginException { 37 | } 38 | 39 | @Override 40 | public boolean canHandleExtension(String extension) { 41 | return extension.equalsIgnoreCase("ifc") || extension.equalsIgnoreCase("ifczip"); 42 | } 43 | 44 | @Override 45 | public ObjectDefinition getUserSettingsDefinition() { 46 | return null; 47 | } 48 | 49 | @Override 50 | public ObjectDefinition getSystemSettingsDefinition() { 51 | return null; 52 | } 53 | 54 | @Override 55 | public Schema determineSchema(byte[] head, boolean usesZip) throws DeserializeException { 56 | DetectIfcVersion detectIfcVersion = new DetectIfcVersion(); 57 | try { 58 | String schemaString = detectIfcVersion.detectVersion(head, usesZip); 59 | Schema schema = Schema.fromIfcHeader(schemaString); 60 | if (schema == null) { 61 | throw new DeserializeException(DeserializerErrorCode.UNSUPPORTED_IFC_SCHEMA_VERSION, "Unsupported IFC schema: " + schemaString); 62 | } 63 | return schema; 64 | } catch (IOException e) { 65 | e.printStackTrace(); 66 | } 67 | return null; 68 | } 69 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/deserializer/StepParser.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.deserializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import org.bimserver.plugins.deserializers.DeserializeException; 21 | import org.bimserver.plugins.deserializers.DeserializerErrorCode; 22 | import org.bimserver.utils.StringUtils; 23 | 24 | public class StepParser { 25 | 26 | private String line; 27 | private int lastIndex = 0; 28 | 29 | public StepParser(String line) { 30 | this.line = line; 31 | if (line.startsWith("(") && line.endsWith(")")) { 32 | this.line = line.substring(1, line.length() - 1); 33 | } 34 | lastIndex = StringUtils.nextField(this.line, 0); 35 | } 36 | 37 | public String readNextString(long lineNumber) throws DeserializeException { 38 | int nextIndex = StringUtils.nextString(line, lastIndex); 39 | String val = null; 40 | try { 41 | val = line.substring(lastIndex, nextIndex - 1).trim(); 42 | } catch (Exception e) { 43 | throw new DeserializeException(DeserializerErrorCode.EXPECTED_STRING, lineNumber, "Expected string"); 44 | } 45 | lastIndex = StringUtils.nextField(this.line, nextIndex); 46 | 47 | if (val.equals("$")) { 48 | return null; 49 | } 50 | 51 | return IfcParserWriterUtils.readString(val, 0); 52 | } 53 | 54 | private void skipSpaces() { 55 | while (lastIndex < line.length() - 1 && line.charAt(lastIndex) == ' ') { 56 | lastIndex++; 57 | } 58 | } 59 | 60 | public StepParser startList() throws DeserializeException { 61 | skipSpaces(); 62 | 63 | int nextIndex = StringUtils.nextString(line, lastIndex); 64 | String val = line.substring(lastIndex, nextIndex - 1).trim(); 65 | lastIndex = StringUtils.nextField(this.line, nextIndex); 66 | return new StepParser(val); 67 | } 68 | 69 | public boolean hasMoreListItems() { 70 | skipSpaces(); 71 | if (lastIndex >= line.length()) { 72 | // End reached 73 | return false; 74 | } 75 | String character = line.substring(lastIndex, lastIndex + 1); 76 | return !character.equals(")"); 77 | } 78 | 79 | public void endList() throws DeserializeException { 80 | String character = line.substring(lastIndex, lastIndex + 1); 81 | if (character.equals(")")) { 82 | lastIndex++; 83 | } else { 84 | throw new DeserializeException(DeserializerErrorCode.EXPECTED_RIGHT_PARENTHESIS, "Expected ), got " + character); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/deserializer/StringDecoder.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.deserializer; 2 | 3 | import com.google.common.base.Charsets; 4 | import org.apache.commons.codec.DecoderException; 5 | import org.apache.commons.codec.binary.Hex; 6 | import org.bimserver.plugins.deserializers.DeserializeException; 7 | import org.bimserver.plugins.deserializers.DeserializerErrorCode; 8 | 9 | import java.nio.ByteBuffer; 10 | import java.nio.charset.Charset; 11 | import java.nio.charset.UnsupportedCharsetException; 12 | import java.util.HashMap; 13 | import java.util.Map; 14 | 15 | public class StringDecoder { 16 | final static private Map alphabets = new HashMap<>(); 17 | static { 18 | for(int i= 0; i<9; i++){ 19 | alphabets.put((char) ('A'+i), "ISO-8859-"+ (char)('1'+ i)); 20 | } 21 | } 22 | private String alphabet; 23 | private final StringBuilder decoded = new StringBuilder(); 24 | private final String encoded; 25 | private int pos = 0; 26 | private final int end; 27 | private final long lineNumber; 28 | 29 | public StringDecoder(String encoded, long lineNumber){ 30 | alphabet = alphabets.get('A'); 31 | this.encoded = encoded; 32 | this.end = encoded.length(); 33 | this.lineNumber = lineNumber; 34 | } 35 | 36 | public String decode() throws DeserializeException{ 37 | int nextBackslash; 38 | while( (nextBackslash = nextPos('\\')) > -1 ){ 39 | decoded.append(encoded, pos, nextBackslash); 40 | setPos(nextBackslash); 41 | readDirective(); 42 | next(); 43 | } 44 | decoded.append(encoded, pos, end); 45 | return decoded.toString(); 46 | } 47 | 48 | private void readDirective() throws DeserializeException { 49 | switch (next()) { 50 | case '\\': 51 | decoded.append('\\'); break; 52 | case 'S': 53 | readPageDirective(); break; 54 | case 'P': 55 | readAlphabetDirective(); break; 56 | case 'X': 57 | readHexDirective(); break; 58 | default: 59 | throw new DeserializeException(DeserializerErrorCode.UNKNOWN_DESERIALIZER_ERROR, lineNumber, "dangling \\, cannot decode directive or escaped backslash"); 60 | } 61 | } 62 | 63 | private void readPageDirective() throws DeserializeException { 64 | if(next()!='\\'){ 65 | throw new DeserializeException(DeserializerErrorCode.UNKNOWN_DESERIALIZER_ERROR, lineNumber, "\\S directive not closed with \\"); 66 | } 67 | ByteBuffer b = ByteBuffer.wrap(new byte[] { (byte) (next() + 128) }); 68 | decoded.append(Charset.forName(alphabet).decode(b)); 69 | } 70 | 71 | private void readAlphabetDirective() throws DeserializeException { 72 | alphabet = alphabets.get(next()); 73 | if(alphabet == null){ 74 | throw new DeserializeException(DeserializerErrorCode.UNKNOWN_DESERIALIZER_ERROR, lineNumber, "\\P invalid identifier in alphabet directive"); 75 | } 76 | if(next()!='\\'){ 77 | throw new DeserializeException(DeserializerErrorCode.UNKNOWN_DESERIALIZER_ERROR, lineNumber, "\\P alphabet directive not closed with \\"); 78 | } 79 | } 80 | 81 | private void readHexDirective() throws DeserializeException { 82 | switch(next()){ 83 | case '2': 84 | readHex2Directive(); 85 | break; 86 | case '4': 87 | readHex4Directive(); 88 | break; 89 | case '\\': 90 | readHexArbitrary(); 91 | break; 92 | default: 93 | throw new DeserializeException(DeserializerErrorCode.UNKNOWN_DESERIALIZER_ERROR, lineNumber, "dangling \\X, cannot decode hex directive "); 94 | } 95 | } 96 | 97 | private void readHexArbitrary() { 98 | int code = Integer.parseInt(new String(new char[]{ next(), next() }), 16); 99 | ByteBuffer b = ByteBuffer.wrap(new byte[] { (byte) (code) }); 100 | decoded.append(Charsets.ISO_8859_1.decode(b)); 101 | } 102 | 103 | private void readHex2Directive() throws DeserializeException { 104 | if ( next() != '\\'){ 105 | throw new DeserializeException(DeserializerErrorCode.UNKNOWN_DESERIALIZER_ERROR, lineNumber, "\\X2 directive not closed with \\"); 106 | } 107 | pos ++; 108 | int indexOfEnd = nextPos("\\X0\\"); 109 | if (indexOfEnd == -1) { 110 | throw new DeserializeException(DeserializerErrorCode.STRING_ENCODING_X4_NOT_CLOSED_WITH_X0, lineNumber, "\\X4\\ not closed with \\X0\\"); 111 | } 112 | if ((indexOfEnd - pos) % 4 != 0) { 113 | throw new DeserializeException(DeserializerErrorCode.STRING_ENCODING_NUMBER_OF_HEX_CHARS_IN_X2_NOT_DIVISIBLE_BY_4, lineNumber, "Number of hex chars in \\X4\\ definition not divisible by 8"); 114 | } 115 | try { 116 | ByteBuffer buffer = ByteBuffer.wrap(Hex.decodeHex(encoded.substring(pos, indexOfEnd).toCharArray())); 117 | decoded.append(Charsets.UTF_16BE.decode(buffer)); 118 | } catch (DecoderException e) { 119 | throw new DeserializeException(DeserializerErrorCode.STRING_ENCODING_CHARACTER_DECODING_EXCEPTION, lineNumber, e); 120 | } 121 | setPos(indexOfEnd+3); 122 | } 123 | 124 | private void readHex4Directive() throws DeserializeException { 125 | if ( next() != '\\'){ 126 | throw new DeserializeException(DeserializerErrorCode.UNKNOWN_DESERIALIZER_ERROR, lineNumber, "\\X4 directive not closed with \\"); 127 | } 128 | pos++; 129 | int indexOfEnd = nextPos("\\X0\\" ); 130 | if (indexOfEnd == -1) { 131 | throw new DeserializeException(DeserializerErrorCode.STRING_ENCODING_X4_NOT_CLOSED_WITH_X0, lineNumber, "\\X4\\ not closed with \\X0\\"); 132 | } 133 | if ((indexOfEnd - pos) % 8 != 0) { 134 | throw new DeserializeException(DeserializerErrorCode.STRING_ENCODING_NUMBER_OF_HEX_CHARS_IN_X4_NOT_DIVISIBLE_BY_8, lineNumber, "Number of hex chars in \\X4\\ definition not divisible by 8"); 135 | } 136 | try { 137 | ByteBuffer buffer = ByteBuffer.wrap(Hex.decodeHex(encoded.substring(pos, indexOfEnd).toCharArray())); 138 | decoded.append(Charset.forName("UTF-32").decode(buffer)); 139 | } catch (DecoderException e) { 140 | throw new DeserializeException(DeserializerErrorCode.STRING_ENCODING_CHARACTER_DECODING_EXCEPTION, lineNumber, e); 141 | } catch (UnsupportedCharsetException e) { 142 | throw new DeserializeException(DeserializerErrorCode.STRING_ENCODING_UTF32_NOT_SUPPORTED_ON_SYSTEM, lineNumber, "UTF-32 is not supported on your system", e); 143 | } 144 | setPos(indexOfEnd+3); 145 | } 146 | 147 | private void setPos(int i){ 148 | if(i>=0 && i<=end){ 149 | pos = i; 150 | } else { 151 | throw new IllegalArgumentException(); 152 | } 153 | } 154 | 155 | private char next(){ 156 | if (pos < end - 1) { 157 | pos++; 158 | return encoded.charAt(pos); 159 | } else { 160 | pos = end; 161 | return '\uffff'; // Stolen from StringCharacterIterator 162 | } 163 | } 164 | 165 | private int nextPos(String c){ 166 | return encoded.indexOf(c, pos); 167 | } 168 | 169 | private int nextPos(char c){ 170 | return encoded.indexOf(c, pos); 171 | } 172 | 173 | 174 | } 175 | /* 176 | String grammar from ISO 10303-21 177 | 178 | LATIN_CODEPOINT = SPACE | DIGIT | LOWER | UPPER | SPECIAL | REVERSE_SOLIDUS | APOSTROPHE. 179 | STRING = "'" { SPECIAL | DIGIT | SPACE | LOWER | UPPER | HIGH_CODEPOINT | APOSTROPHE APOSTROPHE | REVERSE_SOLIDUS REVERSE_SOLIDUS | CONTROL_DIRECTIVE } "'" . 180 | CONTROL_DIRECTIVE = PAGE | ALPHABET | EXTENDED2 | EXTENDED4 | ARBITRARY . 181 | PAGE = REVERSE_SOLIDUS "S" REVERSE_SOLIDUS LATIN_CODEPOINT . 182 | ALPHABET = REVERSE_SOLIDUS "P" UPPER REVERSE_SOLIDUS . 183 | EXTENDED2 = REVERSE_SOLIDUS "X2" REVERSE_SOLIDUS HEX_TWO { HEX_TWO } END_EXTENDED . 184 | EXTENDED4 = REVERSE_SOLIDUS "X4" REVERSE_SOLIDUS HEX_FOUR { HEX_FOUR } END_EXTENDED . 185 | END_EXTENDED = REVERSE_SOLIDUS "X0" REVERSE_SOLIDUS . 186 | ARBITRARY = REVERSE_SOLIDUS "X" REVERSE_SOLIDUS HEX_ONE . 187 | 188 | Refactored grammar to remove first-first conflicts 189 | 190 | STRING = "'" { NON_RS | RS } "'" . 191 | NON_RS = SPECIAL | DIGIT | SPACE | LOWER | UPPER | HIGH_CODEPOINT | APOSTROPHE APOSTROPHE . 192 | RS = REVERSE_SOLIDUS RS_OR_CONTROL . 193 | RS_OR_CONTROL = REVERSE_SOLIDUS | PAGE0 | ALPHABET0 | UNICODE0 . 194 | PAGE0 = "S" REVERSE_SOLIDUS LATIN_CODEPOINT . 195 | ALPHABET0 = "P" UPPER REVERSE_SOLIDUS . 196 | UNICODE0 = "X" UNICODE1. 197 | UNICODE1 = ARBITRARY0 | EXTENDED20 | EXTENDED40 . 198 | ARBITRARY0 = REVERSE_SOLIDUS HEX_ONE . 199 | EXTENDED20 = "2" REVERSE_SOLIDUS HEX_TWO { HEX_TWO } END_EXTENDED . 200 | EXTENDED40 = "4" REVERSE_SOLIDUS HEX_FOUR { HEX_FOUR } END_EXTENDED . 201 | */ 202 | 203 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/serializer/Ifc2x3tc1StepSerializer.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.serializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import org.bimserver.emf.IfcModelInterface; 21 | import org.bimserver.plugins.PluginConfiguration; 22 | import org.bimserver.plugins.serializers.ProjectInfo; 23 | import org.bimserver.plugins.serializers.SerializerException; 24 | 25 | public class Ifc2x3tc1StepSerializer extends IfcStepSerializer { 26 | 27 | public Ifc2x3tc1StepSerializer(PluginConfiguration pluginConfiguration) { 28 | super(pluginConfiguration); 29 | } 30 | 31 | @Override 32 | public void init(IfcModelInterface model, ProjectInfo projectInfo, boolean normalizeOids) throws SerializerException { 33 | setHeaderSchema("IFC2X3"); 34 | super.init(model, projectInfo, normalizeOids); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/serializer/Ifc2x3tc1StepSerializerPlugin.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.serializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.util.Set; 21 | 22 | import org.bimserver.emf.Schema; 23 | import org.bimserver.plugins.PluginConfiguration; 24 | import org.bimserver.plugins.SchemaName; 25 | import org.bimserver.plugins.serializers.Serializer; 26 | 27 | public class Ifc2x3tc1StepSerializerPlugin extends IfcStepSerializerPlugin { 28 | 29 | @Override 30 | public Serializer createSerializer(PluginConfiguration pluginConfiguration) { 31 | return new Ifc2x3tc1StepSerializer(pluginConfiguration); 32 | } 33 | 34 | @Override 35 | public Set getSupportedSchemas() { 36 | return Schema.IFC2X3TC1.toSet(); 37 | } 38 | 39 | @Override 40 | public String getOutputFormat(Schema schema) { 41 | return SchemaName.IFC_STEP_2X3TC1.name(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/serializer/Ifc2x3tc1StepStreamingSerializer.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.serializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import org.bimserver.emf.PackageMetaData; 21 | import org.bimserver.models.store.IfcHeader; 22 | import org.bimserver.plugins.PluginConfiguration; 23 | import org.bimserver.plugins.PluginManagerInterface; 24 | import org.bimserver.plugins.serializers.ObjectProvider; 25 | import org.bimserver.plugins.serializers.ProjectInfo; 26 | import org.bimserver.plugins.serializers.SerializerException; 27 | 28 | public class Ifc2x3tc1StepStreamingSerializer extends IfcStepStreamingSerializer { 29 | 30 | public Ifc2x3tc1StepStreamingSerializer(PluginConfiguration pluginConfiguration) { 31 | super(pluginConfiguration); 32 | } 33 | 34 | @Override 35 | public void init(ObjectProvider objectProvider, ProjectInfo projectInfo, IfcHeader ifcHeader, PluginManagerInterface pluginManager, PackageMetaData packageMetaData) throws SerializerException { 36 | setHeaderSchema("IFC2X3"); 37 | super.init(objectProvider, projectInfo, ifcHeader, pluginManager, packageMetaData); 38 | } 39 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/serializer/Ifc2x3tc1StepStreamingSerializerPlugin.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.serializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.util.Set; 21 | 22 | import org.bimserver.emf.Schema; 23 | import org.bimserver.plugins.PluginConfiguration; 24 | import org.bimserver.plugins.SchemaName; 25 | import org.bimserver.plugins.serializers.StreamingSerializer; 26 | 27 | public class Ifc2x3tc1StepStreamingSerializerPlugin extends IfcStepStreamingSerializerPlugin { 28 | 29 | @Override 30 | public StreamingSerializer createSerializer(PluginConfiguration pluginConfiguration) { 31 | return new Ifc2x3tc1StepStreamingSerializer(pluginConfiguration); 32 | } 33 | 34 | @Override 35 | public Set getSupportedSchemas() { 36 | return Schema.IFC2X3TC1.toSet(); 37 | } 38 | 39 | @Override 40 | public String getOutputFormat(Schema schema) { 41 | return SchemaName.IFC_STEP_2X3TC1.name(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/serializer/Ifc4StepSerializer.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.serializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import org.bimserver.emf.IfcModelInterface; 21 | import org.bimserver.plugins.PluginConfiguration; 22 | import org.bimserver.plugins.serializers.ProjectInfo; 23 | import org.bimserver.plugins.serializers.SerializerException; 24 | 25 | public class Ifc4StepSerializer extends IfcStepSerializer { 26 | 27 | public Ifc4StepSerializer(PluginConfiguration pluginConfiguration) { 28 | super(pluginConfiguration); 29 | } 30 | 31 | @Override 32 | public void init(IfcModelInterface model, ProjectInfo projectInfo, boolean normalizeOids) throws SerializerException { 33 | setHeaderSchema("IFC4"); 34 | super.init(model, projectInfo, normalizeOids); 35 | } 36 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/serializer/Ifc4StepSerializerPlugin.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.serializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.util.Set; 21 | 22 | import org.bimserver.emf.Schema; 23 | import org.bimserver.plugins.PluginConfiguration; 24 | import org.bimserver.plugins.SchemaName; 25 | import org.bimserver.plugins.serializers.Serializer; 26 | 27 | public class Ifc4StepSerializerPlugin extends IfcStepSerializerPlugin { 28 | 29 | @Override 30 | public Serializer createSerializer(PluginConfiguration pluginConfiguration) { 31 | return new Ifc4StepSerializer(pluginConfiguration); 32 | } 33 | 34 | @Override 35 | public Set getSupportedSchemas() { 36 | return Schema.IFC4.toSet(); 37 | } 38 | 39 | @Override 40 | public String getOutputFormat(Schema schema) { 41 | return SchemaName.IFC_STEP_4.name(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/serializer/Ifc4StepStreamingSerializer.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.serializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import org.bimserver.emf.PackageMetaData; 21 | import org.bimserver.models.store.IfcHeader; 22 | import org.bimserver.plugins.PluginConfiguration; 23 | import org.bimserver.plugins.PluginManagerInterface; 24 | import org.bimserver.plugins.serializers.ObjectProvider; 25 | import org.bimserver.plugins.serializers.ProjectInfo; 26 | import org.bimserver.plugins.serializers.SerializerException; 27 | 28 | public class Ifc4StepStreamingSerializer extends IfcStepStreamingSerializer { 29 | 30 | public Ifc4StepStreamingSerializer(PluginConfiguration pluginConfiguration) { 31 | super(pluginConfiguration); 32 | } 33 | 34 | @Override 35 | public void init(ObjectProvider objectProvider, ProjectInfo projectInfo, IfcHeader ifcHeader, PluginManagerInterface pluginManager, PackageMetaData packageMetaData) throws SerializerException { 36 | setHeaderSchema("IFC4"); 37 | super.init(objectProvider, projectInfo, ifcHeader, pluginManager, packageMetaData); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/serializer/Ifc4StepStreamingSerializerPlugin.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.serializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.util.Set; 21 | 22 | import org.bimserver.emf.Schema; 23 | import org.bimserver.plugins.PluginConfiguration; 24 | import org.bimserver.plugins.SchemaName; 25 | import org.bimserver.plugins.serializers.StreamingSerializer; 26 | 27 | public class Ifc4StepStreamingSerializerPlugin extends IfcStepStreamingSerializerPlugin { 28 | 29 | @Override 30 | public StreamingSerializer createSerializer(PluginConfiguration pluginConfiguration) { 31 | return new Ifc4StepStreamingSerializer(pluginConfiguration); 32 | } 33 | 34 | @Override 35 | public Set getSupportedSchemas() { 36 | return Schema.IFC4.toSet(); 37 | } 38 | 39 | @Override 40 | public String getOutputFormat(Schema schema) { 41 | return SchemaName.IFC_STEP_4.name(); 42 | } 43 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/serializer/IfcStepSerializerPlugin.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.serializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import org.bimserver.models.store.ObjectDefinition; 21 | import org.bimserver.models.store.ParameterDefinition; 22 | import org.bimserver.models.store.PrimitiveDefinition; 23 | import org.bimserver.models.store.PrimitiveEnum; 24 | import org.bimserver.models.store.StoreFactory; 25 | import org.bimserver.models.store.StringType; 26 | import org.bimserver.plugins.PluginConfiguration; 27 | import org.bimserver.plugins.PluginContext; 28 | import org.bimserver.plugins.serializers.AbstractSerializerPlugin; 29 | import org.bimserver.shared.exceptions.PluginException; 30 | 31 | public abstract class IfcStepSerializerPlugin extends AbstractSerializerPlugin { 32 | 33 | @Override 34 | public void init(PluginContext pluginContext, PluginConfiguration systemSettings) throws PluginException { 35 | } 36 | 37 | @Override 38 | public String getDefaultContentType() { 39 | return "application/ifc"; 40 | } 41 | 42 | @Override 43 | public String getDefaultExtension() { 44 | return "ifc"; 45 | } 46 | 47 | @Override 48 | public ObjectDefinition getUserSettingsDefinition() { 49 | ObjectDefinition objectDefinition = super.getUserSettingsDefinition(); 50 | 51 | PrimitiveDefinition stringDefinition = StoreFactory.eINSTANCE.createPrimitiveDefinition(); 52 | stringDefinition.setType(PrimitiveEnum.STRING); 53 | 54 | ParameterDefinition organizationParameter = StoreFactory.eINSTANCE.createParameterDefinition(); 55 | organizationParameter.setIdentifier("organization"); 56 | organizationParameter.setName("Organization"); 57 | organizationParameter.setDescription("Organization name to put in the header"); 58 | StringType defaultValue = StoreFactory.eINSTANCE.createStringType(); 59 | defaultValue.setValue("BIMserver.org"); 60 | organizationParameter.setDefaultValue(defaultValue); 61 | organizationParameter.setType(stringDefinition); 62 | objectDefinition.getParameters().add(organizationParameter); 63 | 64 | ParameterDefinition zipExtension = StoreFactory.eINSTANCE.createParameterDefinition(); 65 | zipExtension.setIdentifier(ZIP_EXTENSION); 66 | zipExtension.setName(ZIP_EXTENSION); 67 | zipExtension.setDescription("Extension of the downloaded file when using zip compression"); 68 | zipExtension.setType(stringDefinition); 69 | StringType defaultZipExtensionValue = StoreFactory.eINSTANCE.createStringType(); 70 | defaultZipExtensionValue.setValue("ifczip"); 71 | zipExtension.setDefaultValue(defaultZipExtensionValue); 72 | objectDefinition.getParameters().add(zipExtension); 73 | 74 | return objectDefinition; 75 | } 76 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/serializer/IfcStepStreamingSerializerPlugin.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.serializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import org.bimserver.models.store.ObjectDefinition; 21 | import org.bimserver.models.store.ParameterDefinition; 22 | import org.bimserver.models.store.PrimitiveDefinition; 23 | import org.bimserver.models.store.PrimitiveEnum; 24 | import org.bimserver.models.store.StoreFactory; 25 | import org.bimserver.models.store.StringType; 26 | import org.bimserver.plugins.PluginConfiguration; 27 | import org.bimserver.plugins.PluginContext; 28 | import org.bimserver.plugins.serializers.StreamingSerializerPlugin; 29 | import org.bimserver.shared.exceptions.PluginException; 30 | 31 | public abstract class IfcStepStreamingSerializerPlugin implements StreamingSerializerPlugin { 32 | 33 | @Override 34 | public void init(PluginContext pluginContext, PluginConfiguration systemSettings) throws PluginException { 35 | } 36 | 37 | public String getDefaultContentType() { 38 | return "application/ifc"; 39 | } 40 | 41 | public String getDefaultExtension() { 42 | return "ifc"; 43 | } 44 | 45 | @Override 46 | public ObjectDefinition getUserSettingsDefinition() { 47 | ObjectDefinition objectDefinition = StoreFactory.eINSTANCE.createObjectDefinition(); 48 | 49 | ParameterDefinition extensionParameter = StoreFactory.eINSTANCE.createParameterDefinition(); 50 | extensionParameter.setIdentifier(EXTENSION); 51 | extensionParameter.setName(EXTENSION); 52 | extensionParameter.setDescription("Extension of the downloaded file"); 53 | PrimitiveDefinition stringType = StoreFactory.eINSTANCE.createPrimitiveDefinition(); 54 | stringType.setType(PrimitiveEnum.STRING); 55 | extensionParameter.setType(stringType); 56 | StringType defaultExtensionValue = StoreFactory.eINSTANCE.createStringType(); 57 | defaultExtensionValue.setValue(getDefaultExtension()); 58 | extensionParameter.setDefaultValue(defaultExtensionValue); 59 | objectDefinition.getParameters().add(extensionParameter); 60 | 61 | ParameterDefinition contentTypeParameter = StoreFactory.eINSTANCE.createParameterDefinition(); 62 | contentTypeParameter.setIdentifier(CONTENT_TYPE); 63 | contentTypeParameter.setName(CONTENT_TYPE); 64 | contentTypeParameter.setDescription("Content-Type in the HTTP header of the downloaded file"); 65 | contentTypeParameter.setType(stringType); 66 | StringType defaultContentTypeValue = StoreFactory.eINSTANCE.createStringType(); 67 | defaultContentTypeValue.setValue(getDefaultContentType()); 68 | contentTypeParameter.setDefaultValue(defaultContentTypeValue); 69 | objectDefinition.getParameters().add(contentTypeParameter); 70 | 71 | PrimitiveDefinition stringDefinition = StoreFactory.eINSTANCE.createPrimitiveDefinition(); 72 | stringDefinition.setType(PrimitiveEnum.STRING); 73 | 74 | ParameterDefinition organizationParameter = StoreFactory.eINSTANCE.createParameterDefinition(); 75 | organizationParameter.setIdentifier("organization"); 76 | organizationParameter.setName("Organization"); 77 | organizationParameter.setDescription("Organization name to put in the header"); 78 | StringType defaultValue = StoreFactory.eINSTANCE.createStringType(); 79 | defaultValue.setValue("BIMserver.org"); 80 | organizationParameter.setDefaultValue(defaultValue); 81 | organizationParameter.setType(stringDefinition); 82 | objectDefinition.getParameters().add(organizationParameter); 83 | 84 | ParameterDefinition zipExtension = StoreFactory.eINSTANCE.createParameterDefinition(); 85 | zipExtension.setIdentifier(ZIP_EXTENSION); 86 | zipExtension.setName(ZIP_EXTENSION); 87 | zipExtension.setDescription("Extension of the downloaded file when using zip compression"); 88 | zipExtension.setType(stringDefinition); 89 | StringType defaultZipExtensionValue = StoreFactory.eINSTANCE.createStringType(); 90 | defaultZipExtensionValue.setValue("ifczip"); 91 | zipExtension.setDefaultValue(defaultZipExtensionValue); 92 | objectDefinition.getParameters().add(zipExtension); 93 | 94 | return objectDefinition; 95 | } 96 | 97 | @Override 98 | public ObjectDefinition getSystemSettingsDefinition() { 99 | return null; 100 | } 101 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/step/serializer/IfcWriterException.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.step.serializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | public class IfcWriterException extends Exception { 21 | 22 | private static final long serialVersionUID = -6573855612652261486L; 23 | 24 | public IfcWriterException(String message) { 25 | super(message); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/xml/deserializer/Ifc2x3tc1XmlDeserializer.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.xml.deserializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | @Deprecated 21 | public class Ifc2x3tc1XmlDeserializer extends IfcXmlDeserializer { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/xml/deserializer/Ifc2x3tc1XmlDeserializerPlugin.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.xml.deserializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.util.Collections; 21 | import java.util.Set; 22 | 23 | import org.bimserver.emf.Schema; 24 | import org.bimserver.plugins.PluginConfiguration; 25 | import org.bimserver.plugins.deserializers.EmfDeserializer; 26 | 27 | @Deprecated 28 | public class Ifc2x3tc1XmlDeserializerPlugin extends IfcXmlDeserializerPlugin { 29 | 30 | @Override 31 | public EmfDeserializer createDeserializer(PluginConfiguration pluginConfiguration) { 32 | return new Ifc2x3tc1XmlDeserializer(); 33 | } 34 | 35 | @Override 36 | public Set getSupportedSchemas() { 37 | return Collections.singleton(Schema.IFC2X3TC1); 38 | } 39 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/xml/deserializer/Ifc4XmlDeserializer.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.xml.deserializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | @Deprecated 21 | public class Ifc4XmlDeserializer extends IfcXmlDeserializer { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/xml/deserializer/Ifc4XmlDeserializerPlugin.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.xml.deserializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.util.Collections; 21 | import java.util.Set; 22 | 23 | import org.bimserver.emf.Schema; 24 | import org.bimserver.plugins.PluginConfiguration; 25 | import org.bimserver.plugins.deserializers.EmfDeserializer; 26 | 27 | @Deprecated 28 | public class Ifc4XmlDeserializerPlugin extends IfcXmlDeserializerPlugin { 29 | 30 | @Override 31 | public EmfDeserializer createDeserializer(PluginConfiguration pluginConfiguration) { 32 | return new Ifc4XmlDeserializer(); 33 | } 34 | 35 | @Override 36 | public Set getSupportedSchemas() { 37 | return Collections.singleton(Schema.IFC4); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/xml/deserializer/IfcXmlDeserializerPlugin.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.xml.deserializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import org.bimserver.models.store.ObjectDefinition; 21 | import org.bimserver.plugins.PluginConfiguration; 22 | import org.bimserver.plugins.PluginContext; 23 | import org.bimserver.plugins.deserializers.DeserializerPlugin; 24 | import org.bimserver.shared.exceptions.PluginException; 25 | 26 | @Deprecated 27 | public abstract class IfcXmlDeserializerPlugin implements DeserializerPlugin { 28 | 29 | @Override 30 | public void init(PluginContext pluginContext, PluginConfiguration systemSettings) throws PluginException { 31 | } 32 | 33 | @Override 34 | public boolean canHandleExtension(String extension) { 35 | return extension.equalsIgnoreCase("ifcxml"); 36 | } 37 | 38 | @Override 39 | public ObjectDefinition getUserSettingsDefinition() { 40 | return null; 41 | } 42 | 43 | @Override 44 | public ObjectDefinition getSystemSettingsDefinition() { 45 | return null; 46 | } 47 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/xml/serializer/IfcXml2x3tc1Serializer.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.xml.serializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import org.bimserver.emf.IfcModelInterface; 21 | import org.bimserver.plugins.serializers.ProjectInfo; 22 | import org.bimserver.plugins.serializers.SerializerException; 23 | 24 | public class IfcXml2x3tc1Serializer extends IfcXmlSerializer { 25 | @Override 26 | public void init(IfcModelInterface model, ProjectInfo projectInfo, boolean normalizeOids) throws SerializerException { 27 | super.init(model, projectInfo, normalizeOids); 28 | } 29 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/xml/serializer/IfcXml2x3tc1SerializerPlugin.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.xml.serializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.util.Set; 21 | 22 | import org.bimserver.emf.Schema; 23 | import org.bimserver.plugins.PluginConfiguration; 24 | import org.bimserver.plugins.serializers.Serializer; 25 | 26 | public class IfcXml2x3tc1SerializerPlugin extends IfcXmlSerializerPlugin { 27 | 28 | @Override 29 | public Set getSupportedSchemas() { 30 | return Schema.IFC2X3TC1.toSet(); 31 | } 32 | 33 | @Override 34 | public Serializer createSerializer(PluginConfiguration plugin) { 35 | return new IfcXml2x3tc1Serializer(); 36 | } 37 | 38 | @Override 39 | public String getOutputFormat(Schema schema) { 40 | return "IFC_XML_2x3TC1"; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/xml/serializer/IfcXml4Serializer.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.xml.serializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import org.bimserver.emf.IfcModelInterface; 21 | import org.bimserver.plugins.serializers.ProjectInfo; 22 | import org.bimserver.plugins.serializers.SerializerException; 23 | 24 | public class IfcXml4Serializer extends IfcXmlSerializer { 25 | @Override 26 | public void init(IfcModelInterface model, ProjectInfo projectInfo, boolean normalizeOids) throws SerializerException { 27 | super.init(model, projectInfo, normalizeOids); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/xml/serializer/IfcXml4SerializerPlugin.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.xml.serializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.util.Set; 21 | 22 | import org.bimserver.emf.Schema; 23 | import org.bimserver.plugins.PluginConfiguration; 24 | import org.bimserver.plugins.serializers.Serializer; 25 | 26 | public class IfcXml4SerializerPlugin extends IfcXmlSerializerPlugin { 27 | 28 | @Override 29 | public Set getSupportedSchemas() { 30 | return Schema.IFC4.toSet(); 31 | } 32 | 33 | @Override 34 | public Serializer createSerializer(PluginConfiguration plugin) { 35 | return new IfcXml4Serializer(); 36 | } 37 | 38 | @Override 39 | public String getOutputFormat(Schema schema) { 40 | return "IFC_XML_4"; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/xml/serializer/IfcXmlSerializer.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.xml.serializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.io.File; 21 | import java.io.FileNotFoundException; 22 | import java.io.FileOutputStream; 23 | import java.io.OutputStream; 24 | import java.io.PrintWriter; 25 | import java.util.HashMap; 26 | import java.util.Map; 27 | import java.util.Set; 28 | 29 | import org.apache.commons.lang.StringEscapeUtils; 30 | import org.bimserver.emf.IfcModelInterface; 31 | import org.bimserver.ifc.IfcSerializer; 32 | import org.bimserver.models.ifc2x3tc1.Tristate; 33 | import org.bimserver.models.store.StringType; 34 | import org.bimserver.plugins.serializers.ProgressReporter; 35 | import org.bimserver.plugins.serializers.ProjectInfo; 36 | import org.bimserver.plugins.serializers.SerializerException; 37 | import org.bimserver.utils.UTF8PrintWriter; 38 | import org.eclipse.emf.common.util.AbstractEList; 39 | import org.eclipse.emf.common.util.Enumerator; 40 | import org.eclipse.emf.ecore.EAttribute; 41 | import org.eclipse.emf.ecore.EClass; 42 | import org.eclipse.emf.ecore.EClassifier; 43 | import org.eclipse.emf.ecore.EDataType; 44 | import org.eclipse.emf.ecore.EEnum; 45 | import org.eclipse.emf.ecore.EObject; 46 | import org.eclipse.emf.ecore.EReference; 47 | import org.eclipse.emf.ecore.EStructuralFeature; 48 | import org.eclipse.emf.ecore.EcorePackage; 49 | 50 | import nl.tue.buildingsmart.schema.Attribute; 51 | import nl.tue.buildingsmart.schema.BaseType; 52 | import nl.tue.buildingsmart.schema.DefinedType; 53 | import nl.tue.buildingsmart.schema.EntityDefinition; 54 | import nl.tue.buildingsmart.schema.ExplicitAttribute; 55 | import nl.tue.buildingsmart.schema.IntegerType; 56 | import nl.tue.buildingsmart.schema.ListType; 57 | import nl.tue.buildingsmart.schema.RealType; 58 | import nl.tue.buildingsmart.schema.SetType; 59 | 60 | public abstract class IfcXmlSerializer extends IfcSerializer { 61 | 62 | private PrintWriter out; 63 | private Map objectToOidMap; 64 | private int tabs; 65 | 66 | @Override 67 | public void init(IfcModelInterface model, ProjectInfo projectInfo, boolean normalizeOids) throws SerializerException { 68 | super.init(model, projectInfo, normalizeOids); 69 | objectToOidMap = new HashMap((int) model.size()); 70 | for (Long key : model.keySet()) { 71 | objectToOidMap.put(model.get(key), key); 72 | } 73 | } 74 | 75 | @Override 76 | public boolean write(OutputStream out, ProgressReporter progressReporter) throws SerializerException { 77 | switch (getMode()) { 78 | case HEADER: 79 | setMode(Mode.BODY); 80 | case BODY: { 81 | this.out = new UTF8PrintWriter(out); 82 | printLineTabbed(""); 83 | tabs = 0; 84 | printLineTabbed(""); 85 | tabs++; 86 | printLineTabbed(""); 87 | tabs++; 88 | Set keySet = model.getObjects().keySet(); 89 | int progress = 0; 90 | for (Long key : keySet) { 91 | EObject object = model.getObjects().get(key); 92 | if (object.eClass().getEStructuralFeature("wrappedValue") == null) { 93 | store(key, object); 94 | } 95 | if (progressReporter != null) progressReporter.update(progress++, keySet.size()); 96 | } 97 | tabs--; 98 | printLineTabbed(""); 99 | tabs--; 100 | printLineTabbed(""); 101 | this.out.flush(); 102 | setMode(Mode.FINISHED); 103 | return true; 104 | } 105 | case FINISHED: { 106 | return false; 107 | } 108 | case FOOTER: 109 | return false; 110 | default: 111 | break; 112 | } 113 | return false; 114 | } 115 | 116 | public void write(File file, ProgressReporter progressReporter) throws FileNotFoundException, SerializerException { 117 | write(new FileOutputStream(file), progressReporter); 118 | } 119 | 120 | /** 121 | * Writes the XML structural equivalent of each IFC "record" in an IFC file. 122 | * 123 | * @param key 124 | * record ID 125 | * @param object 126 | * IFC object with this record ID 127 | * @throws SerializerException 128 | */ 129 | /* 130 | * Because of insufficient info in the EMF model a few hacks were necessary 131 | * to guarantee XML code that obeys the IFC XML schema. When these 132 | * shortcomings are solved the hacks will be removed. (PW) 133 | */ 134 | private void store(Long key, EObject object) throws SerializerException { 135 | if (object.eClass().getEAnnotation("hidden") != null) { 136 | return; 137 | } 138 | printLineTabbed("<" + object.eClass().getName() + " id=\"i" + key + "\">"); 139 | tabs++; 140 | for (EStructuralFeature structuralFeature : object.eClass().getEAllStructuralFeatures()) { 141 | if (structuralFeature.getEAnnotation("hidden") != null) { 142 | continue; 143 | } 144 | EntityDefinition entityBN = getPackageMetaData().getSchemaDefinition().getEntityBN(object.eClass().getName().toUpperCase()); 145 | Attribute attributeBN = entityBN != null ? entityBN.getAttributeBNWithSuper(structuralFeature.getName()) : null; 146 | boolean derived = entityBN.isDerived(structuralFeature.getName()); 147 | if (structuralFeature instanceof EAttribute || (!getPackageMetaData().isInverse((EReference)structuralFeature) && !structuralFeature.isDerived() && !derived)) { 148 | // Because of small deviations in the string/float/string 149 | // conversions some float attributes are also stored in the 150 | // original string representations. These auxiliary attribute 151 | // types should be skipped in the XML output. Though their value 152 | // must be used instead of the original attribute types. 153 | if (structuralFeature.getEAnnotation("hidden") != null) { 154 | continue; 155 | } 156 | Object value = object.eGet(structuralFeature); 157 | if (value == null) { 158 | } else { 159 | EClassifier classifier = structuralFeature.getEType(); 160 | if (!structuralFeature.isMany()) { 161 | if (classifier instanceof EClass) { 162 | EObject eObject = (EObject) value; 163 | EClass type = eObject.eClass(); 164 | printTabbed("<" + structuralFeature.getName() + ">"); 165 | if (type.getEAnnotation("wrapped") != null) { 166 | // Only references should print the type, 167 | // GlobalId is an exception, because in EMF we 168 | // chose to create a Class for GlobalId, because 169 | // of the (added) backreference to IfcRoot 170 | boolean showTag = (structuralFeature instanceof EReference && !(structuralFeature.getName().equals("GlobalId"))); 171 | if (showTag) { 172 | print("<" + type.getName() + ">"); 173 | } 174 | EStructuralFeature wrappedFeature = type.getEStructuralFeature("wrappedValue"); 175 | Object get = ((EObject) value).eGet(wrappedFeature); 176 | if (wrappedFeature.getEType() == EcorePackage.eINSTANCE.getEString()) { 177 | printEscaped((String) get); 178 | } else { 179 | if (!type.getName().equals("IfcLogical") && !type.getName().equals("IfcBoolean")) { 180 | print(get.toString()); 181 | } else { 182 | writeValue(get); 183 | } 184 | } 185 | if (showTag) { 186 | print(""); 187 | } 188 | } else { 189 | String ref = "i" + objectToOidMap.get(value); 190 | print("<" + type.getName() + " xsi:nil=\"true\" ref=\"" + ref + "\"/>"); 191 | } 192 | printLine(""); 193 | } else if (classifier instanceof EEnum) { 194 | Enumerator enumerator = (Enumerator) value; 195 | if (enumerator.getName().equals("NULL")) { 196 | continue; 197 | } 198 | printTabbed("<" + structuralFeature.getName() + ">"); 199 | writeValue(value); 200 | printLine(""); 201 | } else if (classifier instanceof EDataType) { 202 | printTabbed("<" + structuralFeature.getName() + ">"); 203 | print(value.toString()); 204 | printLine(""); 205 | } 206 | } else { 207 | AbstractEList list = (AbstractEList) value; 208 | String type = "set"; 209 | if (attributeBN instanceof ExplicitAttribute) { 210 | ExplicitAttribute explicitAttribute = (ExplicitAttribute) attributeBN; 211 | if (list.isEmpty() && explicitAttribute.isOptional()) 212 | continue; 213 | BaseType domain = explicitAttribute.getDomain(true); 214 | if (domain == null) { 215 | domain = explicitAttribute.getDomain(); 216 | if (domain instanceof DefinedType) { 217 | if (((DefinedType) domain).getName().equals("IfcCompoundPlaneAngleMeasure")) { 218 | type = "list"; 219 | } 220 | } 221 | } 222 | if (domain instanceof SetType) { 223 | type = "set"; 224 | } else if (domain instanceof ListType) { 225 | type = "list"; 226 | if (structuralFeature.getName().equals("Polygon")) { 227 | type = "list-unique"; 228 | } 229 | } 230 | } 231 | printLineTabbed("<" + structuralFeature.getName() + " ex:cType=\"" + type + "\" >"); 232 | tabs++; 233 | int i = 0; 234 | for (Object o : list) { 235 | if (o instanceof EObject) { 236 | EObject eObject = (EObject) o; 237 | EStructuralFeature wrappedFeature = eObject.eClass().getEStructuralFeature("wrappedValue"); 238 | if (wrappedFeature != null) { 239 | Object val = eObject.eGet(wrappedFeature); 240 | printLineTabbed("<" + eObject.eClass().getName() + " pos=\"" + i + "\">" + val + ""); 241 | } else { 242 | String ref = "i" + objectToOidMap.get(eObject); 243 | printLineTabbed("<" + eObject.eClass().getName() + " pos=\"" + i + "\" xsi:nil=\"true\" ref=\"" + ref + "\" />"); 244 | } 245 | i++; 246 | } else { 247 | if (attributeBN instanceof ExplicitAttribute) { 248 | BaseType domain = ((ExplicitAttribute) attributeBN).getDomain(true); 249 | if (attributeBN.getName().equals("RefLatitude") || attributeBN.getName().equals("RefLongitude")) { 250 | printLineTabbed("" + o + ""); 251 | } else if (domain instanceof ListType) { 252 | BaseType elementType = ((ListType) domain).getElement_type(); 253 | if (elementType instanceof DefinedType) { 254 | DefinedType def = (DefinedType) elementType; 255 | printLineTabbed("<" + def.getName() + ">" + o + ""); 256 | } else if (elementType instanceof RealType) { 257 | printLineTabbed("" + o + ""); 258 | } else if (elementType instanceof IntegerType) { 259 | printLineTabbed("" + o + ""); 260 | } else if (elementType instanceof StringType) { 261 | printLineTabbed("" + o + ""); 262 | } 263 | } 264 | } 265 | } 266 | } 267 | tabs--; 268 | printLineTabbed(""); 269 | // } 270 | } 271 | } 272 | } 273 | } 274 | tabs--; 275 | printLineTabbed(""); 276 | } 277 | 278 | private void writeValue(Object value) { 279 | if (value instanceof Tristate && value == Tristate.UNDEFINED) { 280 | print("unknown"); 281 | } else { 282 | print(value.toString().toLowerCase()); 283 | } 284 | } 285 | 286 | private void printEscaped(String value) { 287 | out.print(StringEscapeUtils.escapeXml(value)); 288 | } 289 | 290 | private void writeTabs(int tabs) { 291 | for (int i = 0; i < tabs; i++) { 292 | out.print("\t"); 293 | } 294 | } 295 | 296 | private void printTabbed(String str) { 297 | writeTabs(tabs); 298 | out.print(str); 299 | } 300 | 301 | private void printLineTabbed(String str) { 302 | writeTabs(tabs); 303 | out.println(str); 304 | } 305 | 306 | private void print(String str) { 307 | out.print(str); 308 | } 309 | 310 | private void printLine(String str) { 311 | out.println(str); 312 | } 313 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/ifc/xml/serializer/IfcXmlSerializerPlugin.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.ifc.xml.serializer; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import org.bimserver.models.store.ObjectDefinition; 21 | import org.bimserver.models.store.ParameterDefinition; 22 | import org.bimserver.models.store.PrimitiveDefinition; 23 | import org.bimserver.models.store.PrimitiveEnum; 24 | import org.bimserver.models.store.StoreFactory; 25 | import org.bimserver.models.store.StringType; 26 | import org.bimserver.plugins.PluginConfiguration; 27 | import org.bimserver.plugins.PluginContext; 28 | import org.bimserver.plugins.serializers.AbstractSerializerPlugin; 29 | import org.bimserver.shared.exceptions.PluginException; 30 | 31 | public abstract class IfcXmlSerializerPlugin extends AbstractSerializerPlugin { 32 | 33 | @Override 34 | public void init(PluginContext pluginContext, PluginConfiguration systemSettings) throws PluginException { 35 | } 36 | 37 | @Override 38 | public String getDefaultContentType() { 39 | return "application/ifcxml"; 40 | } 41 | 42 | @Override 43 | public String getDefaultExtension() { 44 | return "ifcxml"; 45 | } 46 | 47 | @Override 48 | public ObjectDefinition getUserSettingsDefinition() { 49 | ObjectDefinition settingsDefinition = super.getUserSettingsDefinition(); 50 | 51 | PrimitiveDefinition stringDefinition = StoreFactory.eINSTANCE.createPrimitiveDefinition(); 52 | stringDefinition.setType(PrimitiveEnum.STRING); 53 | 54 | ParameterDefinition zipExtension = StoreFactory.eINSTANCE.createParameterDefinition(); 55 | zipExtension.setIdentifier(ZIP_EXTENSION); 56 | zipExtension.setName(ZIP_EXTENSION); 57 | zipExtension.setDescription("Extension of the downloaded file when using zip compression"); 58 | zipExtension.setType(stringDefinition); 59 | StringType defaultZipExtensionValue = StoreFactory.eINSTANCE.createStringType(); 60 | defaultZipExtensionValue.setValue("ifczip"); 61 | zipExtension.setDefaultValue(defaultZipExtensionValue); 62 | settingsDefinition.getParameters().add(zipExtension); 63 | 64 | return settingsDefinition; 65 | } 66 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/noprenderengine/DefaultNopRenderEngine.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.noprenderengine; 2 | 3 | import java.util.GregorianCalendar; 4 | 5 | /****************************************************************************** 6 | * Copyright (C) 2009-2019 BIMserver.org 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Affero General Public License as 10 | * published by the Free Software Foundation, either version 3 of the 11 | * License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Affero General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Affero General Public License 19 | * along with this program. If not, see {@literal}. 20 | *****************************************************************************/ 21 | 22 | import org.bimserver.models.store.ObjectDefinition; 23 | import org.bimserver.plugins.PluginConfiguration; 24 | import org.bimserver.plugins.PluginContext; 25 | import org.bimserver.plugins.renderengine.RenderEngine; 26 | import org.bimserver.plugins.renderengine.RenderEngineException; 27 | import org.bimserver.plugins.renderengine.RenderEnginePlugin; 28 | import org.bimserver.plugins.renderengine.VersionInfo; 29 | import org.bimserver.shared.exceptions.PluginException; 30 | 31 | public class DefaultNopRenderEngine implements RenderEnginePlugin { 32 | 33 | @Override 34 | public void init(PluginContext pluginContext, PluginConfiguration systemSettings) throws PluginException { 35 | 36 | } 37 | 38 | @Override 39 | public ObjectDefinition getUserSettingsDefinition() { 40 | return null; 41 | } 42 | 43 | @Override 44 | public ObjectDefinition getSystemSettingsDefinition() { 45 | return null; 46 | } 47 | 48 | @Override 49 | public RenderEngine createRenderEngine(PluginConfiguration pluginConfiguration, String schema) throws RenderEngineException { 50 | return new NopRenderEngine(); 51 | } 52 | 53 | @Override 54 | public VersionInfo getVersionInfo() { 55 | return new VersionInfo("nop", "nop", new GregorianCalendar(), "nop"); 56 | } 57 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/noprenderengine/NopRenderEngine.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.noprenderengine; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.io.InputStream; 21 | 22 | import org.bimserver.plugins.renderengine.Metrics; 23 | import org.bimserver.plugins.renderengine.RenderEngine; 24 | import org.bimserver.plugins.renderengine.RenderEngineException; 25 | import org.bimserver.plugins.renderengine.RenderEngineModel; 26 | 27 | public class NopRenderEngine implements RenderEngine { 28 | 29 | @Override 30 | public void init() throws RenderEngineException { 31 | } 32 | 33 | @Override 34 | public RenderEngineModel openModel(InputStream inputStream, long size) throws RenderEngineException { 35 | return new NopRenderEngineModel(); 36 | } 37 | 38 | @Override 39 | public RenderEngineModel openModel(InputStream inputStream) throws RenderEngineException { 40 | return new NopRenderEngineModel(); 41 | } 42 | 43 | @Override 44 | public void close() throws RenderEngineException { 45 | } 46 | 47 | @Override 48 | public boolean isCalculateQuantities() { 49 | return false; 50 | } 51 | 52 | @Override 53 | public boolean isApplyLayerSets() { 54 | return false; 55 | } 56 | 57 | @Override 58 | public Metrics getMetrics() { 59 | return null; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/noprenderengine/NopRenderEngineGeometry.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.noprenderengine; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | /****************************************************************************** 6 | * Copyright (C) 2009-2019 BIMserver.org 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Affero General Public License as 10 | * published by the Free Software Foundation, either version 3 of the 11 | * License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Affero General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Affero General Public License 19 | * along with this program. If not, see {@literal}. 20 | *****************************************************************************/ 21 | 22 | import org.bimserver.plugins.renderengine.RenderEngineGeometry; 23 | 24 | public class NopRenderEngineGeometry extends RenderEngineGeometry { 25 | 26 | public NopRenderEngineGeometry(ByteBuffer indices, ByteBuffer vertices, ByteBuffer normals, ByteBuffer materials, ByteBuffer materialIndices) { 27 | super(indices, vertices, normals, materials, materialIndices); 28 | } 29 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/noprenderengine/NopRenderEngineInstance.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.noprenderengine; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | /****************************************************************************** 6 | * Copyright (C) 2009-2019 BIMserver.org 7 | * 8 | * This program is free software: you can redistribute it and/or modify 9 | * it under the terms of the GNU Affero General Public License as 10 | * published by the Free Software Foundation, either version 3 of the 11 | * License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Affero General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Affero General Public License 19 | * along with this program. If not, see {@literal}. 20 | *****************************************************************************/ 21 | 22 | import org.bimserver.geometry.Matrix; 23 | import org.bimserver.plugins.renderengine.RenderEngineException; 24 | import org.bimserver.plugins.renderengine.RenderEngineGeometry; 25 | import org.bimserver.plugins.renderengine.RenderEngineInstance; 26 | 27 | import com.fasterxml.jackson.databind.node.ObjectNode; 28 | 29 | public class NopRenderEngineInstance implements RenderEngineInstance { 30 | 31 | @Override 32 | public double[] getTransformationMatrix() throws RenderEngineException { 33 | return Matrix.identity(); 34 | } 35 | 36 | @Override 37 | public RenderEngineGeometry generateGeometry() throws RenderEngineException { 38 | return new NopRenderEngineGeometry(ByteBuffer.allocate(0), ByteBuffer.allocate(0), ByteBuffer.allocate(0), ByteBuffer.allocate(0), ByteBuffer.allocate(0)); 39 | } 40 | 41 | @Override 42 | public ObjectNode getAdditionalData() throws RenderEngineException { 43 | return null; 44 | } 45 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/noprenderengine/NopRenderEngineModel.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.noprenderengine; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.util.ArrayList; 21 | import java.util.Collection; 22 | 23 | import org.bimserver.plugins.renderengine.RenderEngineException; 24 | import org.bimserver.plugins.renderengine.RenderEngineFilter; 25 | import org.bimserver.plugins.renderengine.RenderEngineInstance; 26 | import org.bimserver.plugins.renderengine.RenderEngineModel; 27 | import org.bimserver.plugins.renderengine.RenderEngineSettings; 28 | 29 | public class NopRenderEngineModel implements RenderEngineModel { 30 | 31 | @Override 32 | public void setFormat(int format, int mask) throws RenderEngineException { 33 | } 34 | 35 | @Override 36 | public void setSettings(RenderEngineSettings settings) throws RenderEngineException { 37 | } 38 | 39 | @Override 40 | public RenderEngineInstance getInstanceFromExpressId(long oid) throws RenderEngineException { 41 | return new NopRenderEngineInstance(); 42 | } 43 | 44 | @Override 45 | public Collection listInstances() throws RenderEngineException { 46 | return new ArrayList<>(); 47 | } 48 | 49 | @Override 50 | public void generateGeneralGeometry() throws RenderEngineException { 51 | } 52 | 53 | @Override 54 | public void close() throws RenderEngineException { 55 | } 56 | 57 | @Override 58 | public void setFilter(RenderEngineFilter renderEngineFilter) throws RenderEngineException { 59 | } 60 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/serializers/JsonSerializer.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.serializers; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.io.OutputStream; 21 | 22 | import org.bimserver.emf.IfcModelInterface; 23 | import org.bimserver.emf.SharedJsonSerializer; 24 | import org.bimserver.ifc.IfcSerializer; 25 | import org.bimserver.plugins.serializers.ProgressReporter; 26 | import org.bimserver.plugins.serializers.ProjectInfo; 27 | import org.bimserver.plugins.serializers.SerializerException; 28 | 29 | /** 30 | * @author Ruben de Laat 31 | * Deprecated, use the JsonStreamingSerializer 32 | */ 33 | @Deprecated 34 | public class JsonSerializer extends IfcSerializer { 35 | 36 | private SharedJsonSerializer sharedJsonSerializer; 37 | 38 | @Override 39 | public void init(IfcModelInterface model, ProjectInfo projectInfo, boolean normalizeOids) throws SerializerException { 40 | super.init(model, projectInfo, normalizeOids); 41 | sharedJsonSerializer = new SharedJsonSerializer(getModel(), true); 42 | } 43 | 44 | @Override 45 | protected boolean write(OutputStream outputStream, ProgressReporter progressReporter) throws SerializerException { 46 | return sharedJsonSerializer.write(outputStream, progressReporter); 47 | } 48 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/serializers/JsonSerializerPlugin.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.serializers; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.util.Set; 21 | 22 | import org.bimserver.emf.Schema; 23 | import org.bimserver.models.store.ObjectDefinition; 24 | import org.bimserver.plugins.PluginConfiguration; 25 | import org.bimserver.plugins.PluginContext; 26 | import org.bimserver.plugins.serializers.AbstractSerializerPlugin; 27 | import org.bimserver.plugins.serializers.EmfSerializer; 28 | import org.bimserver.shared.exceptions.PluginException; 29 | 30 | /** 31 | * @author Ruben de Laat 32 | * Deprecated, use the JsonStreamingSerializer 33 | */ 34 | @Deprecated 35 | public class JsonSerializerPlugin extends AbstractSerializerPlugin { 36 | 37 | @Override 38 | public EmfSerializer createSerializer(PluginConfiguration pluginConfiguration) { 39 | return new JsonSerializer(); 40 | } 41 | 42 | @Override 43 | public void init(PluginContext pluginContext, PluginConfiguration systemSettings) throws PluginException { 44 | } 45 | 46 | @Override 47 | public String getDefaultContentType() { 48 | return "application/json"; 49 | } 50 | 51 | @Override 52 | public String getDefaultExtension() { 53 | return "json"; 54 | } 55 | 56 | @Override 57 | public ObjectDefinition getUserSettingsDefinition() { 58 | return super.getUserSettingsDefinition(); 59 | } 60 | 61 | @Override 62 | public Set getSupportedSchemas() { 63 | return Schema.asSet(Schema.IFC2X3TC1, Schema.IFC4); 64 | } 65 | 66 | @Override 67 | public String getOutputFormat(Schema schema) { 68 | switch (schema) { 69 | case IFC2X3TC1: 70 | return "IFC_JSON_2X3TC1"; 71 | case IFC4: 72 | return "IFC_JSON_4"; 73 | default: 74 | return null; 75 | } 76 | } 77 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/serializers/JsonSerializerPluginWithGeometry.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.serializers; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.util.Set; 21 | 22 | import org.bimserver.emf.Schema; 23 | import org.bimserver.models.store.ObjectDefinition; 24 | import org.bimserver.plugins.PluginConfiguration; 25 | import org.bimserver.plugins.PluginContext; 26 | import org.bimserver.plugins.serializers.AbstractSerializerPlugin; 27 | import org.bimserver.plugins.serializers.EmfSerializer; 28 | import org.bimserver.shared.exceptions.PluginException; 29 | 30 | /** 31 | * @author Ruben de Laat 32 | * Deprecated, use the JsonStreamingSerializer 33 | */ 34 | @Deprecated 35 | public class JsonSerializerPluginWithGeometry extends AbstractSerializerPlugin { 36 | 37 | @Override 38 | public EmfSerializer createSerializer(PluginConfiguration pluginConfiguration) { 39 | return new JsonSerializerWithGeometry(); 40 | } 41 | 42 | @Override 43 | public void init(PluginContext pluginContext, PluginConfiguration systemSettings) throws PluginException { 44 | } 45 | 46 | @Override 47 | public String getDefaultContentType() { 48 | return "application/json"; 49 | } 50 | 51 | @Override 52 | public String getDefaultExtension() { 53 | return "json"; 54 | } 55 | 56 | @Override 57 | public ObjectDefinition getUserSettingsDefinition() { 58 | return super.getUserSettingsDefinition(); 59 | } 60 | 61 | @Override 62 | public Set getSupportedSchemas() { 63 | return Schema.asSet(Schema.IFC2X3TC1, Schema.IFC4); 64 | } 65 | 66 | @Override 67 | public String getOutputFormat(Schema schema) { 68 | switch (schema) { 69 | case IFC2X3TC1: 70 | return "IFC_JSON_GEOM_2x3TC1"; 71 | case IFC4: 72 | return "IFC_JSON_GEOM_4"; 73 | default: return null; 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/serializers/JsonSerializerWithGeometry.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.serializers; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.io.OutputStream; 21 | 22 | import org.bimserver.emf.IfcModelInterface; 23 | import org.bimserver.emf.SharedJsonSerializer; 24 | import org.bimserver.ifc.IfcSerializer; 25 | import org.bimserver.plugins.serializers.ProgressReporter; 26 | import org.bimserver.plugins.serializers.ProjectInfo; 27 | import org.bimserver.plugins.serializers.SerializerException; 28 | 29 | /** 30 | * @author Ruben de Laat 31 | * Deprecated, use the JsonStreamingSerializer 32 | */ 33 | @Deprecated 34 | public class JsonSerializerWithGeometry extends IfcSerializer { 35 | 36 | private SharedJsonSerializer sharedJsonSerializer; 37 | 38 | @Override 39 | public void init(IfcModelInterface model, ProjectInfo projectInfo, boolean normalizeOids) throws SerializerException { 40 | super.init(model, projectInfo, normalizeOids); 41 | sharedJsonSerializer = new SharedJsonSerializer(getModel(), true); 42 | } 43 | 44 | @Override 45 | protected boolean write(OutputStream outputStream, ProgressReporter progressReporter) throws SerializerException { 46 | return sharedJsonSerializer.write(outputStream, progressReporter); 47 | } 48 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/serializers/JsonStreamingSerializerPlugin.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.serializers; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.util.HashSet; 21 | import java.util.Set; 22 | 23 | import org.bimserver.emf.Schema; 24 | import org.bimserver.models.store.ObjectDefinition; 25 | import org.bimserver.models.store.ParameterDefinition; 26 | import org.bimserver.models.store.PrimitiveDefinition; 27 | import org.bimserver.models.store.PrimitiveEnum; 28 | import org.bimserver.models.store.StoreFactory; 29 | import org.bimserver.models.store.StringType; 30 | import org.bimserver.plugins.PluginConfiguration; 31 | import org.bimserver.plugins.PluginContext; 32 | import org.bimserver.plugins.serializers.StreamingSerializer; 33 | import org.bimserver.plugins.serializers.StreamingSerializerPlugin; 34 | import org.bimserver.shared.exceptions.PluginException; 35 | 36 | public class JsonStreamingSerializerPlugin implements StreamingSerializerPlugin { 37 | 38 | @Override 39 | public void init(PluginContext pluginContext, PluginConfiguration systemSettings) throws PluginException { 40 | } 41 | 42 | @Override 43 | public ObjectDefinition getUserSettingsDefinition() { 44 | ObjectDefinition objectDefinition = StoreFactory.eINSTANCE.createObjectDefinition(); 45 | 46 | ParameterDefinition extensionParameter = StoreFactory.eINSTANCE.createParameterDefinition(); 47 | extensionParameter.setIdentifier(EXTENSION); 48 | extensionParameter.setDescription("Extension of the downloaded file"); 49 | PrimitiveDefinition stringType = StoreFactory.eINSTANCE.createPrimitiveDefinition(); 50 | stringType.setType(PrimitiveEnum.STRING); 51 | extensionParameter.setType(stringType); 52 | StringType defaultExtensionValue = StoreFactory.eINSTANCE.createStringType(); 53 | defaultExtensionValue.setValue("json"); 54 | extensionParameter.setDefaultValue(defaultExtensionValue); 55 | objectDefinition.getParameters().add(extensionParameter); 56 | 57 | ParameterDefinition contentTypeParameter = StoreFactory.eINSTANCE.createParameterDefinition(); 58 | contentTypeParameter.setIdentifier(CONTENT_TYPE); 59 | contentTypeParameter.setDescription("Content-Type in the HTTP header of the downloaded file"); 60 | contentTypeParameter.setType(stringType); 61 | StringType defaultContentTypeValue = StoreFactory.eINSTANCE.createStringType(); 62 | defaultContentTypeValue.setValue("application/json"); 63 | contentTypeParameter.setDefaultValue(defaultContentTypeValue); 64 | objectDefinition.getParameters().add(contentTypeParameter); 65 | 66 | PrimitiveDefinition stringDefinition = StoreFactory.eINSTANCE.createPrimitiveDefinition(); 67 | stringDefinition.setType(PrimitiveEnum.STRING); 68 | 69 | ParameterDefinition zipExtension = StoreFactory.eINSTANCE.createParameterDefinition(); 70 | zipExtension.setIdentifier(ZIP_EXTENSION); 71 | zipExtension.setDescription("Extension of the downloaded file when using zip compression"); 72 | zipExtension.setType(stringDefinition); 73 | StringType defaultZipExtensionValue = StoreFactory.eINSTANCE.createStringType(); 74 | defaultZipExtensionValue.setValue("zip"); 75 | zipExtension.setDefaultValue(defaultZipExtensionValue); 76 | objectDefinition.getParameters().add(zipExtension); 77 | 78 | return objectDefinition; 79 | } 80 | 81 | @Override 82 | public ObjectDefinition getSystemSettingsDefinition() { 83 | return null; 84 | } 85 | 86 | @Override 87 | public StreamingSerializer createSerializer(PluginConfiguration pluginConfiguration) { 88 | return new StreamingJsonSerializer(pluginConfiguration); 89 | } 90 | 91 | @Override 92 | public Set getSupportedSchemas() { 93 | Set schemas = new HashSet<>(); 94 | schemas.add(Schema.IFC2X3TC1); 95 | schemas.add(Schema.IFC4); 96 | return schemas; 97 | } 98 | 99 | @Override 100 | public String getOutputFormat(Schema schema) { 101 | switch (schema) { 102 | case IFC2X3TC1: 103 | return "IFC_JSON_2X3TC1"; 104 | case IFC4: 105 | return "IFC_JSON_4"; 106 | default: 107 | return null; 108 | } 109 | } 110 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/serializers/MinimalJsonStreamingSerializerPlugin.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.serializers; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.util.HashSet; 21 | import java.util.Set; 22 | 23 | import org.bimserver.emf.Schema; 24 | import org.bimserver.models.store.ObjectDefinition; 25 | import org.bimserver.models.store.ParameterDefinition; 26 | import org.bimserver.models.store.PrimitiveDefinition; 27 | import org.bimserver.models.store.PrimitiveEnum; 28 | import org.bimserver.models.store.StoreFactory; 29 | import org.bimserver.models.store.StringType; 30 | import org.bimserver.plugins.PluginConfiguration; 31 | import org.bimserver.plugins.PluginContext; 32 | import org.bimserver.plugins.serializers.StreamingSerializer; 33 | import org.bimserver.plugins.serializers.StreamingSerializerPlugin; 34 | import org.bimserver.shared.exceptions.PluginException; 35 | 36 | /** 37 | * @author Ruben de Laat 38 | * Deprecated, use the JsonStreamingSerializer 39 | */ 40 | @Deprecated 41 | public class MinimalJsonStreamingSerializerPlugin implements StreamingSerializerPlugin { 42 | 43 | @Override 44 | public void init(PluginContext pluginContext, PluginConfiguration systemSettings) throws PluginException { 45 | } 46 | 47 | @Override 48 | public ObjectDefinition getUserSettingsDefinition() { 49 | ObjectDefinition objectDefinition = StoreFactory.eINSTANCE.createObjectDefinition(); 50 | 51 | ParameterDefinition extensionParameter = StoreFactory.eINSTANCE.createParameterDefinition(); 52 | extensionParameter.setIdentifier(EXTENSION); 53 | extensionParameter.setDescription("Extension of the downloaded file"); 54 | PrimitiveDefinition stringType = StoreFactory.eINSTANCE.createPrimitiveDefinition(); 55 | stringType.setType(PrimitiveEnum.STRING); 56 | extensionParameter.setType(stringType); 57 | StringType defaultExtensionValue = StoreFactory.eINSTANCE.createStringType(); 58 | defaultExtensionValue.setValue("json"); 59 | extensionParameter.setDefaultValue(defaultExtensionValue); 60 | objectDefinition.getParameters().add(extensionParameter); 61 | 62 | ParameterDefinition contentTypeParameter = StoreFactory.eINSTANCE.createParameterDefinition(); 63 | contentTypeParameter.setIdentifier(CONTENT_TYPE); 64 | contentTypeParameter.setDescription("Content-Type in the HTTP header of the downloaded file"); 65 | contentTypeParameter.setType(stringType); 66 | StringType defaultContentTypeValue = StoreFactory.eINSTANCE.createStringType(); 67 | defaultContentTypeValue.setValue("application/json"); 68 | contentTypeParameter.setDefaultValue(defaultContentTypeValue); 69 | objectDefinition.getParameters().add(contentTypeParameter); 70 | 71 | PrimitiveDefinition stringDefinition = StoreFactory.eINSTANCE.createPrimitiveDefinition(); 72 | stringDefinition.setType(PrimitiveEnum.STRING); 73 | 74 | ParameterDefinition zipExtension = StoreFactory.eINSTANCE.createParameterDefinition(); 75 | zipExtension.setIdentifier(ZIP_EXTENSION); 76 | zipExtension.setDescription("Extension of the downloaded file when using zip compression"); 77 | zipExtension.setType(stringDefinition); 78 | StringType defaultZipExtensionValue = StoreFactory.eINSTANCE.createStringType(); 79 | defaultZipExtensionValue.setValue("zip"); 80 | zipExtension.setDefaultValue(defaultZipExtensionValue); 81 | objectDefinition.getParameters().add(zipExtension); 82 | 83 | return objectDefinition; 84 | } 85 | 86 | @Override 87 | public ObjectDefinition getSystemSettingsDefinition() { 88 | return null; 89 | } 90 | 91 | @Override 92 | public StreamingSerializer createSerializer(PluginConfiguration pluginConfiguration) { 93 | return new MinimalStreamingJsonSerializer(pluginConfiguration); 94 | } 95 | 96 | @Override 97 | public Set getSupportedSchemas() { 98 | Set schemas = new HashSet<>(); 99 | schemas.add(Schema.IFC2X3TC1); 100 | schemas.add(Schema.IFC4); 101 | return schemas; 102 | } 103 | 104 | @Override 105 | public String getOutputFormat(Schema schema) { 106 | switch (schema) { 107 | case IFC2X3TC1: 108 | return "IFC_JSON_2X3TC1"; 109 | case IFC4: 110 | return "IFC_JSON_4"; 111 | default: 112 | return null; 113 | } 114 | } 115 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/serializers/MinimalStreamingJsonSerializer.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.serializers; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.io.InputStream; 21 | import java.io.OutputStream; 22 | 23 | import org.bimserver.BimserverDatabaseException; 24 | import org.bimserver.emf.PackageMetaData; 25 | import org.bimserver.emf.SharedJsonStreamingSerializer; 26 | import org.bimserver.models.store.IfcHeader; 27 | import org.bimserver.plugins.PluginConfiguration; 28 | import org.bimserver.plugins.PluginManagerInterface; 29 | import org.bimserver.plugins.serializers.ObjectProvider; 30 | import org.bimserver.plugins.serializers.ProjectInfo; 31 | import org.bimserver.plugins.serializers.SerializerException; 32 | import org.bimserver.plugins.serializers.SerializerInputstream; 33 | import org.bimserver.plugins.serializers.StreamingReader; 34 | import org.bimserver.plugins.serializers.StreamingSerializer; 35 | 36 | /** 37 | * @author Ruben de Laat 38 | * Deprecated, use the JsonStreamingSerializer 39 | */ 40 | @Deprecated 41 | public class MinimalStreamingJsonSerializer implements StreamingSerializer, StreamingReader { 42 | 43 | private ObjectProvider objectProvider; 44 | private IfcHeader ifcHeader; 45 | private PluginConfiguration pluginConfiguration; 46 | private SharedJsonStreamingSerializer sharedJsonStreamingSerializer; 47 | 48 | public MinimalStreamingJsonSerializer(PluginConfiguration pluginConfiguration) { 49 | this.pluginConfiguration = pluginConfiguration; 50 | } 51 | 52 | @Override 53 | public void init(ObjectProvider objectProvider, ProjectInfo projectInfo, IfcHeader ifcHeader, PluginManagerInterface pluginManager, PackageMetaData packageMetaData) throws SerializerException { 54 | this.objectProvider = objectProvider; 55 | this.ifcHeader = ifcHeader; 56 | sharedJsonStreamingSerializer = new SharedJsonStreamingSerializer(objectProvider, ifcHeader, true, true); 57 | } 58 | 59 | @Override 60 | public void writeToOutputStream(OutputStream outputStream) throws SerializerException, BimserverDatabaseException { 61 | boolean result = sharedJsonStreamingSerializer.write(outputStream); 62 | while (result) { 63 | result = sharedJsonStreamingSerializer.write(outputStream); 64 | } 65 | } 66 | 67 | @Override 68 | public InputStream getInputStream() { 69 | return new SerializerInputstream(this); 70 | } 71 | 72 | @Override 73 | public boolean write(OutputStream out) throws SerializerException, BimserverDatabaseException { 74 | return sharedJsonStreamingSerializer.write(out); 75 | } 76 | } -------------------------------------------------------------------------------- /IfcPlugins/src/org/bimserver/serializers/StreamingJsonSerializer.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.serializers; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.io.InputStream; 21 | import java.io.OutputStream; 22 | 23 | import org.bimserver.BimserverDatabaseException; 24 | import org.bimserver.emf.PackageMetaData; 25 | import org.bimserver.emf.SharedJsonStreamingSerializer; 26 | import org.bimserver.models.store.IfcHeader; 27 | import org.bimserver.plugins.PluginConfiguration; 28 | import org.bimserver.plugins.PluginManagerInterface; 29 | import org.bimserver.plugins.serializers.ObjectProvider; 30 | import org.bimserver.plugins.serializers.ProjectInfo; 31 | import org.bimserver.plugins.serializers.SerializerException; 32 | import org.bimserver.plugins.serializers.SerializerInputstream; 33 | import org.bimserver.plugins.serializers.StreamingReader; 34 | import org.bimserver.plugins.serializers.StreamingSerializer; 35 | 36 | public class StreamingJsonSerializer implements StreamingSerializer, StreamingReader { 37 | 38 | private SharedJsonStreamingSerializer sharedJsonStreamingSerializer; 39 | 40 | public StreamingJsonSerializer(PluginConfiguration pluginConfiguration) { 41 | } 42 | 43 | @Override 44 | public void init(ObjectProvider objectProvider, ProjectInfo projectInfo, IfcHeader ifcHeader, PluginManagerInterface pluginManager, PackageMetaData packageMetaData) throws SerializerException { 45 | sharedJsonStreamingSerializer = new SharedJsonStreamingSerializer(objectProvider, ifcHeader, true, false); 46 | } 47 | 48 | @Override 49 | public void writeToOutputStream(OutputStream outputStream) throws SerializerException, BimserverDatabaseException { 50 | boolean result = sharedJsonStreamingSerializer.write(outputStream); 51 | while (result) { 52 | result = sharedJsonStreamingSerializer.write(outputStream); 53 | } 54 | } 55 | 56 | @Override 57 | public InputStream getInputStream() { 58 | return new SerializerInputstream(this); 59 | } 60 | 61 | @Override 62 | public boolean write(OutputStream out) throws SerializerException, BimserverDatabaseException { 63 | return sharedJsonStreamingSerializer.write(out); 64 | } 65 | } -------------------------------------------------------------------------------- /IfcPlugins/test/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d{HH:mm:ss} %-5level [%thread]: %-80message \(%file:%line\) %n 7 | 8 | 9 | DEBUG 10 | ACCEPT 11 | 12 | 13 | INFO 14 | ACCEPT 15 | 16 | 17 | TRACE 18 | ACCEPT 19 | 20 | 21 | WARN 22 | DENY 23 | 24 | 25 | ERROR 26 | DENY 27 | 28 | 29 | 30 | 31 | %d{HH:mm:ss} %-5level [%thread]: %-80message \(%file:%line\) %n 32 | 33 | 34 | DEBUG 35 | DENY 36 | 37 | 38 | INFO 39 | DENY 40 | 41 | 42 | TRACE 43 | DENY 44 | 45 | 46 | WARN 47 | ACCEPT 48 | 49 | 50 | ERROR 51 | ACCEPT 52 | 53 | System.err 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /IfcPlugins/test/org/bimserver/test/TestReadAddWrite.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.test; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.io.ByteArrayInputStream; 21 | import java.io.ByteArrayOutputStream; 22 | import java.io.IOException; 23 | import java.io.InputStream; 24 | import java.net.MalformedURLException; 25 | import java.net.URL; 26 | import java.nio.file.Paths; 27 | 28 | import org.apache.commons.io.IOUtils; 29 | import org.bimserver.emf.IfcModelInterface; 30 | import org.bimserver.emf.IfcModelInterfaceException; 31 | import org.bimserver.emf.PackageMetaData; 32 | import org.bimserver.emf.Schema; 33 | import org.bimserver.ifc.step.deserializer.Ifc2x3tc1StepDeserializer; 34 | import org.bimserver.ifc.step.serializer.Ifc2x3tc1StepSerializer; 35 | import org.bimserver.models.ifc2x3tc1.Ifc2x3tc1Package; 36 | import org.bimserver.models.ifc2x3tc1.IfcBuilding; 37 | import org.bimserver.models.ifc2x3tc1.IfcElementQuantity; 38 | import org.bimserver.models.ifc2x3tc1.IfcQuantityVolume; 39 | import org.bimserver.models.ifc2x3tc1.IfcRelDefinesByProperties; 40 | import org.bimserver.plugins.PluginConfiguration; 41 | import org.bimserver.plugins.deserializers.DeserializeException; 42 | import org.bimserver.plugins.serializers.SerializerException; 43 | import org.junit.Test; 44 | 45 | public class TestReadAddWrite { 46 | @Test 47 | public void test() { 48 | Ifc2x3tc1StepDeserializer deserializer = new Ifc2x3tc1StepDeserializer(); 49 | PackageMetaData packageMetaData = new PackageMetaData(Ifc2x3tc1Package.eINSTANCE, Schema.IFC2X3TC1, Paths.get("tmp")); 50 | deserializer.init(packageMetaData); 51 | 52 | try { 53 | URL url = new URL("https://raw.githubusercontent.com/opensourceBIM/IFC-files/master/HHS%20Office/construction.ifc"); 54 | InputStream openStream = url.openStream(); 55 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 56 | IOUtils.copy(openStream, baos); 57 | IfcModelInterface model = deserializer.read(new ByteArrayInputStream(baos.toByteArray()), "", baos.size(), null); 58 | 59 | // This is needed so we start with a clean slate of express id's 60 | model.resetExpressIds(); 61 | 62 | // This is needed so we continue counting at highest already existing oid 63 | model.fixOidCounter(); 64 | 65 | for (IfcBuilding building : model.getAllWithSubTypes(IfcBuilding.class)) { 66 | try { 67 | // Use createAndAdd to actually add the object to the model 68 | IfcQuantityVolume g_volume = model.createAndAdd(IfcQuantityVolume.class); 69 | g_volume.setName("Test Quantity"); 70 | g_volume.setVolumeValue(1000000000); 71 | 72 | IfcElementQuantity el_gv = model.createAndAdd(IfcElementQuantity.class); 73 | el_gv.getQuantities().add(g_volume); 74 | 75 | IfcRelDefinesByProperties ifcRelDefinesByProperties1 = model.createAndAdd(IfcRelDefinesByProperties.class); 76 | ifcRelDefinesByProperties1.setRelatingPropertyDefinition(el_gv); 77 | ifcRelDefinesByProperties1.getRelatedObjects().add(building); 78 | building.getIsDefinedBy().add(ifcRelDefinesByProperties1); 79 | } catch (IfcModelInterfaceException e) { 80 | e.printStackTrace(); 81 | } 82 | } 83 | 84 | Ifc2x3tc1StepSerializer serializer = new Ifc2x3tc1StepSerializer(new PluginConfiguration()); 85 | serializer.init(model, null, true); // Put "true" as the last argument in order to generate new express id's 86 | serializer.writeToFile(Paths.get("output.ifc"), null); 87 | } catch (MalformedURLException e) { 88 | e.printStackTrace(); 89 | } catch (IOException e) { 90 | e.printStackTrace(); 91 | } catch (DeserializeException e) { 92 | e.printStackTrace(); 93 | } catch (SerializerException e) { 94 | e.printStackTrace(); 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /IfcPlugins/test/org/bimserver/test/TestReadModifyWrite.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.test; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.io.ByteArrayInputStream; 21 | import java.io.ByteArrayOutputStream; 22 | import java.io.IOException; 23 | import java.io.InputStream; 24 | import java.net.MalformedURLException; 25 | import java.net.URL; 26 | import java.nio.file.Paths; 27 | 28 | import org.apache.commons.io.IOUtils; 29 | import org.bimserver.emf.IfcModelInterface; 30 | import org.bimserver.emf.PackageMetaData; 31 | import org.bimserver.emf.Schema; 32 | import org.bimserver.ifc.step.deserializer.Ifc2x3tc1StepDeserializer; 33 | import org.bimserver.ifc.step.serializer.Ifc2x3tc1StepSerializer; 34 | import org.bimserver.models.ifc2x3tc1.Ifc2x3tc1Package; 35 | import org.bimserver.models.ifc2x3tc1.IfcWall; 36 | import org.bimserver.plugins.PluginConfiguration; 37 | import org.bimserver.plugins.deserializers.DeserializeException; 38 | import org.bimserver.plugins.serializers.SerializerException; 39 | import org.junit.Test; 40 | 41 | public class TestReadModifyWrite { 42 | @Test 43 | public void test() { 44 | Ifc2x3tc1StepDeserializer deserializer = new Ifc2x3tc1StepDeserializer(); 45 | PackageMetaData packageMetaData = new PackageMetaData(Ifc2x3tc1Package.eINSTANCE, Schema.IFC2X3TC1, Paths.get("tmp")); 46 | deserializer.init(packageMetaData); 47 | 48 | try { 49 | URL url = new URL("https://raw.githubusercontent.com/opensourceBIM/IFC-files/master/HHS%20Office/construction.ifc"); 50 | InputStream openStream = url.openStream(); 51 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 52 | IOUtils.copy(openStream, baos); 53 | IfcModelInterface model = deserializer.read(new ByteArrayInputStream(baos.toByteArray()), "", baos.size(), null); 54 | 55 | for (IfcWall ifcWall : model.getAllWithSubTypes(IfcWall.class)) { 56 | ifcWall.setName(ifcWall.getName() + " Modified"); 57 | } 58 | 59 | Ifc2x3tc1StepSerializer serializer = new Ifc2x3tc1StepSerializer(new PluginConfiguration()); 60 | serializer.init(model, null, false); 61 | serializer.writeToFile(Paths.get("output.ifc"), null); 62 | } catch (MalformedURLException e) { 63 | e.printStackTrace(); 64 | } catch (IOException e) { 65 | e.printStackTrace(); 66 | } catch (DeserializeException e) { 67 | e.printStackTrace(); 68 | } catch (SerializerException e) { 69 | e.printStackTrace(); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /IfcPlugins/test/org/bimserver/test/TestReadWrite.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.test; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import java.io.ByteArrayInputStream; 21 | import java.io.ByteArrayOutputStream; 22 | import java.io.IOException; 23 | import java.io.InputStream; 24 | import java.net.MalformedURLException; 25 | import java.net.URL; 26 | import java.nio.file.Paths; 27 | 28 | import org.apache.commons.io.IOUtils; 29 | import org.bimserver.emf.IfcModelInterface; 30 | import org.bimserver.emf.PackageMetaData; 31 | import org.bimserver.emf.Schema; 32 | import org.bimserver.ifc.step.deserializer.Ifc2x3tc1StepDeserializer; 33 | import org.bimserver.ifc.step.serializer.Ifc2x3tc1StepSerializer; 34 | import org.bimserver.models.ifc2x3tc1.Ifc2x3tc1Package; 35 | import org.bimserver.plugins.PluginConfiguration; 36 | import org.bimserver.plugins.deserializers.DeserializeException; 37 | import org.bimserver.plugins.serializers.SerializerException; 38 | import org.junit.Test; 39 | 40 | public class TestReadWrite { 41 | @Test 42 | public void test() { 43 | Ifc2x3tc1StepDeserializer deserializer = new Ifc2x3tc1StepDeserializer(); 44 | PackageMetaData packageMetaData = new PackageMetaData(Ifc2x3tc1Package.eINSTANCE, Schema.IFC2X3TC1, Paths.get("tmp")); 45 | deserializer.init(packageMetaData); 46 | 47 | try { 48 | URL url = new URL("https://raw.githubusercontent.com/opensourceBIM/IFC-files/master/HHS%20Office/construction.ifc"); 49 | InputStream openStream = url.openStream(); 50 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 51 | IOUtils.copy(openStream, baos); 52 | IfcModelInterface model = deserializer.read(new ByteArrayInputStream(baos.toByteArray()), "", baos.size(), null); 53 | 54 | Ifc2x3tc1StepSerializer serializer = new Ifc2x3tc1StepSerializer(new PluginConfiguration()); 55 | serializer.init(model, null, false); 56 | serializer.writeToFile(Paths.get("output.ifc"), null); 57 | } catch (MalformedURLException e) { 58 | e.printStackTrace(); 59 | } catch (IOException e) { 60 | e.printStackTrace(); 61 | } catch (DeserializeException e) { 62 | e.printStackTrace(); 63 | } catch (SerializerException e) { 64 | e.printStackTrace(); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /IfcPlugins/test/org/bimserver/test/TestStringDecode.java: -------------------------------------------------------------------------------- 1 | package org.bimserver.test; 2 | 3 | /****************************************************************************** 4 | * Copyright (C) 2009-2019 BIMserver.org 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as 8 | * published by the Free Software Foundation, either version 3 of the 9 | * License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with this program. If not, see {@literal}. 18 | *****************************************************************************/ 19 | 20 | import org.bimserver.ifc.step.deserializer.IfcParserWriterUtils; 21 | import org.bimserver.plugins.deserializers.DeserializeException; 22 | import org.junit.Test; 23 | 24 | import junit.framework.Assert; 25 | 26 | public class TestStringDecode { 27 | @Test 28 | public void testOrder() { 29 | try { 30 | Assert.assertEquals("【S】铝合金-浅灰色(窗框)", IfcParserWriterUtils.readString("'\\X2\\3010\\X0\\S\\X2\\301194DD540891D1\\X0\\-\\X2\\6D4570708272FF087A976846FF09\\X0\\'", 0)); 31 | // Nordic character in UTF-16: 32 | Assert.assertEquals("Vaffelrøre", IfcParserWriterUtils.readString("'Vaffelr\\X2\\00F8\\X0\\re'", 0)); 33 | // Nordic character in UTF-32: 34 | Assert.assertEquals("Vaffelrøre", IfcParserWriterUtils.readString("'Vaffelr\\X4\\000000F8\\X0\\re'", 0)); 35 | 36 | Assert.assertEquals("Åäèíèöà", IfcParserWriterUtils.readString("'\\S\\E\\S\\d\\S\\h\\S\\m\\S\\h\\S\\v\\S\\`'", 0)); 37 | Assert.assertEquals("Øòóê", IfcParserWriterUtils.readString("'\\S\\X\\S\\r\\S\\s\\S\\j'", 0)); 38 | Assert.assertEquals("转角", IfcParserWriterUtils.readString("'\\X2\\8F6C89D2\\X0\\'", 0)); 39 | Assert.assertEquals("/*", IfcParserWriterUtils.readString("'/*'", 0)); 40 | Assert.assertEquals("Fläche", IfcParserWriterUtils.readString("'Fl\\X2\\00E4\\X0\\che'", 0)); 41 | Assert.assertEquals("Länge", IfcParserWriterUtils.readString("'L\\X2\\00E4\\X0\\nge'", 0)); 42 | 43 | // This string is taken from (and edited) ifc4_add2.ifc, pretty sure the original is invalid though 44 | Assert.assertEquals("相对于纵轴的旋转角。对全局坐标系中的垂直柱,该属性为相对于轴的角度。(若轮廓方向在轴上,则转角为0。)对全局坐标系中的非垂直柱,该属性为相对于Z轴的角度。(若轮廓方向在Z轴上,则转角为0。)\n" + 45 | "该属性所提供的形状信息是对内部形状描述和几何参数的补充。如果几何参数与该属性所提供的形状属性不符,应以几何参数为准。对CAD等几何编辑程序,该属性应为只写类型。A注:IFC2x4新添属性", IfcParserWriterUtils.readString("'\\X2\\76F85BF94E8E7EB58F74768465CB8F6C89D230025BF951685C40575068077CFB4E2D7684578276F467F1FF0C8BE55C5E60274E3A76F85BF94E8E\\X0\\\\X2\\8F74768489D25EA63002FF0882E58F6E5ED365B954115728\\X0\\\\X2\\8F744E0AFF0C52198F6C89D24E3A\\X0\\0\\X2\\3002FF095BF951685C40575068077CFB4E2D7684975E578276F467F1FF0C8BE55C5E60274E3A76F85BF94E8E\\X0\\Z\\X2\\8F74768489D25EA63002FF0882E58F6E5ED365B954115728\\X0\\Z\\X2\\8F744E0AFF0C52198F6C89D24E3A\\X0\\0\\X2\\3002FF09\\X0\\\\X\\0A\\X2\\8BE55C5E6027624063D04F9B76845F6272B64FE1606F662F5BF9518590E85F6272B663CF8FF0548C51E04F5553C2657076848865514530025982679C51E04F5553C265704E0E8BE55C5E6027624063D04F9B76845F6272B65C5E60274E0D7B26FF0C5E944EE551E04F5553C265704E3A51C630025BF9\\X0\\CAD\\X2\\7B4951E04F557F168F917A0B5E8FFF0C8BE55C5E60275E944E3A53EA51997C7B578B3002\\X0\\A\\X2\\6CE8FF1A\\X0\\IFC2x4\\X2\\65B06DFB5C5E6027\\X0\\'", 0)); 46 | Assert.assertEquals("REALIZAČNÝ PROJEKT", IfcParserWriterUtils.readString("'REALIZA\\X2\\010C\\X0\\N\\X\\DD PROJEKT'", 0)); // this is correct 47 | Assert.assertEquals("REALIZAČNÝ PROJEKT", IfcParserWriterUtils.readString("'\\PB\\REALIZA\\S\\HN\\S\\] PROJEKT'", 0)); // This is ISO 8859-2 48 | // Assert.assertEquals("REALIZAČNÝ PROJEKT", IfcParserWriterUtils.readString("'REALIZA\\X\\C8N\\X\\DD PROJEKT'", 0)); // This is ISO 8859-2, but \\X\\ directive does not work this way 49 | Assert.assertEquals("ÄÜÖ", IfcParserWriterUtils.readString("'\\S\\D\\S\\\\\\S\\V'",0)); 50 | Assert.assertEquals("0.00 \\X\\B0C", IfcParserWriterUtils.readString("'0.00 \\\\X\\\\B0C'", 0)); 51 | String lorem = "'Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'"; 52 | Assert.assertEquals( lorem.substring(1, lorem.length()-1) , IfcParserWriterUtils.readString(lorem, 0)); 53 | } catch (DeserializeException e) { 54 | Assert.fail(e.getMessage()); 55 | } 56 | } 57 | 58 | @Test(expected = DeserializeException.class) 59 | public void testWrongDanglingBackslash () throws DeserializeException { 60 | IfcParserWriterUtils.readString("'one \\ two'", 0); 61 | } 62 | 63 | @Test(expected = DeserializeException.class) 64 | public void testDirectiveXMissingBackslash () throws DeserializeException { 65 | IfcParserWriterUtils.readString("'one \\Xtwo'", 0); 66 | } 67 | 68 | @Test(expected = DeserializeException.class) 69 | public void testDirectiveXMissingEnd () throws DeserializeException { 70 | IfcParserWriterUtils.readString("'L\\X2\\00E4nge'", 0); 71 | } 72 | 73 | @Test 74 | public void testPerformance() throws DeserializeException { 75 | for (int i=0; i<10000; i++){ 76 | testOrder(); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # IfcPlugins 2 | BIMserver plugins that provide IFC serialization/deserialization 3 | --------------------------------------------------------------------------------