Add file offset to instance reference errors so that they are picked up by ifcopenshell.validate

This commit is contained in:
Thomas Krijnen
2025-03-25 11:44:46 +01:00
parent 3744b81ccd
commit bd92821b2e
3 changed files with 16 additions and 15 deletions
+6 -6
View File
@@ -1423,10 +1423,10 @@ void IfcFile::initialize_(IfcParse::IfcSpfStream* s) {
const auto& ref = p.first.name_;
const auto& refattr = p.first.index_;
if (auto* v = boost::get<reference_or_simple_type>(&p.second)) {
if (auto* name = boost::get<int>(v)) {
if (auto* name = boost::get<InstanceReference>(v)) {
entity_by_id_t::const_iterator it = byid_.find(*name);
if (it == byid_.end()) {
Logger::Error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found");
Logger::Error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset));
} else {
byid_[p.first.name_]->data().storage_.set(p.first.index_, it->second);
}
@@ -1437,10 +1437,10 @@ void IfcFile::initialize_(IfcParse::IfcSpfStream* s) {
aggregate_of_instance::ptr instances(new aggregate_of_instance);
instances->reserve(v->size());
for (const auto& vi : *v) {
if (auto* name = boost::get<int>(&vi)) {
if (auto* name = boost::get<InstanceReference>(&vi)) {
entity_by_id_t::const_iterator it = byid_.find(*name);
if (it == byid_.end()) {
Logger::Error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found");
Logger::Error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset));
} else {
instances->push(it->second);
}
@@ -1454,10 +1454,10 @@ void IfcFile::initialize_(IfcParse::IfcSpfStream* s) {
for (const auto& vi : *v) {
std::vector<IfcUtil::IfcBaseClass*> inner;
for (const auto& vii : vi) {
if (auto* name = boost::get<int>(&vii)) {
if (auto* name = boost::get<InstanceReference>(&vii)) {
entity_by_id_t::const_iterator it = byid_.find(*name);
if (it == byid_.end()) {
Logger::Error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found");
Logger::Error("Instance reference #" + std::to_string(*name) + " used by instance #" + std::to_string(ref) + " at attribute index " + std::to_string(refattr) + " not found at offset " + std::to_string(name->file_offset));
} else {
inner.push_back(it->second);
}