Compare commits

...

1 Commits

Author SHA1 Message Date
Andrej730 9a13e4de5c expose ifc file identity to entity mapping to python api
Can be useful for debugging or identifying entities that were already added to the ifc file. E.g. if entity was added before and adding it again won't update it but with identity map it's possible to know that entity will need to be updated manually.
2024-03-21 17:49:25 +05:00
3 changed files with 20 additions and 1 deletions
+3 -1
View File
@@ -122,9 +122,9 @@ public:
static bool guid_map() { return guid_map_; }
static void guid_map(bool b) { guid_map_ = b; }
private:
typedef std::map<uint32_t, IfcUtil::IfcBaseClass*> entity_entity_map_t;
private:
bool parsing_complete_;
file_open_status good_ = file_open_status::SUCCESS;
@@ -276,6 +276,8 @@ public:
void recalculate_id_counter();
entity_entity_map_t getEntityFileMapCopy() const;
IfcUtil::IfcBaseClass* addEntity(IfcUtil::IfcBaseClass* entity, int id=-1);
void addEntities(aggregate_of_instance::ptr es);
+8
View File
@@ -1839,6 +1839,14 @@ void IfcFile::addEntities(aggregate_of_instance::ptr es) {
}
}
IfcFile::entity_entity_map_t IfcFile::getEntityFileMapCopy() const {
std::map<uint32_t, IfcUtil::IfcBaseClass*> copy_map;
for (const auto& pair : entity_file_map) {
copy_map[pair.first] = pair.second;
}
return copy_map;
}
IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity, int id) {
if (id != -1 && byid.find((unsigned)id) != byid.end()) {
throw IfcParse::IfcException("An instance with id " + boost::lexical_cast<std::string>(id) + " is already part of this file");
+9
View File
@@ -593,6 +593,15 @@ static IfcUtil::ArgumentType helper_fn_attribute_type(const IfcUtil::IfcBaseClas
return f;
}
PyObject* get_identity_mapping(IfcParse::IfcFile* f) {
PyObject* pyDict = PyDict_New();
for (const auto& pair : f->getEntityFileMapCopy()) {
PyDict_SetItem(pyDict, pythonize(pair.first), pythonize(pair.second));
}
return pyDict;
}
const char* version() {
return IFCOPENSHELL_VERSION;
}