mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 10:33:44 +00:00
ifcviewer: auto-guess FederatedFalseOrigin on first model added
When the user adds a model into a fresh, untitled federation that still
has the default (0,0,0, no rotation) FederatedFalseOrigin, derive an
origin from the first instance's placement_transformation (lifted
through CoordinateOperation when enabled) and the helmert grid-north
baked into ModelGeoref::coordinate_operation_meters. Multi-file batches
naturally settle: whichever load finishes first anchors the federation,
the rest see a non-default origin and skip. Saved .ifcfeds keep their
authoritative origin.
Adds Placement.{h,cpp} (port of util/placement.py — a2p,
get_axis2placement, get_local_placement) so Geolocation no longer needs
its own anonymous getAxis2Placement, and xaxis2angleDeg in Geolocation
mirroring util/geolocation.xaxis2angle.
SceneLoader captures the first instance's placement_transformation from
either the sidecar's InstanceCpu[0] or the streamer's first
InstanceChunk, so the guess works on both load paths without re-reading
the IFC.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include <QDateTime>
|
||||
#include <QVector3D>
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -125,6 +126,27 @@ struct ModelGeoref {
|
||||
// caller doesn't want to cache.
|
||||
ModelGeoref computeModelGeoref(ifcopenshell::file* ifc_file);
|
||||
|
||||
// Build a FederatedFalseOrigin guess so that a model lands near the
|
||||
// federation origin instead of out at its surveyor coordinates. Designed
|
||||
// to work without an open IFC file so it's usable from sidecar-only loads
|
||||
// (the inputs are all derivable from the InstanceCpu cache + ModelGeoref).
|
||||
//
|
||||
// Position: `first_placement_meters` is the model's "anchor" placement —
|
||||
// typically the first instance's `placement_transformation`, which the
|
||||
// iterator already produces in metres (its `convert-back-units` default
|
||||
// is false). The translation is optionally lifted through
|
||||
// `georef.coordinate_operation_meters` (controlled by
|
||||
// `apply_coordinate_operation`), then expressed in the federation unit.
|
||||
//
|
||||
// Rotation: read directly from `georef.coordinate_operation_meters` when
|
||||
// `apply_coordinate_operation && has_coordinate_operation` (this is the
|
||||
// helmert grid-north angle). Otherwise zero. Anticlockwise positive.
|
||||
FederatedFalseOrigin
|
||||
guessFederatedFalseOrigin(const Eigen::Matrix4d& first_placement_meters,
|
||||
const ModelGeoref& georef,
|
||||
const FederationConfig& fed_cfg,
|
||||
bool apply_coordinate_operation);
|
||||
|
||||
// 1 federation_unit -> N metres.
|
||||
double federationUnitToMeters(const FederationConfig&);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user