From 335d571854c2200b557ca808fbe79a8e265b5a35 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Wed, 19 Aug 2026 20:10:10 +0500 Subject: [PATCH] gltf_serializer: refactor proj code into a separate call --- src/serializers/gltf_serializer.cpp | 14 +++++++++++--- src/serializers/gltf_serializer.h | 4 ++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/serializers/gltf_serializer.cpp b/src/serializers/gltf_serializer.cpp index 04e6b2716b..4e2f524c3d 100644 --- a/src/serializers/gltf_serializer.cpp +++ b/src/serializers/gltf_serializer.cpp @@ -508,7 +508,7 @@ void gltf_serializer::finalize() { } namespace { - void normalize(std::array& v) { + [[maybe_unused]] void normalize(std::array& v) { auto l = std::sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); v[0] /= l; @@ -516,13 +516,13 @@ namespace { v[2] /= l; } - void cross(const std::array& v1, const std::array& v2, std::array& result) { + [[maybe_unused]] void cross(const std::array& v1, const std::array& v2, std::array& result) { result[0] = v1[1] * v2[2] - v1[2] * v2[1]; result[1] = v1[2] * v2[0] - v1[0] * v2[2]; result[2] = v1[0] * v2[1] - v1[1] * v2[0]; } - void proj_log(void* data, int, const char* c) { + [[maybe_unused]] void proj_log(void* data, int, const char* c) { auto logger = static_cast(data); if (logger) { logger->error("SER", 1, "PROJ: " + std::string(c)); @@ -627,6 +627,14 @@ void gltf_serializer::setFile(ifcopenshell::file& f) { } } + setup_georeferencing(crs_epsg, eastings_northings_elevation, crs_x_axis); +} + +void gltf_serializer::setup_georeferencing( + [[maybe_unused]] const std::optional& crs_epsg, + [[maybe_unused]] const std::optional>& eastings_northings_elevation, + [[maybe_unused]] std::optional> crs_x_axis) +{ #ifdef WITH_PROJ if (crs_epsg) { diff --git a/src/serializers/gltf_serializer.h b/src/serializers/gltf_serializer.h index 2a007c7bb9..e04fc6b637 100644 --- a/src/serializers/gltf_serializer.h +++ b/src/serializers/gltf_serializer.h @@ -42,6 +42,10 @@ private: std::vector roots_; int writeMaterial(const ifcopenshell::geom::taxonomy::style::ptr style); + void setup_georeferencing( + const std::optional& crs_epsg, + const std::optional>& eastings_northings_elevation, + std::optional> crs_x_axis); public: gltf_serializer(const std::string& filename, const ifcopenshell::geom::settings& settings, ifcopenshell::logger* logger = nullptr); virtual ~gltf_serializer();