diff --git a/src/ifcgeom/IfcGeomElement.h b/src/ifcgeom/IfcGeomElement.h index 7121425e11..6842f7ab45 100644 --- a/src/ifcgeom/IfcGeomElement.h +++ b/src/ifcgeom/IfcGeomElement.h @@ -72,7 +72,7 @@ namespace IfcGeom { // Use the id to compare, or the elevation is the elements are IfcBuildingStoreys and the elevation is set friend bool operator < (const Element& element1, const Element& element2) { if (element1.type() == "IfcBuildingStorey" && element2.type() == "IfcBuildingStorey") { - size_t attr_index = element1.product()->declaration().attribute_index("Elevation"); + size_t attr_index = element1.product()->declaration().as_entity()->attribute_index("Elevation"); auto elev_attr1 = element1.product()->data().get_attribute_value(attr_index); auto elev_attr2 = element2.product()->data().get_attribute_value(attr_index); diff --git a/src/ifcparse/IfcBaseClass.h b/src/ifcparse/IfcBaseClass.h index 0226147638..108009035d 100644 --- a/src/ifcparse/IfcBaseClass.h +++ b/src/ifcparse/IfcBaseClass.h @@ -124,19 +124,6 @@ public: void toString(std::ostream&, bool upper = false) const; }; -class IFC_PARSE_API IfcLateBoundEntity : public IfcBaseClass { - private: - const IfcParse::declaration* decl_; - - public: - IfcLateBoundEntity(const IfcParse::declaration* decl, IfcEntityInstanceData&& data) : IfcBaseClass(std::move(data)), - decl_(decl) {} - - virtual const IfcParse::declaration& declaration() const { - return *decl_; - } -}; - class IFC_PARSE_API IfcBaseEntity : public IfcBaseClass { public: IfcBaseEntity(IfcEntityInstanceData&& data); @@ -145,7 +132,7 @@ class IFC_PARSE_API IfcBaseEntity : public IfcBaseClass { : IfcBaseClass(IfcEntityInstanceData(storage_t(n))) {} - virtual const IfcParse::entity& declaration() const = 0; + virtual const IfcParse::declaration& declaration() const = 0; AttributeValue get(const std::string& name) const; @@ -162,6 +149,19 @@ class IFC_PARSE_API IfcBaseEntity : public IfcBaseClass { void populate_derived(); }; +class IFC_PARSE_API IfcLateBoundEntity : public IfcBaseEntity { +private: + const IfcParse::declaration* decl_; + +public: + IfcLateBoundEntity(const IfcParse::declaration* decl, IfcEntityInstanceData&& data) : IfcBaseEntity(std::move(data)), + decl_(decl) {} + + virtual const IfcParse::declaration& declaration() const { + return *decl_; + } +}; + // TODO: Investigate whether these should be template classes instead class IFC_PARSE_API IfcBaseType : public IfcBaseClass { public: diff --git a/src/ifcparse/IfcUtil.cpp b/src/ifcparse/IfcUtil.cpp index 87f951ae2c..57008fe260 100644 --- a/src/ifcparse/IfcUtil.cpp +++ b/src/ifcparse/IfcUtil.cpp @@ -207,10 +207,10 @@ IfcUtil::IfcBaseEntity::IfcBaseEntity(IfcEntityInstanceData&& data) {} void IfcUtil::IfcBaseEntity::populate_derived() { - for (auto it = declaration().derived().begin(); it != declaration().derived().end(); ++it) { + for (auto it = declaration().as_entity()->derived().begin(); it != declaration().as_entity()->derived().end(); ++it) { if (*it) { this->data().storage_.set( - std::distance(declaration().derived().begin(), it), + std::distance(declaration().as_entity()->derived().begin(), it), Derived{} ); } diff --git a/src/serializers/schema_dependent/XmlSerializer.cpp b/src/serializers/schema_dependent/XmlSerializer.cpp index f842117367..43cac574c2 100644 --- a/src/serializers/schema_dependent/XmlSerializer.cpp +++ b/src/serializers/schema_dependent/XmlSerializer.cpp @@ -152,7 +152,7 @@ boost::optional format_attribute(ifcopenshell::geometry::abstract_m // Appends to a node with possibly existing attributes ptree* format_entity_instance(ifcopenshell::geometry::abstract_mapping* mapping, IfcUtil::IfcBaseEntity* instance, ptree& child, ptree& tree, bool as_link = false) { - const unsigned n = instance->declaration().attribute_count(); + const unsigned n = instance->declaration().as_entity()->attribute_count(); for (unsigned i = 0; i < n; ++i) { try { instance->data().get_attribute_value(i); @@ -163,7 +163,7 @@ ptree* format_entity_instance(ifcopenshell::geometry::abstract_mapping* mapping, auto argument = instance->data().get_attribute_value(i); if (argument.isNull()) continue; - std::string argument_name = instance->declaration().attribute_by_index(i)->name(); + std::string argument_name = instance->declaration().as_entity()->attribute_by_index(i)->name(); std::map::const_iterator argument_name_it; argument_name_it = POSTFIX_SCHEMA(argument_name_map).find(argument_name); if (argument_name_it != POSTFIX_SCHEMA(argument_name_map).end()) {