mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 18:43:26 +00:00
Update python wrapper
This commit is contained in:
@@ -66,7 +66,7 @@ private:
|
||||
|
||||
bool parsing_complete_;
|
||||
|
||||
const schema_definition* schema_;
|
||||
const IfcParse::schema_definition* schema_;
|
||||
|
||||
entity_by_id_t byid;
|
||||
entities_by_type_t bytype;
|
||||
@@ -173,7 +173,7 @@ public:
|
||||
void register_inverse(unsigned, IfcUtil::IfcBaseClass*);
|
||||
void unregister_inverse(unsigned, IfcUtil::IfcBaseClass*);
|
||||
|
||||
const schema_definition* schema() const { return schema_; }
|
||||
const IfcParse::schema_definition* schema() const { return schema_; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1124,9 +1124,15 @@ void IfcEntityInstanceData::setArgument(unsigned int i, Argument* a, IfcUtil::Ar
|
||||
std::string enum_literal = a->toString();
|
||||
// Remove leading and trailing '.'
|
||||
enum_literal = enum_literal.substr(1, enum_literal.size() - 2);
|
||||
const IfcParse::enumeration_type* enum_type = get_schema().declaration_by_name(type())->as_entity()->all_attributes()[i]->type_of_attribute()->as_named_type()->declared_type()->as_enumeration_type();
|
||||
|
||||
std::vector<std::string>::const_iterator it = std::find(enum_type->enumeration_items().begin(), enum_type->enumeration_items().end(), enum_literal);
|
||||
|
||||
const IfcParse::enumeration_type* enum_type = get_schema().declaration_by_name(type())->as_entity()->
|
||||
attribute_by_index(i)->type_of_attribute()->as_named_type()->declared_type()->as_enumeration_type();
|
||||
|
||||
std::vector<std::string>::const_iterator it = std::find(
|
||||
enum_type->enumeration_items().begin(),
|
||||
enum_type->enumeration_items().end(),
|
||||
enum_literal);
|
||||
|
||||
if (it == enum_type->enumeration_items().end()) {
|
||||
throw IfcParse::IfcException(enum_literal + " does not name a valid item for " + enum_type->name());
|
||||
}
|
||||
|
||||
@@ -212,7 +212,6 @@ namespace IfcParse {
|
||||
std::string name_;
|
||||
aggregate_type type_of_aggregation_;
|
||||
int bound1_, bound2_;
|
||||
parameter_type* type_of_element_;
|
||||
const entity* entity_reference_;
|
||||
const attribute* attribute_reference_;
|
||||
public:
|
||||
@@ -252,6 +251,21 @@ namespace IfcParse {
|
||||
return attr->name() == name_;
|
||||
}
|
||||
};
|
||||
|
||||
const attribute* attribute_by_index_(size_t& index) const {
|
||||
const attribute* attr = 0;
|
||||
if (supertype_) {
|
||||
attr = supertype_->attribute_by_index_(index);
|
||||
}
|
||||
if (attr == 0) {
|
||||
if (index < attributes_.size()) {
|
||||
return attributes_[index];
|
||||
}
|
||||
index -= attributes_.size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public:
|
||||
entity(const std::string& name, entity* supertype)
|
||||
: declaration(name)
|
||||
@@ -310,6 +324,22 @@ namespace IfcParse {
|
||||
return attrs;
|
||||
}
|
||||
|
||||
const attribute* attribute_by_index(size_t index) const {
|
||||
const attribute* attr = attribute_by_index_(index);
|
||||
if (attr == 0) {
|
||||
throw IfcParse::IfcException("Attribute index out of bounds");
|
||||
}
|
||||
return attr;
|
||||
}
|
||||
|
||||
size_t attribute_count() const {
|
||||
size_t super_count = 0;
|
||||
if (supertype_) {
|
||||
super_count = supertype_->attribute_count();
|
||||
}
|
||||
return super_count + attributes_.size();
|
||||
}
|
||||
|
||||
ptrdiff_t attribute_index(const attribute* attr) const {
|
||||
const entity* current = this;
|
||||
ptrdiff_t index = -1;
|
||||
|
||||
Reference in New Issue
Block a user