Update python wrapper

This commit is contained in:
Thomas Krijnen
2017-12-11 17:20:22 +01:00
parent e7ccf7269a
commit 33e1fa6a14
6 changed files with 225 additions and 102 deletions
+2 -2
View File
@@ -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_; }
};
}
+9 -3
View File
@@ -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());
}
+31 -1
View File
@@ -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;