2626
2727#ifdef USE_IFC4
2828
29+ #include < set>
30+
2931#include " ../ifcparse/Ifc4.h"
3032#include " ../ifcparse/Ifc4-rt.h"
3133#include " ../ifcparse/IfcException.h"
@@ -42,6 +44,8 @@ using namespace IfcUtil;
4244std::map<Type::Enum,IfcEntityDescriptor*> entity_descriptor_map;
4345std::map<Type::Enum,IfcEnumerationDescriptor*> enumeration_descriptor_map;
4446std::map<std::pair<Type::Enum, std::string>, std::pair<Type::Enum, int > > inverse_map;
47+ std::map<Type::Enum,std::set<int > > derived_map;
48+
4549void InitDescriptorMap () {
4650 IfcEntityDescriptor* current;
4751 current = entity_descriptor_map[Type::IfcAbsorbedDoseMeasure] = new IfcEntityDescriptor (Type::IfcAbsorbedDoseMeasure,0 );
@@ -4854,6 +4858,13 @@ void InitInverseMap() {
48544858 inverse_map.insert (std::make_pair (std::make_pair (Type::IfcTypeResource, " ResourceOf" ), std::make_pair (Type::IfcRelAssignsToResource, 6 )));
48554859}
48564860
4861+ void InitDerivedMap () {
4862+ {std::set<int > idxs; idxs.insert (2 ); idxs.insert (3 ); idxs.insert (4 ); idxs.insert (5 ); derived_map[Type::IfcGeometricRepresentationSubContext] = idxs;}
4863+ {std::set<int > idxs; idxs.insert (3 ); derived_map[Type::IfcMirroredProfileDef] = idxs;}
4864+ {std::set<int > idxs; idxs.insert (0 ); idxs.insert (1 ); derived_map[Type::IfcOrientedEdge] = idxs;}
4865+ {std::set<int > idxs; idxs.insert (0 ); derived_map[Type::IfcSIUnit] = idxs;}
4866+ }
4867+
48574868int Type::GetAttributeIndex (Enum t, const std::string& a) {
48584869 if (entity_descriptor_map.empty ()) ::InitDescriptorMap ();
48594870 std::map<Type::Enum,IfcEntityDescriptor*>::const_iterator i = entity_descriptor_map.find (t);
@@ -4889,6 +4900,12 @@ bool Type::GetAttributeOptional(Enum t, unsigned char a) {
48894900 else return i->second ->getArgumentOptional (a);
48904901}
48914902
4903+ bool Type::GetAttributeDerived (Enum t, unsigned char a) {
4904+ if (derived_map.empty ()) ::InitDerivedMap ();
4905+ std::map<Type::Enum,std::set<int > >::const_iterator i = derived_map.find (t);
4906+ return i != derived_map.end () && i->second .find (a) != i->second .end ();
4907+ }
4908+
48924909std::pair<const char *, int > Type::GetEnumerationIndex (Enum t, const std::string& a) {
48934910 if (enumeration_descriptor_map.empty ()) ::InitDescriptorMap ();
48944911 std::map<Type::Enum,IfcEnumerationDescriptor*>::const_iterator i = enumeration_descriptor_map.find (t);
@@ -4920,10 +4937,11 @@ Type::Enum Type::GetAttributeEnumerationClass(Enum t, unsigned char a) {
49204937}
49214938
49224939void Type::PopulateDerivedFields (IfcWrite::IfcWritableEntity* e) {
4923- Type::Enum type = e->type ();
4924- if (type == Type::IfcGeometricRepresentationSubContext) { e->setArgumentDerived (2 ); e->setArgumentDerived (3 ); e->setArgumentDerived (4 ); e->setArgumentDerived (5 ); }
4925- if (type == Type::IfcMirroredProfileDef) { e->setArgumentDerived (3 ); }
4926- if (type == Type::IfcOrientedEdge) { e->setArgumentDerived (0 ); e->setArgumentDerived (1 ); }
4927- if (type == Type::IfcSIUnit) { e->setArgumentDerived (0 ); }
4940+ std::map<Type::Enum, std::set<int > >::const_iterator i = derived_map.find (e->type ());
4941+ if (i != derived_map.end ()) {
4942+ for (std::set<int >::const_iterator it = i->second .begin (); it != i->second .end (); ++it) {
4943+ e->setArgumentDerived (*it);
4944+ }
4945+ }
49284946}
49294947#endif
0 commit comments