mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-14 11:24:19 +00:00
refactor: extract src/ifcutil/ from src/ifcviewer/ (Unit, Geolocation, Placement)
Unit / Geolocation / Placement are schema-agnostic IFC helpers ported
from ifcopenshell.util.{unit,geolocation,placement}. Nothing about
them is viewer-specific: pure IfcParse + Eigen, no Qt, no IfcGeom, no
renderer. Living under src/ifcviewer/ implies an unwanted dependency
direction every time a non-viewer caller (test_federation, the bonsai
SettingsView georef readout, a future standalone IFC tool) wants to
use them.
Move them to a new `src/ifcutil/` static lib (IfcUtil). The lib has
PUBLIC `target_include_directories(${CMAKE_CURRENT_SOURCE_DIR})` so
callers that link IfcUtil can keep `#include "Unit.h"` etc. without
relative-path adjustments — the include dir propagates transitively
via IfcViewer's PUBLIC link.
## Changes
* `git mv src/ifcviewer/{Geolocation,Placement,Unit}.{h,cpp}
→ src/ifcutil/` (history follows the rename).
* `src/ifcutil/CMakeLists.txt`: IfcUtil static lib, PUBLIC links
IfcParse + Eigen3::Eigen, PUBLIC include dir.
* `cmake/CMakeLists.txt`: `add_subdirectory(../src/ifcutil ifcutil)`
before ifcviewer/ so the link target exists when IfcViewer's
CMakeLists runs.
* `src/ifcviewer/CMakeLists.txt`: IfcUtil added to IfcViewer's PUBLIC
link_libraries.
* `src/ifcviewer/tests/CMakeLists.txt`: test_federation drops the
explicit `${IFCVIEWER_SRC}/{Unit,Geolocation,Placement}.cpp`
source list and links `IfcUtil` instead (matches how production
code resolves the symbols).
* `src/bonsaiviewer/modules/models/SettingsView.cpp`: the two
explicit `#include "../../../ifcviewer/{Geolocation,Unit}.h"`
paths swap to `../../../ifcutil/…`. All other callers use bare
`#include "Unit.h"` style and continue to work via the propagated
include dir.
## Verification
* `ninja -C build-viewer` builds clean: IfcUtil + IfcViewer +
IfcViewerMinimal + BonsaiViewer + all four pre-existing
ifcviewer tests + the two from-wgpu tests.
* `test_federation` runs green: 226 assertions in 22 test cases
pass with IfcUtil linked instead of the explicit-source compile.
* `git log --follow` traces e.g. `Geolocation.cpp` back through the
rename to its prior location in src/ifcviewer/.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -66,15 +66,6 @@ find_package(Eigen3 REQUIRED)
|
||||
add_executable(test_federation
|
||||
test_federation.cpp
|
||||
${IFCVIEWER_SRC}/Federation.cpp
|
||||
# Federation pulls in Unit::convert for federationUnitToMeters and
|
||||
# Geolocation helpers (helmertMetersFromParameters, getWcs, getMapUnit)
|
||||
# for computeModelGeoref; compile both directly so the test doesn't
|
||||
# have to link the whole IfcViewer library (which would drag in
|
||||
# Qt6::OpenGL, OpenCASCADE, etc.). Placement.cpp provides
|
||||
# getAxis2Placement, called from Geolocation::getWcs.
|
||||
${IFCVIEWER_SRC}/Unit.cpp
|
||||
${IFCVIEWER_SRC}/Geolocation.cpp
|
||||
${IFCVIEWER_SRC}/Placement.cpp
|
||||
)
|
||||
set_target_properties(test_federation PROPERTIES AUTOMOC ON)
|
||||
target_include_directories(test_federation PRIVATE ${IFCVIEWER_SRC})
|
||||
@@ -84,6 +75,11 @@ 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
|
||||
IfcParse # Unit.cpp uses express::Base / file APIs
|
||||
# IfcUtil provides Unit::convert + Geolocation helpers
|
||||
# (helmertMetersFromParameters, getWcs, getMapUnit) + Placement
|
||||
# (getAxis2Placement, called from Geolocation::getWcs). Linking the
|
||||
# static lib avoids re-compiling those .cpp files here and pulls
|
||||
# the IfcUtil include dir + IfcParse transitively.
|
||||
IfcUtil
|
||||
)
|
||||
catch_discover_tests(test_federation)
|
||||
|
||||
Reference in New Issue
Block a user