From 58a5f881e637125755d2f5c3cc7555eb42b45957 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Thu, 20 Mar 2025 13:57:30 +0100 Subject: [PATCH] Retrieve length unit info from underlying mapping in iterator #6355 --- src/ifcgeom/Iterator.h | 10 ++++------ src/ifcgeom/abstract_mapping.h | 1 + src/ifcgeom/mapping/mapping.h | 1 + 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ifcgeom/Iterator.h b/src/ifcgeom/Iterator.h index 78c6ddc532..e6e9dd42b0 100644 --- a/src/ifcgeom/Iterator.h +++ b/src/ifcgeom/Iterator.h @@ -150,10 +150,6 @@ namespace IfcGeom { int done; int total; - // @todo these appear uninitialized? - std::string unit_name_; - double unit_magnitude_; - ifcopenshell::geometry::taxonomy::point3 bounds_min_; ifcopenshell::geometry::taxonomy::point3 bounds_max_; @@ -166,8 +162,8 @@ namespace IfcGeom { public: void set_cache(GeometrySerializer* cache) { cache_ = cache; } - const std::string& unit_name() const { return unit_name_; } - double unit_magnitude() const { return unit_magnitude_; } + const std::string& unit_name() const { return converter_->mapping()->get_length_unit_name(); } + double unit_magnitude() const { return converter_->mapping()->get_length_unit(); } // Check if error occurred during iterator initialization or iteration over elements. bool had_error_processing_elements() const { return had_error_processing_elements_; } @@ -903,6 +899,8 @@ namespace IfcGeom { for (auto& p : all_processed_elements_) { delete p; } + + delete converter_; } }; } diff --git a/src/ifcgeom/abstract_mapping.h b/src/ifcgeom/abstract_mapping.h index c8174d5363..c8ba61e1b4 100644 --- a/src/ifcgeom/abstract_mapping.h +++ b/src/ifcgeom/abstract_mapping.h @@ -45,6 +45,7 @@ namespace geometry { virtual const IfcUtil::IfcBaseEntity* get_product_type(const IfcUtil::IfcBaseEntity*) = 0; virtual const IfcUtil::IfcBaseEntity* get_single_material_association(const IfcUtil::IfcBaseEntity*) = 0; virtual double get_length_unit() const = 0; + virtual const std::string& get_length_unit_name() const = 0; virtual IfcUtil::IfcBaseEntity* representation_of(const IfcUtil::IfcBaseEntity* product) = 0; const Settings& settings() const { return settings_; } diff --git a/src/ifcgeom/mapping/mapping.h b/src/ifcgeom/mapping/mapping.h index 61e8b4d7b6..054e0a7efc 100644 --- a/src/ifcgeom/mapping/mapping.h +++ b/src/ifcgeom/mapping/mapping.h @@ -86,6 +86,7 @@ namespace geometry { virtual std::map get_layers(IfcUtil::IfcBaseEntity*); virtual void initialize_settings(); virtual double get_length_unit() const { return length_unit_; } + virtual const std::string& get_length_unit_name() const { return length_unit_name_; } virtual aggregate_of_instance::ptr find_openings(const IfcUtil::IfcBaseEntity*); virtual IfcUtil::IfcBaseEntity* representation_of(const IfcUtil::IfcBaseEntity* product);