mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 01:31:00 +00:00
#1861 update globalid map on attribute change
This commit is contained in:
@@ -269,7 +269,9 @@ public:
|
|||||||
|
|
||||||
unsigned int FreshId() { return ++MaxId; }
|
unsigned int FreshId() { return ++MaxId; }
|
||||||
|
|
||||||
unsigned int getMaxId() { return MaxId; }
|
unsigned int getMaxId() const { return MaxId; }
|
||||||
|
|
||||||
|
const IfcParse::declaration* const ifcroot_type() const { return ifcroot_type_; }
|
||||||
|
|
||||||
void recalculate_id_counter();
|
void recalculate_id_counter();
|
||||||
|
|
||||||
@@ -311,6 +313,8 @@ public:
|
|||||||
bool& parsing_complete() { return parsing_complete_; }
|
bool& parsing_complete() { return parsing_complete_; }
|
||||||
|
|
||||||
void build_inverses();
|
void build_inverses();
|
||||||
|
|
||||||
|
entity_by_guid_t& internal_guid_map() { return byguid; };
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef WITH_IFCXML
|
#ifdef WITH_IFCXML
|
||||||
|
|||||||
@@ -1436,6 +1436,21 @@ void IfcEntityInstanceData::setArgument(size_t i, Argument* a, IfcUtil::Argument
|
|||||||
if (attributes_[i] != 0) {
|
if (attributes_[i] != 0) {
|
||||||
Argument* current_attribute = attributes_[i];
|
Argument* current_attribute = attributes_[i];
|
||||||
if (this->file) {
|
if (this->file) {
|
||||||
|
|
||||||
|
// Deregister old attribute guid in file guid map.
|
||||||
|
if (i == 0 && this->file->ifcroot_type() && this->type()->is(*this->file->ifcroot_type())) {
|
||||||
|
try {
|
||||||
|
auto guid = (std::string) *current_attribute;
|
||||||
|
auto it = this->file->internal_guid_map().find(guid);
|
||||||
|
if (it != this->file->internal_guid_map().end() && &it->second->data() == this) {
|
||||||
|
this->file->internal_guid_map().erase(it);
|
||||||
|
}
|
||||||
|
} catch (IfcParse::IfcException& e) {
|
||||||
|
Logger::Error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deregister inverse indices in file
|
||||||
unregister_inverse_visitor visitor(*this->file, *this);
|
unregister_inverse_visitor visitor(*this->file, *this);
|
||||||
apply_individual_instance_visitor(current_attribute, i).apply(visitor);
|
apply_individual_instance_visitor(current_attribute, i).apply(visitor);
|
||||||
}
|
}
|
||||||
@@ -1443,11 +1458,28 @@ void IfcEntityInstanceData::setArgument(size_t i, Argument* a, IfcUtil::Argument
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this->file) {
|
if (this->file) {
|
||||||
|
// Register inverse indices in file
|
||||||
register_inverse_visitor visitor(*this->file, *this);
|
register_inverse_visitor visitor(*this->file, *this);
|
||||||
apply_individual_instance_visitor(new_attribute, i).apply(visitor);
|
apply_individual_instance_visitor(new_attribute, i).apply(visitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
attributes_[i] = new_attribute;
|
attributes_[i] = new_attribute;
|
||||||
|
|
||||||
|
// Register new attribute guid in guid map
|
||||||
|
if (this->file) {
|
||||||
|
if (i == 0 && this->file->ifcroot_type() && this->type()->is(*this->file->ifcroot_type())) {
|
||||||
|
try {
|
||||||
|
auto guid = (std::string) *new_attribute;
|
||||||
|
auto it = this->file->internal_guid_map().find(guid);
|
||||||
|
if (it != this->file->internal_guid_map().end()) {
|
||||||
|
Logger::Warning("Duplicate guid " + guid);
|
||||||
|
}
|
||||||
|
this->file->internal_guid_map()[guid] = this->file->instance_by_id(this->id());
|
||||||
|
} catch (IfcParse::IfcException& e) {
|
||||||
|
Logger::Error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user