Skip to content

Commit 5928204

Browse files
authored
Merge pull request #1080 from ThatOpen/CachceReset
Add Reset Cache
2 parents 0b947cc + 053aca4 commit 5928204

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed

src/cpp/geometry/IfcGeometryLoader.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ namespace webifc::geometry
2020
ReadLinearScalingFactor();
2121
}
2222

23+
void IfcGeometryLoader::ResetCache() {
24+
_relVoidRel = PopulateRelVoidsRelMap();
25+
_relVoids = PopulateRelVoidsMap();
26+
_relAggregates = PopulateRelAggregatesMap();
27+
_relNests = PopulateRelNestsMap();
28+
_relElementAggregates = PopulateRelElementAggregatesMap();
29+
_styledItems = PopulateStyledItemMap();
30+
_relMaterials = PopulateRelMaterialsMap();
31+
_materialDefinitions = PopulateMaterialDefinitionsMap();
32+
}
33+
2334
void IfcGeometryLoader::Clear() const{
2435
_expressIDToPlacement.clear();
2536
std::unordered_map<uint32_t, glm::dmat4>().swap(_expressIDToPlacement);

src/cpp/geometry/IfcGeometryLoader.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ namespace webifc::geometry
2626
{
2727
public:
2828
IfcGeometryLoader(const webifc::parsing::IfcLoader &loader,const webifc::schema::IfcSchemaManager &schemaManager,uint16_t circleSegments);
29+
void ResetCache();
2930
std::array<glm::dvec3,2> GetAxis1Placement(const uint32_t expressID) const;
3031
glm::dmat3 GetAxis2Placement2D(const uint32_t expressID) const;
3132
glm::dmat4 GetLocalPlacement(const uint32_t expressID, glm::dvec3 vector = glm::dvec3(1)) const;
@@ -70,14 +71,14 @@ namespace webifc::geometry
7071
std::vector<IfcSegmentIndexSelect> ReadCurveIndices() const;
7172
const webifc::parsing::IfcLoader &_loader;
7273
const webifc::schema::IfcSchemaManager &_schemaManager;
73-
const std::unordered_map<uint32_t, std::vector<uint32_t>> _relVoidRel;
74-
const std::unordered_map<uint32_t, std::vector<uint32_t>> _relVoids;
75-
const std::unordered_map<uint32_t, std::vector<uint32_t>> _relNests;
76-
const std::unordered_map<uint32_t, std::vector<uint32_t>> _relAggregates;
77-
const std::unordered_map<uint32_t, std::vector<uint32_t>> _relElementAggregates;
78-
const std::unordered_map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> _styledItems;
79-
const std::unordered_map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> _relMaterials;
80-
const std::unordered_map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> _materialDefinitions;
74+
std::unordered_map<uint32_t, std::vector<uint32_t>> _relVoidRel;
75+
std::unordered_map<uint32_t, std::vector<uint32_t>> _relVoids;
76+
std::unordered_map<uint32_t, std::vector<uint32_t>> _relNests;
77+
std::unordered_map<uint32_t, std::vector<uint32_t>> _relAggregates;
78+
std::unordered_map<uint32_t, std::vector<uint32_t>> _relElementAggregates;
79+
std::unordered_map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> _styledItems;
80+
std::unordered_map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> _relMaterials;
81+
std::unordered_map<uint32_t, std::vector<std::pair<uint32_t, uint32_t>>> _materialDefinitions;
8182
double _linearScalingFactor = 1;
8283
double _squaredScalingFactor = 1;
8384
double _cubicScalingFactor = 1;

src/cpp/web-ifc-wasm.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,10 @@ std::string DecodeText(std::string text) {
721721
return webifc::parsing::p21decode(strView);
722722
}
723723

724+
void ResetCache(uint32_t modelID) {
725+
if (manager.IsModelOpen(modelID)) manager.GetGeometryProcessor(modelID)->GetLoader().ResetCache();
726+
}
727+
724728
EMSCRIPTEN_BINDINGS(my_module) {
725729

726730
emscripten::class_<webifc::geometry::IfcGeometry>("IfcGeometry")

src/ts/web-ifc-api.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,4 +1120,13 @@ export class IfcAPI {
11201120
return this.wasmModule.DecodeText(text);
11211121
}
11221122

1123+
/**
1124+
* Resets the Cached IFC Data - useful when changing the geometry of a model
1125+
* @param modelID Model handle retrieved by OpenModel
1126+
*/
1127+
1128+
ResetCache(modelID: number) {
1129+
return this.wasmModule.DecodeText(modelID);
1130+
}
1131+
11231132
}

0 commit comments

Comments
 (0)