mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 13:43:40 +00:00
ifcviewer: rename stage1/2/3/4 to their proper IFC-mapped names
Replace the placeholder "stage1/2/3/4" terminology with names that
mirror the IFC concepts each step represents:
stage 1 -> PlacementTransformation
(per-instance, derived from IfcObjectPlacement)
stage 2 -> CoordinateOperation
(per-model, IfcCoordinateOperation / IfcMapConversion)
stage 3 -> FederatedFalseOrigin
(federation-wide, user-nominated)
stage 4 -> ModelTransformation
(per-model, user-authored within the federation)
API renames:
FederationOrigin -> FederatedFalseOrigin
ModelTransform -> ModelTransformation
composeFederationOrigin -> composeFederatedFalseOrigin
composeModelTransform -> composeModelTransformation
Federation::setOrigin -> Federation::setFederatedFalseOrigin
Federation::setModelTransform -> Federation::setModelTransformation
Federation::origin() -> Federation::federatedFalseOrigin()
Federation::Model::transform_intent -> ::model_transformation
ModelGeoref::stage2_meters -> ::coordinate_operation_meters
ModelGeoref::has_stage2 -> ::has_coordinate_operation
JSON keys in .ifcfed renamed in lockstep:
origin -> federated_false_origin
transform_intent -> model_transformation
The streamer's per-mesh "stage 1 vertex rebasing" comment is reframed:
the rebase isn't its own stage — it's a precision optimisation applied
inside the PlacementTransformation step.
All 36 ctest cases pass under the new names.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+63
-51
@@ -33,27 +33,33 @@
|
||||
|
||||
namespace ifcopenshell { class file; }
|
||||
|
||||
// === Stage-3/4 data model ===
|
||||
// === Federation transformation pipeline ===
|
||||
//
|
||||
// A federation places one or more IFC models in a shared scene. Each model's
|
||||
// final per-instance transform is composed as
|
||||
// final per-instance transform is the composition of four named stages:
|
||||
//
|
||||
// stage3 · stage4 · stage2 · placement_stage1
|
||||
// FederatedFalseOrigin · ModelTransformation · CoordinateOperation
|
||||
// · PlacementTransformation
|
||||
//
|
||||
// where:
|
||||
// - stage1 is per-mesh vertex rebasing (load-time, immutable)
|
||||
// - stage2 is the per-model georef matrix from IfcMapConversion etc.
|
||||
// (load-time, immutable; can be toggled off)
|
||||
// - stage3 is the federation-wide false origin (mutable, federation-scope)
|
||||
// - stage4 is the per-model placement within the federation (mutable, per-model)
|
||||
// - PlacementTransformation: per-instance, derived from the IFC's
|
||||
// IfcObjectPlacement chain (load-time, immutable). This is the
|
||||
// iterator's per-shape transform.
|
||||
// - CoordinateOperation: per-model, derived from the IFC's
|
||||
// IfcCoordinateOperation (e.g. IfcMapConversion + IfcProjectedCRS).
|
||||
// Load-time, immutable; can be toggled on/off.
|
||||
// - FederatedFalseOrigin: federation-wide. Mutable, persisted in
|
||||
// `.ifcfed`. Re-applied to every model.
|
||||
// - ModelTransformation: per-model, user-authored within the federation.
|
||||
// Mutable, persisted in `.ifcfed`.
|
||||
//
|
||||
// All composed matrices are in metres. User-authored numbers are stored in
|
||||
// their source units (model project unit / model map unit / federation unit)
|
||||
// to round-trip without precision loss; conversion happens in the compose
|
||||
// helpers.
|
||||
|
||||
// Federation-wide unit; the value space for FederationOrigin.xyz and
|
||||
// ModelTransform::{b, pivot}.
|
||||
// Federation-wide unit; the value space for FederatedFalseOrigin.xyz and
|
||||
// ModelTransformation::{b, pivot}.
|
||||
struct FederationConfig {
|
||||
// IfcSIUnit name ("METRE") or IfcConversionBasedUnit name ("foot", "inch").
|
||||
std::string unit_name = "METRE";
|
||||
@@ -62,26 +68,29 @@ struct FederationConfig {
|
||||
std::string unit_prefix = "";
|
||||
};
|
||||
|
||||
// Stage 3 — the federation false origin. Authoring intent is "nominate this
|
||||
// XYZ as the new origin, with optional Z-axis heading rotation". Composed
|
||||
// as stage3 = R_z(rz_deg) · T(-xyz_in_metres).
|
||||
struct FederationOrigin {
|
||||
// FederatedFalseOrigin — the user-nominated federation origin. Authoring
|
||||
// intent is "nominate this XYZ as the new origin, with optional Z-axis
|
||||
// heading rotation". Composed as R_z(rz_deg) · T(-xyz_in_metres).
|
||||
struct FederatedFalseOrigin {
|
||||
Eigen::Vector3d xyz = Eigen::Vector3d::Zero(); // federation unit
|
||||
double rz_deg = 0.0;
|
||||
};
|
||||
|
||||
// Frame in which ModelTransform.a is expressed.
|
||||
// ModelLocal — pre-stage2 model coordinates, in the model's project length unit
|
||||
// ModelGlobal — post-stage2 model coordinates, in the model's map unit
|
||||
// Frame in which ModelTransformation.a is expressed.
|
||||
// ModelLocal — pre-CoordinateOperation model coordinates, in the model's
|
||||
// project length unit
|
||||
// ModelGlobal — post-CoordinateOperation model coordinates, in the model's
|
||||
// map unit
|
||||
enum class AFrame { ModelLocal, ModelGlobal };
|
||||
|
||||
// Stage 4 — the per-model placement within the federation. Authoring intent
|
||||
// is "rotate the model around `pivot`, then translate so that point `a` lands
|
||||
// at point `b`". Composed as
|
||||
// ModelTransformation — the per-model placement within the federation.
|
||||
// Authoring intent is "rotate the model around `pivot`, then translate so
|
||||
// that point `a` lands at point `b`". Composed as
|
||||
//
|
||||
// R_local = R_z(rz) · R_y(ry) · R_x(rx) [intrinsic XYZ]
|
||||
// R_at_pivot = T(pivot_m) · R_local · T(-pivot_m)
|
||||
// stage4 = T(b_m - R_at_pivot · a_m) · R_at_pivot
|
||||
struct ModelTransform {
|
||||
// result = T(b_m - R_at_pivot · a_m) · R_at_pivot
|
||||
struct ModelTransformation {
|
||||
AFrame a_frame = AFrame::ModelGlobal;
|
||||
Eigen::Vector3d a = Eigen::Vector3d::Zero(); // model project / map unit
|
||||
Eigen::Vector3d b = Eigen::Vector3d::Zero(); // federation unit
|
||||
@@ -98,37 +107,40 @@ 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.
|
||||
// Per-model georeferencing data derived from the IFC.
|
||||
// `coordinate_operation_meters` is the helmert · inv(wcs) matrix in metres
|
||||
// representing the IfcCoordinateOperation; consumers compose it before
|
||||
// FederatedFalseOrigin / ModelTransformation at upload time. When the
|
||||
// model has no map conversion, `has_coordinate_operation == false` and the
|
||||
// matrix is identity.
|
||||
struct ModelGeoref {
|
||||
ModelUnits units;
|
||||
Eigen::Matrix4d stage2_meters = Eigen::Matrix4d::Identity();
|
||||
bool has_stage2 = false;
|
||||
Eigen::Matrix4d coordinate_operation_meters = Eigen::Matrix4d::Identity();
|
||||
bool has_coordinate_operation = 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.
|
||||
// from `ifc_file` and reduce them to a metres-in / metres-out
|
||||
// CoordinateOperation 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&);
|
||||
|
||||
// Compose stage 3 (federation false origin) into a 4x4 matrix in metres.
|
||||
Eigen::Matrix4d composeFederationOrigin(const FederationOrigin&,
|
||||
const FederationConfig&);
|
||||
// Compose FederatedFalseOrigin into a 4x4 matrix in metres.
|
||||
Eigen::Matrix4d composeFederatedFalseOrigin(const FederatedFalseOrigin&,
|
||||
const FederationConfig&);
|
||||
|
||||
// Compose stage 4 (per-model placement within the federation) into a 4x4
|
||||
// matrix in metres. `stage2_meters` is the model's georef matrix (e.g.
|
||||
// helmertMetersFromParameters · inv(wcs_meters)) — needed to lift `a` into
|
||||
// metres when a_frame == ModelLocal. Pass identity when stage 2 is disabled
|
||||
// or absent.
|
||||
Eigen::Matrix4d composeModelTransform(const ModelTransform&,
|
||||
const FederationConfig& fed_cfg,
|
||||
const ModelUnits& model_units,
|
||||
const Eigen::Matrix4d& stage2_meters);
|
||||
// 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
|
||||
// `a` into metres when a_frame == ModelLocal. Pass identity when the
|
||||
// CoordinateOperation is disabled or absent.
|
||||
Eigen::Matrix4d composeModelTransformation(const ModelTransformation&,
|
||||
const FederationConfig& fed_cfg,
|
||||
const ModelUnits& model_units,
|
||||
const Eigen::Matrix4d& coordinate_operation_meters);
|
||||
|
||||
// === Federation persistence (.ifcfed) ===
|
||||
//
|
||||
@@ -151,11 +163,11 @@ public:
|
||||
};
|
||||
|
||||
struct Model {
|
||||
QString id; // stable, persisted
|
||||
QString id; // stable, persisted
|
||||
QString display_name;
|
||||
QString source_kind = "local"; // future: "http", "speckle", ...
|
||||
QString source_path; // resolved absolute when kind == "local"
|
||||
ModelTransform transform_intent; // stage 4
|
||||
QString source_kind = "local"; // future: "http", "speckle", ...
|
||||
QString source_path; // resolved absolute when kind == "local"
|
||||
ModelTransformation model_transformation;
|
||||
bool visible = true;
|
||||
};
|
||||
|
||||
@@ -174,8 +186,8 @@ public:
|
||||
void clearHomeView();
|
||||
|
||||
void setConfig(const FederationConfig&);
|
||||
void setOrigin(const FederationOrigin&);
|
||||
void setModelTransform(const QString& fed_id, const ModelTransform&);
|
||||
void setFederatedFalseOrigin(const FederatedFalseOrigin&);
|
||||
void setModelTransformation(const QString& fed_id, const ModelTransformation&);
|
||||
|
||||
// Accessors
|
||||
const std::vector<Model>& models() const { return models_; }
|
||||
@@ -187,7 +199,7 @@ public:
|
||||
bool hasHomeView() const { return has_home_view_; }
|
||||
const HomeView& homeView() const { return home_view_; }
|
||||
const FederationConfig& config() const { return config_; }
|
||||
const FederationOrigin& origin() const { return origin_; }
|
||||
const FederatedFalseOrigin& federatedFalseOrigin() const { return federated_false_origin_; }
|
||||
|
||||
signals:
|
||||
void dirtyChanged(bool dirty);
|
||||
@@ -202,8 +214,8 @@ private:
|
||||
QDateTime created_;
|
||||
QDateTime modified_;
|
||||
std::vector<Model> models_;
|
||||
FederationConfig config_;
|
||||
FederationOrigin origin_;
|
||||
FederationConfig config_;
|
||||
FederatedFalseOrigin federated_false_origin_;
|
||||
bool has_home_view_ = false;
|
||||
HomeView home_view_;
|
||||
bool dirty_ = false;
|
||||
|
||||
Reference in New Issue
Block a user