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
+17
View File
@@ -31,6 +31,8 @@
#include <string>
#include <vector>
namespace ifcopenshell { class file; }
// === Stage-3/4 data model ===
//
// A federation places one or more IFC models in a shared scene. Each model's
@@ -96,6 +98,21 @@ struct ModelUnits {
double map_unit_to_meters = 1.0;
};
// Per-model georeferencing data derived from the IFC. `stage2_meters` is
// the helmert · inv(wcs) georef matrix in metres; consumers compose it
// before stage 3 / stage 4 at upload time. When the model has no map
// conversion, `has_stage2 == false` and `stage2_meters` is identity.
struct ModelGeoref {
ModelUnits units;
Eigen::Matrix4d stage2_meters = Eigen::Matrix4d::Identity();
bool has_stage2 = false;
};
// Read a model's project length unit, map unit, helmert parameters, and WCS
// from `ifc_file` and reduce them to a metres-in / metres-out georef matrix.
// Pure compute; safe to call repeatedly if the caller doesn't want to cache.
ModelGeoref computeModelGeoref(ifcopenshell::file* ifc_file);
// 1 federation_unit -> N metres.
double federationUnitToMeters(const FederationConfig&);