Skip to content

Commit 1d25e59

Browse files
authored
Merge pull request #1952 from barvirm/optimalization
Optimalizations
2 parents 040287f + 6784ea9 commit 1d25e59

13 files changed

Lines changed: 3117 additions & 1111 deletions

benchmark.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
# System informations
2-
{"cpuName":"Apple M1","freeRam":165.203125,"totalRam":8192}
2+
{"cpuName":"Apple M1","freeRam":137.484375,"totalRam":8192}
33
_________
44
| filename | Size (mb) | Time to open model (ms) | Time to execute all (ms) | Total ifc entities | Total meshes | Total geometries | total errors |
55
|-------|-------|-------|-------|-------|-------|-------|-------|
6-
| tests/ifcfiles/public/AC20-FZK-Haus.ifc | 2 | 26 | 200 | 44249 | 83 | 103 | 0 |
7-
tests/ifcfiles/public/C20-Institute-Var-2.ifc | 10 | 82 | 617 | 147712 | 702 | 821 | 0 |
8-
tests/ifcfiles/public/FM_ARC_DigitalHub.ifc | 14 | 96 | 918 | 266483 | 705 | 725 | 0 |
9-
tests/ifcfiles/public/ISSUE_005_haus.ifc | 2 | 20 | 189 | 44249 | 83 | 103 | 0 |
10-
tests/ifcfiles/public/ISSUE_021_Mini Project.ifc | 3 | 22 | 684 | 49044 | 2636 | 3697 | 0 |
11-
tests/ifcfiles/public/ISSUE_034_HouseZ.ifc | 5 | 35 | 145 | 81806 | 228 | 239 | 0 |
6+
| tests/ifcfiles/public/AC20-FZK-Haus.ifc | 2 | 21 | 188 | 44249 | 83 | 103 | 0 |
7+
tests/ifcfiles/public/C20-Institute-Var-2.ifc | 10 | 59 | 593 | 147712 | 702 | 821 | 0 |
8+
tests/ifcfiles/public/FM_ARC_DigitalHub.ifc | 14 | 70 | 919 | 266483 | 705 | 725 | 0 |
9+
tests/ifcfiles/public/ISSUE_005_haus.ifc | 2 | 20 | 188 | 44249 | 83 | 103 | 0 |
10+
tests/ifcfiles/public/ISSUE_021_Mini Project.ifc | 3 | 17 | 638 | 49044 | 2636 | 3697 | 0 |
11+
tests/ifcfiles/public/ISSUE_034_HouseZ.ifc | 5 | 24 | 128 | 81806 | 228 | 239 | 0 |
1212
tests/ifcfiles/public/ISSUE_044_test_IFCCOMPOSITEPROFILEDEF.ifc | 0 | 0 | 1 | 435 | 7 | 11 | 0 |
13-
tests/ifcfiles/public/ISSUE_053_20181220Holter_Tower_10.ifczip | 29 | 1408 | 4990 | 2807815 | 60285 | 60847 | 0 |
14-
tests/ifcfiles/public/ISSUE_068_ARK_NUS_skolebygg.ifc | 55 | 492 | 2189 | 945194 | 4459 | 4542 | 0 |
15-
tests/ifcfiles/public/ISSUE_098_R8_F1_MAB_AR_M3_XX_XXX_MO_7000.ifc | 70 | 596 | 5711 | 1139622 | 11124 | 11338 | 0 |
16-
tests/ifcfiles/public/ISSUE_102_M3D-CON-CD.ifc | 26 | 218 | 2071 | 503608 | 1616 | 1635 | 0 |
17-
tests/ifcfiles/public/ISSUE_102_M3D-CON.ifc | 6 | 43 | 203 | 123282 | 138 | 143 | 0 |
18-
tests/ifcfiles/public/ISSUE_126_model.ifc | 4 | 32 | 114 | 88876 | 257 | 288 | 0 |
19-
tests/ifcfiles/public/ISSUE_129_N1540_17_EXE_MOD_448200_02_09_11SMC_IGC_V17.ifc | 12 | 81 | 633 | 202661 | 959 | 981 | 0 |
20-
tests/ifcfiles/public/ISSUE_159_kleine_Wohnung_R22.ifc | 10 | 71 | 635 | 189788 | 425 | 457 | 0 |
21-
tests/ifcfiles/public/ISSUE_171_IfcSurfaceCurveSweptAreaSolid.ifc | 0 | 2 | 20 | 4327 | 60 | 141 | 0 |
22-
tests/ifcfiles/public/IfcOpenHouse_IFC4.ifc | 0 | 1 | 6 | 2885 | 35 | 43 | 0 |
13+
tests/ifcfiles/public/ISSUE_053_20181220Holter_Tower_10.ifczip | 29 | 1158 | 4608 | 2807815 | 60285 | 60847 | 0 |
14+
tests/ifcfiles/public/ISSUE_068_ARK_NUS_skolebygg.ifc | 55 | 339 | 2052 | 945194 | 4459 | 4542 | 0 |
15+
tests/ifcfiles/public/ISSUE_098_R8_F1_MAB_AR_M3_XX_XXX_MO_7000.ifc | 70 | 448 | 5530 | 1139622 | 11124 | 11338 | 0 |
16+
tests/ifcfiles/public/ISSUE_102_M3D-CON-CD.ifc | 26 | 166 | 2571 | 503608 | 1616 | 1635 | 0 |
17+
tests/ifcfiles/public/ISSUE_102_M3D-CON.ifc | 6 | 29 | 182 | 123282 | 138 | 143 | 0 |
18+
tests/ifcfiles/public/ISSUE_126_model.ifc | 4 | 21 | 99 | 88876 | 257 | 288 | 0 |
19+
tests/ifcfiles/public/ISSUE_129_N1540_17_EXE_MOD_448200_02_09_11SMC_IGC_V17.ifc | 12 | 58 | 599 | 202661 | 959 | 981 | 0 |
20+
tests/ifcfiles/public/ISSUE_159_kleine_Wohnung_R22.ifc | 10 | 63 | 625 | 189788 | 425 | 457 | 0 |
21+
tests/ifcfiles/public/ISSUE_171_IfcSurfaceCurveSweptAreaSolid.ifc | 0 | 1 | 19 | 4327 | 60 | 141 | 0 |
22+
tests/ifcfiles/public/IfcOpenHouse_IFC4.ifc | 0 | 1 | 5 | 2885 | 35 | 43 | 0 |
2323
tests/ifcfiles/public/KIT-Simple-Road-Test-Web-IFC4x3_RC2.ifc | 0 | 2 | 4 | 6500 | 66 | 119 | 0 |
24-
tests/ifcfiles/public/LTU_A-House_redesign.ifczip | 34 | 1409 | 7367 | 3359234 | 6928 | 6945 | 0 |
25-
tests/ifcfiles/public/Office_A_20110811.ifc | 4 | 29 | 209 | 62930 | 803 | 810 | 0 |
26-
tests/ifcfiles/public/S_Office_Integrated Design Archi.ifc | 30 | 284 | 5394 | 551442 | 3417 | 3873 | 0 |
27-
tests/ifcfiles/public/Sample_entities.ifc | 0 | 1 | 1 | 466 | 2 | 10 | 0 |
28-
tests/ifcfiles/public/Viadotto Acerno.ifc | 32 | 236 | 3242 | 253318 | 6546 | 7051 | 0 |
29-
tests/ifcfiles/public/advanced_model.ifc | 34 | 248 | 1614 | 594374 | 6401 | 14120 | 0 |
30-
tests/ifcfiles/public/dental_clinic.ifc | 12 | 83 | 430 | 209259 | 2586 | 2626 | 0 |
31-
tests/ifcfiles/public/duplex.ifc | 2 | 16 | 63 | 38898 | 215 | 224 | 0 |
32-
tests/ifcfiles/public/example.ifc | 0 | 3 | 8 | 6490 | 115 | 119 | 0 |
33-
tests/ifcfiles/public/ifcbridge-model01.ifc | 14 | 102 | 318 | 296968 | 165 | 168 | 0 |
34-
tests/ifcfiles/public/schependomlaan.ifc | 47 | 349 | 533 | 714485 | 3569 | 3643 | 0 |
35-
tests/ifcfiles/public/tested_sample_project.ifc | 1 | 5 | 81 | 14119 | 93 | 98 | 0 |
24+
tests/ifcfiles/public/LTU_A-House_redesign.ifczip | 34 | 1134 | 7623 | 3359234 | 6928 | 6945 | 0 |
25+
tests/ifcfiles/public/Office_A_20110811.ifc | 4 | 24 | 164 | 62930 | 803 | 810 | 0 |
26+
tests/ifcfiles/public/S_Office_Integrated Design Archi.ifc | 30 | 196 | 5338 | 551442 | 3417 | 3873 | 0 |
27+
tests/ifcfiles/public/Sample_entities.ifc | 0 | 1 | 0 | 466 | 2 | 10 | 0 |
28+
tests/ifcfiles/public/Viadotto Acerno.ifc | 32 | 185 | 3139 | 253318 | 6546 | 7051 | 0 |
29+
tests/ifcfiles/public/advanced_model.ifc | 34 | 213 | 1523 | 594374 | 6401 | 14120 | 0 |
30+
tests/ifcfiles/public/dental_clinic.ifc | 12 | 58 | 392 | 209259 | 2586 | 2626 | 0 |
31+
tests/ifcfiles/public/duplex.ifc | 2 | 11 | 57 | 38898 | 215 | 224 | 0 |
32+
tests/ifcfiles/public/example.ifc | 0 | 2 | 7 | 6490 | 115 | 119 | 0 |
33+
tests/ifcfiles/public/ifcbridge-model01.ifc | 14 | 80 | 285 | 296968 | 165 | 168 | 0 |
34+
tests/ifcfiles/public/schependomlaan.ifc | 47 | 301 | 523 | 714485 | 3569 | 3643 | 0 |
35+
tests/ifcfiles/public/tested_sample_project.ifc | 1 | 3 | 74 | 14119 | 93 | 98 | 0 |
3636
#Totals
37-
*Total Time to Open*:5992
38-
*Total Time*:38590
37+
*Total Time to Open*:4705
38+
*Total Time*:38074

src/cpp/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ if(EMSCRIPTEN)
103103
# build parameters for web-ifc
104104
add_executable(web-ifc ${web-ifc-source} ${web-ifc-wasm})
105105
param_setter(web-ifc)
106-
set_target_properties(web-ifc PROPERTIES LINK_FLAGS "${DEBUG_FLAG} --bind -flto --define-macro=REAL_T_IS_DOUBLE -s ALLOW_MEMORY_GROWTH=1 -s DYNAMIC_EXECUTION=0 -s MAXIMUM_MEMORY=4GB -sSTACK_SIZE=5MB -s EXPORT_NAME=WebIFCWasm -s MODULARIZE=1 -s ENVIRONMENT=web -sASSERTIONS=1 -s EXPORTED_RUNTIME_METHODS=\"['HEAPU8','HEAPU32','HEAPF32']\"")
106+
set_target_properties(web-ifc PROPERTIES LINK_FLAGS "${DEBUG_FLAG} --bind -msimd128 -flto --define-macro=REAL_T_IS_DOUBLE -s ALLOW_MEMORY_GROWTH=1 -s DYNAMIC_EXECUTION=0 -s MAXIMUM_MEMORY=4GB -sSTACK_SIZE=5MB -s EXPORT_NAME=WebIFCWasm -s MODULARIZE=1 -s ENVIRONMENT=web -sASSERTIONS=1 -s EXPORTED_RUNTIME_METHODS=\"['HEAPU8','HEAPU32','HEAPF32']\"")
107107

108108
add_executable(web-ifc-node ${web-ifc-source} ${web-ifc-wasm})
109109
param_setter(web-ifc-node)
110-
set_target_properties(web-ifc-node PROPERTIES LINK_FLAGS "${DEBUG_FLAG} --bind -flto --define-macro=REAL_T_IS_DOUBLE -s ALLOW_MEMORY_GROWTH=1 -s DYNAMIC_EXECUTION=0 -s MAXIMUM_MEMORY=4GB -sSTACK_SIZE=5MB -s EXPORT_NAME=WebIFCWasm -s MODULARIZE=1 -s EXPORTED_RUNTIME_METHODS=\"['HEAPU8','HEAPU32','HEAPF32']\"")
110+
set_target_properties(web-ifc-node PROPERTIES LINK_FLAGS "${DEBUG_FLAG} --bind -msimd128 -flto --define-macro=REAL_T_IS_DOUBLE -s ALLOW_MEMORY_GROWTH=1 -s DYNAMIC_EXECUTION=0 -s MAXIMUM_MEMORY=4GB -sSTACK_SIZE=5MB -s EXPORT_NAME=WebIFCWasm -s MODULARIZE=1 -s EXPORTED_RUNTIME_METHODS=\"['HEAPU8','HEAPU32','HEAPF32']\"")
111111

112112
# multi-treaded versions
113113
add_executable(web-ifc-mt ${web-ifc-source} ${web-ifc-wasm})

src/cpp/web-ifc/cache/IfcCache.cpp

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,13 @@ namespace webifc::cache
2828
void IfcCache::Clear()
2929
{
3030
_expressIDToPlacement.clear();
31-
std::unordered_map<uint32_t, glm::dmat4>().swap(_expressIDToPlacement);
3231
_cartesianPoint3DCache.clear();
33-
std::unordered_map<uint32_t, glm::dvec3>().swap(_cartesianPoint3DCache);
3432
_cartesianPoint2DCache.clear();
35-
std::unordered_map<uint32_t, glm::dvec2>().swap(_cartesianPoint2DCache);
3633
}
3734

38-
std::unordered_map<uint32_t, std::vector<uint32_t>> IfcCache::PopulateRelVoidsMap()
35+
ankerl::unordered_dense::map<uint32_t, std::vector<uint32_t>> IfcCache::PopulateRelVoidsMap()
3936
{
40-
std::unordered_map<uint32_t, std::vector<uint32_t>> resultVector;
37+
ankerl::unordered_dense::map<uint32_t, std::vector<uint32_t>> resultVector;
4138
auto relVoids = _loader.GetExpressIDsWithType(schema::IFCRELVOIDSELEMENT);
4239

4340
for (uint32_t relVoidID : relVoids)
@@ -53,9 +50,9 @@ namespace webifc::cache
5350
return resultVector;
5451
}
5552

56-
std::unordered_map<uint32_t, std::vector<uint32_t>> IfcCache::PopulateRelAggregatesMap()
53+
ankerl::unordered_dense::map<uint32_t, std::vector<uint32_t>> IfcCache::PopulateRelAggregatesMap()
5754
{
58-
std::unordered_map<uint32_t, std::vector<uint32_t>> resultVector;
55+
ankerl::unordered_dense::map<uint32_t, std::vector<uint32_t>> resultVector;
5956
auto relAggregates = _loader.GetExpressIDsWithType(schema::IFCRELAGGREGATES);
6057

6158
for (uint32_t relAggregateID : relAggregates)
@@ -86,9 +83,9 @@ namespace webifc::cache
8683
return resultVector;
8784
}
8885

89-
std::unordered_map<uint32_t, std::vector<uint32_t>> IfcCache::PopulateRelNestsMap()
86+
ankerl::unordered_dense::map<uint32_t, std::vector<uint32_t>> IfcCache::PopulateRelNestsMap()
9087
{
91-
std::unordered_map<uint32_t, std::vector<uint32_t>> resultVector;
88+
ankerl::unordered_dense::map<uint32_t, std::vector<uint32_t>> resultVector;
9289
auto relNests = _loader.GetExpressIDsWithType(schema::IFCRELNESTS);
9390

9491
for (uint32_t relNestID : relNests)
@@ -107,9 +104,9 @@ namespace webifc::cache
107104
return resultVector;
108105
}
109106

110-
std::unordered_map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> IfcCache::PopulateStyledItemMap()
107+
ankerl::unordered_dense::map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> IfcCache::PopulateStyledItemMap()
111108
{
112-
std::unordered_map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> returnVector;
109+
ankerl::unordered_dense::map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> returnVector;
113110
auto styledItems = _loader.GetExpressIDsWithType(schema::IFCSTYLEDITEM);
114111

115112
for (uint32_t styledItemID : styledItems)
@@ -133,9 +130,9 @@ namespace webifc::cache
133130
return returnVector;
134131
}
135132

136-
std::unordered_map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> IfcCache::PopulateRelMaterialsMap()
133+
ankerl::unordered_dense::map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> IfcCache::PopulateRelMaterialsMap()
137134
{
138-
std::unordered_map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> resultVector;
135+
ankerl::unordered_dense::map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> resultVector;
139136
auto styledItems = _loader.GetExpressIDsWithType(schema::IFCRELASSOCIATESMATERIAL);
140137

141138
for (uint32_t styledItemID : styledItems)
@@ -157,9 +154,9 @@ namespace webifc::cache
157154
return resultVector;
158155
}
159156

160-
std::unordered_map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> IfcCache::PopulateMaterialDefinitionsMap()
157+
ankerl::unordered_dense::map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> IfcCache::PopulateMaterialDefinitionsMap()
161158
{
162-
std::unordered_map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> resultVector;
159+
ankerl::unordered_dense::map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> resultVector;
163160
auto matDefs = _loader.GetExpressIDsWithType(schema::IFCMATERIALDEFINITIONREPRESENTATION);
164161

165162
for (uint32_t styledItemID : matDefs)
@@ -342,22 +339,22 @@ namespace webifc::cache
342339
return 1;
343340
}
344341

345-
const std::unordered_map<uint32_t, std::vector<uint32_t>> &IfcCache::GetRelVoids() const
342+
const ankerl::unordered_dense::map<uint32_t, std::vector<uint32_t>> &IfcCache::GetRelVoids() const
346343
{
347344
return _relVoids;
348345
}
349346

350-
const std::unordered_map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> &IfcCache::GetStyledItems() const
347+
const ankerl::unordered_dense::map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> &IfcCache::GetStyledItems() const
351348
{
352349
return _styledItems;
353350
}
354351

355-
const std::unordered_map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> &IfcCache::GetRelMaterials() const
352+
const ankerl::unordered_dense::map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> &IfcCache::GetRelMaterials() const
356353
{
357354
return _relMaterials;
358355
}
359356

360-
const std::unordered_map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> &IfcCache::GetMaterialDefinitions() const
357+
const ankerl::unordered_dense::map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> &IfcCache::GetMaterialDefinitions() const
361358
{
362359
return _materialDefinitions;
363360
}
@@ -376,30 +373,30 @@ namespace webifc::cache
376373
return _angularScalingFactor;
377374
}
378375

379-
const std::unordered_map<uint32_t, std::vector<uint32_t>> &IfcCache::GetRelAggregates() const {
376+
const ankerl::unordered_dense::map<uint32_t, std::vector<uint32_t>> &IfcCache::GetRelAggregates() const {
380377
return _relAggregates;
381378
}
382379

383-
const std::unordered_map<uint32_t, std::vector<uint32_t>> &IfcCache::GetRelNests() const {
380+
const ankerl::unordered_dense::map<uint32_t, std::vector<uint32_t>> &IfcCache::GetRelNests() const {
384381
return _relNests;
385382
}
386383

387-
std::unordered_map<uint32_t, glm::dvec3> &IfcCache::GetCartesianPoint3DCache() {
384+
ankerl::unordered_dense::map<uint32_t, glm::dvec3> &IfcCache::GetCartesianPoint3DCache() {
388385
return _cartesianPoint3DCache;
389386
}
390-
391-
std::unordered_map<uint32_t, glm::dvec2> &IfcCache::GetCartesianPoint2DCache() {
387+
388+
ankerl::unordered_dense::map<uint32_t, glm::dvec2> &IfcCache::GetCartesianPoint2DCache() {
392389
return _cartesianPoint2DCache;
393390
}
394-
395-
std::unordered_map<uint32_t, glm::dmat4> &IfcCache::GetExpressIDToPlacement() {
391+
392+
ankerl::unordered_dense::map<uint32_t, glm::dmat4> &IfcCache::GetExpressIDToPlacement() {
396393
return _expressIDToPlacement;
397394
}
398395

399396
std::vector<geometry::IfcCurve> &IfcCache::GetLocalCurvesList() {
400397
return _localCurvesList;
401398
}
402-
399+
403400
std::vector<uint32_t> &IfcCache::GetLocalCurvesIndices() {
404401
return _localcurvesIndices;
405402
}
@@ -410,7 +407,7 @@ namespace webifc::cache
410407
return newCache;
411408
}
412409

413-
IfcCache::IfcCache(const webifc::parsing::IfcLoader &loader, const std::unordered_map<uint32_t, std::vector<uint32_t>> &relVoids, const std::unordered_map<uint32_t, std::vector<uint32_t>> &relNests, const std::unordered_map<uint32_t, std::vector<uint32_t>> &relAggregates, const std::unordered_map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> &styledItems, const std::unordered_map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> &relMaterials, const std::unordered_map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> &materialDefinitions, double linearScalingFactor, double squaredScalingFactor, double cubicScalingFactor, double angularScalingFactor, std::string angleUnits, const std::vector<geometry::IfcCurve> &localCurvesList, const std::vector<uint32_t> &localcurvesIndices, std::unordered_map<uint32_t, glm::dmat4> expressIDToPlacement)
410+
IfcCache::IfcCache(const webifc::parsing::IfcLoader &loader, const ankerl::unordered_dense::map<uint32_t, std::vector<uint32_t>> &relVoids, const ankerl::unordered_dense::map<uint32_t, std::vector<uint32_t>> &relNests, const ankerl::unordered_dense::map<uint32_t, std::vector<uint32_t>> &relAggregates, const ankerl::unordered_dense::map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> &styledItems, const ankerl::unordered_dense::map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> &relMaterials, const ankerl::unordered_dense::map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> &materialDefinitions, double linearScalingFactor, double squaredScalingFactor, double cubicScalingFactor, double angularScalingFactor, std::string angleUnits, const std::vector<geometry::IfcCurve> &localCurvesList, const std::vector<uint32_t> &localcurvesIndices, ankerl::unordered_dense::map<uint32_t, glm::dmat4> expressIDToPlacement)
414411
: _loader(loader), _relVoids(relVoids), _relNests(relNests), _relAggregates(relAggregates), _styledItems(styledItems), _relMaterials(relMaterials), _materialDefinitions(materialDefinitions), _linearScalingFactor(linearScalingFactor), _squaredScalingFactor(squaredScalingFactor), _cubicScalingFactor(cubicScalingFactor), _angularScalingFactor(angularScalingFactor), _angleUnits(angleUnits), _localCurvesList(localCurvesList), _localcurvesIndices(localcurvesIndices), _expressIDToPlacement(expressIDToPlacement)
415412
{
416413
}

0 commit comments

Comments
 (0)