Skip to content

Commit

Permalink
epam#2746 remove old bond to sgroup before adding a new one
Browse files Browse the repository at this point in the history
  • Loading branch information
jblack-mestre committed Feb 5, 2025
1 parent 121b7d2 commit de1d3e2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions core/render2d/src/render_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,7 @@ void MoleculeRenderInternal::_prepareSGroups(bool collapseAtLeastOneSuperatom)
int neighboringBondID = v.neiEdge(j), bondID = -1;
if (mol.findEdgeIndex(neighboringAtomID, superAtomID) < 0)
{
int oldBondMappingInvPosition = _bondMappingInv.at(neighboringBondID);
if (mol.isQueryMolecule())
{
QueryMolecule& qm = mol.asQueryMolecule();
Expand All @@ -874,13 +875,16 @@ void MoleculeRenderInternal::_prepareSGroups(bool collapseAtLeastOneSuperatom)
else
{
Molecule& amol = mol.asMolecule();
int oldBondTopology = amol.getBondTopology(neighboringBondID);
int oldBondDirection = amol.getBondDirection(neighboringBondID);
amol.removeBond(neighboringBondID);
bondID = amol.addBond(neighboringAtomID, superAtomID, amol.getBondOrder(neighboringBondID));
amol.setEdgeTopology(bondID, amol.getBondTopology(neighboringBondID));
amol.setBondDirection(bondID, mol.getBondDirection(neighboringBondID));
amol.setEdgeTopology(bondID, oldBondTopology);
amol.setBondDirection(bondID, oldBondDirection);
}
if (_bondMappingInv.find(bondID) != _bondMappingInv.end())
_bondMappingInv.erase(bondID);
_bondMappingInv.emplace(bondID, _bondMappingInv.at(neighboringBondID));
_bondMappingInv.emplace(bondID, oldBondMappingInvPosition);
}
}
}
Expand Down

0 comments on commit de1d3e2

Please sign in to comment.