Skip to content

Commit

Permalink
Fix #4166 - Do not delete UniqueModelObjects if not present in HandleMap
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarrec committed Mar 16, 2021
1 parent 0efa720 commit a8847ca
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/model/ModelMerger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,13 @@ namespace model {

ModelMerger::ModelMerger() {
// DLM: TODO expose this to user to give more control over merging?

// Unique Objects
m_iddObjectTypesToMerge.push_back(IddObjectType::OS_Site);
m_iddObjectTypesToMerge.push_back(IddObjectType::OS_Facility);
m_iddObjectTypesToMerge.push_back(IddObjectType::OS_Building);

// Non unique Objects
m_iddObjectTypesToMerge.push_back(IddObjectType::OS_Space);
m_iddObjectTypesToMerge.push_back(IddObjectType::OS_ShadingSurfaceGroup);
m_iddObjectTypesToMerge.push_back(IddObjectType::OS_ThermalZone);
Expand Down Expand Up @@ -1012,12 +1016,18 @@ namespace model {
for (const auto& iddObjectType : iddObjectTypesToMerge()) {
for (auto& currenObject : currentModel.getObjectsByType(iddObjectType)) {
if (m_currentToNewHandleMapping.find(currenObject.handle()) == m_currentToNewHandleMapping.end()) {
currenObject.remove();
if ((iddObjectType == IddObjectType::OS_Site) || (iddObjectType == IddObjectType::OS_Facility)
|| (iddObjectType == IddObjectType::OS_Building)) {
// These are unique objects, so no need to delete them
continue;
} else {
currenObject.remove();
}
}
}
}

//** Merge objects from new model into curret model **//
//** Merge objects from new model into current model **//
for (const auto& iddObjectType : iddObjectTypesToMerge()) {
for (auto& newObject : newModel.getObjectsByType(iddObjectType)) {
getCurrentModelObject(newObject);
Expand Down

0 comments on commit a8847ca

Please sign in to comment.