From ca3eb41c2c9c66acab78f2519d3ef232fc578641 Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Tue, 7 Jan 2025 10:48:30 -0500 Subject: [PATCH] Remove bonds before wrapping atoms to the unit cell Signed-off-by: Geoff Hutchison --- avogadro/core/crystaltools.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/avogadro/core/crystaltools.cpp b/avogadro/core/crystaltools.cpp index 1f6b9c344b..bcf035e751 100644 --- a/avogadro/core/crystaltools.cpp +++ b/avogadro/core/crystaltools.cpp @@ -29,9 +29,16 @@ bool CrystalTools::wrapAtomsToUnitCell(Molecule& molecule) if (!molecule.unitCell()) return false; + // remove any bonds first - otherwise they may wrap + // across the unit cell strangely + molecule.clearBonds(); + std::for_each(molecule.atomPositions3d().begin(), molecule.atomPositions3d().end(), WrapAtomsToCellFunctor(molecule)); + + molecule.perceiveBondsSimple(); + molecule.perceiveBondOrders(); return true; }