This commit is contained in:
Thomas Krijnen
2026-07-03 12:14:15 +02:00
parent a54a8b80d3
commit 55e97e5379
13 changed files with 152 additions and 152 deletions
+10 -10
View File
@@ -18,8 +18,8 @@
********************************************************************************/
#include "Federation.h"
#include "Geolocation.h"
#include "Unit.h"
#include "geolocation.h"
#include "unit.h"
#include <QDir>
#include <QFile>
@@ -103,18 +103,18 @@ ModelGeoref computeModelGeoref(ifcopenshell::file* ifc_file) {
if (!ifc_file) return out;
out.units.project_length_to_meters =
calculateUnitScale(ifc_file, "LENGTHUNIT");
calculate_unit_scale(ifc_file, "LENGTHUNIT");
auto params = getHelmertTransformationParameters(ifc_file);
auto params = get_helmert_transformation_parameters(ifc_file);
const double scale = (params && params->scale != 0.0) ? params->scale : 1.0;
out.units.map_unit_to_meters = out.units.project_length_to_meters / scale;
if (!params) return out;
Eigen::Matrix4d helmert =
helmertMetersFromParameters(*params, out.units.map_unit_to_meters);
helmert_meters_from_parameters(*params, out.units.map_unit_to_meters);
if (auto wcs = getWcs(ifc_file)) {
// getWcs returns the WCS in project units (translation in project
if (auto wcs = get_wcs(ifc_file)) {
// get_wcs returns the WCS in project units (translation in project
// length units). Convert translation to metres before inverting.
Eigen::Matrix4d wcs_m = *wcs;
wcs_m(0, 3) *= out.units.project_length_to_meters;
@@ -147,11 +147,11 @@ guessFederatedFalseOrigin(const Eigen::Vector3d& first_geometry_point_m,
out.xyz = t_m * u_fed_inv;
// Rotation: helmert grid-north baked into coordinate_operation_meters.
// helmertMetersFromParameters built that block as R_z(theta)·diag(fx,fy,fz)
// with theta = atan2(xao, xaa); xaxis2angle is `-theta` in degrees.
// helmert_meters_from_parameters built that block as R_z(theta)·diag(fx,fy,fz)
// with theta = atan2(xao, xaa); x_axis_to_angle_deg is `-theta` in degrees.
if (use_coord_op) {
const Eigen::Matrix4d& M = georef.coordinate_operation_meters;
out.rz_deg = xaxis2angleDeg(M(0, 0), M(1, 0));
out.rz_deg = x_axis_to_angle_deg(M(0, 0), M(1, 0));
}
return out;
}
+2 -2
View File
@@ -101,7 +101,7 @@ struct ModelTransformation {
};
// Per-model unit scales captured at load time. project_length_to_meters comes
// from calculateUnitScale(file, "LENGTHUNIT"). map_unit_to_meters is derived
// from calculate_unit_scale(file, "LENGTHUNIT"). map_unit_to_meters is derived
// from IfcMapConversion.Scale as project_length_to_meters / Scale; the
// IfcProjectedCRS.MapUnit named unit is metadata and does not affect the
// transform composition.
@@ -161,7 +161,7 @@ Eigen::Matrix4d composeFederatedFalseOrigin(const FederatedFalseOrigin&,
// Compose ModelTransformation into a 4x4 matrix in metres.
// `coordinate_operation_meters` is the model's CoordinateOperation matrix
// (e.g. helmertMetersFromParameters · inv(wcs_meters)) — needed to lift
// (e.g. helmert_meters_from_parameters · inv(wcs_meters)) — needed to lift
// `a` into metres when a_frame == ModelLocal. Pass identity when the
// CoordinateOperation is disabled or absent.
Eigen::Matrix4d composeModelTransformation(const ModelTransformation&,
+3 -3
View File
@@ -158,9 +158,9 @@ target_link_libraries(test_federation PRIVATE
Qt${QT_VERSION}::Gui # Federation::HomeView uses QVector3D from QtGui
Qt${QT_VERSION}::Test # QSignalSpy
Eigen3::Eigen # Federation.h: composed matrices use Eigen
# helpers provides Unit::convert + Geolocation helpers
# (helmertMetersFromParameters, getWcs, getMapUnit) + Placement
# (getAxis2Placement, called from Geolocation::getWcs). Linking the
# helpers provides unit conversion and geolocation helpers
# (helmert_meters_from_parameters, get_wcs, get_map_unit) + Placement
# (get_axis2_placement, called from geolocation::get_wcs). Linking the
# static lib avoids re-compiling those .cpp files here and pulls
# the src/helpers include dir + IfcParse transitively.
helpers
+2 -2
View File
@@ -18,7 +18,7 @@
********************************************************************************/
#include "Federation.h"
#include "Geolocation.h"
#include "geolocation.h"
#include <catch2/catch_test_macros.hpp>
@@ -467,7 +467,7 @@ TEST_CASE("helmert metres transform consumes Scale through map unit scale",
const double project_length_to_meters = 0.001;
const double map_unit_to_meters = project_length_to_meters / params.scale;
Eigen::Matrix4d M = helmertMetersFromParameters(params, map_unit_to_meters);
Eigen::Matrix4d M = helmert_meters_from_parameters(params, map_unit_to_meters);
Eigen::Vector4d local_m(10.0, 20.0, 0.0, 1.0);
Eigen::Vector4d global_m = M * local_m;