More serialization options for HDF5

This commit is contained in:
aothms
2015-11-30 22:34:48 +01:00
parent ac8cf298fa
commit 83c4b6a642
13 changed files with 11012 additions and 13944 deletions
+369 -5
View File
@@ -1009,11 +1009,9 @@ enumeration_type* IfcWindowPanelPositionEnum_type = 0;
enumeration_type* IfcWindowStyleConstructionEnum_type = 0;
enumeration_type* IfcWindowStyleOperationEnum_type = 0;
enumeration_type* IfcWorkControlTypeEnum_type = 0;
#ifdef _MSC_VER
# pragma optimize( "", off )
#pragma optimize("", off)
#endif
schema_definition* populate_schema() {
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));
@@ -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);
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);
declarations.push_back(IfcAbsorbedDoseMeasure_type);
@@ -10380,9 +10745,8 @@ schema_definition* populate_schema() {
}
#ifdef _MSC_VER
# pragma optimize( "", on )
#pragma optimize("", on)
#endif
const schema_definition& get_schema() {
static const schema_definition* s = populate_schema();
+9140 -7857
View File
File diff suppressed because it is too large Load Diff
+977 -5948
View File
File diff suppressed because it is too large Load Diff
+2 -3
View File
@@ -23,6 +23,7 @@
#include <map>
#include <set>
#include "../ifcparse/Hdf5Settings.h"
#include "../ifcparse/IfcParse.h"
#include "../ifcparse/IfcSpfHeader.h"
@@ -36,7 +37,6 @@ public:
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<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;
private:
typedef std::map<IfcUtil::IfcBaseClass*, IfcUtil::IfcBaseClass*> entity_entity_map_t;
@@ -49,7 +49,6 @@ private:
entities_by_type_t bytype;
entities_by_ref_t byref;
entity_by_guid_t byguid;
offset_by_id_t offsets;
entity_entity_map_t entity_file_map;
@@ -136,7 +135,7 @@ public:
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
View File
@@ -6,14 +6,37 @@
#pragma message("warning: HDF5 compression support is recommended")
#endif
static bool OVERRIDE = true;
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* h5_dt;
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()) {
if (pt->as_named_type()->declared_type()->as_entity()) {
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) {
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;
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("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));
}
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);
}
@@ -152,10 +189,13 @@ void IfcParse::IfcHdf5File::init_default_types() {
default_cpp_type_names[IfcUtil::Argument_STRING] = "string";
default_cpp_type_names[IfcUtil::Argument_INT] = "integer";
if (OVERRIDE) {
hsize_t dims = 3;
if (settings_.fix_global_id()) {
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["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) {
if (settings_.instantiate_select()) return 0;
std::set<const IfcParse::declaration*> leafs;
visit_select(pt, leafs);
@@ -361,8 +403,11 @@ void IfcParse::IfcHdf5File::write_aggregate(void*& ptr, const IfcEntityList::ptr
void* aggr_ptr = aggr_data;
for (IfcEntityList::it it = ts->begin(); it != ts->end(); ++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(1).getSize(), ref.second);
// 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);
// 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);
}
@@ -436,8 +481,10 @@ void IfcParse::IfcHdf5File::write_select(void*& ptr, IfcUtil::IfcBaseClass* inst
size_t offset = datatype->getMemberOffset(member_index);
auto ref = make_instance_reference(instance);
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(1).getSize(), ref.second);
// 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, 2, ref.first);
write_number_of_size(ptr_member, 4, ref.second);
} else {
Argument& wrapped_data = *instance->data().getArgument(0);
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";
member_index = datatype->getMemberIndex(member_name);
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;
switch(wrapped_data.type()) {
case IfcUtil::Argument_BOOL: {
@@ -489,16 +538,50 @@ void IfcParse::IfcHdf5File::write_select(void*& ptr, IfcUtil::IfcBaseClass* inst
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;
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) {
IfcSchema::Type::Enum ty = it->second->declaration().type();
tys.insert(ty);
// This already is sorted on entity instance name
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());
@@ -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) {
// 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;
size_t datatype_size = declared_types[*it]->getSize();
hsize_t dims = es.size();
// don't chunk too small
// 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;
// H5O_MESG_MAX_SIZE = 65536
const bool compact = es.size() * declared_types[*it]->getSize() < (1 << 15);
if (compress && !compact) {
const bool compact = es.size() * datatype_size < (1 << 15);
if (settings_.compress() && !compact) {
H5::DSetCreatPropList* plist_ = new H5::DSetCreatPropList;
plist_->setChunk(1, &chunk);
// 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;
}
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;
const H5::CompType* dt = (H5::CompType*) declared_types[*it];
int ind = 0;
for (auto jt = es.begin(); jt != es.end(); ++jt, ++ind) {
void* start = ptr;
int member_idx = 0;
H5::DataType member_type;
IfcAbstractEntity& dat = (*jt)->data();
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::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();
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();
// skip for now write later
advance(ptr, set_unset_size);
member_type.close();
member_type = dt->getMemberDataType(member_idx++);
write_number_of_size(ptr, member_type.getSize(), static_cast<unsigned int>(dat.id()));
for (unsigned i = 0; i < dat.getArgumentCount(); ++i, ++is_derived) {
member_type.close();
// ----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) {
continue;
}
@@ -569,6 +701,7 @@ void IfcParse::IfcHdf5File::write_population(const IfcFile& f, bool compress) {
const IfcParse::entity::attribute* schema_attr = attributes[i];
const std::string& attribute_name = schema_attr->name();
Argument& attr_value = *dat.getArgument(i);
member_type = dt->getMemberDataType(member_idx++);
if (attr_value.isNull()) {
@@ -581,11 +714,11 @@ void IfcParse::IfcHdf5File::write_population(const IfcFile& f, bool compress) {
}
} else {
set_unset_mask |= 1 << i;
if (OVERRIDE && attribute_name == "GlobalId") {
if (settings_.fix_global_id() && attribute_name == "GlobalId") {
std::string s = attr_value;
memcpy(static_cast<char*>(ptr), s.c_str(), s.size());
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;
for (auto it = ds.begin(); it != ds.end(); ++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) {
IfcUtil::IfcBaseClass* v = attr_value;
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(1).getSize(), ref.second);
// 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, 2, ref.first);
write_number_of_size(ptr, 4, ref.second);
} else if (member_type == *default_types[simple_type::real_type]) {
double d = attr_value;
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 = buffer_ptr = new uint8_t[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) {
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));
}
}
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);
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]);
ds.close();
/* for (size_t i = 0; i < dataset_size; ++i) {
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) {
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();
}
}
}
+7 -4
View File
@@ -22,11 +22,12 @@
#include "H5Cpp.h"
#include "../ifcparse/Hdf5Settings.h"
#include "../ifcparse/IfcUtil.h"
#include "../ifcparse/IfcFile.h"
namespace IfcParse {
class IfcHdf5File {
private:
class allocator_t {
@@ -50,6 +51,7 @@ namespace IfcParse {
};
allocator_t allocator;
Hdf5Settings settings_;
std::string name_;
schema_definition schema_;
@@ -84,7 +86,7 @@ namespace IfcParse {
void write_select(void*& ptr, IfcUtil::IfcBaseClass* instance, const H5::CompType* datatype) const;
void write_schema(const schema_definition& schema);
void write_population(const IfcFile& f, bool compress);
void write_population(IfcFile& f);
template <typename T>
const H5::DataType* get_datatype() const {
@@ -109,12 +111,13 @@ namespace IfcParse {
public:
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)
, schema_(*f->schema())
, settings_(settings)
{
write_schema(*f->schema());
write_population(*f, compress);
write_population(*f);
};
};
+75 -88
View File
@@ -920,6 +920,73 @@ bool IfcFile::Init(void* data, int 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) {
// Initialize a "C" locale for locale-independent
// 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 + "'");
}
Token token = TokenPtr();
Token previous = TokenPtr();
unsigned int currentId = 0;
lastId = 0;
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 ");
RegisterInstancesToFile populate(byid, byguid, bytype, byref);
populate.populate_guid_mapping() = false;
InstanceStreamer<RegisterInstancesToFile, RegisterInstancesToFile> streamer(this, *stream, *tokens, populate, populate);
streamer.stream();
MaxId = streamer.max_inst_name_encountered();
return true;
}
@@ -1543,6 +1530,6 @@ std::pair<IfcSchema::IfcNamedUnit*, double> IfcFile::getUnit(IfcSchema::IfcUnitE
return return_value;
}
void IfcFile::write_hdf5(const std::string& name, bool compress) const {
IfcHdf5File(this, name, compress);
void IfcFile::write_hdf5(const std::string& name, const Hdf5Settings& settings) {
IfcHdf5File(this, name, settings);
}
+94
View File
@@ -263,6 +263,100 @@ namespace IfcParse {
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);
+90 -4
View File
@@ -201,13 +201,53 @@ namespace IfcParse {
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:
const entity* supertype_; /* NB: IFC explicitly allows only single inheritance */
std::vector<const entity*> subtypes_;
std::vector<const attribute*> attributes_;
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:
entity(const std::string& name, entity* supertype)
: declaration(name)
@@ -237,6 +277,10 @@ namespace IfcParse {
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 attribute*>& attributes() const { return attributes_; }
const std::vector<bool>& derived() const { return derived_; }
@@ -244,17 +288,59 @@ namespace IfcParse {
const std::vector<const attribute*> all_attributes() const {
std::vector<const attribute*> attrs;
attrs.reserve(derived_.size());
// std::vector<const attribute*>::iterator it = attrs.begin();
if (supertype_) {
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(attributes_.begin(), attributes_.end(), it);
std::copy(attributes_.begin(), attributes_.end(), std::back_inserter(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; }
};