ifcviewer: cache per-model georef in SceneLoader

Adds ModelGeoref { ModelUnits units; Eigen::Matrix4d stage2_meters; bool
has_stage2; } and computeModelGeoref(file*) in Federation.{h,cpp}.  The
helper reads the project length unit, IfcProjectedCRS.MapUnit, helmert
parameters and WCS, and reduces them to a metres-in/metres-out stage 2
matrix using the existing Geolocation + Unit primitives.  When the model
has no IfcMapConversion it returns an identity stage_2 with has_stage2
== false, so the upload pipeline can branch cheaply.

SceneLoader::Model gains a cached ModelGeoref; SceneLoader::modelGeoref
(uint32_t mid) computes lazily on first call (returns nullptr when the
IFC file isn't available yet — happens on the sidecar-hit path before
the data-source thread populates the streamer) and serves from cache
afterwards.

Not yet consumed by the upload pipeline; that's the next commit.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Dion Moult
2026-05-01 17:31:08 +10:00
parent 5386c9ec69
commit bea4e38e65
5 changed files with 87 additions and 3 deletions
+12
View File
@@ -69,6 +69,18 @@ ifcopenshell::file* SceneLoader::ifcFile(uint32_t mid) const {
return it == models_.end() ? nullptr : it->second.streamer->ifcFile();
}
const ModelGeoref* SceneLoader::modelGeoref(uint32_t mid) {
auto it = models_.find(mid);
if (it == models_.end()) return nullptr;
auto& m = it->second;
if (m.has_georef) return &m.georef;
auto* file = m.streamer ? m.streamer->ifcFile() : nullptr;
if (!file) return nullptr;
m.georef = computeModelGeoref(file);
m.has_georef = true;
return &m.georef;
}
std::vector<uint32_t> SceneLoader::addFiles(const QStringList& paths) {
std::vector<uint32_t> assigned;
assigned.reserve(paths.size());