Add function to retrieve inverse attributes from Python

This commit is contained in:
Thomas Krijnen
2014-06-03 16:33:38 +02:00
parent 69a27e3591
commit fe172672e9
9 changed files with 335 additions and 1 deletions
+14 -1
View File
@@ -26,6 +26,7 @@ class RuntimeTypingImplementation:
entity_descriptors = []
enumeration_descriptors = []
derived_field_statements = []
inverse_implementations = []
for name, type in mapping.schema.simpletypes.items():
entity_descriptors.append(templates.entity_descriptor % {
@@ -83,13 +84,25 @@ class RuntimeTypingImplementation:
'type' : name,
'statements' : statements
})
for name, type in mapping.schema.entities.items():
if type.inverse:
for attr in type.inverse.elements:
print (attr)
inverse_implementations.append(templates.inverse_implementation % {
'type' : name,
'name' : attr.name,
'related_type' : attr.entity,
'index' : [i for i, a in enumerate(mapping.schema.entities[attr.entity].attributes) if a.name == attr.attribute][0]
})
self.str = templates.rt_implementation % {
'schema_name_upper' : mapping.schema.name.upper(),
'schema_name' : mapping.schema.name.capitalize(),
'entity_descriptors' : '\n'.join(entity_descriptors),
'enumeration_descriptors' : '\n'.join(enumeration_descriptors),
'derived_field_statements' : '\n'.join(derived_field_statements)
'derived_field_statements' : '\n'.join(derived_field_statements),
'inverse_implementations' : '\n'.join(inverse_implementations)
}
self.schema_name = mapping.schema.name.capitalize()
+20
View File
@@ -89,6 +89,7 @@ namespace Type {
const std::string& GetAttributeName(Enum t, unsigned char a);
bool GetAttributeOptional(Enum t, unsigned char a);
std::pair<const char*, int> GetEnumerationIndex(Enum t, const std::string& a);
std::pair<Enum, unsigned> GetInverseAttribute(Enum t, const std::string& a);
Enum GetAttributeEnumerationClass(Enum t, unsigned char a);
void PopulateDerivedFields(IfcWrite::IfcWritableEntity* e);
}}
@@ -181,6 +182,7 @@ using namespace IfcUtil;
std::map<Type::Enum,IfcEntityDescriptor*> entity_descriptor_map;
std::map<Type::Enum,IfcEnumerationDescriptor*> enumeration_descriptor_map;
std::map<std::pair<Type::Enum, std::string>, std::pair<Type::Enum, int> > inverse_map;
void InitDescriptorMap() {
IfcEntityDescriptor* current;
%(entity_descriptors)s
@@ -190,6 +192,10 @@ void InitDescriptorMap() {
%(enumeration_descriptors)s
}
void InitInverseMap() {
%(inverse_implementations)s
}
int Type::GetAttributeIndex(Enum t, const std::string& a) {
if (entity_descriptor_map.empty()) ::InitDescriptorMap();
std::map<Type::Enum,IfcEntityDescriptor*>::const_iterator i = entity_descriptor_map.find(t);
@@ -232,6 +238,18 @@ std::pair<const char*, int> Type::GetEnumerationIndex(Enum t, const std::string&
else return i->second->getIndex(a);
}
std::pair<Type::Enum, unsigned> Type::GetInverseAttribute(Enum t, const std::string& a) {
if (inverse_map.empty()) ::InitInverseMap();
std::map<std::pair<Type::Enum, std::string>, std::pair<Type::Enum, int> >::const_iterator it;
std::pair<Type::Enum, std::string> key = std::make_pair(t, a);
while (true) {
it = inverse_map.find(key);
if (it != inverse_map.end()) return it->second;
if ((key.first = Parent(key.first)) == -1) break;
}
throw IfcException("Attribute not found");
}
Type::Enum Type::GetAttributeEnumerationClass(Enum t, unsigned char a) {
if (entity_descriptor_map.empty()) ::InitDescriptorMap();
std::map<Type::Enum,IfcEntityDescriptor*>::const_iterator i = entity_descriptor_map.find(t);
@@ -357,6 +375,8 @@ constructor_stmt_array = " e->setArgument(%(index)d,(%(name)s)->generalize());"
constructor_stmt_optional = " if (%(name)s) {%(stmt)s } else { e->setArgument(%(index)d); }"
constructor_stmt_derived = " e->setArgumentDerived(%(index)d);"
inverse_implementation = " inverse_map.insert(std::make_pair(std::make_pair(Type::%(type)s, \"%(name)s\"), std::make_pair(Type::%(related_type)s, %(index)d)));"
def multi_line_comment(li):
return ("/// %s"%("\n/// ".join(li))) if len(li) else ""
+131
View File
@@ -41,6 +41,7 @@ using namespace IfcUtil;
std::map<Type::Enum,IfcEntityDescriptor*> entity_descriptor_map;
std::map<Type::Enum,IfcEnumerationDescriptor*> enumeration_descriptor_map;
std::map<std::pair<Type::Enum, std::string>, std::pair<Type::Enum, int> > inverse_map;
void InitDescriptorMap() {
IfcEntityDescriptor* current;
current = entity_descriptor_map[Type::IfcAbsorbedDoseMeasure] = new IfcEntityDescriptor(Type::IfcAbsorbedDoseMeasure,0);
@@ -4047,6 +4048,124 @@ void InitDescriptorMap() {
current_enum = enumeration_descriptor_map[Type::IfcWorkControlTypeEnum] = new IfcEnumerationDescriptor(Type::IfcWorkControlTypeEnum, values);
}
void InitInverseMap() {
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcActor, "IsActingUpon"), std::make_pair(Type::IfcRelAssignsToActor, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcAddress, "OfPerson"), std::make_pair(Type::IfcPerson, 7)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcAddress, "OfOrganization"), std::make_pair(Type::IfcOrganization, 4)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcAnnotation, "ContainedInStructure"), std::make_pair(Type::IfcRelContainedInSpatialStructure, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcAppliedValue, "ValuesReferenced"), std::make_pair(Type::IfcReferencesValueDocument, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcAppliedValue, "ValueOfComponents"), std::make_pair(Type::IfcAppliedValueRelationship, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcAppliedValue, "IsComponentIn"), std::make_pair(Type::IfcAppliedValueRelationship, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcApproval, "Actors"), std::make_pair(Type::IfcApprovalActorRelationship, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcApproval, "IsRelatedWith"), std::make_pair(Type::IfcApprovalRelationship, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcApproval, "Relates"), std::make_pair(Type::IfcApprovalRelationship, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcClassification, "Contains"), std::make_pair(Type::IfcClassificationItem, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcClassificationItem, "IsClassifiedItemIn"), std::make_pair(Type::IfcClassificationItemRelationship, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcClassificationItem, "IsClassifyingItemIn"), std::make_pair(Type::IfcClassificationItemRelationship, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcCompositeCurveSegment, "UsingCurves"), std::make_pair(Type::IfcCompositeCurve, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcConstraint, "ClassifiedAs"), std::make_pair(Type::IfcConstraintClassificationRelationship, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcConstraint, "RelatesConstraints"), std::make_pair(Type::IfcConstraintRelationship, 2)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcConstraint, "IsRelatedWith"), std::make_pair(Type::IfcConstraintRelationship, 3)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcConstraint, "PropertiesForConstraint"), std::make_pair(Type::IfcPropertyConstraintRelationship, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcConstraint, "Aggregates"), std::make_pair(Type::IfcConstraintAggregationRelationship, 2)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcConstraint, "IsAggregatedIn"), std::make_pair(Type::IfcConstraintAggregationRelationship, 3)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcControl, "Controls"), std::make_pair(Type::IfcRelAssignsToControl, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcCovering, "CoversSpaces"), std::make_pair(Type::IfcRelCoversSpaces, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcCovering, "Covers"), std::make_pair(Type::IfcRelCoversBldgElements, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcDimensionCurve, "AnnotatedBySymbols"), std::make_pair(Type::IfcTerminatorSymbol, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcDistributionControlElement, "AssignedToFlowElement"), std::make_pair(Type::IfcRelFlowControlElements, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcDistributionFlowElement, "HasControlElements"), std::make_pair(Type::IfcRelFlowControlElements, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcDocumentInformation, "IsPointedTo"), std::make_pair(Type::IfcDocumentInformationRelationship, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcDocumentInformation, "IsPointer"), std::make_pair(Type::IfcDocumentInformationRelationship, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcDocumentReference, "ReferenceToDocument"), std::make_pair(Type::IfcDocumentInformation, 3)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcDraughtingCallout, "IsRelatedFromCallout"), std::make_pair(Type::IfcDraughtingCalloutRelationship, 3)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcDraughtingCallout, "IsRelatedToCallout"), std::make_pair(Type::IfcDraughtingCalloutRelationship, 2)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcElement, "HasStructuralMember"), std::make_pair(Type::IfcRelConnectsStructuralElement, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcElement, "FillsVoids"), std::make_pair(Type::IfcRelFillsElement, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcElement, "ConnectedTo"), std::make_pair(Type::IfcRelConnectsElements, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcElement, "HasCoverings"), std::make_pair(Type::IfcRelCoversBldgElements, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcElement, "HasProjections"), std::make_pair(Type::IfcRelProjectsElement, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcElement, "ReferencedInStructures"), std::make_pair(Type::IfcRelReferencedInSpatialStructure, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcElement, "HasPorts"), std::make_pair(Type::IfcRelConnectsPortToElement, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcElement, "HasOpenings"), std::make_pair(Type::IfcRelVoidsElement, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcElement, "IsConnectionRealization"), std::make_pair(Type::IfcRelConnectsWithRealizingElements, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcElement, "ProvidesBoundaries"), std::make_pair(Type::IfcRelSpaceBoundary, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcElement, "ConnectedFrom"), std::make_pair(Type::IfcRelConnectsElements, 2)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcElement, "ContainedInStructure"), std::make_pair(Type::IfcRelContainedInSpatialStructure, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcFeatureElementAddition, "ProjectsElements"), std::make_pair(Type::IfcRelProjectsElement, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcFeatureElementSubtraction, "VoidsElements"), std::make_pair(Type::IfcRelVoidsElement, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcGeometricRepresentationContext, "HasSubContexts"), std::make_pair(Type::IfcGeometricRepresentationSubContext, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcGrid, "ContainedInStructure"), std::make_pair(Type::IfcRelContainedInSpatialStructure, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcGridAxis, "PartOfW"), std::make_pair(Type::IfcGrid, 2)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcGridAxis, "PartOfV"), std::make_pair(Type::IfcGrid, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcGridAxis, "PartOfU"), std::make_pair(Type::IfcGrid, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcGridAxis, "HasIntersections"), std::make_pair(Type::IfcVirtualGridIntersection, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcGroup, "IsGroupedBy"), std::make_pair(Type::IfcRelAssignsToGroup, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcLibraryReference, "ReferenceIntoLibrary"), std::make_pair(Type::IfcLibraryInformation, 4)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcMaterial, "HasRepresentation"), std::make_pair(Type::IfcMaterialDefinitionRepresentation, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcMaterial, "ClassifiedAs"), std::make_pair(Type::IfcMaterialClassificationRelationship, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcMaterialLayer, "ToMaterialLayerSet"), std::make_pair(Type::IfcMaterialLayerSet, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcObject, "IsDefinedBy"), std::make_pair(Type::IfcRelDefines, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcObjectDefinition, "HasAssignments"), std::make_pair(Type::IfcRelAssigns, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcObjectDefinition, "IsDecomposedBy"), std::make_pair(Type::IfcRelDecomposes, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcObjectDefinition, "Decomposes"), std::make_pair(Type::IfcRelDecomposes, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcObjectDefinition, "HasAssociations"), std::make_pair(Type::IfcRelAssociates, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcObjectPlacement, "PlacesObject"), std::make_pair(Type::IfcProduct, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcObjectPlacement, "ReferencedByPlacements"), std::make_pair(Type::IfcLocalPlacement, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcOpeningElement, "HasFillings"), std::make_pair(Type::IfcRelFillsElement, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcOrganization, "IsRelatedBy"), std::make_pair(Type::IfcOrganizationRelationship, 3)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcOrganization, "Relates"), std::make_pair(Type::IfcOrganizationRelationship, 2)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcOrganization, "Engages"), std::make_pair(Type::IfcPersonAndOrganization, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcPerson, "EngagedIn"), std::make_pair(Type::IfcPersonAndOrganization, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcPhysicalQuantity, "PartOfComplex"), std::make_pair(Type::IfcPhysicalComplexQuantity, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcPort, "ContainedIn"), std::make_pair(Type::IfcRelConnectsPortToElement, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcPort, "ConnectedFrom"), std::make_pair(Type::IfcRelConnectsPorts, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcPort, "ConnectedTo"), std::make_pair(Type::IfcRelConnectsPorts, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcProcess, "OperatesOn"), std::make_pair(Type::IfcRelAssignsToProcess, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcProcess, "IsSuccessorFrom"), std::make_pair(Type::IfcRelSequence, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcProcess, "IsPredecessorTo"), std::make_pair(Type::IfcRelSequence, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcProduct, "ReferencedBy"), std::make_pair(Type::IfcRelAssignsToProduct, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcProductDefinitionShape, "ShapeOfProduct"), std::make_pair(Type::IfcProduct, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcProductDefinitionShape, "HasShapeAspects"), std::make_pair(Type::IfcShapeAspect, 4)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcProperty, "PropertyForDependance"), std::make_pair(Type::IfcPropertyDependencyRelationship, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcProperty, "PropertyDependsOn"), std::make_pair(Type::IfcPropertyDependencyRelationship, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcProperty, "PartOfComplex"), std::make_pair(Type::IfcComplexProperty, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcPropertyDefinition, "HasAssociations"), std::make_pair(Type::IfcRelAssociates, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcPropertySetDefinition, "PropertyDefinitionOf"), std::make_pair(Type::IfcRelDefinesByProperties, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcPropertySetDefinition, "DefinesType"), std::make_pair(Type::IfcTypeObject, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcRepresentation, "RepresentationMap"), std::make_pair(Type::IfcRepresentationMap, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcRepresentation, "LayerAssignments"), std::make_pair(Type::IfcPresentationLayerAssignment, 2)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcRepresentation, "OfProductRepresentation"), std::make_pair(Type::IfcProductRepresentation, 2)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcRepresentationContext, "RepresentationsInContext"), std::make_pair(Type::IfcRepresentation, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcRepresentationItem, "LayerAssignments"), std::make_pair(Type::IfcPresentationLayerAssignment, 2)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcRepresentationItem, "StyledByItem"), std::make_pair(Type::IfcStyledItem, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcRepresentationMap, "MapUsage"), std::make_pair(Type::IfcMappedItem, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcResource, "ResourceOf"), std::make_pair(Type::IfcRelAssignsToResource, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcScheduleTimeControl, "ScheduleTimeControlAssigned"), std::make_pair(Type::IfcRelAssignsTasks, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcShapeModel, "OfShapeAspect"), std::make_pair(Type::IfcShapeAspect, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcSpace, "HasCoverings"), std::make_pair(Type::IfcRelCoversSpaces, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcSpace, "BoundedBy"), std::make_pair(Type::IfcRelSpaceBoundary, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcSpaceProgram, "HasInteractionReqsFrom"), std::make_pair(Type::IfcRelInteractionRequirements, 3)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcSpaceProgram, "HasInteractionReqsTo"), std::make_pair(Type::IfcRelInteractionRequirements, 4)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcSpatialStructureElement, "ReferencesElements"), std::make_pair(Type::IfcRelReferencedInSpatialStructure, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcSpatialStructureElement, "ServicedBySystems"), std::make_pair(Type::IfcRelServicesBuildings, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcSpatialStructureElement, "ContainsElements"), std::make_pair(Type::IfcRelContainedInSpatialStructure, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcStructuralActivity, "AssignedToStructuralItem"), std::make_pair(Type::IfcRelConnectsStructuralActivity, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcStructuralConnection, "ConnectsStructuralMembers"), std::make_pair(Type::IfcRelConnectsStructuralMember, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcStructuralItem, "AssignedStructuralActivity"), std::make_pair(Type::IfcRelConnectsStructuralActivity, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcStructuralLoadGroup, "SourceOfResultGroup"), std::make_pair(Type::IfcStructuralResultGroup, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcStructuralLoadGroup, "LoadGroupFor"), std::make_pair(Type::IfcStructuralAnalysisModel, 2)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcStructuralMember, "ReferencesElement"), std::make_pair(Type::IfcRelConnectsStructuralElement, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcStructuralMember, "ConnectedBy"), std::make_pair(Type::IfcRelConnectsStructuralMember, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcStructuralReaction, "Causes"), std::make_pair(Type::IfcStructuralAction, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcStructuralResultGroup, "ResultGroupFor"), std::make_pair(Type::IfcStructuralAnalysisModel, 3)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcSystem, "ServicesBuildings"), std::make_pair(Type::IfcRelServicesBuildings, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcTableRow, "OfTable"), std::make_pair(Type::IfcTable, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcTextureCoordinate, "AnnotatedSurface"), std::make_pair(Type::IfcAnnotationSurface, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcTimeSeries, "DocumentedBy"), std::make_pair(Type::IfcTimeSeriesReferenceRelationship, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcTypeObject, "ObjectTypeOf"), std::make_pair(Type::IfcRelDefinesByType, 0)));
}
int Type::GetAttributeIndex(Enum t, const std::string& a) {
if (entity_descriptor_map.empty()) ::InitDescriptorMap();
std::map<Type::Enum,IfcEntityDescriptor*>::const_iterator i = entity_descriptor_map.find(t);
@@ -4089,6 +4208,18 @@ std::pair<const char*, int> Type::GetEnumerationIndex(Enum t, const std::string&
else return i->second->getIndex(a);
}
std::pair<Type::Enum, unsigned> Type::GetInverseAttribute(Enum t, const std::string& a) {
if (inverse_map.empty()) ::InitInverseMap();
std::map<std::pair<Type::Enum, std::string>, std::pair<Type::Enum, int> >::const_iterator it;
std::pair<Type::Enum, std::string> key = std::make_pair(t, a);
while (true) {
it = inverse_map.find(key);
if (it != inverse_map.end()) return it->second;
if ((key.first = Parent(key.first)) == -1) break;
}
throw IfcException("Attribute not found");
}
Type::Enum Type::GetAttributeEnumerationClass(Enum t, unsigned char a) {
if (entity_descriptor_map.empty()) ::InitDescriptorMap();
std::map<Type::Enum,IfcEntityDescriptor*>::const_iterator i = entity_descriptor_map.find(t);
+1
View File
@@ -41,6 +41,7 @@ namespace Type {
const std::string& GetAttributeName(Enum t, unsigned char a);
bool GetAttributeOptional(Enum t, unsigned char a);
std::pair<const char*, int> GetEnumerationIndex(Enum t, const std::string& a);
std::pair<Enum, unsigned> GetInverseAttribute(Enum t, const std::string& a);
Enum GetAttributeEnumerationClass(Enum t, unsigned char a);
void PopulateDerivedFields(IfcWrite::IfcWritableEntity* e);
}}
+160
View File
@@ -41,6 +41,7 @@ using namespace IfcUtil;
std::map<Type::Enum,IfcEntityDescriptor*> entity_descriptor_map;
std::map<Type::Enum,IfcEnumerationDescriptor*> enumeration_descriptor_map;
std::map<std::pair<Type::Enum, std::string>, std::pair<Type::Enum, int> > inverse_map;
void InitDescriptorMap() {
IfcEntityDescriptor* current;
current = entity_descriptor_map[Type::IfcAbsorbedDoseMeasure] = new IfcEntityDescriptor(Type::IfcAbsorbedDoseMeasure,0);
@@ -4701,6 +4702,158 @@ void InitDescriptorMap() {
current_enum = enumeration_descriptor_map[Type::IfcWorkScheduleTypeEnum] = new IfcEnumerationDescriptor(Type::IfcWorkScheduleTypeEnum, values);
}
void InitInverseMap() {
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcActor, "IsActingUpon"), std::make_pair(Type::IfcRelAssignsToActor, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcActorRole, "HasExternalReference"), std::make_pair(Type::IfcExternalReferenceRelationship, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcAddress, "OfPerson"), std::make_pair(Type::IfcPerson, 7)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcAddress, "OfOrganization"), std::make_pair(Type::IfcOrganization, 4)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcAnnotation, "ContainedInStructure"), std::make_pair(Type::IfcRelContainedInSpatialStructure, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcAppliedValue, "HasExternalReference"), std::make_pair(Type::IfcExternalReferenceRelationship, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcApproval, "HasExternalReferences"), std::make_pair(Type::IfcExternalReferenceRelationship, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcApproval, "ApprovedObjects"), std::make_pair(Type::IfcRelAssociatesApproval, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcApproval, "ApprovedResources"), std::make_pair(Type::IfcResourceApprovalRelationship, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcApproval, "IsRelatedWith"), std::make_pair(Type::IfcApprovalRelationship, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcApproval, "Relates"), std::make_pair(Type::IfcApprovalRelationship, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcBuildingElement, "HasCoverings"), std::make_pair(Type::IfcRelCoversBldgElements, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcClassification, "ClassificationForObjects"), std::make_pair(Type::IfcRelAssociatesClassification, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcClassification, "HasReferences"), std::make_pair(Type::IfcClassificationReference, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcClassificationReference, "ClassificationRefForObjects"), std::make_pair(Type::IfcRelAssociatesClassification, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcClassificationReference, "HasReferences"), std::make_pair(Type::IfcClassificationReference, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcCompositeCurveSegment, "UsingCurves"), std::make_pair(Type::IfcCompositeCurve, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcConstraint, "HasExternalReferences"), std::make_pair(Type::IfcExternalReferenceRelationship, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcConstraint, "PropertiesForConstraint"), std::make_pair(Type::IfcResourceConstraintRelationship, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcContext, "IsDefinedBy"), std::make_pair(Type::IfcRelDefinesByProperties, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcContext, "Declares"), std::make_pair(Type::IfcRelDeclares, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcContextDependentUnit, "HasExternalReference"), std::make_pair(Type::IfcExternalReferenceRelationship, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcControl, "Controls"), std::make_pair(Type::IfcRelAssignsToControl, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcConversionBasedUnit, "HasExternalReference"), std::make_pair(Type::IfcExternalReferenceRelationship, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcCovering, "CoversSpaces"), std::make_pair(Type::IfcRelCoversSpaces, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcCovering, "CoversElements"), std::make_pair(Type::IfcRelCoversBldgElements, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcDistributionControlElement, "AssignedToFlowElement"), std::make_pair(Type::IfcRelFlowControlElements, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcDistributionElement, "HasPorts"), std::make_pair(Type::IfcRelConnectsPortToElement, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcDistributionFlowElement, "HasControlElements"), std::make_pair(Type::IfcRelFlowControlElements, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcDocumentInformation, "DocumentInfoForObjects"), std::make_pair(Type::IfcRelAssociatesDocument, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcDocumentInformation, "HasDocumentReferences"), std::make_pair(Type::IfcDocumentReference, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcDocumentInformation, "IsPointedTo"), std::make_pair(Type::IfcDocumentInformationRelationship, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcDocumentInformation, "IsPointer"), std::make_pair(Type::IfcDocumentInformationRelationship, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcDocumentReference, "DocumentRefForObjects"), std::make_pair(Type::IfcRelAssociatesDocument, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcElement, "FillsVoids"), std::make_pair(Type::IfcRelFillsElement, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcElement, "ConnectedTo"), std::make_pair(Type::IfcRelConnectsElements, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcElement, "IsInterferedByElements"), std::make_pair(Type::IfcRelInterferesElements, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcElement, "InterferesElements"), std::make_pair(Type::IfcRelInterferesElements, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcElement, "HasProjections"), std::make_pair(Type::IfcRelProjectsElement, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcElement, "ReferencedInStructures"), std::make_pair(Type::IfcRelReferencedInSpatialStructure, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcElement, "HasOpenings"), std::make_pair(Type::IfcRelVoidsElement, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcElement, "IsConnectionRealization"), std::make_pair(Type::IfcRelConnectsWithRealizingElements, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcElement, "ProvidesBoundaries"), std::make_pair(Type::IfcRelSpaceBoundary, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcElement, "ConnectedFrom"), std::make_pair(Type::IfcRelConnectsElements, 2)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcElement, "ContainedInStructure"), std::make_pair(Type::IfcRelContainedInSpatialStructure, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcExternalReference, "ExternalReferenceForResources"), std::make_pair(Type::IfcExternalReferenceRelationship, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcExternalSpatialElement, "BoundedBy"), std::make_pair(Type::IfcRelSpaceBoundary, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcFace, "HasTextureMaps"), std::make_pair(Type::IfcTextureMap, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcFeatureElementAddition, "ProjectsElements"), std::make_pair(Type::IfcRelProjectsElement, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcFeatureElementSubtraction, "VoidsElements"), std::make_pair(Type::IfcRelVoidsElement, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcGeometricRepresentationContext, "HasSubContexts"), std::make_pair(Type::IfcGeometricRepresentationSubContext, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcGrid, "ContainedInStructure"), std::make_pair(Type::IfcRelContainedInSpatialStructure, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcGridAxis, "PartOfW"), std::make_pair(Type::IfcGrid, 2)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcGridAxis, "PartOfV"), std::make_pair(Type::IfcGrid, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcGridAxis, "PartOfU"), std::make_pair(Type::IfcGrid, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcGridAxis, "HasIntersections"), std::make_pair(Type::IfcVirtualGridIntersection, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcGroup, "IsGroupedBy"), std::make_pair(Type::IfcRelAssignsToGroup, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcLibraryInformation, "LibraryInfoForObjects"), std::make_pair(Type::IfcRelAssociatesLibrary, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcLibraryInformation, "HasLibraryReferences"), std::make_pair(Type::IfcLibraryReference, 2)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcLibraryReference, "LibraryRefForObjects"), std::make_pair(Type::IfcRelAssociatesLibrary, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcMaterial, "HasRepresentation"), std::make_pair(Type::IfcMaterialDefinitionRepresentation, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcMaterial, "IsRelatedWith"), std::make_pair(Type::IfcMaterialRelationship, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcMaterial, "RelatesTo"), std::make_pair(Type::IfcMaterialRelationship, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcMaterialConstituent, "ToMaterialConstituentSet"), std::make_pair(Type::IfcMaterialConstituentSet, 2)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcMaterialDefinition, "AssociatedTo"), std::make_pair(Type::IfcRelAssociatesMaterial, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcMaterialDefinition, "HasExternalReferences"), std::make_pair(Type::IfcExternalReferenceRelationship, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcMaterialDefinition, "HasProperties"), std::make_pair(Type::IfcMaterialProperties, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcMaterialLayer, "ToMaterialLayerSet"), std::make_pair(Type::IfcMaterialLayerSet, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcMaterialProfile, "ToMaterialProfileSet"), std::make_pair(Type::IfcMaterialProfileSet, 2)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcMaterialUsageDefinition, "AssociatedTo"), std::make_pair(Type::IfcRelAssociatesMaterial, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcObject, "IsDeclaredBy"), std::make_pair(Type::IfcRelDefinesByObject, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcObject, "Declares"), std::make_pair(Type::IfcRelDefinesByObject, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcObject, "IsTypedBy"), std::make_pair(Type::IfcRelDefinesByType, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcObject, "IsDefinedBy"), std::make_pair(Type::IfcRelDefinesByProperties, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcObjectDefinition, "HasAssignments"), std::make_pair(Type::IfcRelAssigns, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcObjectDefinition, "Nests"), std::make_pair(Type::IfcRelNests, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcObjectDefinition, "IsNestedBy"), std::make_pair(Type::IfcRelNests, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcObjectDefinition, "HasContext"), std::make_pair(Type::IfcRelDeclares, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcObjectDefinition, "IsDecomposedBy"), std::make_pair(Type::IfcRelAggregates, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcObjectDefinition, "Decomposes"), std::make_pair(Type::IfcRelAggregates, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcObjectDefinition, "HasAssociations"), std::make_pair(Type::IfcRelAssociates, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcObjectPlacement, "PlacesObject"), std::make_pair(Type::IfcProduct, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcObjectPlacement, "ReferencedByPlacements"), std::make_pair(Type::IfcLocalPlacement, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcOpeningElement, "HasFillings"), std::make_pair(Type::IfcRelFillsElement, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcOrganization, "IsRelatedBy"), std::make_pair(Type::IfcOrganizationRelationship, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcOrganization, "Relates"), std::make_pair(Type::IfcOrganizationRelationship, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcOrganization, "Engages"), std::make_pair(Type::IfcPersonAndOrganization, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcPerson, "EngagedIn"), std::make_pair(Type::IfcPersonAndOrganization, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcPhysicalQuantity, "HasExternalReferences"), std::make_pair(Type::IfcExternalReferenceRelationship, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcPhysicalQuantity, "PartOfComplex"), std::make_pair(Type::IfcPhysicalComplexQuantity, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcPort, "ContainedIn"), std::make_pair(Type::IfcRelConnectsPortToElement, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcPort, "ConnectedFrom"), std::make_pair(Type::IfcRelConnectsPorts, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcPort, "ConnectedTo"), std::make_pair(Type::IfcRelConnectsPorts, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcProcess, "IsPredecessorTo"), std::make_pair(Type::IfcRelSequence, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcProcess, "IsSuccessorFrom"), std::make_pair(Type::IfcRelSequence, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcProcess, "OperatesOn"), std::make_pair(Type::IfcRelAssignsToProcess, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcProduct, "ReferencedBy"), std::make_pair(Type::IfcRelAssignsToProduct, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcProductDefinitionShape, "ShapeOfProduct"), std::make_pair(Type::IfcProduct, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcProductDefinitionShape, "HasShapeAspects"), std::make_pair(Type::IfcShapeAspect, 4)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcProfileDef, "HasExternalReference"), std::make_pair(Type::IfcExternalReferenceRelationship, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcProfileDef, "HasProperties"), std::make_pair(Type::IfcProfileProperties, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcProperty, "PartOfPset"), std::make_pair(Type::IfcPropertySet, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcProperty, "PropertyForDependance"), std::make_pair(Type::IfcPropertyDependencyRelationship, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcProperty, "PropertyDependsOn"), std::make_pair(Type::IfcPropertyDependencyRelationship, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcProperty, "PartOfComplex"), std::make_pair(Type::IfcComplexProperty, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcPropertyAbstraction, "HasExternalReferences"), std::make_pair(Type::IfcExternalReferenceRelationship, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcPropertyDefinition, "HasContext"), std::make_pair(Type::IfcRelDeclares, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcPropertyDefinition, "HasAssociations"), std::make_pair(Type::IfcRelAssociates, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcPropertySetDefinition, "DefinesType"), std::make_pair(Type::IfcTypeObject, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcPropertySetDefinition, "IsDefinedBy"), std::make_pair(Type::IfcRelDefinesByTemplate, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcPropertySetDefinition, "DefinesOccurrence"), std::make_pair(Type::IfcRelDefinesByProperties, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcPropertySetTemplate, "Defines"), std::make_pair(Type::IfcRelDefinesByTemplate, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcPropertyTemplate, "PartOfComplexTemplate"), std::make_pair(Type::IfcComplexPropertyTemplate, 2)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcPropertyTemplate, "PartOfPsetTemplate"), std::make_pair(Type::IfcPropertySetTemplate, 2)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcRelSpaceBoundary1stLevel, "InnerBoundaries"), std::make_pair(Type::IfcRelSpaceBoundary1stLevel, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcRelSpaceBoundary2ndLevel, "Corresponds"), std::make_pair(Type::IfcRelSpaceBoundary2ndLevel, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcRepresentation, "RepresentationMap"), std::make_pair(Type::IfcRepresentationMap, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcRepresentation, "LayerAssignments"), std::make_pair(Type::IfcPresentationLayerAssignment, 2)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcRepresentation, "OfProductRepresentation"), std::make_pair(Type::IfcProductRepresentation, 2)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcRepresentationContext, "RepresentationsInContext"), std::make_pair(Type::IfcRepresentation, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcRepresentationItem, "LayerAssignment"), std::make_pair(Type::IfcPresentationLayerAssignment, 2)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcRepresentationItem, "StyledByItem"), std::make_pair(Type::IfcStyledItem, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcRepresentationMap, "HasShapeAspects"), std::make_pair(Type::IfcShapeAspect, 4)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcRepresentationMap, "MapUsage"), std::make_pair(Type::IfcMappedItem, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcResource, "ResourceOf"), std::make_pair(Type::IfcRelAssignsToResource, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcShapeModel, "OfShapeAspect"), std::make_pair(Type::IfcShapeAspect, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcSpace, "HasCoverings"), std::make_pair(Type::IfcRelCoversSpaces, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcSpace, "BoundedBy"), std::make_pair(Type::IfcRelSpaceBoundary, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcSpatialElement, "ContainsElements"), std::make_pair(Type::IfcRelContainedInSpatialStructure, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcSpatialElement, "ServicedBySystems"), std::make_pair(Type::IfcRelServicesBuildings, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcSpatialElement, "ReferencesElements"), std::make_pair(Type::IfcRelReferencedInSpatialStructure, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcStructuralActivity, "AssignedToStructuralItem"), std::make_pair(Type::IfcRelConnectsStructuralActivity, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcStructuralConnection, "ConnectsStructuralMembers"), std::make_pair(Type::IfcRelConnectsStructuralMember, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcStructuralItem, "AssignedStructuralActivity"), std::make_pair(Type::IfcRelConnectsStructuralActivity, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcStructuralLoadGroup, "SourceOfResultGroup"), std::make_pair(Type::IfcStructuralResultGroup, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcStructuralLoadGroup, "LoadGroupFor"), std::make_pair(Type::IfcStructuralAnalysisModel, 2)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcStructuralMember, "ConnectedBy"), std::make_pair(Type::IfcRelConnectsStructuralMember, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcStructuralResultGroup, "ResultGroupFor"), std::make_pair(Type::IfcStructuralAnalysisModel, 3)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcSurfaceTexture, "IsMappedBy"), std::make_pair(Type::IfcTextureCoordinate, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcSurfaceTexture, "UsedInStyles"), std::make_pair(Type::IfcSurfaceStyleWithTextures, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcSystem, "ServicesBuildings"), std::make_pair(Type::IfcRelServicesBuildings, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcTableRow, "OfTable"), std::make_pair(Type::IfcTable, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcTessellatedFaceSet, "HasColours"), std::make_pair(Type::IfcIndexedColourMap, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcTessellatedFaceSet, "HasTextures"), std::make_pair(Type::IfcIndexedTextureMap, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcTimeSeries, "HasExternalReference"), std::make_pair(Type::IfcExternalReferenceRelationship, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcTypeObject, "Types"), std::make_pair(Type::IfcRelDefinesByType, 1)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcTypeProcess, "OperatesOn"), std::make_pair(Type::IfcRelAssignsToProcess, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcTypeProduct, "ReferencedBy"), std::make_pair(Type::IfcRelAssignsToProduct, 0)));
inverse_map.insert(std::make_pair(std::make_pair(Type::IfcTypeResource, "ResourceOf"), std::make_pair(Type::IfcRelAssignsToResource, 0)));
}
int Type::GetAttributeIndex(Enum t, const std::string& a) {
if (entity_descriptor_map.empty()) ::InitDescriptorMap();
std::map<Type::Enum,IfcEntityDescriptor*>::const_iterator i = entity_descriptor_map.find(t);
@@ -4743,6 +4896,13 @@ std::pair<const char*, int> Type::GetEnumerationIndex(Enum t, const std::string&
else return i->second->getIndex(a);
}
std::pair<Type::Enum, unsigned> Type::GetInverseAttribute(Enum t, const std::string& a) {
std::map<std::pair<Type::Enum, std::string>, std::pair<Type::Enum, int> >::const_iterator it;
it = inverse_map.find(std::make_pair(t, a));
if (it == inverse_map.end()) throw IfcException("Attribute not found");
else return it->second;
}
Type::Enum Type::GetAttributeEnumerationClass(Enum t, unsigned char a) {
if (entity_descriptor_map.empty()) ::InitDescriptorMap();
std::map<Type::Enum,IfcEntityDescriptor*>::const_iterator i = entity_descriptor_map.find(t);
+1
View File
@@ -41,6 +41,7 @@ namespace Type {
const std::string& GetAttributeName(Enum t, unsigned char a);
bool GetAttributeOptional(Enum t, unsigned char a);
std::pair<const char*, int> GetEnumerationIndex(Enum t, const std::string& a);
std::pair<Enum, unsigned> GetInverseAttribute(Enum t, const std::string& a);
Enum GetAttributeEnumerationClass(Enum t, unsigned char a);
void PopulateDerivedFields(IfcWrite::IfcWritableEntity* e);
}}
+4
View File
@@ -143,6 +143,10 @@ unsigned IfcParse::IfcUntypedEntity::getArgumentIndex(const std::string& a) cons
std::string IfcParse::IfcUntypedEntity::toString() {
return entity->toString(false);
}
IfcEntities IfcParse::IfcUntypedEntity::get_inverse(const std::string& a) {
std::pair<IfcSchema::Type::Enum, unsigned> inv = IfcSchema::Type::GetInverseAttribute(_type, a);
return entity->getInverse(inv.first);
}
bool IfcParse::IfcUntypedEntity::is_valid() {
const unsigned arg_count = getArgumentCount();
bool valid = true;
+2
View File
@@ -27,6 +27,8 @@ namespace IfcParse {
const char* getArgumentName(unsigned int i) const;
unsigned getArgumentIndex(const std::string& a) const;
IfcEntities get_inverse(const std::string& a);
void setArgument(unsigned int iz);
void setArgument(unsigned int i, int v);
void setArgument(unsigned int i, bool v);
+2
View File
@@ -27,6 +27,8 @@ namespace IfcParse {
ArgumentPtr getArgument(const std::string& a) const;
const char* getArgumentName(unsigned int i) const;
unsigned getArgumentIndex(const std::string& a) const;
IfcEntities get_inverse(const std::string& a);
void setArgument(unsigned int i);
void setArgument(unsigned int i, int v);