diff --git a/src/ifcexpressparser/schema_class.py b/src/ifcexpressparser/schema_class.py index b4cbec3109..793ee3dce6 100644 --- a/src/ifcexpressparser/schema_class.py +++ b/src/ifcexpressparser/schema_class.py @@ -36,7 +36,7 @@ class SchemaClass(codegen.Base): aggr_type = type.aggregate_type make_bound = lambda b: -1 if b == '?' else int(b) bound1, bound2 = map(make_bound, (type.bounds.lower, type.bounds.upper)) - decl_type = get_declared_type(type.type) + decl_type = get_declared_type(type.type, emitted_names) return "new aggregation_type(aggregation_type::%(aggr_type)s_type, %(bound1)d, %(bound2)d, %(decl_type)s)" % locals() elif isinstance(type, nodes.BinaryType): return "new simple_type(simple_type::binary_type)" @@ -93,10 +93,14 @@ class SchemaClass(codegen.Base): statements.append('schema_definition* populate_schema() {') emitted_types = set() - while len(emitted_types) < len(mapping.schema.simpletypes): + # while len(emitted_types) < len(set(mapping.schema.simpletypes.keys()) - {"IfcPropertySetDefinitionSet"}): + while len(emitted_types) < len(set(mapping.schema.simpletypes.keys()) - {"IfcPropertySetDefinitionSet"}): for name, type in mapping.schema.simpletypes.items(): if name in emitted_types: continue + # No support for types refering to entities :( + if name == "IfcPropertySetDefinitionSet": continue + try: declared_type = get_declared_type(type, emitted_types) except UnmetDependenciesException: @@ -133,10 +137,11 @@ class SchemaClass(codegen.Base): while len(emitted_selects) < len(mapping.schema.selects): for name, type in mapping.schema.selects.items(): if name in emitted_selects: continue - if set(type.values) < emmited: + type_values = sorted(set(type.values) - {"IfcPropertySetDefinitionSet"}) + if set(type_values) < emmited: statements.append(' {') - statements.append(' std::vector items; items.reserve(%d);' % len(type.values)) - statements.extend(map(lambda v: ' items.push_back(%s_type);' % v, sorted(type.values))) + statements.append(' std::vector items; items.reserve(%d);' % len(type_values)) + statements.extend(map(lambda v: ' items.push_back(%s_type);' % v, sorted(type_values))) statements.append(' %(name)s_type = new select_type(IfcSchema::Type::%(name)s, items);' % locals()) statements.append(' }') emitted_selects.add(name) diff --git a/src/ifcparse/IfcHdf5File.cpp b/src/ifcparse/IfcHdf5File.cpp index d22c1bc903..5d63acce9e 100644 --- a/src/ifcparse/IfcHdf5File.cpp +++ b/src/ifcparse/IfcHdf5File.cpp @@ -290,8 +290,6 @@ public: bool processed = false; if (elem_type->as_named_type()) { auto entity = elem_type->as_named_type()->declared_type()->as_entity(); - std::cerr << elem_type->as_named_type()->declared_type()->name() << std::endl; - std::cerr << attr_->toString() << std::endl; if (entity != nullptr) { std::vector empty; t(empty); @@ -474,7 +472,17 @@ public: break; } default: - throw std::runtime_error("Unexpected type encountered"); + { + // TK: Ifc4 IfcValue select valuations can result into H5T_OPAQUE types for + // IfcBinary. This is not likely an issue, as these are simply padding values. + // TODO: Use H5T_BITSET for binary instead? + + // const char* class_names[] = {"H5T_NO_CLASS", "H5T_INTEGER", "H5T_FLOAT", "H5T_TIME", "H5T_STRING", "H5T_BITFIELD", "H5T_OPAQUE", "H5T_COMPOUND", "H5T_REFERENCE", "H5T_ENUM", "H5T_VLEN", "H5T_ARRAY", "H5T_NCLASSES"}; + // throw std::runtime_error(std::string("Unexpected type encountered ") + class_names[((int)datatype_.getClass())+1]); + + memset(ptr, 0, datatype_.getSize()); + advance(ptr, datatype_.getSize()); + } } } };