From 76ba3947f5a44d725b79033b9d2a6d7f72002bff Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 30 Aug 2024 21:10:01 +0500 Subject: [PATCH] Expose header properties with invalid values #5246 --- src/ifcparse/IfcSpfHeader.h | 4 ++++ src/ifcwrap/IfcParseWrapper.i | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/ifcparse/IfcSpfHeader.h b/src/ifcparse/IfcSpfHeader.h index f07faeacf9..f71dacfa68 100644 --- a/src/ifcparse/IfcSpfHeader.h +++ b/src/ifcparse/IfcSpfHeader.h @@ -52,6 +52,10 @@ class IFC_PARSE_API HeaderEntity { return data_.size(); } + AttributeValue getArgument(size_t index) const { + return data_.get_attribute_value(index); + } + std::string toString(bool upper = false) const { std::stringstream stream; stream << datatype_; diff --git a/src/ifcwrap/IfcParseWrapper.i b/src/ifcwrap/IfcParseWrapper.i index 3a30620670..117041a6e7 100644 --- a/src/ifcwrap/IfcParseWrapper.i +++ b/src/ifcwrap/IfcParseWrapper.i @@ -520,6 +520,26 @@ static IfcUtil::ArgumentType helper_fn_attribute_type(const IfcUtil::IfcBaseClas } } +// Expose FileDescription and FileName header entities +// to make them readable even if they were not filled properly before. +// Though it is invalid IFC, technically. +// FileSchema is not exposed as IFC file won't load if it's invalid. + +%extend IfcParse::FileDescription { + AttributeValue description() const { return $self->getArgument(0); } + AttributeValue implementation_level() const { return $self->getArgument(1); } +}; + +%extend IfcParse::FileName { + AttributeValue name() const { return $self->getArgument(0); } + AttributeValue time_stamp() const { return $self->getArgument(1); } + AttributeValue author() const { return $self->getArgument(2); } + AttributeValue organization() const { return $self->getArgument(3); } + AttributeValue preprocessor_version() const { return $self->getArgument(4); } + AttributeValue originating_system() const { return $self->getArgument(5); } + AttributeValue authorization() const { return $self->getArgument(6); } +}; + %extend IfcParse::IfcSpfHeader { %pythoncode %{ # Hide the getters with read-only property implementations