Skip to content

Commit 5543de3

Browse files
authored
Merge pull request #2020 from ThatOpen/Fix-Schema
Fix Schemas
2 parents 5735c70 + e009bef commit 5543de3

5 files changed

Lines changed: 22 additions & 0 deletions

File tree

src/cpp/web-ifc/parsing/IfcLoader.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,15 @@ namespace webifc::parsing {
5757
auto line = GetHeaderLinesWithType(schema::FILE_SCHEMA)[0];
5858
MoveToHeaderLineArgument(line, 0);
5959
auto schemas = _schemaManager.GetAvailableSchemas();
60+
auto schemaMaps = _schemaManager.GetAvailableSchemaMaps();
6061

6162
while (!_tokenStream->IsAtEnd()) {
6263
IfcTokenType t = static_cast<IfcTokenType>(_tokenStream->Read<char>());
6364
if (t == IfcTokenType::LINE_END) break;
6465
if (t == IfcTokenType::LABEL)
6566
{
6667
std::string_view schemaName = _tokenStream->ReadString();
68+
if (schemaMaps.contains(schemaName)) schemaName = schemaMaps[schemaName];
6769
for (size_t i = 0; i < schemas.size();i++)
6870
{
6971
if (_schemaManager.GetSchemaName(schemas[i]) == schemaName) return schemas[i];

src/cpp/web-ifc/schema/IfcSchemaManager.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ namespace webifc::schema {
3232
return _schemas;
3333
}
3434

35+
const std::map<std::string_view,std::string_view> &IfcSchemaManager::GetAvailableSchemaMaps() const
36+
{
37+
return _schemaMap;
38+
}
39+
3540
uint32_t IfcSchemaManager::IfcTypeToTypeCode(std::string_view name) const
3641
{
3742
return IfcTypeToTypeCode(name.data(),name.size());

src/cpp/web-ifc/schema/IfcSchemaManager.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "ifc-schema.h"
88
#include <vector>
9+
#include <map>
910
#include <string>
1011
#include <string_view>
1112
#include <unordered_set>
@@ -17,6 +18,7 @@ namespace webifc::schema {
1718
public:
1819
IfcSchemaManager();
1920
const std::vector<IFC_SCHEMA> GetAvailableSchemas() const;
21+
const std::map<std::string_view,std::string_view> &GetAvailableSchemaMaps() const;
2022
std::string_view GetSchemaName(IFC_SCHEMA schema) const;
2123
uint32_t IfcTypeToTypeCode(const std::string_view name) const;
2224
std::string IfcTypeCodeToType(const uint32_t typeCode) const;
@@ -27,6 +29,7 @@ namespace webifc::schema {
2729
std::unordered_set<uint32_t> _ifcElements;
2830
std::vector<IFC_SCHEMA> _schemas;
2931
std::vector<std::string_view> _schemaNames;
32+
std::map<std::string_view,std::string_view> _schemaMap;
3033
void initSchemaData();
3134
uint32_t IfcTypeToTypeCode(const void * name, const size_t len) const;
3235
};

src/cpp/web-ifc/schema/schema-functions.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44
#include "IfcSchemaManager.h"
55
namespace webifc::schema {
66
void IfcSchemaManager::initSchemaData() {
7+
_schemaMap["IFC2X_FINAL"]="IFC2X3";
8+
_schemaMap["IFC4X1"]="IFC4X3";
9+
_schemaMap["IFC4X2"]="IFC4X3";
10+
_schemaMap["IFC4X3_RC3"]="IFC4X3";
11+
_schemaMap["IFC4X3_RC4"]="IFC4X3";
12+
_schemaMap["IFC4X3_RC1"]="IFC4X3";
13+
_schemaMap["IFC4X3_RC2"]="IFC4X3";
14+
_schemaMap["IFC4X3_ADD2"]="IFC4X3";
15+
_schemaMap["IFC4X3_ADD1"]="IFC4X3";
16+
_schemaMap["IFC4X2SCGL"]="IFC4X3";
717
_ifcElements.insert(IFCPRODUCT);
818
_ifcElements.insert(IFCPROXY);
919
_ifcElements.insert(IFCSPATIALSTRUCTUREELEMENT);

src/schema-generator/gen_functional_types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,9 @@ cppSchema.push("#include <string>");
354354
cppSchema.push("#include \"ifc-schema.h\"");
355355
cppSchema.push("#include \"IfcSchemaManager.h\"");
356356
cppSchema.push("namespace webifc::schema {")
357+
357358
cppSchema.push("void IfcSchemaManager::initSchemaData() {");
359+
for (const schemaAlias of schemaAliases) cppSchema.push(`_schemaMap["${schemaAlias.schemaName}"]="${schemaAlias.alias}";`);
358360
completeifcElementList.forEach(element => {
359361
cppSchema.push(`_ifcElements.insert(${element.toUpperCase()});`);
360362
});

0 commit comments

Comments
 (0)