mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 22:11:36 +00:00
More serialization options for HDF5
This commit is contained in:
@@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
|
|
||||||
|
#include "../ifcparse/Hdf5Settings.h"
|
||||||
|
|
||||||
#include "../ifcgeom/IfcGeomIterator.h"
|
#include "../ifcgeom/IfcGeomIterator.h"
|
||||||
|
|
||||||
#include "../ifcconvert/ColladaSerializer.h"
|
#include "../ifcconvert/ColladaSerializer.h"
|
||||||
@@ -132,8 +134,11 @@ int main(int argc, char** argv) {
|
|||||||
("bounds", boost::program_options::value<std::string>(&bounds),
|
("bounds", boost::program_options::value<std::string>(&bounds),
|
||||||
"Specifies the bounding rectangle, for example 512x512, to which the "
|
"Specifies the bounding rectangle, for example 512x512, to which the "
|
||||||
"output will be scaled. Only used when converting to SVG.")
|
"output will be scaled. Only used when converting to SVG.")
|
||||||
("compress",
|
("hdf5-compress", "")
|
||||||
"Compress HDF5.")
|
("hdf5-fix-cartesian-point", "")
|
||||||
|
("hdf5-fix-global-id", "")
|
||||||
|
("hdf5-instantiate-inverse", "")
|
||||||
|
("hdf5-instantiate-select", "")
|
||||||
("include",
|
("include",
|
||||||
"Specifies that the entities listed after --entities are to be included")
|
"Specifies that the entities listed after --entities are to be included")
|
||||||
("exclude",
|
("exclude",
|
||||||
@@ -260,7 +265,13 @@ int main(int argc, char** argv) {
|
|||||||
if (!f.Init(input_filename)) {
|
if (!f.Init(input_filename)) {
|
||||||
Logger::Message(Logger::LOG_ERROR, "Unable to parse .ifc file");
|
Logger::Message(Logger::LOG_ERROR, "Unable to parse .ifc file");
|
||||||
} else {
|
} else {
|
||||||
f.write_hdf5(output_filename, vmap.count("compress") != 0);
|
IfcParse::Hdf5Settings settings;
|
||||||
|
settings.compress() = vmap.count("hdf5-compress") != 0;
|
||||||
|
settings.fix_cartesian_point() = vmap.count("hdf5-fix-cartesian-point") != 0;
|
||||||
|
settings.fix_global_id() = vmap.count("hdf5-fix-global-id") != 0;
|
||||||
|
settings.instantiate_inverse() = vmap.count("hdf5-instantiate-inverse") != 0;
|
||||||
|
settings.instantiate_select() = vmap.count("hdf5-instantiate-select") != 0;
|
||||||
|
f.write_hdf5(output_filename, settings);
|
||||||
exit_code = 0;
|
exit_code = 0;
|
||||||
}
|
}
|
||||||
// } catch (...) {}
|
// } catch (...) {}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ actions = {
|
|||||||
'general_aggregation_types' : "lambda t: AggregationType(t)",
|
'general_aggregation_types' : "lambda t: AggregationType(t)",
|
||||||
'select_type' : "lambda t: SelectType(t)",
|
'select_type' : "lambda t: SelectType(t)",
|
||||||
'binary_type' : "lambda t: BinaryType(t)",
|
'binary_type' : "lambda t: BinaryType(t)",
|
||||||
'subtype_declaration' : "lambda t: SubtypeExpression(t)",
|
'subtype_declaration' : "lambda t: SubTypeExpression(t)",
|
||||||
'derive_clause' : "lambda t: AttributeList('derive', t)",
|
'derive_clause' : "lambda t: AttributeList('derive', t)",
|
||||||
'derived_attr' : "lambda t: DerivedAttribute(t)",
|
'derived_attr' : "lambda t: DerivedAttribute(t)",
|
||||||
'inverse_clause' : "lambda t: AttributeList('inverse', t)",
|
'inverse_clause' : "lambda t: AttributeList('inverse', t)",
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ class AttributeList(Node):
|
|||||||
|
|
||||||
class InverseAttribute(Node):
|
class InverseAttribute(Node):
|
||||||
name = property(lambda self: self.tokens[0])
|
name = property(lambda self: self.tokens[0])
|
||||||
type = property(lambda self: self.tokens[2])
|
type = property(lambda self: None if len(self.tokens) == 6 else self.tokens[2])
|
||||||
bounds = property(lambda self: None if len(self.tokens) == 6 else self.tokens[3])
|
bounds = property(lambda self: None if len(self.tokens) == 6 else self.tokens[3])
|
||||||
entity = property(lambda self: self.tokens[-4])
|
entity = property(lambda self: self.tokens[-4])
|
||||||
attribute = property(lambda self: self.tokens[-2])
|
attribute = property(lambda self: self.tokens[-2])
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class SchemaClass:
|
|||||||
if isinstance(type, nodes.AggregationType):
|
if isinstance(type, nodes.AggregationType):
|
||||||
aggr_type = type.aggregate_type
|
aggr_type = type.aggregate_type
|
||||||
make_bound = lambda b: -1 if b == '?' else int(b)
|
make_bound = lambda b: -1 if b == '?' else int(b)
|
||||||
bound1, bound2 = map(make_bound, (type.bounds.lower, type.bounds.upper))
|
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)
|
||||||
return "new aggregation_type(aggregation_type::%(aggr_type)s_type, %(bound1)d, %(bound2)d, %(decl_type)s)" % locals()
|
return "new aggregation_type(aggregation_type::%(aggr_type)s_type, %(bound1)d, %(bound2)d, %(decl_type)s)" % locals()
|
||||||
elif isinstance(type, nodes.BinaryType):
|
elif isinstance(type, nodes.BinaryType):
|
||||||
@@ -46,7 +46,21 @@ class SchemaClass:
|
|||||||
else:
|
else:
|
||||||
raise UnmetDependenciesException(type)
|
raise UnmetDependenciesException(type)
|
||||||
else:
|
else:
|
||||||
return "new simple_type(simple_type::%s_type)" % type
|
return "new simple_type(simple_type::%s_type)" % type
|
||||||
|
|
||||||
|
def find_inverse_name_and_index(entity_name, attribute_name):
|
||||||
|
attributes_per_subtype = []
|
||||||
|
while True:
|
||||||
|
entity = mapping.schema.entities[entity_name]
|
||||||
|
attr_names = list(map(operator.attrgetter('name'), entity.attributes))
|
||||||
|
if len(attr_names):
|
||||||
|
attributes_per_subtype.append((entity_name, attr_names))
|
||||||
|
if len(entity.supertypes) != 1: break
|
||||||
|
entity_name = entity.supertypes[0]
|
||||||
|
index = 0
|
||||||
|
for et, attrs in attributes_per_subtype[::-1]:
|
||||||
|
try: return et, attrs.index(attribute_name)
|
||||||
|
except: pass
|
||||||
|
|
||||||
self.schema_name = mapping.schema.name.capitalize()
|
self.schema_name = mapping.schema.name.capitalize()
|
||||||
|
|
||||||
@@ -140,6 +154,23 @@ class SchemaClass:
|
|||||||
statements.append(' %(name)s_type->set_attributes(attributes, derived);' % locals())
|
statements.append(' %(name)s_type->set_attributes(attributes, derived);' % locals())
|
||||||
statements.append(' }')
|
statements.append(' }')
|
||||||
|
|
||||||
|
for name, type in mapping.schema.entities.items():
|
||||||
|
if type.inverse:
|
||||||
|
statements.append(' {')
|
||||||
|
statements.append(' std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(%d);' % len(type.inverse.elements))
|
||||||
|
for attr in type.inverse.elements:
|
||||||
|
if attr.bounds:
|
||||||
|
make_bound = lambda b: -1 if b == '?' else int(b)
|
||||||
|
bound1, bound2 = map(make_bound, (attr.bounds.lower, attr.bounds.upper))
|
||||||
|
else:
|
||||||
|
bound1, bound2 = -1, -1
|
||||||
|
attr_name, aggr_type, entity_ref = attr.name, attr.type, attr.entity
|
||||||
|
if aggr_type is None: aggr_type = 'unspecified'
|
||||||
|
attribute_entity, attribute_entity_index = find_inverse_name_and_index(entity_ref, attr.attribute)
|
||||||
|
statements.append(' attributes.push_back(new entity::inverse_attribute("%(attr_name)s", entity::inverse_attribute::%(aggr_type)s_type, %(bound1)d, %(bound2)d, %(entity_ref)s_type, %(attribute_entity)s_type->attributes()[%(attribute_entity_index)d]));' % locals())
|
||||||
|
statements.append(' %(name)s_type->set_inverse_attributes(attributes);' % locals())
|
||||||
|
statements.append(' }')
|
||||||
|
|
||||||
statements.append('')
|
statements.append('')
|
||||||
statements.append(' std::vector<const declaration*> declarations; declarations.reserve(%(num_declarations)d);' % locals())
|
statements.append(' std::vector<const declaration*> declarations; declarations.reserve(%(num_declarations)d);' % locals())
|
||||||
for type_name in declared_types:
|
for type_name in declared_types:
|
||||||
|
|||||||
@@ -1009,11 +1009,9 @@ enumeration_type* IfcWindowPanelPositionEnum_type = 0;
|
|||||||
enumeration_type* IfcWindowStyleConstructionEnum_type = 0;
|
enumeration_type* IfcWindowStyleConstructionEnum_type = 0;
|
||||||
enumeration_type* IfcWindowStyleOperationEnum_type = 0;
|
enumeration_type* IfcWindowStyleOperationEnum_type = 0;
|
||||||
enumeration_type* IfcWorkControlTypeEnum_type = 0;
|
enumeration_type* IfcWorkControlTypeEnum_type = 0;
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# pragma optimize( "", off )
|
#pragma optimize("", off)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
schema_definition* populate_schema() {
|
schema_definition* populate_schema() {
|
||||||
IfcAbsorbedDoseMeasure_type = new type_declaration(IfcSchema::Type::IfcAbsorbedDoseMeasure, new simple_type(simple_type::real_type));
|
IfcAbsorbedDoseMeasure_type = new type_declaration(IfcSchema::Type::IfcAbsorbedDoseMeasure, new simple_type(simple_type::real_type));
|
||||||
IfcAccelerationMeasure_type = new type_declaration(IfcSchema::Type::IfcAccelerationMeasure, new simple_type(simple_type::real_type));
|
IfcAccelerationMeasure_type = new type_declaration(IfcSchema::Type::IfcAccelerationMeasure, new simple_type(simple_type::real_type));
|
||||||
@@ -9394,6 +9392,373 @@ schema_definition* populate_schema() {
|
|||||||
derived.push_back(false); derived.push_back(false); derived.push_back(false); derived.push_back(false); derived.push_back(false);
|
derived.push_back(false); derived.push_back(false); derived.push_back(false); derived.push_back(false); derived.push_back(false);
|
||||||
IfcZone_type->set_attributes(attributes, derived);
|
IfcZone_type->set_attributes(attributes, derived);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("IsActingUpon", entity::inverse_attribute::set_type, 0, -1, IfcRelAssignsToActor_type, IfcRelAssignsToActor_type->attributes()[0]));
|
||||||
|
IfcActor_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(2);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("OfPerson", entity::inverse_attribute::set_type, 0, -1, IfcPerson_type, IfcPerson_type->attributes()[7]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("OfOrganization", entity::inverse_attribute::set_type, 0, -1, IfcOrganization_type, IfcOrganization_type->attributes()[4]));
|
||||||
|
IfcAddress_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ContainedInStructure", entity::inverse_attribute::set_type, 0, 1, IfcRelContainedInSpatialStructure_type, IfcRelContainedInSpatialStructure_type->attributes()[0]));
|
||||||
|
IfcAnnotation_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(3);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ValuesReferenced", entity::inverse_attribute::set_type, 0, -1, IfcReferencesValueDocument_type, IfcReferencesValueDocument_type->attributes()[1]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ValueOfComponents", entity::inverse_attribute::set_type, 0, -1, IfcAppliedValueRelationship_type, IfcAppliedValueRelationship_type->attributes()[0]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("IsComponentIn", entity::inverse_attribute::set_type, 0, -1, IfcAppliedValueRelationship_type, IfcAppliedValueRelationship_type->attributes()[1]));
|
||||||
|
IfcAppliedValue_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(3);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("Actors", entity::inverse_attribute::set_type, 0, -1, IfcApprovalActorRelationship_type, IfcApprovalActorRelationship_type->attributes()[1]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("IsRelatedWith", entity::inverse_attribute::set_type, 0, -1, IfcApprovalRelationship_type, IfcApprovalRelationship_type->attributes()[0]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("Relates", entity::inverse_attribute::set_type, 0, -1, IfcApprovalRelationship_type, IfcApprovalRelationship_type->attributes()[1]));
|
||||||
|
IfcApproval_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("Contains", entity::inverse_attribute::set_type, 0, -1, IfcClassificationItem_type, IfcClassificationItem_type->attributes()[1]));
|
||||||
|
IfcClassification_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(2);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("IsClassifiedItemIn", entity::inverse_attribute::set_type, 0, 1, IfcClassificationItemRelationship_type, IfcClassificationItemRelationship_type->attributes()[1]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("IsClassifyingItemIn", entity::inverse_attribute::set_type, 0, 1, IfcClassificationItemRelationship_type, IfcClassificationItemRelationship_type->attributes()[0]));
|
||||||
|
IfcClassificationItem_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("UsingCurves", entity::inverse_attribute::set_type, 1, -1, IfcCompositeCurve_type, IfcCompositeCurve_type->attributes()[0]));
|
||||||
|
IfcCompositeCurveSegment_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(6);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ClassifiedAs", entity::inverse_attribute::set_type, 0, -1, IfcConstraintClassificationRelationship_type, IfcConstraintClassificationRelationship_type->attributes()[0]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("RelatesConstraints", entity::inverse_attribute::set_type, 0, -1, IfcConstraintRelationship_type, IfcConstraintRelationship_type->attributes()[2]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("IsRelatedWith", entity::inverse_attribute::set_type, 0, -1, IfcConstraintRelationship_type, IfcConstraintRelationship_type->attributes()[3]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("PropertiesForConstraint", entity::inverse_attribute::set_type, 0, -1, IfcPropertyConstraintRelationship_type, IfcPropertyConstraintRelationship_type->attributes()[0]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("Aggregates", entity::inverse_attribute::set_type, 0, -1, IfcConstraintAggregationRelationship_type, IfcConstraintAggregationRelationship_type->attributes()[2]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("IsAggregatedIn", entity::inverse_attribute::set_type, 0, -1, IfcConstraintAggregationRelationship_type, IfcConstraintAggregationRelationship_type->attributes()[3]));
|
||||||
|
IfcConstraint_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("Controls", entity::inverse_attribute::set_type, 0, -1, IfcRelAssignsToControl_type, IfcRelAssignsToControl_type->attributes()[0]));
|
||||||
|
IfcControl_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(2);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("CoversSpaces", entity::inverse_attribute::set_type, 0, 1, IfcRelCoversSpaces_type, IfcRelCoversSpaces_type->attributes()[1]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("Covers", entity::inverse_attribute::set_type, 0, 1, IfcRelCoversBldgElements_type, IfcRelCoversBldgElements_type->attributes()[1]));
|
||||||
|
IfcCovering_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("AnnotatedBySymbols", entity::inverse_attribute::set_type, 0, 2, IfcTerminatorSymbol_type, IfcTerminatorSymbol_type->attributes()[0]));
|
||||||
|
IfcDimensionCurve_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("AssignedToFlowElement", entity::inverse_attribute::set_type, 0, 1, IfcRelFlowControlElements_type, IfcRelFlowControlElements_type->attributes()[0]));
|
||||||
|
IfcDistributionControlElement_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("HasControlElements", entity::inverse_attribute::set_type, 0, 1, IfcRelFlowControlElements_type, IfcRelFlowControlElements_type->attributes()[1]));
|
||||||
|
IfcDistributionFlowElement_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(2);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("IsPointedTo", entity::inverse_attribute::set_type, 0, -1, IfcDocumentInformationRelationship_type, IfcDocumentInformationRelationship_type->attributes()[1]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("IsPointer", entity::inverse_attribute::set_type, 0, 1, IfcDocumentInformationRelationship_type, IfcDocumentInformationRelationship_type->attributes()[0]));
|
||||||
|
IfcDocumentInformation_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ReferenceToDocument", entity::inverse_attribute::set_type, 0, 1, IfcDocumentInformation_type, IfcDocumentInformation_type->attributes()[3]));
|
||||||
|
IfcDocumentReference_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(2);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("IsRelatedFromCallout", entity::inverse_attribute::set_type, 0, -1, IfcDraughtingCalloutRelationship_type, IfcDraughtingCalloutRelationship_type->attributes()[3]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("IsRelatedToCallout", entity::inverse_attribute::set_type, 0, -1, IfcDraughtingCalloutRelationship_type, IfcDraughtingCalloutRelationship_type->attributes()[2]));
|
||||||
|
IfcDraughtingCallout_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(12);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("HasStructuralMember", entity::inverse_attribute::set_type, 0, -1, IfcRelConnectsStructuralElement_type, IfcRelConnectsStructuralElement_type->attributes()[0]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("FillsVoids", entity::inverse_attribute::set_type, 0, 1, IfcRelFillsElement_type, IfcRelFillsElement_type->attributes()[1]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ConnectedTo", entity::inverse_attribute::set_type, 0, -1, IfcRelConnectsElements_type, IfcRelConnectsElements_type->attributes()[1]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("HasCoverings", entity::inverse_attribute::set_type, 0, -1, IfcRelCoversBldgElements_type, IfcRelCoversBldgElements_type->attributes()[0]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("HasProjections", entity::inverse_attribute::set_type, 0, -1, IfcRelProjectsElement_type, IfcRelProjectsElement_type->attributes()[0]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ReferencedInStructures", entity::inverse_attribute::set_type, 0, -1, IfcRelReferencedInSpatialStructure_type, IfcRelReferencedInSpatialStructure_type->attributes()[0]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("HasPorts", entity::inverse_attribute::set_type, 0, -1, IfcRelConnectsPortToElement_type, IfcRelConnectsPortToElement_type->attributes()[1]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("HasOpenings", entity::inverse_attribute::set_type, 0, -1, IfcRelVoidsElement_type, IfcRelVoidsElement_type->attributes()[0]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("IsConnectionRealization", entity::inverse_attribute::set_type, 0, -1, IfcRelConnectsWithRealizingElements_type, IfcRelConnectsWithRealizingElements_type->attributes()[0]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ProvidesBoundaries", entity::inverse_attribute::set_type, 0, -1, IfcRelSpaceBoundary_type, IfcRelSpaceBoundary_type->attributes()[1]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ConnectedFrom", entity::inverse_attribute::set_type, 0, -1, IfcRelConnectsElements_type, IfcRelConnectsElements_type->attributes()[2]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ContainedInStructure", entity::inverse_attribute::set_type, 0, 1, IfcRelContainedInSpatialStructure_type, IfcRelContainedInSpatialStructure_type->attributes()[0]));
|
||||||
|
IfcElement_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ProjectsElements", entity::inverse_attribute::unspecified_type, -1, -1, IfcRelProjectsElement_type, IfcRelProjectsElement_type->attributes()[1]));
|
||||||
|
IfcFeatureElementAddition_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("VoidsElements", entity::inverse_attribute::unspecified_type, -1, -1, IfcRelVoidsElement_type, IfcRelVoidsElement_type->attributes()[1]));
|
||||||
|
IfcFeatureElementSubtraction_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("HasSubContexts", entity::inverse_attribute::set_type, 0, -1, IfcGeometricRepresentationSubContext_type, IfcGeometricRepresentationSubContext_type->attributes()[0]));
|
||||||
|
IfcGeometricRepresentationContext_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ContainedInStructure", entity::inverse_attribute::set_type, 0, 1, IfcRelContainedInSpatialStructure_type, IfcRelContainedInSpatialStructure_type->attributes()[0]));
|
||||||
|
IfcGrid_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(4);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("PartOfW", entity::inverse_attribute::set_type, 0, 1, IfcGrid_type, IfcGrid_type->attributes()[2]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("PartOfV", entity::inverse_attribute::set_type, 0, 1, IfcGrid_type, IfcGrid_type->attributes()[1]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("PartOfU", entity::inverse_attribute::set_type, 0, 1, IfcGrid_type, IfcGrid_type->attributes()[0]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("HasIntersections", entity::inverse_attribute::set_type, 0, -1, IfcVirtualGridIntersection_type, IfcVirtualGridIntersection_type->attributes()[0]));
|
||||||
|
IfcGridAxis_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("IsGroupedBy", entity::inverse_attribute::unspecified_type, -1, -1, IfcRelAssignsToGroup_type, IfcRelAssignsToGroup_type->attributes()[0]));
|
||||||
|
IfcGroup_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ReferenceIntoLibrary", entity::inverse_attribute::set_type, 0, 1, IfcLibraryInformation_type, IfcLibraryInformation_type->attributes()[4]));
|
||||||
|
IfcLibraryReference_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(2);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("HasRepresentation", entity::inverse_attribute::set_type, 0, 1, IfcMaterialDefinitionRepresentation_type, IfcMaterialDefinitionRepresentation_type->attributes()[0]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ClassifiedAs", entity::inverse_attribute::set_type, 0, 1, IfcMaterialClassificationRelationship_type, IfcMaterialClassificationRelationship_type->attributes()[1]));
|
||||||
|
IfcMaterial_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ToMaterialLayerSet", entity::inverse_attribute::unspecified_type, -1, -1, IfcMaterialLayerSet_type, IfcMaterialLayerSet_type->attributes()[0]));
|
||||||
|
IfcMaterialLayer_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("IsDefinedBy", entity::inverse_attribute::set_type, 0, -1, IfcRelDefines_type, IfcRelDefines_type->attributes()[0]));
|
||||||
|
IfcObject_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(4);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("HasAssignments", entity::inverse_attribute::set_type, 0, -1, IfcRelAssigns_type, IfcRelAssigns_type->attributes()[0]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("IsDecomposedBy", entity::inverse_attribute::set_type, 0, -1, IfcRelDecomposes_type, IfcRelDecomposes_type->attributes()[0]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("Decomposes", entity::inverse_attribute::set_type, 0, 1, IfcRelDecomposes_type, IfcRelDecomposes_type->attributes()[1]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("HasAssociations", entity::inverse_attribute::set_type, 0, -1, IfcRelAssociates_type, IfcRelAssociates_type->attributes()[0]));
|
||||||
|
IfcObjectDefinition_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(2);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("PlacesObject", entity::inverse_attribute::set_type, 1, 1, IfcProduct_type, IfcProduct_type->attributes()[0]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ReferencedByPlacements", entity::inverse_attribute::set_type, 0, -1, IfcLocalPlacement_type, IfcLocalPlacement_type->attributes()[0]));
|
||||||
|
IfcObjectPlacement_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("HasFillings", entity::inverse_attribute::set_type, 0, -1, IfcRelFillsElement_type, IfcRelFillsElement_type->attributes()[0]));
|
||||||
|
IfcOpeningElement_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(3);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("IsRelatedBy", entity::inverse_attribute::set_type, 0, -1, IfcOrganizationRelationship_type, IfcOrganizationRelationship_type->attributes()[3]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("Relates", entity::inverse_attribute::set_type, 0, -1, IfcOrganizationRelationship_type, IfcOrganizationRelationship_type->attributes()[2]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("Engages", entity::inverse_attribute::set_type, 0, -1, IfcPersonAndOrganization_type, IfcPersonAndOrganization_type->attributes()[1]));
|
||||||
|
IfcOrganization_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("EngagedIn", entity::inverse_attribute::set_type, 0, -1, IfcPersonAndOrganization_type, IfcPersonAndOrganization_type->attributes()[0]));
|
||||||
|
IfcPerson_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("PartOfComplex", entity::inverse_attribute::set_type, 0, 1, IfcPhysicalComplexQuantity_type, IfcPhysicalComplexQuantity_type->attributes()[0]));
|
||||||
|
IfcPhysicalQuantity_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(3);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ContainedIn", entity::inverse_attribute::unspecified_type, -1, -1, IfcRelConnectsPortToElement_type, IfcRelConnectsPortToElement_type->attributes()[0]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ConnectedFrom", entity::inverse_attribute::set_type, 0, 1, IfcRelConnectsPorts_type, IfcRelConnectsPorts_type->attributes()[1]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ConnectedTo", entity::inverse_attribute::set_type, 0, 1, IfcRelConnectsPorts_type, IfcRelConnectsPorts_type->attributes()[0]));
|
||||||
|
IfcPort_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(3);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("OperatesOn", entity::inverse_attribute::set_type, 0, -1, IfcRelAssignsToProcess_type, IfcRelAssignsToProcess_type->attributes()[0]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("IsSuccessorFrom", entity::inverse_attribute::set_type, 0, -1, IfcRelSequence_type, IfcRelSequence_type->attributes()[1]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("IsPredecessorTo", entity::inverse_attribute::set_type, 0, -1, IfcRelSequence_type, IfcRelSequence_type->attributes()[0]));
|
||||||
|
IfcProcess_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ReferencedBy", entity::inverse_attribute::set_type, 0, -1, IfcRelAssignsToProduct_type, IfcRelAssignsToProduct_type->attributes()[0]));
|
||||||
|
IfcProduct_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(2);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ShapeOfProduct", entity::inverse_attribute::set_type, 1, 1, IfcProduct_type, IfcProduct_type->attributes()[1]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("HasShapeAspects", entity::inverse_attribute::set_type, 0, -1, IfcShapeAspect_type, IfcShapeAspect_type->attributes()[4]));
|
||||||
|
IfcProductDefinitionShape_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(3);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("PropertyForDependance", entity::inverse_attribute::set_type, 0, -1, IfcPropertyDependencyRelationship_type, IfcPropertyDependencyRelationship_type->attributes()[0]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("PropertyDependsOn", entity::inverse_attribute::set_type, 0, -1, IfcPropertyDependencyRelationship_type, IfcPropertyDependencyRelationship_type->attributes()[1]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("PartOfComplex", entity::inverse_attribute::set_type, 0, 1, IfcComplexProperty_type, IfcComplexProperty_type->attributes()[1]));
|
||||||
|
IfcProperty_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("HasAssociations", entity::inverse_attribute::set_type, 0, -1, IfcRelAssociates_type, IfcRelAssociates_type->attributes()[0]));
|
||||||
|
IfcPropertyDefinition_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(2);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("PropertyDefinitionOf", entity::inverse_attribute::set_type, 0, 1, IfcRelDefinesByProperties_type, IfcRelDefinesByProperties_type->attributes()[0]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("DefinesType", entity::inverse_attribute::set_type, 0, 1, IfcTypeObject_type, IfcTypeObject_type->attributes()[1]));
|
||||||
|
IfcPropertySetDefinition_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(3);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("RepresentationMap", entity::inverse_attribute::set_type, 0, 1, IfcRepresentationMap_type, IfcRepresentationMap_type->attributes()[1]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("LayerAssignments", entity::inverse_attribute::set_type, 0, -1, IfcPresentationLayerAssignment_type, IfcPresentationLayerAssignment_type->attributes()[2]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("OfProductRepresentation", entity::inverse_attribute::set_type, 0, 1, IfcProductRepresentation_type, IfcProductRepresentation_type->attributes()[2]));
|
||||||
|
IfcRepresentation_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("RepresentationsInContext", entity::inverse_attribute::set_type, 0, -1, IfcRepresentation_type, IfcRepresentation_type->attributes()[0]));
|
||||||
|
IfcRepresentationContext_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(2);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("LayerAssignments", entity::inverse_attribute::set_type, 0, -1, IfcPresentationLayerAssignment_type, IfcPresentationLayerAssignment_type->attributes()[2]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("StyledByItem", entity::inverse_attribute::set_type, 0, 1, IfcStyledItem_type, IfcStyledItem_type->attributes()[0]));
|
||||||
|
IfcRepresentationItem_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("MapUsage", entity::inverse_attribute::set_type, 0, -1, IfcMappedItem_type, IfcMappedItem_type->attributes()[0]));
|
||||||
|
IfcRepresentationMap_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ResourceOf", entity::inverse_attribute::set_type, 0, -1, IfcRelAssignsToResource_type, IfcRelAssignsToResource_type->attributes()[0]));
|
||||||
|
IfcResource_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ScheduleTimeControlAssigned", entity::inverse_attribute::unspecified_type, -1, -1, IfcRelAssignsTasks_type, IfcRelAssignsTasks_type->attributes()[0]));
|
||||||
|
IfcScheduleTimeControl_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("OfShapeAspect", entity::inverse_attribute::set_type, 0, 1, IfcShapeAspect_type, IfcShapeAspect_type->attributes()[0]));
|
||||||
|
IfcShapeModel_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(2);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("HasCoverings", entity::inverse_attribute::set_type, 0, -1, IfcRelCoversSpaces_type, IfcRelCoversSpaces_type->attributes()[0]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("BoundedBy", entity::inverse_attribute::set_type, 0, -1, IfcRelSpaceBoundary_type, IfcRelSpaceBoundary_type->attributes()[0]));
|
||||||
|
IfcSpace_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(2);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("HasInteractionReqsFrom", entity::inverse_attribute::set_type, 0, -1, IfcRelInteractionRequirements_type, IfcRelInteractionRequirements_type->attributes()[3]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("HasInteractionReqsTo", entity::inverse_attribute::set_type, 0, -1, IfcRelInteractionRequirements_type, IfcRelInteractionRequirements_type->attributes()[4]));
|
||||||
|
IfcSpaceProgram_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(3);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ReferencesElements", entity::inverse_attribute::set_type, 0, -1, IfcRelReferencedInSpatialStructure_type, IfcRelReferencedInSpatialStructure_type->attributes()[1]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ServicedBySystems", entity::inverse_attribute::set_type, 0, -1, IfcRelServicesBuildings_type, IfcRelServicesBuildings_type->attributes()[1]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ContainsElements", entity::inverse_attribute::set_type, 0, -1, IfcRelContainedInSpatialStructure_type, IfcRelContainedInSpatialStructure_type->attributes()[1]));
|
||||||
|
IfcSpatialStructureElement_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("AssignedToStructuralItem", entity::inverse_attribute::unspecified_type, -1, -1, IfcRelConnectsStructuralActivity_type, IfcRelConnectsStructuralActivity_type->attributes()[1]));
|
||||||
|
IfcStructuralActivity_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ConnectsStructuralMembers", entity::inverse_attribute::set_type, 1, -1, IfcRelConnectsStructuralMember_type, IfcRelConnectsStructuralMember_type->attributes()[1]));
|
||||||
|
IfcStructuralConnection_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("AssignedStructuralActivity", entity::inverse_attribute::set_type, 0, -1, IfcRelConnectsStructuralActivity_type, IfcRelConnectsStructuralActivity_type->attributes()[0]));
|
||||||
|
IfcStructuralItem_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(2);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("SourceOfResultGroup", entity::inverse_attribute::set_type, 0, 1, IfcStructuralResultGroup_type, IfcStructuralResultGroup_type->attributes()[1]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("LoadGroupFor", entity::inverse_attribute::set_type, 0, -1, IfcStructuralAnalysisModel_type, IfcStructuralAnalysisModel_type->attributes()[2]));
|
||||||
|
IfcStructuralLoadGroup_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(2);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ReferencesElement", entity::inverse_attribute::set_type, 0, -1, IfcRelConnectsStructuralElement_type, IfcRelConnectsStructuralElement_type->attributes()[1]));
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ConnectedBy", entity::inverse_attribute::set_type, 0, -1, IfcRelConnectsStructuralMember_type, IfcRelConnectsStructuralMember_type->attributes()[0]));
|
||||||
|
IfcStructuralMember_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("Causes", entity::inverse_attribute::set_type, 0, -1, IfcStructuralAction_type, IfcStructuralAction_type->attributes()[1]));
|
||||||
|
IfcStructuralReaction_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ResultGroupFor", entity::inverse_attribute::set_type, 0, 1, IfcStructuralAnalysisModel_type, IfcStructuralAnalysisModel_type->attributes()[3]));
|
||||||
|
IfcStructuralResultGroup_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ServicesBuildings", entity::inverse_attribute::set_type, 0, 1, IfcRelServicesBuildings_type, IfcRelServicesBuildings_type->attributes()[0]));
|
||||||
|
IfcSystem_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("OfTable", entity::inverse_attribute::unspecified_type, -1, -1, IfcTable_type, IfcTable_type->attributes()[1]));
|
||||||
|
IfcTableRow_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("AnnotatedSurface", entity::inverse_attribute::set_type, 1, 1, IfcAnnotationSurface_type, IfcAnnotationSurface_type->attributes()[1]));
|
||||||
|
IfcTextureCoordinate_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("DocumentedBy", entity::inverse_attribute::set_type, 0, 1, IfcTimeSeriesReferenceRelationship_type, IfcTimeSeriesReferenceRelationship_type->attributes()[0]));
|
||||||
|
IfcTimeSeries_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(1);
|
||||||
|
attributes.push_back(new entity::inverse_attribute("ObjectTypeOf", entity::inverse_attribute::set_type, 0, 1, IfcRelDefinesByType_type, IfcRelDefinesByType_type->attributes()[0]));
|
||||||
|
IfcTypeObject_type->set_inverse_attributes(attributes);
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<const declaration*> declarations; declarations.reserve(980);
|
std::vector<const declaration*> declarations; declarations.reserve(980);
|
||||||
declarations.push_back(IfcAbsorbedDoseMeasure_type);
|
declarations.push_back(IfcAbsorbedDoseMeasure_type);
|
||||||
@@ -10380,9 +10745,8 @@ schema_definition* populate_schema() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# pragma optimize( "", on )
|
#pragma optimize("", on)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const schema_definition& get_schema() {
|
const schema_definition& get_schema() {
|
||||||
|
|
||||||
static const schema_definition* s = populate_schema();
|
static const schema_definition* s = populate_schema();
|
||||||
|
|||||||
+9140
-7857
File diff suppressed because it is too large
Load Diff
+977
-5948
File diff suppressed because it is too large
Load Diff
@@ -23,6 +23,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
|
#include "../ifcparse/Hdf5Settings.h"
|
||||||
#include "../ifcparse/IfcParse.h"
|
#include "../ifcparse/IfcParse.h"
|
||||||
#include "../ifcparse/IfcSpfHeader.h"
|
#include "../ifcparse/IfcSpfHeader.h"
|
||||||
|
|
||||||
@@ -36,7 +37,6 @@ public:
|
|||||||
typedef std::map<unsigned int, IfcUtil::IfcBaseClass*> entity_by_id_t;
|
typedef std::map<unsigned int, IfcUtil::IfcBaseClass*> entity_by_id_t;
|
||||||
typedef std::map<std::string, IfcSchema::IfcRoot*> entity_by_guid_t;
|
typedef std::map<std::string, IfcSchema::IfcRoot*> entity_by_guid_t;
|
||||||
typedef std::map<unsigned int, IfcEntityList::ptr> entities_by_ref_t;
|
typedef std::map<unsigned int, IfcEntityList::ptr> entities_by_ref_t;
|
||||||
typedef std::map<unsigned int, unsigned int> offset_by_id_t;
|
|
||||||
typedef entity_by_id_t::const_iterator const_iterator;
|
typedef entity_by_id_t::const_iterator const_iterator;
|
||||||
private:
|
private:
|
||||||
typedef std::map<IfcUtil::IfcBaseClass*, IfcUtil::IfcBaseClass*> entity_entity_map_t;
|
typedef std::map<IfcUtil::IfcBaseClass*, IfcUtil::IfcBaseClass*> entity_entity_map_t;
|
||||||
@@ -49,7 +49,6 @@ private:
|
|||||||
entities_by_type_t bytype;
|
entities_by_type_t bytype;
|
||||||
entities_by_ref_t byref;
|
entities_by_ref_t byref;
|
||||||
entity_by_guid_t byguid;
|
entity_by_guid_t byguid;
|
||||||
offset_by_id_t offsets;
|
|
||||||
|
|
||||||
entity_entity_map_t entity_file_map;
|
entity_entity_map_t entity_file_map;
|
||||||
|
|
||||||
@@ -136,7 +135,7 @@ public:
|
|||||||
|
|
||||||
const schema_definition* schema() const { return schema_; }
|
const schema_definition* schema() const { return schema_; }
|
||||||
|
|
||||||
void write_hdf5(const std::string&, bool compress) const;
|
void write_hdf5(const std::string&, const Hdf5Settings&);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+209
-28
@@ -6,14 +6,37 @@
|
|||||||
#pragma message("warning: HDF5 compression support is recommended")
|
#pragma message("warning: HDF5 compression support is recommended")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool OVERRIDE = true;
|
|
||||||
|
|
||||||
class UnmetDependencyException : public std::exception {};
|
class UnmetDependencyException : public std::exception {};
|
||||||
|
|
||||||
|
void visit(void* buffer, H5::DataType* dt) {
|
||||||
|
if (dt->getClass() == H5T_COMPOUND) {
|
||||||
|
H5::CompType* ct = (H5::CompType*) dt;
|
||||||
|
for (int i = 0; i < ct->getNmembers(); ++i) {
|
||||||
|
std::cerr << ct->getMemberName(i) << " ";
|
||||||
|
size_t offs = ct->getMemberOffset(i);
|
||||||
|
H5::DataType dt2 = ct->getMemberDataType(i);
|
||||||
|
visit((uint8_t*)buffer+offs, &dt2);
|
||||||
|
dt2.close();
|
||||||
|
}
|
||||||
|
} else if (dt->getClass() == H5T_VLEN) {
|
||||||
|
hvl_t* ht = (hvl_t*) buffer;
|
||||||
|
H5::VarLenType* vt = (H5::VarLenType*) dt;
|
||||||
|
H5::DataType dt2 = vt->getSuper();
|
||||||
|
for (int i = 0; i < ht->len; ++i) {
|
||||||
|
std::cerr << i << " ";
|
||||||
|
visit((uint8_t*)ht->p + i * vt->getSize(), &dt2);
|
||||||
|
}
|
||||||
|
dt2.close();
|
||||||
|
} else if (dt->getClass() == H5T_STRING) {
|
||||||
|
char* c = *(char**)buffer;
|
||||||
|
std::cerr << "'" << c << "'" << " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
H5::DataType* IfcParse::IfcHdf5File::map_type(const IfcParse::parameter_type* pt) {
|
H5::DataType* IfcParse::IfcHdf5File::map_type(const IfcParse::parameter_type* pt) {
|
||||||
H5::DataType* h5_dt;
|
H5::DataType* h5_dt;
|
||||||
if (pt->as_aggregation_type()) {
|
if (pt->as_aggregation_type()) {
|
||||||
h5_dt = new H5::VarLenType(map_type(pt->as_aggregation_type()->type_of_element()));
|
h5_dt = new H5::VarLenType(map_type(pt->as_aggregation_type()->type_of_element()));
|
||||||
} else if (pt->as_named_type()) {
|
} else if (pt->as_named_type()) {
|
||||||
if (pt->as_named_type()->declared_type()->as_entity()) {
|
if (pt->as_named_type()->declared_type()->as_entity()) {
|
||||||
h5_dt = new H5::DataType();
|
h5_dt = new H5::DataType();
|
||||||
@@ -80,9 +103,13 @@ H5::DataType* IfcParse::IfcHdf5File::commit(H5::DataType* dt, const std::string&
|
|||||||
|
|
||||||
H5::CompType* IfcParse::IfcHdf5File::map_entity(const IfcParse::entity* e) {
|
H5::CompType* IfcParse::IfcHdf5File::map_entity(const IfcParse::entity* e) {
|
||||||
std::vector<const IfcParse::entity::attribute*> attributes = e->all_attributes();
|
std::vector<const IfcParse::entity::attribute*> attributes = e->all_attributes();
|
||||||
|
std::vector<const IfcParse::entity::inverse_attribute*> inverse_attributes;
|
||||||
|
if (settings_.instantiate_inverse()) {
|
||||||
|
inverse_attributes = e->all_inverse_attributes();
|
||||||
|
}
|
||||||
|
|
||||||
std::vector< IfcParse::IfcHdf5File::compound_member > h5_attributes;
|
std::vector< IfcParse::IfcHdf5File::compound_member > h5_attributes;
|
||||||
h5_attributes.reserve(attributes.size() + 2);
|
h5_attributes.reserve(attributes.size() + inverse_attributes.size() + 2);
|
||||||
|
|
||||||
h5_attributes.push_back(std::make_pair(std::string("set_unset_bitmap"), &H5::PredType::NATIVE_INT16));
|
h5_attributes.push_back(std::make_pair(std::string("set_unset_bitmap"), &H5::PredType::NATIVE_INT16));
|
||||||
h5_attributes.push_back(std::make_pair(std::string("Entity-Instance-Identifier"), &H5::PredType::NATIVE_INT32));
|
h5_attributes.push_back(std::make_pair(std::string("Entity-Instance-Identifier"), &H5::PredType::NATIVE_INT32));
|
||||||
@@ -105,6 +132,16 @@ H5::CompType* IfcParse::IfcHdf5File::map_entity(const IfcParse::entity* e) {
|
|||||||
h5_attributes.push_back(std::make_pair(name, type));
|
h5_attributes.push_back(std::make_pair(name, type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (settings_.instantiate_inverse()) {
|
||||||
|
for (auto it = inverse_attributes.begin(); it != inverse_attributes.end(); ++it) {
|
||||||
|
const std::string& name = (*it)->name();
|
||||||
|
H5::DataType* ir_copy = new H5::DataType();
|
||||||
|
ir_copy->copy(*instance_reference);
|
||||||
|
const H5::DataType* type = new H5::VarLenType(ir_copy);
|
||||||
|
h5_attributes.push_back(std::make_pair(name, type));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return create_compound(h5_attributes);
|
return create_compound(h5_attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,10 +189,13 @@ void IfcParse::IfcHdf5File::init_default_types() {
|
|||||||
default_cpp_type_names[IfcUtil::Argument_STRING] = "string";
|
default_cpp_type_names[IfcUtil::Argument_STRING] = "string";
|
||||||
default_cpp_type_names[IfcUtil::Argument_INT] = "integer";
|
default_cpp_type_names[IfcUtil::Argument_INT] = "integer";
|
||||||
|
|
||||||
if (OVERRIDE) {
|
if (settings_.fix_global_id()) {
|
||||||
hsize_t dims = 3;
|
|
||||||
overridden_types["GlobalId"] = new H5::StrType(H5::PredType::C_S1, 22);
|
overridden_types["GlobalId"] = new H5::StrType(H5::PredType::C_S1, 22);
|
||||||
|
}
|
||||||
|
if (settings_.fix_cartesian_point()) {
|
||||||
|
hsize_t dims = 3;
|
||||||
overridden_types["Coordinates"] = new H5::ArrayType(*default_types[simple_type::real_type], 1, &dims);
|
overridden_types["Coordinates"] = new H5::ArrayType(*default_types[simple_type::real_type], 1, &dims);
|
||||||
|
overridden_types["DirectionRatios"] = new H5::ArrayType(*default_types[simple_type::real_type], 1, &dims);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,6 +223,8 @@ std::string IfcParse::IfcHdf5File::flatten_aggregate_name(const IfcParse::parame
|
|||||||
}
|
}
|
||||||
|
|
||||||
H5::DataType* IfcParse::IfcHdf5File::map_select(const IfcParse::select_type* pt) {
|
H5::DataType* IfcParse::IfcHdf5File::map_select(const IfcParse::select_type* pt) {
|
||||||
|
if (settings_.instantiate_select()) return 0;
|
||||||
|
|
||||||
std::set<const IfcParse::declaration*> leafs;
|
std::set<const IfcParse::declaration*> leafs;
|
||||||
visit_select(pt, leafs);
|
visit_select(pt, leafs);
|
||||||
|
|
||||||
@@ -361,8 +403,11 @@ void IfcParse::IfcHdf5File::write_aggregate(void*& ptr, const IfcEntityList::ptr
|
|||||||
void* aggr_ptr = aggr_data;
|
void* aggr_ptr = aggr_data;
|
||||||
for (IfcEntityList::it it = ts->begin(); it != ts->end(); ++it) {
|
for (IfcEntityList::it it = ts->begin(); it != ts->end(); ++it) {
|
||||||
auto ref = make_instance_reference(*it);
|
auto ref = make_instance_reference(*it);
|
||||||
write_number_of_size(aggr_ptr, instance_reference->getMemberDataType(0).getSize(), ref.first);
|
// write_number_of_size(aggr_ptr, instance_reference->getMemberDataType(0).getSize(), ref.first);
|
||||||
write_number_of_size(aggr_ptr, instance_reference->getMemberDataType(1).getSize(), ref.second);
|
// write_number_of_size(aggr_ptr, instance_reference->getMemberDataType(1).getSize(), ref.second);
|
||||||
|
// Hard-coded for efficiency
|
||||||
|
write_number_of_size(aggr_ptr, 2, ref.first);
|
||||||
|
write_number_of_size(aggr_ptr, 4, ref.second);
|
||||||
}
|
}
|
||||||
write_vlen_t(ptr, n_elements, aggr_data);
|
write_vlen_t(ptr, n_elements, aggr_data);
|
||||||
}
|
}
|
||||||
@@ -436,8 +481,10 @@ void IfcParse::IfcHdf5File::write_select(void*& ptr, IfcUtil::IfcBaseClass* inst
|
|||||||
size_t offset = datatype->getMemberOffset(member_index);
|
size_t offset = datatype->getMemberOffset(member_index);
|
||||||
auto ref = make_instance_reference(instance);
|
auto ref = make_instance_reference(instance);
|
||||||
void* ptr_member = (uint8_t*) ptr + offset;
|
void* ptr_member = (uint8_t*) ptr + offset;
|
||||||
write_number_of_size(ptr_member, instance_reference->getMemberDataType(0).getSize(), ref.first);
|
// write_number_of_size(ptr_member, instance_reference->getMemberDataType(0).getSize(), ref.first);
|
||||||
write_number_of_size(ptr_member, instance_reference->getMemberDataType(1).getSize(), ref.second);
|
// write_number_of_size(ptr_member, instance_reference->getMemberDataType(1).getSize(), ref.second);
|
||||||
|
write_number_of_size(ptr_member, 2, ref.first);
|
||||||
|
write_number_of_size(ptr_member, 4, ref.second);
|
||||||
} else {
|
} else {
|
||||||
Argument& wrapped_data = *instance->data().getArgument(0);
|
Argument& wrapped_data = *instance->data().getArgument(0);
|
||||||
IfcUtil::ArgumentType ty = wrapped_data.type();
|
IfcUtil::ArgumentType ty = wrapped_data.type();
|
||||||
@@ -447,7 +494,9 @@ void IfcParse::IfcHdf5File::write_select(void*& ptr, IfcUtil::IfcBaseClass* inst
|
|||||||
std::string member_name = default_cpp_type_names.find(ty)->second + "-value";
|
std::string member_name = default_cpp_type_names.find(ty)->second + "-value";
|
||||||
member_index = datatype->getMemberIndex(member_name);
|
member_index = datatype->getMemberIndex(member_name);
|
||||||
size_t offset = datatype->getMemberOffset(member_index);
|
size_t offset = datatype->getMemberOffset(member_index);
|
||||||
size_t member_size = datatype->getMemberDataType(member_index).getSize();
|
H5::DataType memberdt = datatype->getMemberDataType(member_index);
|
||||||
|
size_t member_size = memberdt.getSize();
|
||||||
|
memberdt.close();
|
||||||
void* ptr_member = (uint8_t*) ptr + offset;
|
void* ptr_member = (uint8_t*) ptr + offset;
|
||||||
switch(wrapped_data.type()) {
|
switch(wrapped_data.type()) {
|
||||||
case IfcUtil::Argument_BOOL: {
|
case IfcUtil::Argument_BOOL: {
|
||||||
@@ -489,16 +538,50 @@ void IfcParse::IfcHdf5File::write_select(void*& ptr, IfcUtil::IfcBaseClass* inst
|
|||||||
advance(ptr, datatype->getSize());
|
advance(ptr, datatype->getSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
void IfcParse::IfcHdf5File::write_population(const IfcFile& f, bool compress) {
|
void IfcParse::IfcHdf5File::write_population(IfcFile& f) {
|
||||||
std::set<IfcSchema::Type::Enum> tys;
|
std::set<IfcSchema::Type::Enum> tys;
|
||||||
|
|
||||||
this->file->close();
|
// Wth was this?
|
||||||
|
// this->file->close();
|
||||||
|
|
||||||
|
std::set<IfcSchema::Type::Enum> types_with_instiated_selected;
|
||||||
|
|
||||||
for (auto it = f.begin(); it != f.end(); ++it) {
|
for (auto it = f.begin(); it != f.end(); ++it) {
|
||||||
IfcSchema::Type::Enum ty = it->second->declaration().type();
|
IfcSchema::Type::Enum ty = it->second->declaration().type();
|
||||||
tys.insert(ty);
|
tys.insert(ty);
|
||||||
// This already is sorted on entity instance name
|
// This already is sorted on entity instance name
|
||||||
sorted_entities[ty].push_back(it->second);
|
sorted_entities[ty].push_back(it->second);
|
||||||
|
|
||||||
|
if (settings_.instantiate_select()) {
|
||||||
|
bool has=false;
|
||||||
|
for (unsigned i = 0; i < it->second->data().getArgumentCount(); ++i) {
|
||||||
|
Argument* attr = it->second->data().getArgument(i);
|
||||||
|
if (attr->type() == IfcUtil::Argument_ENTITY_INSTANCE) {
|
||||||
|
IfcUtil::IfcBaseClass* inst = *attr;
|
||||||
|
if (!inst->declaration().as_entity()) {
|
||||||
|
IfcSchema::Type::Enum ty2 = inst->declaration().type();
|
||||||
|
tys.insert(ty2);
|
||||||
|
sorted_entities[ty2].push_back(inst);
|
||||||
|
has = true;
|
||||||
|
}
|
||||||
|
} else if (attr->type() == IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE) {
|
||||||
|
IfcEntityList::ptr insts = *attr;
|
||||||
|
for (auto it = insts->begin(); it != insts->end(); ++it) {
|
||||||
|
if (!(*it)->declaration().as_entity()) {
|
||||||
|
IfcSchema::Type::Enum ty2 = (*it)->declaration().type();
|
||||||
|
tys.insert(ty2);
|
||||||
|
sorted_entities[ty2].push_back(*it);
|
||||||
|
has = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (has) {
|
||||||
|
types_with_instiated_selected.insert(ty);
|
||||||
|
} else {
|
||||||
|
static_cast<IfcParse::Entity*>(&it->second->data())->Unload();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dataset_names.assign(tys.begin(), tys.end());
|
dataset_names.assign(tys.begin(), tys.end());
|
||||||
@@ -506,7 +589,15 @@ void IfcParse::IfcHdf5File::write_population(const IfcFile& f, bool compress) {
|
|||||||
|
|
||||||
for (auto it = dataset_names.begin(); it != dataset_names.end(); ++it) {
|
for (auto it = dataset_names.begin(); it != dataset_names.end(); ++it) {
|
||||||
|
|
||||||
|
// std::cout << "begin inner loop" << std::endl;
|
||||||
|
// std::cin.get();
|
||||||
|
|
||||||
|
// if (*it != IfcSchema::Type::IfcUnitAssignment) continue;
|
||||||
|
|
||||||
|
std::cerr << IfcSchema::Type::ToString(*it) << std::endl;
|
||||||
|
|
||||||
const std::vector<IfcUtil::IfcBaseClass*>& es = sorted_entities.find(*it)->second;
|
const std::vector<IfcUtil::IfcBaseClass*>& es = sorted_entities.find(*it)->second;
|
||||||
|
size_t datatype_size = declared_types[*it]->getSize();
|
||||||
hsize_t dims = es.size();
|
hsize_t dims = es.size();
|
||||||
// don't chunk too small
|
// don't chunk too small
|
||||||
// hsize_t chunk = (std::min)(std::max(es.size() / 64, (size_t)8), es.size());
|
// hsize_t chunk = (std::min)(std::max(es.size() / 64, (size_t)8), es.size());
|
||||||
@@ -515,8 +606,8 @@ void IfcParse::IfcHdf5File::write_population(const IfcFile& f, bool compress) {
|
|||||||
|
|
||||||
const H5::DSetCreatPropList* plist;
|
const H5::DSetCreatPropList* plist;
|
||||||
// H5O_MESG_MAX_SIZE = 65536
|
// H5O_MESG_MAX_SIZE = 65536
|
||||||
const bool compact = es.size() * declared_types[*it]->getSize() < (1 << 15);
|
const bool compact = es.size() * datatype_size < (1 << 15);
|
||||||
if (compress && !compact) {
|
if (settings_.compress() && !compact) {
|
||||||
H5::DSetCreatPropList* plist_ = new H5::DSetCreatPropList;
|
H5::DSetCreatPropList* plist_ = new H5::DSetCreatPropList;
|
||||||
plist_->setChunk(1, &chunk);
|
plist_->setChunk(1, &chunk);
|
||||||
// D'oh. Order is significant, according to h5ex_d_shuffle.c
|
// D'oh. Order is significant, according to h5ex_d_shuffle.c
|
||||||
@@ -532,22 +623,59 @@ void IfcParse::IfcHdf5File::write_population(const IfcFile& f, bool compress) {
|
|||||||
plist = &H5::DSetCreatPropList::DEFAULT;
|
plist = &H5::DSetCreatPropList::DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
H5::DataSet ds = population_group.createDataSet(IfcSchema::Type::ToString(*it) + "_instances", *declared_types[*it], H5::DataSpace(1, &dims), *plist);
|
H5::DataSpace space(1, &dims);
|
||||||
|
H5::DataSet ds = population_group.createDataSet(IfcSchema::Type::ToString(*it) + "_instances", *declared_types[*it], space, *plist);
|
||||||
|
|
||||||
void* data = allocator.allocate(declared_types[*it]->getSize() * static_cast<size_t>(dims));
|
size_t dataset_size = declared_types[*it]->getSize() * static_cast<size_t>(dims);
|
||||||
|
void* data = allocator.allocate(dataset_size);
|
||||||
|
|
||||||
|
std::cerr << dataset_size << std::endl;
|
||||||
|
|
||||||
void* ptr = data;
|
void* ptr = data;
|
||||||
const H5::CompType* dt = (H5::CompType*) declared_types[*it];
|
const H5::CompType* dt = (H5::CompType*) declared_types[*it];
|
||||||
int ind = 0;
|
int ind = 0;
|
||||||
|
|
||||||
for (auto jt = es.begin(); jt != es.end(); ++jt, ++ind) {
|
for (auto jt = es.begin(); jt != es.end(); ++jt, ++ind) {
|
||||||
|
void* start = ptr;
|
||||||
|
|
||||||
int member_idx = 0;
|
int member_idx = 0;
|
||||||
|
|
||||||
H5::DataType member_type;
|
H5::DataType member_type;
|
||||||
|
|
||||||
IfcAbstractEntity& dat = (*jt)->data();
|
IfcAbstractEntity& dat = (*jt)->data();
|
||||||
const declaration& decl = (*jt)->declaration();
|
const declaration& decl = (*jt)->declaration();
|
||||||
|
|
||||||
|
if (!decl.as_entity()) {
|
||||||
|
if (!settings_.instantiate_select()) throw;
|
||||||
|
// This is a type
|
||||||
|
auto q = dt->getClass();
|
||||||
|
auto s = dt->getSize();
|
||||||
|
const Argument& attr_value = *dat.getArgument(0);
|
||||||
|
if (*dt == *default_types[simple_type::real_type]) {
|
||||||
|
double d = attr_value;
|
||||||
|
write_number_of_size(ptr, s, d);
|
||||||
|
} else if (*dt == *default_types[simple_type::string_type]) {
|
||||||
|
std::string s = attr_value;
|
||||||
|
write(ptr, s);
|
||||||
|
} else if (*dt == *default_types[simple_type::integer_type]) {
|
||||||
|
int i = attr_value;
|
||||||
|
write_number_of_size(ptr, s, i);
|
||||||
|
} else if (*dt == *default_types[simple_type::boolean_type] ||
|
||||||
|
*dt == *default_types[simple_type::logical_type])
|
||||||
|
{
|
||||||
|
bool b = attr_value;
|
||||||
|
write_number_of_size(ptr, s, static_cast<uint8_t>(b ? 1 : 0));
|
||||||
|
} else {
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<const IfcParse::entity::attribute*> attributes = decl.as_entity()->all_attributes();
|
std::vector<const IfcParse::entity::attribute*> attributes = decl.as_entity()->all_attributes();
|
||||||
|
std::vector<const IfcParse::entity::inverse_attribute*> inverse_attributes;
|
||||||
|
if (settings_.instantiate_inverse()) {
|
||||||
|
inverse_attributes = decl.as_entity()->all_inverse_attributes();
|
||||||
|
}
|
||||||
const std::vector<bool>& attributes_derived_in_subtype = decl.as_entity()->derived();
|
const std::vector<bool>& attributes_derived_in_subtype = decl.as_entity()->derived();
|
||||||
std::vector<bool>::const_iterator is_derived = attributes_derived_in_subtype.begin();
|
std::vector<bool>::const_iterator is_derived = attributes_derived_in_subtype.begin();
|
||||||
|
|
||||||
@@ -557,11 +685,15 @@ void IfcParse::IfcHdf5File::write_population(const IfcFile& f, bool compress) {
|
|||||||
size_t set_unset_size = member_type.getSize();
|
size_t set_unset_size = member_type.getSize();
|
||||||
// skip for now write later
|
// skip for now write later
|
||||||
advance(ptr, set_unset_size);
|
advance(ptr, set_unset_size);
|
||||||
|
member_type.close();
|
||||||
|
|
||||||
member_type = dt->getMemberDataType(member_idx++);
|
member_type = dt->getMemberDataType(member_idx++);
|
||||||
write_number_of_size(ptr, member_type.getSize(), static_cast<unsigned int>(dat.id()));
|
write_number_of_size(ptr, member_type.getSize(), static_cast<unsigned int>(dat.id()));
|
||||||
|
member_type.close();
|
||||||
for (unsigned i = 0; i < dat.getArgumentCount(); ++i, ++is_derived) {
|
|
||||||
|
// ----v----- In some IFC files there are extra superfluous attributes in the instantiation. For example FJK haus.
|
||||||
|
const size_t attr_count = (std::min)(attributes.size(), (size_t) dat.getArgumentCount());
|
||||||
|
for (unsigned i = 0; i < attr_count; ++i, ++is_derived) {
|
||||||
if (*is_derived) {
|
if (*is_derived) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -569,6 +701,7 @@ void IfcParse::IfcHdf5File::write_population(const IfcFile& f, bool compress) {
|
|||||||
const IfcParse::entity::attribute* schema_attr = attributes[i];
|
const IfcParse::entity::attribute* schema_attr = attributes[i];
|
||||||
const std::string& attribute_name = schema_attr->name();
|
const std::string& attribute_name = schema_attr->name();
|
||||||
Argument& attr_value = *dat.getArgument(i);
|
Argument& attr_value = *dat.getArgument(i);
|
||||||
|
|
||||||
member_type = dt->getMemberDataType(member_idx++);
|
member_type = dt->getMemberDataType(member_idx++);
|
||||||
|
|
||||||
if (attr_value.isNull()) {
|
if (attr_value.isNull()) {
|
||||||
@@ -581,11 +714,11 @@ void IfcParse::IfcHdf5File::write_population(const IfcFile& f, bool compress) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
set_unset_mask |= 1 << i;
|
set_unset_mask |= 1 << i;
|
||||||
if (OVERRIDE && attribute_name == "GlobalId") {
|
if (settings_.fix_global_id() && attribute_name == "GlobalId") {
|
||||||
std::string s = attr_value;
|
std::string s = attr_value;
|
||||||
memcpy(static_cast<char*>(ptr), s.c_str(), s.size());
|
memcpy(static_cast<char*>(ptr), s.c_str(), s.size());
|
||||||
advance(ptr, s.length());
|
advance(ptr, s.length());
|
||||||
} else if (OVERRIDE && attribute_name == "Coordinates") {
|
} else if (settings_.fix_cartesian_point() && (attribute_name == "Coordinates" || attribute_name == "DirectionRatios")) {
|
||||||
std::vector<double> ds = attr_value;
|
std::vector<double> ds = attr_value;
|
||||||
for (auto it = ds.begin(); it != ds.end(); ++it) {
|
for (auto it = ds.begin(); it != ds.end(); ++it) {
|
||||||
write_number_of_size(ptr, default_types[simple_type::real_type]->getSize(), *it);
|
write_number_of_size(ptr, default_types[simple_type::real_type]->getSize(), *it);
|
||||||
@@ -596,8 +729,10 @@ void IfcParse::IfcHdf5File::write_population(const IfcFile& f, bool compress) {
|
|||||||
} else if (member_type == *instance_reference) {
|
} else if (member_type == *instance_reference) {
|
||||||
IfcUtil::IfcBaseClass* v = attr_value;
|
IfcUtil::IfcBaseClass* v = attr_value;
|
||||||
auto ref = make_instance_reference(v);
|
auto ref = make_instance_reference(v);
|
||||||
write_number_of_size(ptr, instance_reference->getMemberDataType(0).getSize(), ref.first);
|
// write_number_of_size(ptr, instance_reference->getMemberDataType(0).getSize(), ref.first);
|
||||||
write_number_of_size(ptr, instance_reference->getMemberDataType(1).getSize(), ref.second);
|
// write_number_of_size(ptr, instance_reference->getMemberDataType(1).getSize(), ref.second);
|
||||||
|
write_number_of_size(ptr, 2, ref.first);
|
||||||
|
write_number_of_size(ptr, 4, ref.second);
|
||||||
} else if (member_type == *default_types[simple_type::real_type]) {
|
} else if (member_type == *default_types[simple_type::real_type]) {
|
||||||
double d = attr_value;
|
double d = attr_value;
|
||||||
write_number_of_size(ptr, member_type.getSize(), d);
|
write_number_of_size(ptr, member_type.getSize(), d);
|
||||||
@@ -637,6 +772,7 @@ void IfcParse::IfcHdf5File::write_population(const IfcFile& f, bool compress) {
|
|||||||
void* buffer_ptr;
|
void* buffer_ptr;
|
||||||
// void* buffer = buffer_ptr = new uint8_t[size_in_bytes * num_elements];
|
// void* buffer = buffer_ptr = new uint8_t[size_in_bytes * num_elements];
|
||||||
void* buffer = buffer_ptr = allocator.allocate(size_in_bytes * num_elements);
|
void* buffer = buffer_ptr = allocator.allocate(size_in_bytes * num_elements);
|
||||||
|
memset(buffer, 0, size_in_bytes * num_elements);
|
||||||
for (auto it = es->begin(); it != es->end(); ++it) {
|
for (auto it = es->begin(); it != es->end(); ++it) {
|
||||||
write_select(buffer_ptr, *it, static_cast<const H5::CompType*>(datatype));
|
write_select(buffer_ptr, *it, static_cast<const H5::CompType*>(datatype));
|
||||||
}
|
}
|
||||||
@@ -681,18 +817,63 @@ void IfcParse::IfcHdf5File::write_population(const IfcFile& f, bool compress) {
|
|||||||
write_select(ptr, attr_value, static_cast<H5::CompType*>(&member_type));
|
write_select(ptr, attr_value, static_cast<H5::CompType*>(&member_type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
member_type.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto it = inverse_attributes.begin(); it != inverse_attributes.end(); ++it) {
|
||||||
|
member_type = dt->getMemberDataType(member_idx++);
|
||||||
|
|
||||||
|
auto q = member_type.getClass();
|
||||||
|
if (member_type.getClass() != H5T_VLEN) {
|
||||||
|
std::cerr << dt->getMemberName(member_idx - 1) << " ";
|
||||||
|
std::cerr << "Inverse attribute must be vlen" << std::endl;
|
||||||
|
}
|
||||||
|
const IfcParse::entity* entity_ref = (*it)->entity_reference();
|
||||||
|
const IfcParse::entity::attribute* attribute_ref = (*it)->attribute_reference();
|
||||||
|
IfcEntityList::ptr instances = f.getInverse(dat.id(), entity_ref->type(), entity_ref->attribute_index(attribute_ref));
|
||||||
|
if (instances->size() == 0) {
|
||||||
|
memset(ptr, 0, member_type.getSize());
|
||||||
|
advance(ptr, member_type.getSize());
|
||||||
|
} else {
|
||||||
|
write_aggregate(ptr, instances);
|
||||||
|
}
|
||||||
|
|
||||||
|
member_type.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
write_number_of_size(set_unset_ptr, set_unset_size, set_unset_mask);
|
write_number_of_size(set_unset_ptr, set_unset_size, set_unset_mask);
|
||||||
|
const size_t written_length = (uint8_t*) ptr - (uint8_t*) start;
|
||||||
|
|
||||||
|
if (written_length != datatype_size) {
|
||||||
|
std::cerr << "Written " << written_length << " bytes, but expected " << datatype_size << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ds.write(data, *declared_types[*it]);
|
/* for (size_t i = 0; i < dataset_size; ++i) {
|
||||||
ds.close();
|
std::cout << std::hex << (int)((uint8_t*)data)[i] << " ";
|
||||||
|
} */
|
||||||
|
|
||||||
allocator.free();
|
// visit(data, declared_types[*it]);
|
||||||
|
ds.write(data, *declared_types[*it]);
|
||||||
|
H5Dvlen_reclaim(declared_types[*it]->getId(), space.getId(), H5P_DEFAULT, data);
|
||||||
|
|
||||||
|
ds.close();
|
||||||
|
space.close();
|
||||||
|
|
||||||
|
if (plist != &H5::DSetCreatPropList::DEFAULT) {
|
||||||
|
// ->close() doesn't work due to const, hack hack hack
|
||||||
|
H5Pclose(plist->getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
// allocator.free();
|
||||||
|
delete[] data;
|
||||||
|
|
||||||
for (auto it = es.begin(); it != es.end(); ++it) {
|
for (auto it = es.begin(); it != es.end(); ++it) {
|
||||||
static_cast<IfcParse::Entity*>(&(**it).data())->Unload();
|
if (types_with_instiated_selected.find((**it).declaration().type()) == types_with_instiated_selected.end()) {
|
||||||
|
// Instances possibly refering to embedded simple type instantiations are not freed
|
||||||
|
static_cast<IfcParse::Entity*>(&(**it).data())->Unload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,11 +22,12 @@
|
|||||||
|
|
||||||
#include "H5Cpp.h"
|
#include "H5Cpp.h"
|
||||||
|
|
||||||
|
#include "../ifcparse/Hdf5Settings.h"
|
||||||
#include "../ifcparse/IfcUtil.h"
|
#include "../ifcparse/IfcUtil.h"
|
||||||
#include "../ifcparse/IfcFile.h"
|
#include "../ifcparse/IfcFile.h"
|
||||||
|
|
||||||
namespace IfcParse {
|
namespace IfcParse {
|
||||||
|
|
||||||
class IfcHdf5File {
|
class IfcHdf5File {
|
||||||
private:
|
private:
|
||||||
class allocator_t {
|
class allocator_t {
|
||||||
@@ -50,6 +51,7 @@ namespace IfcParse {
|
|||||||
};
|
};
|
||||||
|
|
||||||
allocator_t allocator;
|
allocator_t allocator;
|
||||||
|
Hdf5Settings settings_;
|
||||||
|
|
||||||
std::string name_;
|
std::string name_;
|
||||||
schema_definition schema_;
|
schema_definition schema_;
|
||||||
@@ -84,7 +86,7 @@ namespace IfcParse {
|
|||||||
void write_select(void*& ptr, IfcUtil::IfcBaseClass* instance, const H5::CompType* datatype) const;
|
void write_select(void*& ptr, IfcUtil::IfcBaseClass* instance, const H5::CompType* datatype) const;
|
||||||
|
|
||||||
void write_schema(const schema_definition& schema);
|
void write_schema(const schema_definition& schema);
|
||||||
void write_population(const IfcFile& f, bool compress);
|
void write_population(IfcFile& f);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const H5::DataType* get_datatype() const {
|
const H5::DataType* get_datatype() const {
|
||||||
@@ -109,12 +111,13 @@ namespace IfcParse {
|
|||||||
public:
|
public:
|
||||||
typedef std::pair<std::string, const H5::DataType*> compound_member;
|
typedef std::pair<std::string, const H5::DataType*> compound_member;
|
||||||
|
|
||||||
IfcHdf5File(const IfcFile* f, const std::string& name, bool compress)
|
IfcHdf5File(IfcFile* f, const std::string& name, const Hdf5Settings& settings)
|
||||||
: name_(name)
|
: name_(name)
|
||||||
, schema_(*f->schema())
|
, schema_(*f->schema())
|
||||||
|
, settings_(settings)
|
||||||
{
|
{
|
||||||
write_schema(*f->schema());
|
write_schema(*f->schema());
|
||||||
write_population(*f, compress);
|
write_population(*f);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+75
-88
@@ -920,6 +920,73 @@ bool IfcFile::Init(void* data, int len) {
|
|||||||
return IfcFile::Init(new IfcSpfStream(data,len));
|
return IfcFile::Init(new IfcSpfStream(data,len));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class RegisterInstancesToFile {
|
||||||
|
private:
|
||||||
|
IfcFile::entity_by_id_t& byid_;
|
||||||
|
IfcFile::entity_by_guid_t& byguid_;
|
||||||
|
IfcFile::entities_by_type_t& bytype_;
|
||||||
|
IfcFile::entities_by_ref_t& byref_;
|
||||||
|
|
||||||
|
bool populate_guid_mapping_;
|
||||||
|
public:
|
||||||
|
RegisterInstancesToFile(
|
||||||
|
IfcFile::entity_by_id_t& byid,
|
||||||
|
IfcFile::entity_by_guid_t& byguid,
|
||||||
|
IfcFile::entities_by_type_t& bytype,
|
||||||
|
IfcFile::entities_by_ref_t& byref
|
||||||
|
)
|
||||||
|
: byid_(byid)
|
||||||
|
, byguid_(byguid)
|
||||||
|
, bytype_(bytype)
|
||||||
|
, byref_(byref)
|
||||||
|
, populate_guid_mapping_(true)
|
||||||
|
{}
|
||||||
|
|
||||||
|
const bool& populate_guid_mapping() const { return populate_guid_mapping_; }
|
||||||
|
bool& populate_guid_mapping() { return populate_guid_mapping_; }
|
||||||
|
|
||||||
|
void operator()(IfcUtil::IfcBaseClass* instance) {
|
||||||
|
if (populate_guid_mapping_ && instance->declaration().is(IfcSchema::Type::IfcRoot)) {
|
||||||
|
IfcSchema::IfcRoot* ifc_root = (IfcSchema::IfcRoot*) instance;
|
||||||
|
try {
|
||||||
|
const std::string guid = ifc_root->GlobalId();
|
||||||
|
if (byguid_.insert(std::make_pair(guid, ifc_root)).second == false) {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "Duplicate instance with guid '" << guid << "' not stored";
|
||||||
|
Logger::Message(Logger::LOG_WARNING,ss.str());
|
||||||
|
}
|
||||||
|
} catch (const IfcException& ex) {
|
||||||
|
Logger::Message(Logger::LOG_ERROR,ex.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const IfcParse::entity* entity = instance->declaration().as_entity();
|
||||||
|
while(entity) {
|
||||||
|
IfcEntityList::ptr& instances_by_type = bytype_[entity->type()];
|
||||||
|
if (!instances_by_type) {
|
||||||
|
instances_by_type.reset(new IfcEntityList);
|
||||||
|
}
|
||||||
|
instances_by_type->push(instance);
|
||||||
|
entity = entity->supertype();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int id = instance->data().id();
|
||||||
|
if (byid_.insert(std::make_pair(id, instance)).second == false) {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "Duplicate instance with id '" << id << "' not stored";
|
||||||
|
Logger::Message(Logger::LOG_WARNING,ss.str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void operator()(IfcUtil::IfcBaseClass* instance, unsigned int refering_inst_name) {
|
||||||
|
IfcEntityList::ptr& instances_by_ref = byref_[refering_inst_name];
|
||||||
|
if (!instances_by_ref) {
|
||||||
|
instances_by_ref.reset(new IfcEntityList);
|
||||||
|
}
|
||||||
|
instances_by_ref->push(instance);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
bool IfcFile::Init(IfcParse::IfcSpfStream* s) {
|
bool IfcFile::Init(IfcParse::IfcSpfStream* s) {
|
||||||
// Initialize a "C" locale for locale-independent
|
// Initialize a "C" locale for locale-independent
|
||||||
// number parsing. See comment above on line 41.
|
// number parsing. See comment above on line 41.
|
||||||
@@ -942,92 +1009,12 @@ bool IfcFile::Init(IfcParse::IfcSpfStream* s) {
|
|||||||
Logger::Message(Logger::LOG_ERROR, std::string("File schema encountered different from expected '") + IfcSchema::Identifier + "'");
|
Logger::Message(Logger::LOG_ERROR, std::string("File schema encountered different from expected '") + IfcSchema::Identifier + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
Token token = TokenPtr();
|
RegisterInstancesToFile populate(byid, byguid, bytype, byref);
|
||||||
Token previous = TokenPtr();
|
populate.populate_guid_mapping() = false;
|
||||||
|
InstanceStreamer<RegisterInstancesToFile, RegisterInstancesToFile> streamer(this, *stream, *tokens, populate, populate);
|
||||||
unsigned int currentId = 0;
|
streamer.stream();
|
||||||
lastId = 0;
|
MaxId = streamer.max_inst_name_encountered();
|
||||||
int x = 0;
|
|
||||||
Entity* e;
|
|
||||||
IfcUtil::IfcBaseClass* entity = 0;
|
|
||||||
Logger::Status("Scanning file...");
|
|
||||||
while ( ! stream->eof ) {
|
|
||||||
if ( currentId ) {
|
|
||||||
try {
|
|
||||||
e = new Entity(currentId,this);
|
|
||||||
if (this->create_latebound_entities()) {
|
|
||||||
entity = new IfcLateBoundEntity(e);
|
|
||||||
} else {
|
|
||||||
entity = IfcSchema::SchemaEntity(e);
|
|
||||||
}
|
|
||||||
} catch (const IfcException& ex) {
|
|
||||||
currentId = 0;
|
|
||||||
Logger::Message(Logger::LOG_ERROR,ex.what());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// Update the status after every 1000 instances parsed
|
|
||||||
if ( !((++x)%1000) ) {
|
|
||||||
std::stringstream ss; ss << "\r#" << currentId;
|
|
||||||
Logger::Status(ss.str(), false);
|
|
||||||
}
|
|
||||||
if ( entity->declaration().is(IfcSchema::Type::IfcRoot) ) {
|
|
||||||
IfcSchema::IfcRoot* ifc_root = (IfcSchema::IfcRoot*) entity;
|
|
||||||
try {
|
|
||||||
const std::string guid = ifc_root->GlobalId();
|
|
||||||
if ( byguid.find(guid) != byguid.end() ) {
|
|
||||||
std::stringstream ss;
|
|
||||||
ss << "Overwriting entity with guid " << guid;
|
|
||||||
Logger::Message(Logger::LOG_WARNING,ss.str());
|
|
||||||
}
|
|
||||||
byguid[guid] = ifc_root;
|
|
||||||
} catch (const IfcException& ex) {
|
|
||||||
Logger::Message(Logger::LOG_ERROR,ex.what());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IfcSchema::Type::Enum ty = entity->declaration().type();
|
|
||||||
do {
|
|
||||||
IfcEntityList::ptr instances_by_type = entitiesByType(ty);
|
|
||||||
if (!instances_by_type) {
|
|
||||||
instances_by_type = IfcEntityList::ptr(new IfcEntityList());
|
|
||||||
bytype[ty] = instances_by_type;
|
|
||||||
}
|
|
||||||
instances_by_type->push(entity);
|
|
||||||
ty = IfcSchema::Type::Parent(ty);
|
|
||||||
} while ( ty > -1 );
|
|
||||||
|
|
||||||
if ( byid.find(currentId) != byid.end() ) {
|
|
||||||
std::stringstream ss;
|
|
||||||
ss << "Overwriting entity with id " << currentId;
|
|
||||||
Logger::Message(Logger::LOG_WARNING,ss.str());
|
|
||||||
}
|
|
||||||
byid[currentId] = entity;
|
|
||||||
|
|
||||||
MaxId = (std::max)(MaxId,currentId);
|
|
||||||
currentId = 0;
|
|
||||||
} else {
|
|
||||||
try { token = tokens->Next(); }
|
|
||||||
catch (... ) { token = TokenPtr(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! (token.second || token.first) ) break;
|
|
||||||
|
|
||||||
if ( (previous.second || previous.first) && TokenFunc::isIdentifier(previous) ) {
|
|
||||||
int id = TokenFunc::asInt(previous);
|
|
||||||
if ( TokenFunc::isOperator(token,'=') ) {
|
|
||||||
currentId = id;
|
|
||||||
} else if (entity) {
|
|
||||||
IfcEntityList::ptr instances_by_ref = entitiesByReference(id);
|
|
||||||
if (!instances_by_ref) {
|
|
||||||
instances_by_ref = IfcEntityList::ptr(new IfcEntityList());
|
|
||||||
byref[id] = instances_by_ref;
|
|
||||||
}
|
|
||||||
instances_by_ref->push(entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
previous = token;
|
|
||||||
}
|
|
||||||
Logger::Status("\rDone scanning file ");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1543,6 +1530,6 @@ std::pair<IfcSchema::IfcNamedUnit*, double> IfcFile::getUnit(IfcSchema::IfcUnitE
|
|||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IfcFile::write_hdf5(const std::string& name, bool compress) const {
|
void IfcFile::write_hdf5(const std::string& name, const Hdf5Settings& settings) {
|
||||||
IfcHdf5File(this, name, compress);
|
IfcHdf5File(this, name, settings);
|
||||||
}
|
}
|
||||||
@@ -263,6 +263,100 @@ namespace IfcParse {
|
|||||||
IfcWrite::IfcWritableEntity* isWritable();
|
IfcWrite::IfcWritableEntity* isWritable();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename Fn1, typename Fn2>
|
||||||
|
class InstanceStreamer {
|
||||||
|
private:
|
||||||
|
IfcFile* file_;
|
||||||
|
IfcSpfStream& stream_;
|
||||||
|
IfcSpfLexer& lexer_;
|
||||||
|
Fn1& fn1_;
|
||||||
|
Fn2& fn2_;
|
||||||
|
|
||||||
|
unsigned int current_inst_name_,
|
||||||
|
last_inst_name_,
|
||||||
|
num_insts_encountered_,
|
||||||
|
max_inst_name_encountered_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
InstanceStreamer(IfcFile* file, IfcSpfStream& stream, IfcSpfLexer& lexer, Fn1& fn1, Fn2& fn2)
|
||||||
|
: file_(file)
|
||||||
|
, stream_(stream)
|
||||||
|
, lexer_(lexer)
|
||||||
|
, fn1_(fn1)
|
||||||
|
, fn2_(fn2)
|
||||||
|
, current_inst_name_(0)
|
||||||
|
, last_inst_name_(0)
|
||||||
|
, num_insts_encountered_(0)
|
||||||
|
, max_inst_name_encountered_(0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
unsigned int current_inst_name() { return current_inst_name_; }
|
||||||
|
unsigned int last_inst_name() { return last_inst_name_; }
|
||||||
|
unsigned int num_insts_encountered() { return num_insts_encountered_; }
|
||||||
|
unsigned int max_inst_name_encountered() { return max_inst_name_encountered_; }
|
||||||
|
|
||||||
|
void stream() {
|
||||||
|
Logger::Status("Scanning file...");
|
||||||
|
|
||||||
|
Token token = TokenPtr();
|
||||||
|
Token previous = TokenPtr();
|
||||||
|
|
||||||
|
Entity* inst_data;
|
||||||
|
IfcUtil::IfcBaseClass* entity_instance = 0;
|
||||||
|
while (!stream_.eof) {
|
||||||
|
if (current_inst_name_ != 0) {
|
||||||
|
try {
|
||||||
|
inst_data = new Entity(current_inst_name_, file_);
|
||||||
|
if (file_->create_latebound_entities()) {
|
||||||
|
entity_instance = new IfcLateBoundEntity(inst_data);
|
||||||
|
} else {
|
||||||
|
entity_instance = IfcSchema::SchemaEntity(inst_data);
|
||||||
|
}
|
||||||
|
} catch (const IfcException& ex) {
|
||||||
|
current_inst_name_ = 0;
|
||||||
|
Logger::Message(Logger::LOG_ERROR, ex.what());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the status after every 1000 instances parsed
|
||||||
|
if (((++num_insts_encountered_) % 1000) == 0) {
|
||||||
|
std::stringstream ss; ss << "\r#" << current_inst_name_;
|
||||||
|
Logger::Status(ss.str(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn1_(entity_instance);
|
||||||
|
|
||||||
|
max_inst_name_encountered_ = (std::max)(max_inst_name_encountered_, current_inst_name_);
|
||||||
|
|
||||||
|
current_inst_name_ = 0;
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
token = lexer_.Next();
|
||||||
|
} catch (...) {
|
||||||
|
token = TokenPtr();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(token.second || token.first)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((previous.second || previous.first) && TokenFunc::isIdentifier(previous)) {
|
||||||
|
int id = TokenFunc::asInt(previous);
|
||||||
|
if (TokenFunc::isOperator(token, '=')) {
|
||||||
|
current_inst_name_ = id;
|
||||||
|
} else if (entity_instance) {
|
||||||
|
fn2_(entity_instance, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
previous = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger::Status("\rDone scanning file ");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream& operator<< (std::ostream& os, const IfcParse::IfcFile& f);
|
std::ostream& operator<< (std::ostream& os, const IfcParse::IfcFile& f);
|
||||||
|
|||||||
@@ -201,13 +201,53 @@ namespace IfcParse {
|
|||||||
bool optional() const { return optional_; }
|
bool optional() const { return optional_; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class inverse_attribute {
|
||||||
|
public:
|
||||||
|
typedef enum { bag_type, set_type, unspecified_type } aggregate_type;
|
||||||
|
protected:
|
||||||
|
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:
|
||||||
|
inverse_attribute(const std::string& name, aggregate_type type_of_aggregation, int bound1, int bound2, const entity* entity_reference, const attribute* attribute_reference)
|
||||||
|
: name_(name)
|
||||||
|
, type_of_aggregation_(type_of_aggregation)
|
||||||
|
, bound1_(bound1)
|
||||||
|
, bound2_(bound2)
|
||||||
|
, entity_reference_(entity_reference)
|
||||||
|
, attribute_reference_(attribute_reference)
|
||||||
|
{}
|
||||||
|
|
||||||
|
const std::string& name() const { return name_; }
|
||||||
|
aggregate_type type_of_aggregation() const { type_of_aggregation_; }
|
||||||
|
int bound1() const { return bound1_; }
|
||||||
|
int bound2() const { return bound2_; }
|
||||||
|
const entity* entity_reference() const { return entity_reference_; }
|
||||||
|
const attribute* attribute_reference() const { return attribute_reference_; }
|
||||||
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const entity* supertype_; /* NB: IFC explicitly allows only single inheritance */
|
const entity* supertype_; /* NB: IFC explicitly allows only single inheritance */
|
||||||
std::vector<const entity*> subtypes_;
|
std::vector<const entity*> subtypes_;
|
||||||
|
|
||||||
std::vector<const attribute*> attributes_;
|
std::vector<const attribute*> attributes_;
|
||||||
std::vector<bool> derived_;
|
std::vector<bool> derived_;
|
||||||
|
|
||||||
|
std::vector<const inverse_attribute*> inverse_attributes_;
|
||||||
|
|
||||||
|
class attribute_by_name_cmp : public std::unary_function<const attribute*, bool> {
|
||||||
|
private:
|
||||||
|
std::string name_;
|
||||||
|
public:
|
||||||
|
attribute_by_name_cmp(const std::string name)
|
||||||
|
: name_(name) {}
|
||||||
|
bool operator()(const attribute* attr) {
|
||||||
|
return attr->name() == name_;
|
||||||
|
}
|
||||||
|
};
|
||||||
public:
|
public:
|
||||||
entity(const std::string& name, entity* supertype)
|
entity(const std::string& name, entity* supertype)
|
||||||
: declaration(name)
|
: declaration(name)
|
||||||
@@ -237,6 +277,10 @@ namespace IfcParse {
|
|||||||
derived_ = derived;
|
derived_ = derived;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_inverse_attributes(const std::vector<const inverse_attribute*>& inverse_attributes) {
|
||||||
|
inverse_attributes_ = inverse_attributes;
|
||||||
|
}
|
||||||
|
|
||||||
const std::vector<const entity*>& subtypes() const { return subtypes_; }
|
const std::vector<const entity*>& subtypes() const { return subtypes_; }
|
||||||
const std::vector<const attribute*>& attributes() const { return attributes_; }
|
const std::vector<const attribute*>& attributes() const { return attributes_; }
|
||||||
const std::vector<bool>& derived() const { return derived_; }
|
const std::vector<bool>& derived() const { return derived_; }
|
||||||
@@ -244,17 +288,59 @@ namespace IfcParse {
|
|||||||
const std::vector<const attribute*> all_attributes() const {
|
const std::vector<const attribute*> all_attributes() const {
|
||||||
std::vector<const attribute*> attrs;
|
std::vector<const attribute*> attrs;
|
||||||
attrs.reserve(derived_.size());
|
attrs.reserve(derived_.size());
|
||||||
// std::vector<const attribute*>::iterator it = attrs.begin();
|
|
||||||
if (supertype_) {
|
if (supertype_) {
|
||||||
const std::vector<const attribute*> supertype_attrs = supertype_->all_attributes();
|
const std::vector<const attribute*> supertype_attrs = supertype_->all_attributes();
|
||||||
// it = std::copy(supertype_attrs.begin(), supertype_attrs.end(), it);
|
|
||||||
std::copy(supertype_attrs.begin(), supertype_attrs.end(), std::back_inserter(attrs));
|
std::copy(supertype_attrs.begin(), supertype_attrs.end(), std::back_inserter(attrs));
|
||||||
}
|
}
|
||||||
// std::copy(attributes_.begin(), attributes_.end(), it);
|
|
||||||
std::copy(attributes_.begin(), attributes_.end(), std::back_inserter(attrs));
|
std::copy(attributes_.begin(), attributes_.end(), std::back_inserter(attrs));
|
||||||
return attrs;
|
return attrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::vector<const inverse_attribute*> all_inverse_attributes() const {
|
||||||
|
std::vector<const inverse_attribute*> attrs;
|
||||||
|
if (supertype_) {
|
||||||
|
const std::vector<const inverse_attribute*> supertype_inv_attrs = supertype_->all_inverse_attributes();
|
||||||
|
std::copy(supertype_inv_attrs.begin(), supertype_inv_attrs.end(), std::back_inserter(attrs));
|
||||||
|
}
|
||||||
|
std::copy(inverse_attributes_.begin(), inverse_attributes_.end(), std::back_inserter(attrs));
|
||||||
|
return attrs;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptrdiff_t attribute_index(const attribute* attr) const {
|
||||||
|
const entity* current = this;
|
||||||
|
ptrdiff_t index = -1;
|
||||||
|
do {
|
||||||
|
if (index > -1) {
|
||||||
|
index += current->attributes().size();
|
||||||
|
} else {
|
||||||
|
auto it = std::find(current->attributes().begin(), current->attributes().end(), attr);
|
||||||
|
if (it != current->attributes().end()) {
|
||||||
|
index = std::distance(current->attributes().begin(), it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (current = current->supertype_);
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptrdiff_t attribute_index(const std::string& attr_name) const {
|
||||||
|
const entity* current = this;
|
||||||
|
ptrdiff_t index = -1;
|
||||||
|
attribute_by_name_cmp cmp(attr_name);
|
||||||
|
do {
|
||||||
|
if (index > -1) {
|
||||||
|
index += current->attributes().size();
|
||||||
|
} else {
|
||||||
|
auto it = std::find_if(current->attributes().begin(), current->attributes().end(), cmp);
|
||||||
|
if (it != current->attributes().end()) {
|
||||||
|
index = std::distance(current->attributes().begin(), it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (current = current->supertype_);
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
const entity* supertype() const { return supertype_; }
|
||||||
|
|
||||||
virtual const entity* as_entity() const { return this; }
|
virtual const entity* as_entity() const { return this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user